OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_USER_MANAGER_USER_ID_H_ | 5 #ifndef COMPONENTS_USER_MANAGER_USER_ID_H_ |
6 #define COMPONENTS_USER_MANAGER_USER_ID_H_ | 6 #define COMPONENTS_USER_MANAGER_USER_ID_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include "base/containers/hash_tables.h" | |
9 | 10 |
10 namespace user_manager { | 11 namespace user_manager { |
11 | 12 |
12 // Type that contains enough information to identify user on ChromeOS. | 13 // Type that contains enough information to identify user on ChromeOS. |
13 typedef std::string UserID; | 14 //typedef std::string UserID; |
15 | |
16 class UserID { | |
17 public: | |
18 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
| |
19 | |
20 UserID(const UserID& other); | |
21 | |
22 bool operator==(const UserID& other) const; | |
23 bool operator!=(const UserID& other) const; | |
24 bool operator<(const UserID& right) const; | |
25 | |
26 bool empty() const; | |
27 void clear(); | |
28 | |
29 const std::string& GetGaiaId() const; | |
30 const std::string& GetUserEmail() const; | |
31 | |
32 void SetGaiaId(const std::string& gaia_id); | |
33 void SetUserEmail(const std::string& email); | |
34 | |
35 std::string Serialize() const; | |
36 | |
37 static UserID FromUserEmail(const std::string& user_email); | |
38 static UserID Deserialize(const std::string& serialized); | |
39 | |
40 private: | |
41 std::string gaia_id_; | |
42 std::string user_email_; | |
43 }; | |
44 | |
45 // Returns a reference to a singleton. | |
46 const UserID& EmptyUserID(); | |
14 | 47 |
15 } // namespace user_manager | 48 } // namespace user_manager |
16 | 49 |
50 namespace BASE_HASH_NAMESPACE { | |
51 | |
52 // Implement hashing of UserID, so it can be used as a key in STL containers. | |
53 template<> | |
54 struct hash<user_manager::UserID> { | |
55 std::size_t operator()(const user_manager::UserID& user_id) const; | |
56 }; | |
57 | |
58 } // namespace BASE_HASH_NAMESPACE | |
59 | |
17 #endif // COMPONENTS_USER_MANAGER_USER_ID_H_ | 60 #endif // COMPONENTS_USER_MANAGER_USER_ID_H_ |
OLD | NEW |