client_id.cc 1013 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/offline_pages/core/client_id.h"
  5. #include <ostream>
  6. namespace offline_pages {
  7. ClientId::ClientId() {}
  8. ClientId::ClientId(const std::string& name_space, const std::string& id)
  9. : name_space(name_space), id(id) {}
  10. bool ClientId::operator==(const ClientId& client_id) const {
  11. return name_space == client_id.name_space && id == client_id.id;
  12. }
  13. bool ClientId::operator<(const ClientId& client_id) const {
  14. if (name_space == client_id.name_space)
  15. return (id < client_id.id);
  16. return name_space < client_id.name_space;
  17. }
  18. std::string ClientId::ToString() const {
  19. return std::string("ClientId(")
  20. .append(name_space)
  21. .append(", ")
  22. .append(id)
  23. .append(")");
  24. }
  25. std::ostream& operator<<(std::ostream& out, const ClientId& cid) {
  26. return out << cid.ToString();
  27. }
  28. } // namespace offline_pages