| 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> |
| 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 "google_apis/gcm/base/mcs_message.h" | 16 #include "google_apis/gcm/base/mcs_message.h" |
| 17 #include "google_apis/gcm/engine/gcm_store.h" | 17 #include "google_apis/gcm/engine/gcm_store.h" |
| 18 #include "google_apis/gcm/engine/mcs_client.h" | 18 #include "google_apis/gcm/engine/mcs_client.h" |
| 19 #include "google_apis/gcm/engine/registration_request.h" | 19 #include "google_apis/gcm/engine/registration_request.h" |
| 20 #include "google_apis/gcm/engine/unregistration_request.h" | 20 #include "google_apis/gcm/engine/unregistration_request.h" |
| 21 #include "google_apis/gcm/gcm_client.h" | 21 #include "google_apis/gcm/gcm_client.h" |
| 22 #include "google_apis/gcm/gcm_stats_recorder.h" |
| 22 #include "google_apis/gcm/protocol/android_checkin.pb.h" | 23 #include "google_apis/gcm/protocol/android_checkin.pb.h" |
| 23 #include "net/base/net_log.h" | 24 #include "net/base/net_log.h" |
| 24 #include "net/url_request/url_request_context_getter.h" | 25 #include "net/url_request/url_request_context_getter.h" |
| 25 | 26 |
| 26 class GURL; | 27 class GURL; |
| 27 | 28 |
| 28 namespace base { | 29 namespace base { |
| 29 class Clock; | 30 class Clock; |
| 30 } // namespace base | 31 } // namespace base |
| 31 | 32 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 44 class GCM_EXPORT GCMInternalsBuilder { | 45 class GCM_EXPORT GCMInternalsBuilder { |
| 45 public: | 46 public: |
| 46 GCMInternalsBuilder(); | 47 GCMInternalsBuilder(); |
| 47 virtual ~GCMInternalsBuilder(); | 48 virtual ~GCMInternalsBuilder(); |
| 48 | 49 |
| 49 virtual scoped_ptr<base::Clock> BuildClock(); | 50 virtual scoped_ptr<base::Clock> BuildClock(); |
| 50 virtual scoped_ptr<MCSClient> BuildMCSClient( | 51 virtual scoped_ptr<MCSClient> BuildMCSClient( |
| 51 const std::string& version, | 52 const std::string& version, |
| 52 base::Clock* clock, | 53 base::Clock* clock, |
| 53 ConnectionFactory* connection_factory, | 54 ConnectionFactory* connection_factory, |
| 54 GCMStore* gcm_store); | 55 GCMStore* gcm_store, |
| 56 GCMStatsRecorder* recorder); |
| 55 virtual scoped_ptr<ConnectionFactory> BuildConnectionFactory( | 57 virtual scoped_ptr<ConnectionFactory> BuildConnectionFactory( |
| 56 const std::vector<GURL>& endpoints, | 58 const std::vector<GURL>& endpoints, |
| 57 const net::BackoffEntry::Policy& backoff_policy, | 59 const net::BackoffEntry::Policy& backoff_policy, |
| 58 scoped_refptr<net::HttpNetworkSession> network_session, | 60 scoped_refptr<net::HttpNetworkSession> network_session, |
| 59 net::NetLog* net_log); | 61 net::NetLog* net_log); |
| 60 }; | 62 }; |
| 61 | 63 |
| 62 // Implements the GCM Client. It is used to coordinate MCS Client (communication | 64 // Implements the GCM Client. It is used to coordinate MCS Client (communication |
| 63 // with MCS) and other pieces of GCM infrastructure like Registration and | 65 // with MCS) and other pieces of GCM infrastructure like Registration and |
| 64 // Checkins. It also allows for registering user delegates that host | 66 // Checkins. It also allows for registering user delegates that host |
| (...skipping 14 matching lines...) Expand all Loading... |
| 79 Delegate* delegate) OVERRIDE; | 81 Delegate* delegate) OVERRIDE; |
| 80 virtual void Load() OVERRIDE; | 82 virtual void Load() OVERRIDE; |
| 81 virtual void Stop() OVERRIDE; | 83 virtual void Stop() OVERRIDE; |
| 82 virtual void CheckOut() OVERRIDE; | 84 virtual void CheckOut() OVERRIDE; |
| 83 virtual void Register(const std::string& app_id, | 85 virtual void Register(const std::string& app_id, |
| 84 const std::vector<std::string>& sender_ids) OVERRIDE; | 86 const std::vector<std::string>& sender_ids) OVERRIDE; |
| 85 virtual void Unregister(const std::string& app_id) OVERRIDE; | 87 virtual void Unregister(const std::string& app_id) OVERRIDE; |
| 86 virtual void Send(const std::string& app_id, | 88 virtual void Send(const std::string& app_id, |
| 87 const std::string& receiver_id, | 89 const std::string& receiver_id, |
| 88 const OutgoingMessage& message) OVERRIDE; | 90 const OutgoingMessage& message) OVERRIDE; |
| 91 virtual void SetRecording(bool recording) OVERRIDE; |
| 92 virtual void ClearActivityLogs() OVERRIDE; |
| 89 virtual GCMStatistics GetStatistics() const OVERRIDE; | 93 virtual GCMStatistics GetStatistics() const OVERRIDE; |
| 90 | 94 |
| 91 private: | 95 private: |
| 92 // State representation of the GCMClient. | 96 // State representation of the GCMClient. |
| 93 // Any change made to this enum should have corresponding change in the | 97 // Any change made to this enum should have corresponding change in the |
| 94 // GetStateString(...) function. | 98 // GetStateString(...) function. |
| 95 enum State { | 99 enum State { |
| 96 // Uninitialized. | 100 // Uninitialized. |
| 97 UNINITIALIZED, | 101 UNINITIALIZED, |
| 98 // Initialized, | 102 // Initialized, |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 203 |
| 200 // Fires OnMessageSendError event on the delegate of this calss, based on the | 204 // Fires OnMessageSendError event on the delegate of this calss, based on the |
| 201 // details in |data_message_stanza| and |message_data|. | 205 // details in |data_message_stanza| and |message_data|. |
| 202 void HandleIncomingSendError( | 206 void HandleIncomingSendError( |
| 203 const mcs_proto::DataMessageStanza& data_message_stanza, | 207 const mcs_proto::DataMessageStanza& data_message_stanza, |
| 204 MessageData& message_data); | 208 MessageData& message_data); |
| 205 | 209 |
| 206 // Builder for the GCM internals (mcs client, etc.). | 210 // Builder for the GCM internals (mcs client, etc.). |
| 207 scoped_ptr<GCMInternalsBuilder> internals_builder_; | 211 scoped_ptr<GCMInternalsBuilder> internals_builder_; |
| 208 | 212 |
| 213 // Recorder that logs GCM activities. |
| 214 GCMStatsRecorder recorder_; |
| 215 |
| 209 // State of the GCM Client Implementation. | 216 // State of the GCM Client Implementation. |
| 210 State state_; | 217 State state_; |
| 211 | 218 |
| 212 Delegate* delegate_; | 219 Delegate* delegate_; |
| 213 | 220 |
| 214 // Device checkin info (android ID and security token used by device). | 221 // Device checkin info (android ID and security token used by device). |
| 215 CheckinInfo device_checkin_info_; | 222 CheckinInfo device_checkin_info_; |
| 216 | 223 |
| 217 // Clock used for timing of retry logic. Passed in for testing. Owned by | 224 // Clock used for timing of retry logic. Passed in for testing. Owned by |
| 218 // GCMClientImpl. | 225 // GCMClientImpl. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 261 |
| 255 // Factory for creating references in callbacks. | 262 // Factory for creating references in callbacks. |
| 256 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; | 263 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; |
| 257 | 264 |
| 258 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); | 265 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); |
| 259 }; | 266 }; |
| 260 | 267 |
| 261 } // namespace gcm | 268 } // namespace gcm |
| 262 | 269 |
| 263 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ | 270 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_H_ |
| OLD | NEW |