| 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 <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/containers/scoped_ptr_map.h" |
| 15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 17 #include "base/stl_util.h" | |
| 18 #include "components/gcm_driver/gcm_client.h" | 19 #include "components/gcm_driver/gcm_client.h" |
| 19 #include "components/gcm_driver/gcm_stats_recorder_impl.h" | 20 #include "components/gcm_driver/gcm_stats_recorder_impl.h" |
| 20 #include "google_apis/gcm/base/mcs_message.h" | 21 #include "google_apis/gcm/base/mcs_message.h" |
| 21 #include "google_apis/gcm/engine/gcm_store.h" | 22 #include "google_apis/gcm/engine/gcm_store.h" |
| 22 #include "google_apis/gcm/engine/gservices_settings.h" | 23 #include "google_apis/gcm/engine/gservices_settings.h" |
| 23 #include "google_apis/gcm/engine/mcs_client.h" | 24 #include "google_apis/gcm/engine/mcs_client.h" |
| 24 #include "google_apis/gcm/engine/registration_request.h" | 25 #include "google_apis/gcm/engine/registration_request.h" |
| 25 #include "google_apis/gcm/engine/unregistration_request.h" | 26 #include "google_apis/gcm/engine/unregistration_request.h" |
| 26 #include "google_apis/gcm/protocol/android_checkin.pb.h" | 27 #include "google_apis/gcm/protocol/android_checkin.pb.h" |
| 27 #include "google_apis/gcm/protocol/checkin.pb.h" | 28 #include "google_apis/gcm/protocol/checkin.pb.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // Map of account email addresses and OAuth2 tokens that will be sent to the | 166 // Map of account email addresses and OAuth2 tokens that will be sent to the |
| 166 // checkin server on a next checkin. | 167 // checkin server on a next checkin. |
| 167 std::map<std::string, std::string> account_tokens; | 168 std::map<std::string, std::string> account_tokens; |
| 168 // As set of accounts last checkin was completed with. | 169 // As set of accounts last checkin was completed with. |
| 169 std::set<std::string> last_checkin_accounts; | 170 std::set<std::string> last_checkin_accounts; |
| 170 }; | 171 }; |
| 171 | 172 |
| 172 // Collection of pending registration requests. Keys are RegistrationInfo | 173 // Collection of pending registration requests. Keys are RegistrationInfo |
| 173 // instance, while values are pending registration requests to obtain a | 174 // instance, while values are pending registration requests to obtain a |
| 174 // registration ID for requesting application. | 175 // registration ID for requesting application. |
| 175 typedef std::map<linked_ptr<RegistrationInfo>, | 176 typedef base::ScopedPtrMap<linked_ptr<RegistrationInfo>, |
| 176 RegistrationRequest*, | 177 scoped_ptr<RegistrationRequest>, |
| 177 RegistrationInfoComparer> PendingRegistrationRequests; | 178 RegistrationInfoComparer> |
| 179 PendingRegistrationRequests; |
| 178 | 180 |
| 179 // Collection of pending unregistration requests. Keys are RegistrationInfo | 181 // Collection of pending unregistration requests. Keys are RegistrationInfo |
| 180 // instance, while values are pending unregistration requests to disable the | 182 // instance, while values are pending unregistration requests to disable the |
| 181 // registration ID currently assigned to the application. | 183 // registration ID currently assigned to the application. |
| 182 typedef std::map<linked_ptr<RegistrationInfo>, | 184 typedef base::ScopedPtrMap<linked_ptr<RegistrationInfo>, |
| 183 UnregistrationRequest*, | 185 scoped_ptr<UnregistrationRequest>, |
| 184 RegistrationInfoComparer> PendingUnregistrationRequests; | 186 RegistrationInfoComparer> |
| 187 PendingUnregistrationRequests; |
| 185 | 188 |
| 186 friend class GCMClientImplTest; | 189 friend class GCMClientImplTest; |
| 187 friend class GCMClientInstanceIDTest; | 190 friend class GCMClientInstanceIDTest; |
| 188 | 191 |
| 189 // Returns text representation of the enum State. | 192 // Returns text representation of the enum State. |
| 190 std::string GetStateString() const; | 193 std::string GetStateString() const; |
| 191 | 194 |
| 192 // Callbacks for the MCSClient. | 195 // Callbacks for the MCSClient. |
| 193 // Receives messages and dispatches them to relevant user delegates. | 196 // Receives messages and dispatches them to relevant user delegates. |
| 194 void OnMessageReceivedFromMCS(const gcm::MCSMessage& message); | 197 void OnMessageReceivedFromMCS(const gcm::MCSMessage& message); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 scoped_ptr<MCSClient> mcs_client_; | 345 scoped_ptr<MCSClient> mcs_client_; |
| 343 | 346 |
| 344 scoped_ptr<CheckinRequest> checkin_request_; | 347 scoped_ptr<CheckinRequest> checkin_request_; |
| 345 | 348 |
| 346 // Cached registration info. | 349 // Cached registration info. |
| 347 RegistrationInfoMap registrations_; | 350 RegistrationInfoMap registrations_; |
| 348 | 351 |
| 349 // Currently pending registration requests. GCMClientImpl owns the | 352 // Currently pending registration requests. GCMClientImpl owns the |
| 350 // RegistrationRequests. | 353 // RegistrationRequests. |
| 351 PendingRegistrationRequests pending_registration_requests_; | 354 PendingRegistrationRequests pending_registration_requests_; |
| 352 STLValueDeleter<PendingRegistrationRequests> | |
| 353 pending_registration_requests_deleter_; | |
| 354 | 355 |
| 355 // Currently pending unregistration requests. GCMClientImpl owns the | 356 // Currently pending unregistration requests. GCMClientImpl owns the |
| 356 // UnregistrationRequests. | 357 // UnregistrationRequests. |
| 357 PendingUnregistrationRequests pending_unregistration_requests_; | 358 PendingUnregistrationRequests pending_unregistration_requests_; |
| 358 STLValueDeleter<PendingUnregistrationRequests> | |
| 359 pending_unregistration_requests_deleter_; | |
| 360 | 359 |
| 361 // G-services settings that were provided by MCS. | 360 // G-services settings that were provided by MCS. |
| 362 GServicesSettings gservices_settings_; | 361 GServicesSettings gservices_settings_; |
| 363 | 362 |
| 364 // Time of the last successful checkin. | 363 // Time of the last successful checkin. |
| 365 base::Time last_checkin_time_; | 364 base::Time last_checkin_time_; |
| 366 | 365 |
| 367 // Cached instance ID data, key is app ID and value is pair of instance ID | 366 // Cached instance ID data, key is app ID and value is pair of instance ID |
| 368 // and extra data. | 367 // and extra data. |
| 369 std::map<std::string, std::pair<std::string, std::string>> instance_id_data_; | 368 std::map<std::string, std::pair<std::string, std::string>> instance_id_data_; |
| 370 | 369 |
| 371 // Factory for creating references when scheduling periodic checkin. | 370 // Factory for creating references when scheduling periodic checkin. |
| 372 base::WeakPtrFactory<GCMClientImpl> periodic_checkin_ptr_factory_; | 371 base::WeakPtrFactory<GCMClientImpl> periodic_checkin_ptr_factory_; |
| 373 | 372 |
| 374 // Factory for wiping out GCM store. | 373 // Factory for wiping out GCM store. |
| 375 base::WeakPtrFactory<GCMClientImpl> destroying_gcm_store_ptr_factory_; | 374 base::WeakPtrFactory<GCMClientImpl> destroying_gcm_store_ptr_factory_; |
| 376 | 375 |
| 377 // Factory for creating references in callbacks. | 376 // Factory for creating references in callbacks. |
| 378 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; | 377 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; |
| 379 | 378 |
| 380 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); | 379 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); |
| 381 }; | 380 }; |
| 382 | 381 |
| 383 } // namespace gcm | 382 } // namespace gcm |
| 384 | 383 |
| 385 #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ | 384 #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ |
| OLD | NEW |