| 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 ScopedPtrMap<linked_ptr<RegistrationInfo>, |
| 176 RegistrationRequest*, | 177 scoped_ptr<RegistrationRequest>, |
| 177 RegistrationInfoComparer> PendingRegistrationRequests; | 178 RegistrationInfoComparer> PendingRegistrationRequests; |
| 178 | 179 |
| 179 // Collection of pending unregistration requests. Keys are RegistrationInfo | 180 // Collection of pending unregistration requests. Keys are RegistrationInfo |
| 180 // instance, while values are pending unregistration requests to disable the | 181 // instance, while values are pending unregistration requests to disable the |
| 181 // registration ID currently assigned to the application. | 182 // registration ID currently assigned to the application. |
| 182 typedef std::map<linked_ptr<RegistrationInfo>, | 183 typedef ScopedPtrMap<linked_ptr<RegistrationInfo>, |
| 183 UnregistrationRequest*, | 184 scoped_ptr<UnregistrationRequest>, |
| 184 RegistrationInfoComparer> PendingUnregistrationRequests; | 185 RegistrationInfoComparer> PendingUnregistrationRequests; |
| 185 | 186 |
| 186 friend class GCMClientImplTest; | 187 friend class GCMClientImplTest; |
| 187 friend class GCMClientInstanceIDTest; | 188 friend class GCMClientInstanceIDTest; |
| 188 | 189 |
| 189 // Returns text representation of the enum State. | 190 // Returns text representation of the enum State. |
| 190 std::string GetStateString() const; | 191 std::string GetStateString() const; |
| 191 | 192 |
| 192 // Callbacks for the MCSClient. | 193 // Callbacks for the MCSClient. |
| 193 // Receives messages and dispatches them to relevant user delegates. | 194 // Receives messages and dispatches them to relevant user delegates. |
| 194 void OnMessageReceivedFromMCS(const gcm::MCSMessage& message); | 195 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_; | 343 scoped_ptr<MCSClient> mcs_client_; |
| 343 | 344 |
| 344 scoped_ptr<CheckinRequest> checkin_request_; | 345 scoped_ptr<CheckinRequest> checkin_request_; |
| 345 | 346 |
| 346 // Cached registration info. | 347 // Cached registration info. |
| 347 RegistrationInfoMap registrations_; | 348 RegistrationInfoMap registrations_; |
| 348 | 349 |
| 349 // Currently pending registration requests. GCMClientImpl owns the | 350 // Currently pending registration requests. GCMClientImpl owns the |
| 350 // RegistrationRequests. | 351 // RegistrationRequests. |
| 351 PendingRegistrationRequests pending_registration_requests_; | 352 PendingRegistrationRequests pending_registration_requests_; |
| 352 STLValueDeleter<PendingRegistrationRequests> | |
| 353 pending_registration_requests_deleter_; | |
| 354 | 353 |
| 355 // Currently pending unregistration requests. GCMClientImpl owns the | 354 // Currently pending unregistration requests. GCMClientImpl owns the |
| 356 // UnregistrationRequests. | 355 // UnregistrationRequests. |
| 357 PendingUnregistrationRequests pending_unregistration_requests_; | 356 PendingUnregistrationRequests pending_unregistration_requests_; |
| 358 STLValueDeleter<PendingUnregistrationRequests> | |
| 359 pending_unregistration_requests_deleter_; | |
| 360 | 357 |
| 361 // G-services settings that were provided by MCS. | 358 // G-services settings that were provided by MCS. |
| 362 GServicesSettings gservices_settings_; | 359 GServicesSettings gservices_settings_; |
| 363 | 360 |
| 364 // Time of the last successful checkin. | 361 // Time of the last successful checkin. |
| 365 base::Time last_checkin_time_; | 362 base::Time last_checkin_time_; |
| 366 | 363 |
| 367 // Cached instance ID data, key is app ID and value is pair of instance ID | 364 // Cached instance ID data, key is app ID and value is pair of instance ID |
| 368 // and extra data. | 365 // and extra data. |
| 369 std::map<std::string, std::pair<std::string, std::string>> instance_id_data_; | 366 std::map<std::string, std::pair<std::string, std::string>> instance_id_data_; |
| 370 | 367 |
| 371 // Factory for creating references when scheduling periodic checkin. | 368 // Factory for creating references when scheduling periodic checkin. |
| 372 base::WeakPtrFactory<GCMClientImpl> periodic_checkin_ptr_factory_; | 369 base::WeakPtrFactory<GCMClientImpl> periodic_checkin_ptr_factory_; |
| 373 | 370 |
| 374 // Factory for wiping out GCM store. | 371 // Factory for wiping out GCM store. |
| 375 base::WeakPtrFactory<GCMClientImpl> destroying_gcm_store_ptr_factory_; | 372 base::WeakPtrFactory<GCMClientImpl> destroying_gcm_store_ptr_factory_; |
| 376 | 373 |
| 377 // Factory for creating references in callbacks. | 374 // Factory for creating references in callbacks. |
| 378 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; | 375 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; |
| 379 | 376 |
| 380 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); | 377 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); |
| 381 }; | 378 }; |
| 382 | 379 |
| 383 } // namespace gcm | 380 } // namespace gcm |
| 384 | 381 |
| 385 #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ | 382 #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ |
| OLD | NEW |