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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 // WARNING: This is permanent, and the client must be recreated with new | 122 // WARNING: This is permanent, and the client must be recreated with new |
123 // credentials afterwards. | 123 // credentials afterwards. |
124 void Destroy(); | 124 void Destroy(); |
125 | 125 |
126 // Returns the current state of the client. | 126 // Returns the current state of the client. |
127 State state() const { return state_; } | 127 State state() const { return state_; } |
128 | 128 |
129 private: | 129 private: |
130 typedef uint32 StreamId; | 130 typedef uint32 StreamId; |
131 typedef std::string PersistentId; | 131 typedef std::string PersistentId; |
132 typedef std::string AppId; | |
fgorski
2014/01/28 18:10:27
If you mean to use project_id as a value of that f
fgorski
2014/01/28 18:13:31
And speaking of multi-profile scenario... what if
Nicolas Zea
2014/01/31 11:58:43
I've gone ahead and modified this to use a Collaps
| |
132 typedef std::vector<StreamId> StreamIdList; | 133 typedef std::vector<StreamId> StreamIdList; |
133 typedef std::vector<PersistentId> PersistentIdList; | 134 typedef std::vector<PersistentId> PersistentIdList; |
135 typedef std::map<std::string, ReliablePacketInfo*> TokenMap; | |
134 typedef std::map<StreamId, PersistentId> StreamIdToPersistentIdMap; | 136 typedef std::map<StreamId, PersistentId> StreamIdToPersistentIdMap; |
135 typedef linked_ptr<ReliablePacketInfo> MCSPacketInternal; | 137 typedef linked_ptr<ReliablePacketInfo> MCSPacketInternal; |
136 | 138 |
137 // Resets the internal state and builds a new login request, acknowledging | 139 // Resets the internal state and builds a new login request, acknowledging |
138 // any pending server-to-device messages and rebuilding the send queue | 140 // any pending server-to-device messages and rebuilding the send queue |
139 // from all unacknowledged device-to-server messages. | 141 // from all unacknowledged device-to-server messages. |
140 // Should only be called when the connection has been reset. | 142 // Should only be called when the connection has been reset. |
141 void ResetStateAndBuildLoginRequest(mcs_proto::LoginRequest* request); | 143 void ResetStateAndBuildLoginRequest(mcs_proto::LoginRequest* request); |
142 | 144 |
143 // Send a heartbeat to the MCS server. | 145 // Send a heartbeat to the MCS server. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 ConnectionHandler* connection_handler_; | 207 ConnectionHandler* connection_handler_; |
206 | 208 |
207 // ----- Reliablie Message Queue section ----- | 209 // ----- Reliablie Message Queue section ----- |
208 // Note: all queues/maps are ordered from oldest (front/begin) message to | 210 // Note: all queues/maps are ordered from oldest (front/begin) message to |
209 // most recent (back/end). | 211 // most recent (back/end). |
210 | 212 |
211 // Send/acknowledge queues. | 213 // Send/acknowledge queues. |
212 std::deque<MCSPacketInternal> to_send_; | 214 std::deque<MCSPacketInternal> to_send_; |
213 std::deque<MCSPacketInternal> to_resend_; | 215 std::deque<MCSPacketInternal> to_resend_; |
214 | 216 |
217 // Map of collapse keys to their pending messages. | |
218 std::map<AppId, linked_ptr<TokenMap> > collapse_key_map_; | |
219 | |
215 // Last device_to_server stream id acknowledged by the server. | 220 // Last device_to_server stream id acknowledged by the server. |
216 StreamId last_device_to_server_stream_id_received_; | 221 StreamId last_device_to_server_stream_id_received_; |
217 // Last server_to_device stream id acknowledged by this device. | 222 // Last server_to_device stream id acknowledged by this device. |
218 StreamId last_server_to_device_stream_id_received_; | 223 StreamId last_server_to_device_stream_id_received_; |
219 // The stream id for the last sent message. A new message should consume | 224 // The stream id for the last sent message. A new message should consume |
220 // stream_id_out_ + 1. | 225 // stream_id_out_ + 1. |
221 StreamId stream_id_out_; | 226 StreamId stream_id_out_; |
222 // The stream id of the last received message. The LoginResponse will always | 227 // The stream id of the last received message. The LoginResponse will always |
223 // have a stream id of 1, and stream ids increment by 1 for each received | 228 // have a stream id of 1, and stream ids increment by 1 for each received |
224 // message. | 229 // message. |
(...skipping 21 matching lines...) Expand all Loading... | |
246 HeartbeatManager heartbeat_manager_; | 251 HeartbeatManager heartbeat_manager_; |
247 | 252 |
248 base::WeakPtrFactory<MCSClient> weak_ptr_factory_; | 253 base::WeakPtrFactory<MCSClient> weak_ptr_factory_; |
249 | 254 |
250 DISALLOW_COPY_AND_ASSIGN(MCSClient); | 255 DISALLOW_COPY_AND_ASSIGN(MCSClient); |
251 }; | 256 }; |
252 | 257 |
253 } // namespace gcm | 258 } // namespace gcm |
254 | 259 |
255 #endif // GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ | 260 #endif // GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ |
OLD | NEW |