| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_GCM_DRIVER_GCM_CLIENT_IMPL_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ |
| 6 #define COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ | 6 #define COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // True if accounts were already provided through SetAccountsForCheckin(), | 168 // True if accounts were already provided through SetAccountsForCheckin(), |
| 169 // or when |last_checkin_accounts| was loaded as empty. | 169 // or when |last_checkin_accounts| was loaded as empty. |
| 170 bool accounts_set; | 170 bool accounts_set; |
| 171 // Map of account email addresses and OAuth2 tokens that will be sent to the | 171 // Map of account email addresses and OAuth2 tokens that will be sent to the |
| 172 // checkin server on a next checkin. | 172 // checkin server on a next checkin. |
| 173 std::map<std::string, std::string> account_tokens; | 173 std::map<std::string, std::string> account_tokens; |
| 174 // As set of accounts last checkin was completed with. | 174 // As set of accounts last checkin was completed with. |
| 175 std::set<std::string> last_checkin_accounts; | 175 std::set<std::string> last_checkin_accounts; |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 // Reasons for resetting the GCM Store. |
| 179 // Note: this enum is recorded into a histogram. Do not change enum value |
| 180 // or order. |
| 181 enum ResetReason { |
| 182 LOAD_FAILURE, // GCM store failed to load, but the store exists. |
| 183 CHECKIN_REJECTED, // Checkin was rejected by server. |
| 184 |
| 185 RESET_REASON_COUNT, |
| 186 }; |
| 187 |
| 178 // Collection of pending registration requests. Keys are RegistrationInfo | 188 // Collection of pending registration requests. Keys are RegistrationInfo |
| 179 // instance, while values are pending registration requests to obtain a | 189 // instance, while values are pending registration requests to obtain a |
| 180 // registration ID for requesting application. | 190 // registration ID for requesting application. |
| 181 using PendingRegistrationRequests = | 191 using PendingRegistrationRequests = |
| 182 std::map<linked_ptr<RegistrationInfo>, | 192 std::map<linked_ptr<RegistrationInfo>, |
| 183 std::unique_ptr<RegistrationRequest>, | 193 std::unique_ptr<RegistrationRequest>, |
| 184 RegistrationInfoComparer>; | 194 RegistrationInfoComparer>; |
| 185 | 195 |
| 186 // Collection of pending unregistration requests. Keys are RegistrationInfo | 196 // Collection of pending unregistration requests. Keys are RegistrationInfo |
| 187 // instance, while values are pending unregistration requests to disable the | 197 // instance, while values are pending unregistration requests to disable the |
| (...skipping 25 matching lines...) Expand all Loading... |
| 213 void OnLoadCompleted(std::unique_ptr<GCMStore::LoadResult> result); | 223 void OnLoadCompleted(std::unique_ptr<GCMStore::LoadResult> result); |
| 214 // Starts the GCM. | 224 // Starts the GCM. |
| 215 void StartGCM(); | 225 void StartGCM(); |
| 216 // Initializes mcs_client_, which handles the connection to MCS. | 226 // Initializes mcs_client_, which handles the connection to MCS. |
| 217 void InitializeMCSClient(); | 227 void InitializeMCSClient(); |
| 218 // Complets the first time device checkin. | 228 // Complets the first time device checkin. |
| 219 void OnFirstTimeDeviceCheckinCompleted(const CheckinInfo& checkin_info); | 229 void OnFirstTimeDeviceCheckinCompleted(const CheckinInfo& checkin_info); |
| 220 // Starts a login on mcs_client_. | 230 // Starts a login on mcs_client_. |
| 221 void StartMCSLogin(); | 231 void StartMCSLogin(); |
| 222 // Resets the GCM store when it is corrupted. | 232 // Resets the GCM store when it is corrupted. |
| 223 void ResetStore(); | 233 void ResetStore(ResetReason reset_reason); |
| 224 // Sets state to ready. This will initiate the MCS login and notify the | 234 // Sets state to ready. This will initiate the MCS login and notify the |
| 225 // delegates. | 235 // delegates. |
| 226 void OnReady(const std::vector<AccountMapping>& account_mappings, | 236 void OnReady(const std::vector<AccountMapping>& account_mappings, |
| 227 const base::Time& last_token_fetch_time); | 237 const base::Time& last_token_fetch_time); |
| 228 | 238 |
| 229 // Starts a first time device checkin. | 239 // Starts a first time device checkin. |
| 230 void StartCheckin(); | 240 void StartCheckin(); |
| 231 // Completes the device checkin request by parsing the |checkin_response|. | 241 // Completes the device checkin request by parsing the |checkin_response|. |
| 232 // Function also cleans up the pending checkin. | 242 // Function also cleans up the pending checkin. |
| 233 void OnCheckinCompleted( | 243 void OnCheckinCompleted( |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 394 |
| 385 // Factory for creating references in callbacks. | 395 // Factory for creating references in callbacks. |
| 386 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; | 396 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; |
| 387 | 397 |
| 388 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); | 398 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); |
| 389 }; | 399 }; |
| 390 | 400 |
| 391 } // namespace gcm | 401 } // namespace gcm |
| 392 | 402 |
| 393 #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ | 403 #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ |
| OLD | NEW |