| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_SIGNIN_SIGNIN_INTERNALS_UTIL_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_INTERNALS_UTIL_H_ |
| 6 #define CHROME_BROWSER_SIGNIN_SIGNIN_INTERNALS_UTIL_H_ | 6 #define CHROME_BROWSER_SIGNIN_SIGNIN_INTERNALS_UTIL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 TIMED_FIELDS_COUNT = TIMED_FIELDS_END - TIMED_FIELDS_BEGIN, | 57 TIMED_FIELDS_COUNT = TIMED_FIELDS_END - TIMED_FIELDS_BEGIN, |
| 58 SIGNIN_FIELDS_END = TIMED_FIELDS_END, | 58 SIGNIN_FIELDS_END = TIMED_FIELDS_END, |
| 59 SIGNIN_FIELDS_COUNT = SIGNIN_FIELDS_END - SIGNIN_FIELDS_BEGIN | 59 SIGNIN_FIELDS_COUNT = SIGNIN_FIELDS_END - SIGNIN_FIELDS_BEGIN |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 // Encapsulates diagnostic information about tokens for different services. | 62 // Encapsulates diagnostic information about tokens for different services. |
| 63 // Note that although SigninStatus contains a map of service names to token | 63 // Note that although SigninStatus contains a map of service names to token |
| 64 // values, we replicate the service name within this struct for a cleaner | 64 // values, we replicate the service name within this struct for a cleaner |
| 65 // serialization (with ToValue()). | 65 // serialization (with ToValue()). |
| 66 struct TokenInfo { | 66 struct TokenInfo { |
| 67 std::string token; // The actual token. | 67 std::string token; // The actual token. |
| 68 std::string status; // Status of the last token fetch. | 68 std::string status; // Status of the last token fetch. |
| 69 std::string time; // Timestamp of the last token fetch. | 69 std::string time; // Timestamp of the last token fetch |
| 70 int64 time_internal; // Same as |time|, but in base::Time internal format. |
| 70 std::string service; // The service that this token is for. | 71 std::string service; // The service that this token is for. |
| 71 | 72 |
| 72 TokenInfo(const std::string& token, | 73 TokenInfo(const std::string& token, |
| 73 const std::string& status, | 74 const std::string& status, |
| 74 const std::string& time, | 75 const std::string& time, |
| 76 const int64& time_internal, |
| 75 const std::string& service); | 77 const std::string& service); |
| 76 TokenInfo(); | 78 TokenInfo(); |
| 77 ~TokenInfo(); | 79 ~TokenInfo(); |
| 78 | 80 |
| 79 DictionaryValue* ToValue(); | 81 DictionaryValue* ToValue(); |
| 80 }; | 82 }; |
| 81 | 83 |
| 82 // Associates a service name with its token information. | 84 // Associates a service name with its token information. |
| 83 typedef std::map<std::string, TokenInfo> TokenInfoMap; | 85 typedef std::map<std::string, TokenInfo> TokenInfoMap; |
| 84 | 86 |
| 85 // Returns the root preference path for the service. The path should be | 87 // Returns the root preference path for the service. The path should be |
| 86 // qualified with one of .value, .status or .time to get the respective | 88 // qualified with one of .value, .status or .time to get the respective |
| 87 // full preference path names. | 89 // full preference path names. |
| 88 std::string TokenPrefPath(const std::string& service_name); | 90 std::string TokenPrefPath(const std::string& service_name); |
| 89 | 91 |
| 90 // Many values in SigninStatus are also associated with a timestamp. | 92 // Many values in SigninStatus are also associated with a timestamp. |
| 91 // This makes it easier to keep values and their assoicated times together. | 93 // This makes it easier to keep values and their associated times together. |
| 92 typedef std::pair<std::string, std::string> TimedSigninStatusValue; | 94 typedef std::pair<std::string, std::string> TimedSigninStatusValue; |
| 93 | 95 |
| 94 // Returns the name of a SigninStatus field. | 96 // Returns the name of a SigninStatus field. |
| 95 std::string SigninStatusFieldToString(UntimedSigninStatusField field); | 97 std::string SigninStatusFieldToString(UntimedSigninStatusField field); |
| 96 std::string SigninStatusFieldToString(TimedSigninStatusField field); | 98 std::string SigninStatusFieldToString(TimedSigninStatusField field); |
| 97 | 99 |
| 98 // Encapsulates both authentication and token related information. Used | 100 // Encapsulates both authentication and token related information. Used |
| 99 // by SigninInternals to maintain information that needs to be shown in | 101 // by SigninInternals to maintain information that needs to be shown in |
| 100 // the about:signin-internals page. | 102 // the about:signin-internals page. |
| 101 struct SigninStatus { | 103 struct SigninStatus { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 bool update_time) {} | 138 bool update_time) {} |
| 137 virtual void NotifyTokenReceivedFailure(const std::string& token_name, | 139 virtual void NotifyTokenReceivedFailure(const std::string& token_name, |
| 138 const std::string& error) {} | 140 const std::string& error) {} |
| 139 virtual void NotifyClearStoredToken(const std::string& token_name) {} | 141 virtual void NotifyClearStoredToken(const std::string& token_name) {} |
| 140 | 142 |
| 141 }; | 143 }; |
| 142 | 144 |
| 143 } // namespace | 145 } // namespace |
| 144 | 146 |
| 145 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_INTERNALS_UTIL_H_ | 147 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_INTERNALS_UTIL_H_ |
| OLD | NEW |