| 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 // These are (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 // Serialize() returns JSON dictionary, |
| 51 // Deserialize() restores AccountId after serialization. |
| 52 std::string Serialize() const; |
| 53 static bool Deserialize(const std::string& serialized, |
| 54 AccountId* out_account_id); |
| 50 | 55 |
| 51 private: | 56 private: |
| 52 AccountId(); | 57 AccountId(); |
| 53 AccountId(const std::string& gaia_id, const std::string& user_email); | 58 AccountId(const std::string& gaia_id, const std::string& user_email); |
| 54 | 59 |
| 55 std::string gaia_id_; | 60 std::string gaia_id_; |
| 56 std::string user_email_; | 61 std::string user_email_; |
| 57 }; | 62 }; |
| 58 | 63 |
| 59 // Returns a reference to a singleton. | 64 // Returns a reference to a singleton. |
| 60 const AccountId& EmptyAccountId(); | 65 const AccountId& EmptyAccountId(); |
| 61 | 66 |
| 62 namespace BASE_HASH_NAMESPACE { | 67 namespace BASE_HASH_NAMESPACE { |
| 63 | 68 |
| 64 // Implement hashing of AccountId, so it can be used as a key in STL containers. | 69 // Implement hashing of AccountId, so it can be used as a key in STL containers. |
| 65 template <> | 70 template <> |
| 66 struct hash<AccountId> { | 71 struct hash<AccountId> { |
| 67 std::size_t operator()(const AccountId& user_id) const; | 72 std::size_t operator()(const AccountId& user_id) const; |
| 68 }; | 73 }; |
| 69 | 74 |
| 70 } // namespace BASE_HASH_NAMESPACE | 75 } // namespace BASE_HASH_NAMESPACE |
| 71 | 76 |
| 72 #endif // COMPONENTS_SIGNIN_CORE_ACCOUNT_ID_ACCOUNT_ID_H_ | 77 #endif // COMPONENTS_SIGNIN_CORE_ACCOUNT_ID_ACCOUNT_ID_H_ |
| OLD | NEW |