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_SIGNIN_CORE_ACCOUNT_ID_ACCOUNT_ID_H_ | 5 #ifndef COMPONENTS_SIGNIN_CORE_ACCOUNT_ID_ACCOUNT_ID_H_ |
6 #define COMPONENTS_SIGNIN_CORE_ACCOUNT_ID_ACCOUNT_ID_H_ | 6 #define COMPONENTS_SIGNIN_CORE_ACCOUNT_ID_ACCOUNT_ID_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... | |
38 | 38 |
39 // This method is to be used during transition period only. | 39 // This method is to be used during transition period only. |
40 static AccountId FromUserEmail(const std::string& user_email); | 40 static AccountId FromUserEmail(const std::string& user_email); |
41 // This method is to be used during transition period only. | 41 // This method is to be used during transition period only. |
42 static AccountId FromGaiaId(const std::string& gaia_id); | 42 static AccountId FromGaiaId(const std::string& gaia_id); |
43 // This method is the preferred way to construct AccountId if you have | 43 // This method is the preferred way to construct AccountId if you have |
44 // full account information. | 44 // full account information. |
45 static AccountId FromUserEmailGaiaId(const std::string& user_email, | 45 static AccountId FromUserEmailGaiaId(const std::string& user_email, |
46 const std::string& gaia_id); | 46 const std::string& gaia_id); |
47 | 47 |
48 // std::string Serialize() const; | 48 // This is (for now) unstable and cannot be used to store serialized data to |
49 // static AccountId Deserialize(const std::string& serialized); | 49 // persistent storage. Only in-memory storage is safe. |
50 std::string Serialize() const; | |
51 static bool Deserialize(const std::string& serialized, | |
52 AccountId* out_account_id); | |
stevenjb
2015/11/11 20:39:23
Even if these are unstable, please document that t
Alexander Alekseev
2015/11/12 06:53:04
Done.
| |
50 | 53 |
51 private: | 54 private: |
52 AccountId(); | 55 AccountId(); |
53 AccountId(const std::string& gaia_id, const std::string& user_email); | 56 AccountId(const std::string& gaia_id, const std::string& user_email); |
54 | 57 |
55 std::string gaia_id_; | 58 std::string gaia_id_; |
56 std::string user_email_; | 59 std::string user_email_; |
57 }; | 60 }; |
58 | 61 |
59 // Returns a reference to a singleton. | 62 // Returns a reference to a singleton. |
60 const AccountId& EmptyAccountId(); | 63 const AccountId& EmptyAccountId(); |
61 | 64 |
62 namespace BASE_HASH_NAMESPACE { | 65 namespace BASE_HASH_NAMESPACE { |
63 | 66 |
64 // Implement hashing of AccountId, so it can be used as a key in STL containers. | 67 // Implement hashing of AccountId, so it can be used as a key in STL containers. |
65 template <> | 68 template <> |
66 struct hash<AccountId> { | 69 struct hash<AccountId> { |
67 std::size_t operator()(const AccountId& user_id) const; | 70 std::size_t operator()(const AccountId& user_id) const; |
68 }; | 71 }; |
69 | 72 |
70 } // namespace BASE_HASH_NAMESPACE | 73 } // namespace BASE_HASH_NAMESPACE |
71 | 74 |
72 #endif // COMPONENTS_SIGNIN_CORE_ACCOUNT_ID_ACCOUNT_ID_H_ | 75 #endif // COMPONENTS_SIGNIN_CORE_ACCOUNT_ID_ACCOUNT_ID_H_ |
OLD | NEW |