client_id.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. #ifndef COMPONENTS_OFFLINE_PAGES_CORE_CLIENT_ID_H_
  5. #define COMPONENTS_OFFLINE_PAGES_CORE_CLIENT_ID_H_
  6. #include <iosfwd>
  7. #include <string>
  8. namespace offline_pages {
  9. // Defines a namespace/id pair that allows offline page clients to uniquely
  10. // identify their own items within adopting internal systems. It is the client's
  11. // responsibility to keep id values unique within its assigned namespace, but it
  12. // is not a requirement.
  13. struct ClientId {
  14. ClientId();
  15. ClientId(const std::string& name_space, const std::string& id);
  16. bool operator==(const ClientId& client_id) const;
  17. bool operator<(const ClientId& client_id) const;
  18. std::string ToString() const;
  19. // The namespace that identifies the client (of course 'namespace' is a
  20. // reserved word, so...).
  21. std::string name_space;
  22. // The client specified id that allows it to uniquely identify entries within
  23. // its namespace. These values are opaque to offline page systems and not used
  24. // internally as an identifier.
  25. std::string id;
  26. };
  27. std::ostream& operator<<(std::ostream& out, const ClientId& cid);
  28. } // namespace offline_pages
  29. #endif // COMPONENTS_OFFLINE_PAGES_CORE_CLIENT_ID_H_