OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ |
6 #define GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ | 6 #define GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 GCM_EXPORT GCMClientImpl : public GCMClient { |
77 : public GCMClient, public GCMStatsRecorder::Delegate { | |
78 public: | 77 public: |
79 explicit GCMClientImpl(scoped_ptr<GCMInternalsBuilder> internals_builder); | 78 explicit GCMClientImpl(scoped_ptr<GCMInternalsBuilder> internals_builder); |
80 virtual ~GCMClientImpl(); | 79 virtual ~GCMClientImpl(); |
81 | 80 |
82 // Overridden from GCMClient: | 81 // Overridden from GCMClient: |
83 virtual void Initialize( | 82 virtual void Initialize( |
84 const checkin_proto::ChromeBuildProto& chrome_build_proto, | 83 const checkin_proto::ChromeBuildProto& chrome_build_proto, |
85 const base::FilePath& store_path, | 84 const base::FilePath& store_path, |
86 const std::vector<std::string>& account_ids, | 85 const std::vector<std::string>& account_ids, |
87 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, | 86 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, |
88 const scoped_refptr<net::URLRequestContextGetter>& | 87 const scoped_refptr<net::URLRequestContextGetter>& |
89 url_request_context_getter, | 88 url_request_context_getter, |
90 GCMClient::Delegate* delegate) OVERRIDE; | 89 Delegate* delegate) OVERRIDE; |
91 virtual void Load() OVERRIDE; | 90 virtual void Load() OVERRIDE; |
92 virtual void Stop() OVERRIDE; | 91 virtual void Stop() OVERRIDE; |
93 virtual void CheckOut() OVERRIDE; | 92 virtual void CheckOut() OVERRIDE; |
94 virtual void Register(const std::string& app_id, | 93 virtual void Register(const std::string& app_id, |
95 const std::vector<std::string>& sender_ids) OVERRIDE; | 94 const std::vector<std::string>& sender_ids) OVERRIDE; |
96 virtual void Unregister(const std::string& app_id) OVERRIDE; | 95 virtual void Unregister(const std::string& app_id) OVERRIDE; |
97 virtual void Send(const std::string& app_id, | 96 virtual void Send(const std::string& app_id, |
98 const std::string& receiver_id, | 97 const std::string& receiver_id, |
99 const OutgoingMessage& message) OVERRIDE; | 98 const OutgoingMessage& message) OVERRIDE; |
100 virtual void SetRecording(bool recording) OVERRIDE; | 99 virtual void SetRecording(bool recording) OVERRIDE; |
101 virtual void ClearActivityLogs() OVERRIDE; | 100 virtual void ClearActivityLogs() OVERRIDE; |
102 virtual GCMStatistics GetStatistics() const OVERRIDE; | 101 virtual GCMStatistics GetStatistics() const OVERRIDE; |
103 virtual void OnActivityRecorded() OVERRIDE; | |
104 | 102 |
105 private: | 103 private: |
106 // State representation of the GCMClient. | 104 // State representation of the GCMClient. |
107 // Any change made to this enum should have corresponding change in the | 105 // Any change made to this enum should have corresponding change in the |
108 // GetStateString(...) function. | 106 // GetStateString(...) function. |
109 enum State { | 107 enum State { |
110 // Uninitialized. | 108 // Uninitialized. |
111 UNINITIALIZED, | 109 UNINITIALIZED, |
112 // Initialized, | 110 // Initialized, |
113 INITIALIZED, | 111 INITIALIZED, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 228 |
231 // Builder for the GCM internals (mcs client, etc.). | 229 // Builder for the GCM internals (mcs client, etc.). |
232 scoped_ptr<GCMInternalsBuilder> internals_builder_; | 230 scoped_ptr<GCMInternalsBuilder> internals_builder_; |
233 | 231 |
234 // Recorder that logs GCM activities. | 232 // Recorder that logs GCM activities. |
235 GCMStatsRecorder recorder_; | 233 GCMStatsRecorder recorder_; |
236 | 234 |
237 // State of the GCM Client Implementation. | 235 // State of the GCM Client Implementation. |
238 State state_; | 236 State state_; |
239 | 237 |
240 GCMClient::Delegate* delegate_; | 238 Delegate* delegate_; |
241 | 239 |
242 // Device checkin info (android ID and security token used by device). | 240 // Device checkin info (android ID and security token used by device). |
243 CheckinInfo device_checkin_info_; | 241 CheckinInfo device_checkin_info_; |
244 | 242 |
245 // Clock used for timing of retry logic. Passed in for testing. Owned by | 243 // Clock used for timing of retry logic. Passed in for testing. Owned by |
246 // GCMClientImpl. | 244 // GCMClientImpl. |
247 scoped_ptr<base::Clock> clock_; | 245 scoped_ptr<base::Clock> clock_; |
248 | 246 |
249 // Information about the chrome build. | 247 // Information about the chrome build. |
250 // TODO(fgorski): Check if it can be passed in constructor and made const. | 248 // TODO(fgorski): Check if it can be passed in constructor and made const. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 289 |
292 // Factory for creating references in callbacks. | 290 // Factory for creating references in callbacks. |
293 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; | 291 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; |
294 | 292 |
295 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); | 293 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); |
296 }; | 294 }; |
297 | 295 |
298 } // namespace gcm | 296 } // namespace gcm |
299 | 297 |
300 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ | 298 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ |
OLD | NEW |