| 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_ENGINE_MCS_CLIENT_H_ | 5 #ifndef GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ |
| 6 #define GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ | 6 #define GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> |
| 12 #include <string> | 13 #include <string> |
| 13 #include <vector> | 14 #include <vector> |
| 14 | 15 |
| 15 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 17 #include "base/memory/linked_ptr.h" | 18 #include "base/memory/linked_ptr.h" |
| 18 #include "base/memory/scoped_ptr.h" | |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "google_apis/gcm/base/gcm_export.h" | 20 #include "google_apis/gcm/base/gcm_export.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/connection_factory.h" | 22 #include "google_apis/gcm/engine/connection_factory.h" |
| 23 #include "google_apis/gcm/engine/connection_handler.h" | 23 #include "google_apis/gcm/engine/connection_handler.h" |
| 24 #include "google_apis/gcm/engine/gcm_store.h" | 24 #include "google_apis/gcm/engine/gcm_store.h" |
| 25 #include "google_apis/gcm/engine/heartbeat_manager.h" | 25 #include "google_apis/gcm/engine/heartbeat_manager.h" |
| 26 | 26 |
| 27 namespace base { | 27 namespace base { |
| 28 class Clock; | 28 class Clock; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // passing the id/token information back via |initialization_callback| along | 111 // passing the id/token information back via |initialization_callback| along |
| 112 // with a |success == true| result. If no GCM information is present (and | 112 // with a |success == true| result. If no GCM information is present (and |
| 113 // this is therefore a fresh client), a clean GCM store will be created and | 113 // this is therefore a fresh client), a clean GCM store will be created and |
| 114 // values of 0 will be returned via |initialization_callback| with | 114 // values of 0 will be returned via |initialization_callback| with |
| 115 // |success == true|. | 115 // |success == true|. |
| 116 // If an error loading the GCM store is encountered, | 116 // If an error loading the GCM store is encountered, |
| 117 // |initialization_callback| will be invoked with |success == false|. | 117 // |initialization_callback| will be invoked with |success == false|. |
| 118 void Initialize(const ErrorCallback& initialization_callback, | 118 void Initialize(const ErrorCallback& initialization_callback, |
| 119 const OnMessageReceivedCallback& message_received_callback, | 119 const OnMessageReceivedCallback& message_received_callback, |
| 120 const OnMessageSentCallback& message_sent_callback, | 120 const OnMessageSentCallback& message_sent_callback, |
| 121 scoped_ptr<GCMStore::LoadResult> load_result); | 121 std::unique_ptr<GCMStore::LoadResult> load_result); |
| 122 | 122 |
| 123 // Logs the client into the server. Client must be initialized. | 123 // Logs the client into the server. Client must be initialized. |
| 124 // |android_id| and |security_token| are optional if this is not a new | 124 // |android_id| and |security_token| are optional if this is not a new |
| 125 // client, else they must be non-zero. | 125 // client, else they must be non-zero. |
| 126 // Successful login will result in |message_received_callback| being invoked | 126 // Successful login will result in |message_received_callback| being invoked |
| 127 // with a valid LoginResponse. | 127 // with a valid LoginResponse. |
| 128 // Login failure (typically invalid id/token) will shut down the client, and | 128 // Login failure (typically invalid id/token) will shut down the client, and |
| 129 // |initialization_callback| to be invoked with |success = false|. | 129 // |initialization_callback| to be invoked with |success = false|. |
| 130 virtual void Login(uint64_t android_id, uint64_t security_token); | 130 virtual void Login(uint64_t android_id, uint64_t security_token); |
| 131 | 131 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 144 // Returns the size of the send message queue. | 144 // Returns the size of the send message queue. |
| 145 int GetSendQueueSize() const; | 145 int GetSendQueueSize() const; |
| 146 | 146 |
| 147 // Returns the size of the resend messaage queue. | 147 // Returns the size of the resend messaage queue. |
| 148 int GetResendQueueSize() const; | 148 int GetResendQueueSize() const; |
| 149 | 149 |
| 150 // Returns text representation of the state enum. | 150 // Returns text representation of the state enum. |
| 151 std::string GetStateString() const; | 151 std::string GetStateString() const; |
| 152 | 152 |
| 153 // Updates the timer used by |heartbeat_manager_| for sending heartbeats. | 153 // Updates the timer used by |heartbeat_manager_| for sending heartbeats. |
| 154 void UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer); | 154 void UpdateHeartbeatTimer(std::unique_ptr<base::Timer> timer); |
| 155 | 155 |
| 156 // Allows a caller to set a heartbeat interval (in milliseconds) with which | 156 // Allows a caller to set a heartbeat interval (in milliseconds) with which |
| 157 // the MCS connection will be monitored on both ends, to detect device | 157 // the MCS connection will be monitored on both ends, to detect device |
| 158 // presence. In case the newly set interval is less then the current one, | 158 // presence. In case the newly set interval is less then the current one, |
| 159 // connection will be restarted with new heartbeat interval. Valid values have | 159 // connection will be restarted with new heartbeat interval. Valid values have |
| 160 // to be between GetMax/GetMinClientHeartbeatIntervalMs of HeartbeatManager, | 160 // to be between GetMax/GetMinClientHeartbeatIntervalMs of HeartbeatManager, |
| 161 // otherwise the setting won't take effect. | 161 // otherwise the setting won't take effect. |
| 162 void AddHeartbeatInterval(const std::string& scope, int interval_ms); | 162 void AddHeartbeatInterval(const std::string& scope, int interval_ms); |
| 163 void RemoveHeartbeatInterval(const std::string& scope); | 163 void RemoveHeartbeatInterval(const std::string& scope); |
| 164 | 164 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 188 | 188 |
| 189 // Attempt to send a message. | 189 // Attempt to send a message. |
| 190 void MaybeSendMessage(); | 190 void MaybeSendMessage(); |
| 191 | 191 |
| 192 // Helper for sending a protobuf along with any unacknowledged ids to the | 192 // Helper for sending a protobuf along with any unacknowledged ids to the |
| 193 // wire. | 193 // wire. |
| 194 void SendPacketToWire(ReliablePacketInfo* packet_info); | 194 void SendPacketToWire(ReliablePacketInfo* packet_info); |
| 195 | 195 |
| 196 // Handle a data message sent to the MCS client system from the MCS server. | 196 // Handle a data message sent to the MCS client system from the MCS server. |
| 197 void HandleMCSDataMesssage( | 197 void HandleMCSDataMesssage( |
| 198 scoped_ptr<google::protobuf::MessageLite> protobuf); | 198 std::unique_ptr<google::protobuf::MessageLite> protobuf); |
| 199 | 199 |
| 200 // Handle a packet received over the wire. | 200 // Handle a packet received over the wire. |
| 201 void HandlePacketFromWire(scoped_ptr<google::protobuf::MessageLite> protobuf); | 201 void HandlePacketFromWire( |
| 202 std::unique_ptr<google::protobuf::MessageLite> protobuf); |
| 202 | 203 |
| 203 // ReliableMessageQueue acknowledgment helpers. | 204 // ReliableMessageQueue acknowledgment helpers. |
| 204 // Handle a StreamAck sent by the server confirming receipt of all | 205 // Handle a StreamAck sent by the server confirming receipt of all |
| 205 // messages up to the message with stream id |last_stream_id_received|. | 206 // messages up to the message with stream id |last_stream_id_received|. |
| 206 void HandleStreamAck(StreamId last_stream_id_received_); | 207 void HandleStreamAck(StreamId last_stream_id_received_); |
| 207 // Handle a SelectiveAck sent by the server confirming all messages | 208 // Handle a SelectiveAck sent by the server confirming all messages |
| 208 // in |id_list|. | 209 // in |id_list|. |
| 209 void HandleSelectiveAck(const PersistentIdList& id_list); | 210 void HandleSelectiveAck(const PersistentIdList& id_list); |
| 210 // Handle server confirmation of a device message, including device's | 211 // Handle server confirmation of a device message, including device's |
| 211 // acknowledgment of receipt of messages. | 212 // acknowledgment of receipt of messages. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 GCMStatsRecorder* recorder_; | 308 GCMStatsRecorder* recorder_; |
| 308 | 309 |
| 309 base::WeakPtrFactory<MCSClient> weak_ptr_factory_; | 310 base::WeakPtrFactory<MCSClient> weak_ptr_factory_; |
| 310 | 311 |
| 311 DISALLOW_COPY_AND_ASSIGN(MCSClient); | 312 DISALLOW_COPY_AND_ASSIGN(MCSClient); |
| 312 }; | 313 }; |
| 313 | 314 |
| 314 } // namespace gcm | 315 } // namespace gcm |
| 315 | 316 |
| 316 #endif // GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ | 317 #endif // GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ |
| OLD | NEW |