OLD | NEW |
1 // Copyright 2013 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 GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ |
6 #define GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ | 6 #define COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "components/gcm_driver/gcm_client.h" |
| 17 #include "components/gcm_driver/gcm_stats_recorder_impl.h" |
16 #include "google_apis/gcm/base/mcs_message.h" | 18 #include "google_apis/gcm/base/mcs_message.h" |
17 #include "google_apis/gcm/engine/gcm_store.h" | 19 #include "google_apis/gcm/engine/gcm_store.h" |
18 #include "google_apis/gcm/engine/gservices_settings.h" | 20 #include "google_apis/gcm/engine/gservices_settings.h" |
19 #include "google_apis/gcm/engine/mcs_client.h" | 21 #include "google_apis/gcm/engine/mcs_client.h" |
20 #include "google_apis/gcm/engine/registration_request.h" | 22 #include "google_apis/gcm/engine/registration_request.h" |
21 #include "google_apis/gcm/engine/unregistration_request.h" | 23 #include "google_apis/gcm/engine/unregistration_request.h" |
22 #include "google_apis/gcm/gcm_client.h" | |
23 #include "google_apis/gcm/monitoring/gcm_stats_recorder_impl.h" | |
24 #include "google_apis/gcm/protocol/android_checkin.pb.h" | 24 #include "google_apis/gcm/protocol/android_checkin.pb.h" |
25 #include "google_apis/gcm/protocol/checkin.pb.h" | 25 #include "google_apis/gcm/protocol/checkin.pb.h" |
26 #include "net/base/net_log.h" | 26 #include "net/base/net_log.h" |
27 #include "net/url_request/url_request_context_getter.h" | 27 #include "net/url_request/url_request_context_getter.h" |
28 | 28 |
29 class GURL; | 29 class GURL; |
30 | 30 |
31 namespace base { | 31 namespace base { |
32 class Clock; | 32 class Clock; |
33 class Time; | 33 class Time; |
34 } // namespace base | 34 } // namespace base |
35 | 35 |
36 namespace mcs_proto { | 36 namespace mcs_proto { |
37 class DataMessageStanza; | 37 class DataMessageStanza; |
38 } // namespace mcs_proto | 38 } // namespace mcs_proto |
39 | 39 |
40 namespace net { | 40 namespace net { |
41 class HttpNetworkSession; | 41 class HttpNetworkSession; |
42 } // namespace net | 42 } // namespace net |
43 | 43 |
44 namespace gcm { | 44 namespace gcm { |
45 | 45 |
46 class CheckinRequest; | 46 class CheckinRequest; |
47 class ConnectionFactory; | 47 class ConnectionFactory; |
48 class GCMClientImplTest; | 48 class GCMClientImplTest; |
49 | 49 |
50 // Helper class for building GCM internals. Allows tests to inject fake versions | 50 // Helper class for building GCM internals. Allows tests to inject fake versions |
51 // as necessary. | 51 // as necessary. |
52 class GCM_EXPORT GCMInternalsBuilder { | 52 class GCMInternalsBuilder { |
53 public: | 53 public: |
54 GCMInternalsBuilder(); | 54 GCMInternalsBuilder(); |
55 virtual ~GCMInternalsBuilder(); | 55 virtual ~GCMInternalsBuilder(); |
56 | 56 |
57 virtual scoped_ptr<base::Clock> BuildClock(); | 57 virtual scoped_ptr<base::Clock> BuildClock(); |
58 virtual scoped_ptr<MCSClient> BuildMCSClient( | 58 virtual scoped_ptr<MCSClient> BuildMCSClient( |
59 const std::string& version, | 59 const std::string& version, |
60 base::Clock* clock, | 60 base::Clock* clock, |
61 ConnectionFactory* connection_factory, | 61 ConnectionFactory* connection_factory, |
62 GCMStore* gcm_store, | 62 GCMStore* gcm_store, |
63 GCMStatsRecorder* recorder); | 63 GCMStatsRecorder* recorder); |
64 virtual scoped_ptr<ConnectionFactory> BuildConnectionFactory( | 64 virtual scoped_ptr<ConnectionFactory> BuildConnectionFactory( |
65 const std::vector<GURL>& endpoints, | 65 const std::vector<GURL>& endpoints, |
66 const net::BackoffEntry::Policy& backoff_policy, | 66 const net::BackoffEntry::Policy& backoff_policy, |
67 scoped_refptr<net::HttpNetworkSession> network_session, | 67 scoped_refptr<net::HttpNetworkSession> network_session, |
68 net::NetLog* net_log, | 68 net::NetLog* net_log, |
69 GCMStatsRecorder* recorder); | 69 GCMStatsRecorder* recorder); |
70 }; | 70 }; |
71 | 71 |
72 // Implements the GCM Client. It is used to coordinate MCS Client (communication | 72 // Implements the GCM Client. It is used to coordinate MCS Client (communication |
73 // with MCS) and other pieces of GCM infrastructure like Registration and | 73 // with MCS) and other pieces of GCM infrastructure like Registration and |
74 // Checkins. It also allows for registering user delegates that host | 74 // Checkins. It also allows for registering user delegates that host |
75 // applications that send and receive messages. | 75 // applications that send and receive messages. |
76 class GCM_EXPORT GCMClientImpl | 76 class GCMClientImpl |
77 : public GCMClient, public GCMStatsRecorder::Delegate { | 77 : public GCMClient, public GCMStatsRecorder::Delegate { |
78 public: | 78 public: |
79 explicit GCMClientImpl(scoped_ptr<GCMInternalsBuilder> internals_builder); | 79 explicit GCMClientImpl(scoped_ptr<GCMInternalsBuilder> internals_builder); |
80 virtual ~GCMClientImpl(); | 80 virtual ~GCMClientImpl(); |
81 | 81 |
82 // Overridden from GCMClient: | 82 // Overridden from GCMClient: |
83 virtual void Initialize( | 83 virtual void Initialize( |
84 const ChromeBuildInfo& chrome_build_info, | 84 const ChromeBuildInfo& chrome_build_info, |
85 const base::FilePath& store_path, | 85 const base::FilePath& store_path, |
86 const std::vector<std::string>& account_ids, | 86 const std::vector<std::string>& account_ids, |
(...skipping 27 matching lines...) Expand all Loading... |
114 INITIALIZED, | 114 INITIALIZED, |
115 // GCM store loading is in progress. | 115 // GCM store loading is in progress. |
116 LOADING, | 116 LOADING, |
117 // Initial device checkin is in progress. | 117 // Initial device checkin is in progress. |
118 INITIAL_DEVICE_CHECKIN, | 118 INITIAL_DEVICE_CHECKIN, |
119 // Ready to accept requests. | 119 // Ready to accept requests. |
120 READY, | 120 READY, |
121 }; | 121 }; |
122 | 122 |
123 // The check-in info for the user. Returned by the server. | 123 // The check-in info for the user. Returned by the server. |
124 struct GCM_EXPORT CheckinInfo { | 124 struct CheckinInfo { |
125 CheckinInfo() : android_id(0), secret(0) {} | 125 CheckinInfo() : android_id(0), secret(0) {} |
126 bool IsValid() const { return android_id != 0 && secret != 0; } | 126 bool IsValid() const { return android_id != 0 && secret != 0; } |
127 void Reset() { | 127 void Reset() { |
128 android_id = 0; | 128 android_id = 0; |
129 secret = 0; | 129 secret = 0; |
130 } | 130 } |
131 | 131 |
132 uint64 android_id; | 132 uint64 android_id; |
133 uint64 secret; | 133 uint64 secret; |
134 }; | 134 }; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 base::WeakPtrFactory<GCMClientImpl> periodic_checkin_ptr_factory_; | 291 base::WeakPtrFactory<GCMClientImpl> periodic_checkin_ptr_factory_; |
292 | 292 |
293 // Factory for creating references in callbacks. | 293 // Factory for creating references in callbacks. |
294 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; | 294 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; |
295 | 295 |
296 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); | 296 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); |
297 }; | 297 }; |
298 | 298 |
299 } // namespace gcm | 299 } // namespace gcm |
300 | 300 |
301 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ | 301 #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ |
OLD | NEW |