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/containers/scoped_ptr_map.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "components/gcm_driver/gcm_client.h" | 19 #include "components/gcm_driver/gcm_client.h" |
20 #include "components/gcm_driver/gcm_stats_recorder_impl.h" | 20 #include "components/gcm_driver/gcm_stats_recorder_impl.h" |
21 #include "google_apis/gcm/base/mcs_message.h" | 21 #include "google_apis/gcm/base/mcs_message.h" |
22 #include "google_apis/gcm/engine/gcm_store.h" | 22 #include "google_apis/gcm/engine/gcm_store.h" |
23 #include "google_apis/gcm/engine/gservices_settings.h" | 23 #include "google_apis/gcm/engine/gservices_settings.h" |
24 #include "google_apis/gcm/engine/mcs_client.h" | 24 #include "google_apis/gcm/engine/mcs_client.h" |
25 #include "google_apis/gcm/engine/registration_request.h" | 25 #include "google_apis/gcm/engine/registration_request.h" |
26 #include "google_apis/gcm/engine/unregistration_request.h" | 26 #include "google_apis/gcm/engine/unregistration_request.h" |
27 #include "google_apis/gcm/protocol/android_checkin.pb.h" | 27 #include "google_apis/gcm/protocol/android_checkin.pb.h" |
28 #include "google_apis/gcm/protocol/checkin.pb.h" | 28 #include "google_apis/gcm/protocol/checkin.pb.h" |
29 #include "net/log/net_log.h" | |
30 #include "net/url_request/url_request_context_getter.h" | 29 #include "net/url_request/url_request_context_getter.h" |
31 | 30 |
32 class GURL; | 31 class GURL; |
33 | 32 |
34 namespace base { | 33 namespace base { |
35 class Clock; | 34 class Clock; |
36 class Time; | 35 class Time; |
37 } // namespace base | 36 } // namespace base |
38 | 37 |
39 namespace mcs_proto { | 38 namespace mcs_proto { |
(...skipping 20 matching lines...) Expand all Loading... |
60 virtual scoped_ptr<base::Clock> BuildClock(); | 59 virtual scoped_ptr<base::Clock> BuildClock(); |
61 virtual scoped_ptr<MCSClient> BuildMCSClient( | 60 virtual scoped_ptr<MCSClient> BuildMCSClient( |
62 const std::string& version, | 61 const std::string& version, |
63 base::Clock* clock, | 62 base::Clock* clock, |
64 ConnectionFactory* connection_factory, | 63 ConnectionFactory* connection_factory, |
65 GCMStore* gcm_store, | 64 GCMStore* gcm_store, |
66 GCMStatsRecorder* recorder); | 65 GCMStatsRecorder* recorder); |
67 virtual scoped_ptr<ConnectionFactory> BuildConnectionFactory( | 66 virtual scoped_ptr<ConnectionFactory> BuildConnectionFactory( |
68 const std::vector<GURL>& endpoints, | 67 const std::vector<GURL>& endpoints, |
69 const net::BackoffEntry::Policy& backoff_policy, | 68 const net::BackoffEntry::Policy& backoff_policy, |
70 const scoped_refptr<net::HttpNetworkSession>& gcm_network_session, | 69 net::HttpNetworkSession* gcm_network_session, |
71 const scoped_refptr<net::HttpNetworkSession>& http_network_session, | 70 net::HttpNetworkSession* http_network_session, |
72 net::NetLog* net_log, | |
73 GCMStatsRecorder* recorder); | 71 GCMStatsRecorder* recorder); |
74 }; | 72 }; |
75 | 73 |
76 // Implements the GCM Client. It is used to coordinate MCS Client (communication | 74 // Implements the GCM Client. It is used to coordinate MCS Client (communication |
77 // with MCS) and other pieces of GCM infrastructure like Registration and | 75 // with MCS) and other pieces of GCM infrastructure like Registration and |
78 // Checkins. It also allows for registering user delegates that host | 76 // Checkins. It also allows for registering user delegates that host |
79 // applications that send and receive messages. | 77 // applications that send and receive messages. |
80 class GCMClientImpl | 78 class GCMClientImpl |
81 : public GCMClient, public GCMStatsRecorder::Delegate, | 79 : public GCMClient, public GCMStatsRecorder::Delegate, |
82 public ConnectionFactory::ConnectionListener { | 80 public ConnectionFactory::ConnectionListener { |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 // serial number mappings. | 327 // serial number mappings. |
330 scoped_ptr<GCMStore> gcm_store_; | 328 scoped_ptr<GCMStore> gcm_store_; |
331 | 329 |
332 // Data loaded from the GCM store. | 330 // Data loaded from the GCM store. |
333 scoped_ptr<GCMStore::LoadResult> load_result_; | 331 scoped_ptr<GCMStore::LoadResult> load_result_; |
334 | 332 |
335 // Tracks if the GCM store has been reset. This is used to prevent from | 333 // Tracks if the GCM store has been reset. This is used to prevent from |
336 // resetting and loading from the store again and again. | 334 // resetting and loading from the store again and again. |
337 bool gcm_store_reset_; | 335 bool gcm_store_reset_; |
338 | 336 |
339 scoped_refptr<net::HttpNetworkSession> network_session_; | 337 scoped_ptr<net::HttpNetworkSession> network_session_; |
340 net::BoundNetLog net_log_; | |
341 scoped_ptr<ConnectionFactory> connection_factory_; | 338 scoped_ptr<ConnectionFactory> connection_factory_; |
342 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 339 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
343 | 340 |
344 // Controls receiving and sending of packets and reliable message queueing. | 341 // Controls receiving and sending of packets and reliable message queueing. |
| 342 // Must be destroyed before |network_session_|. |
345 scoped_ptr<MCSClient> mcs_client_; | 343 scoped_ptr<MCSClient> mcs_client_; |
346 | 344 |
347 scoped_ptr<CheckinRequest> checkin_request_; | 345 scoped_ptr<CheckinRequest> checkin_request_; |
348 | 346 |
349 // Cached registration info. | 347 // Cached registration info. |
350 RegistrationInfoMap registrations_; | 348 RegistrationInfoMap registrations_; |
351 | 349 |
352 // Currently pending registration requests. GCMClientImpl owns the | 350 // Currently pending registration requests. GCMClientImpl owns the |
353 // RegistrationRequests. | 351 // RegistrationRequests. |
354 PendingRegistrationRequests pending_registration_requests_; | 352 PendingRegistrationRequests pending_registration_requests_; |
(...skipping 20 matching lines...) Expand all Loading... |
375 | 373 |
376 // Factory for creating references in callbacks. | 374 // Factory for creating references in callbacks. |
377 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; | 375 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; |
378 | 376 |
379 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); | 377 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); |
380 }; | 378 }; |
381 | 379 |
382 } // namespace gcm | 380 } // namespace gcm |
383 | 381 |
384 #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ | 382 #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ |
OLD | NEW |