Index: components/user_manager/user_id.h |
diff --git a/components/user_manager/user_id.h b/components/user_manager/user_id.h |
index bf8730a6cd5feeb59457cedb254d577ed30c4420..fa0b840192778f54e60937fb8e2fa18ed6a8b00b 100644 |
--- a/components/user_manager/user_id.h |
+++ b/components/user_manager/user_id.h |
@@ -6,12 +6,55 @@ |
#define COMPONENTS_USER_MANAGER_USER_ID_H_ |
#include <string> |
+#include "base/containers/hash_tables.h" |
namespace user_manager { |
// Type that contains enough information to identify user on ChromeOS. |
-typedef std::string UserID; |
+//typedef std::string UserID; |
+ |
+class UserID { |
+ public: |
+ UserID(const std::string& gaia_id, const std::string& user_email); |
Denis Kuznetsov (DE-MUC)
2015/06/10 16:50:45
I would make this one private and force using From
|
+ |
+ UserID(const UserID& other); |
+ |
+ bool operator==(const UserID& other) const; |
+ bool operator!=(const UserID& other) const; |
+ bool operator<(const UserID& right) const; |
+ |
+ bool empty() const; |
+ void clear(); |
+ |
+ const std::string& GetGaiaId() const; |
+ const std::string& GetUserEmail() const; |
+ |
+ void SetGaiaId(const std::string& gaia_id); |
+ void SetUserEmail(const std::string& email); |
+ |
+ std::string Serialize() const; |
+ |
+ static UserID FromUserEmail(const std::string& user_email); |
+ static UserID Deserialize(const std::string& serialized); |
+ |
+ private: |
+ std::string gaia_id_; |
+ std::string user_email_; |
+}; |
+ |
+// Returns a reference to a singleton. |
+const UserID& EmptyUserID(); |
} // namespace user_manager |
+namespace BASE_HASH_NAMESPACE { |
+ |
+// Implement hashing of UserID, so it can be used as a key in STL containers. |
+template<> |
+struct hash<user_manager::UserID> { |
+ std::size_t operator()(const user_manager::UserID& user_id) const; |
+}; |
+ |
+} // namespace BASE_HASH_NAMESPACE |
+ |
#endif // COMPONENTS_USER_MANAGER_USER_ID_H_ |