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 <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 18 matching lines...) Expand all Loading... | |
29 } // namespace protobuf | 29 } // namespace protobuf |
30 } // namespace google | 30 } // namespace google |
31 | 31 |
32 namespace mcs_proto { | 32 namespace mcs_proto { |
33 class LoginRequest; | 33 class LoginRequest; |
34 } | 34 } |
35 | 35 |
36 namespace gcm { | 36 namespace gcm { |
37 | 37 |
38 class ConnectionFactory; | 38 class ConnectionFactory; |
39 class CollapseKey; | |
jianli
2014/02/04 22:55:14
nit: sort
Nicolas Zea
2014/02/12 23:35:46
Done.
| |
39 struct ReliablePacketInfo; | 40 struct ReliablePacketInfo; |
40 | 41 |
41 // An MCS client. This client is in charge of all communications with an | 42 // An MCS client. This client is in charge of all communications with an |
42 // MCS endpoint, and is capable of reliably sending/receiving GCM messages. | 43 // MCS endpoint, and is capable of reliably sending/receiving GCM messages. |
43 // NOTE: Not thread safe. This class should live on the same thread as that | 44 // NOTE: Not thread safe. This class should live on the same thread as that |
44 // network requests are performed on. | 45 // network requests are performed on. |
45 class GCM_EXPORT MCSClient { | 46 class GCM_EXPORT MCSClient { |
46 public: | 47 public: |
47 enum State { | 48 enum State { |
48 UNINITIALIZED, // Uninitialized. | 49 UNINITIALIZED, // Uninitialized. |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 ConnectionHandler* connection_handler_; | 212 ConnectionHandler* connection_handler_; |
212 | 213 |
213 // ----- Reliablie Message Queue section ----- | 214 // ----- Reliablie Message Queue section ----- |
214 // Note: all queues/maps are ordered from oldest (front/begin) message to | 215 // Note: all queues/maps are ordered from oldest (front/begin) message to |
215 // most recent (back/end). | 216 // most recent (back/end). |
216 | 217 |
217 // Send/acknowledge queues. | 218 // Send/acknowledge queues. |
218 std::deque<MCSPacketInternal> to_send_; | 219 std::deque<MCSPacketInternal> to_send_; |
219 std::deque<MCSPacketInternal> to_resend_; | 220 std::deque<MCSPacketInternal> to_resend_; |
220 | 221 |
222 // Map of collapse keys to their pending messages. | |
223 std::map<CollapseKey, ReliablePacketInfo*> collapse_key_map_; | |
jianli
2014/02/04 22:55:14
It seems that the value "ReliablePacketInfo*" is o
Nicolas Zea
2014/02/12 23:35:46
Good catch. Note that to_resend_ will never share
| |
224 | |
221 // Last device_to_server stream id acknowledged by the server. | 225 // Last device_to_server stream id acknowledged by the server. |
222 StreamId last_device_to_server_stream_id_received_; | 226 StreamId last_device_to_server_stream_id_received_; |
223 // Last server_to_device stream id acknowledged by this device. | 227 // Last server_to_device stream id acknowledged by this device. |
224 StreamId last_server_to_device_stream_id_received_; | 228 StreamId last_server_to_device_stream_id_received_; |
225 // The stream id for the last sent message. A new message should consume | 229 // The stream id for the last sent message. A new message should consume |
226 // stream_id_out_ + 1. | 230 // stream_id_out_ + 1. |
227 StreamId stream_id_out_; | 231 StreamId stream_id_out_; |
228 // The stream id of the last received message. The LoginResponse will always | 232 // The stream id of the last received message. The LoginResponse will always |
229 // have a stream id of 1, and stream ids increment by 1 for each received | 233 // have a stream id of 1, and stream ids increment by 1 for each received |
230 // message. | 234 // message. |
(...skipping 21 matching lines...) Expand all Loading... | |
252 HeartbeatManager heartbeat_manager_; | 256 HeartbeatManager heartbeat_manager_; |
253 | 257 |
254 base::WeakPtrFactory<MCSClient> weak_ptr_factory_; | 258 base::WeakPtrFactory<MCSClient> weak_ptr_factory_; |
255 | 259 |
256 DISALLOW_COPY_AND_ASSIGN(MCSClient); | 260 DISALLOW_COPY_AND_ASSIGN(MCSClient); |
257 }; | 261 }; |
258 | 262 |
259 } // namespace gcm | 263 } // namespace gcm |
260 | 264 |
261 #endif // GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ | 265 #endif // GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ |
OLD | NEW |