Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Side by Side Diff: google_apis/gcm/engine/mcs_client.h

Issue 148293002: [GCM] Add basic collapse key support for upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « google_apis/gcm/engine/gcm_store_impl.cc ('k') | google_apis/gcm/engine/mcs_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
28 class MessageLite; 28 class MessageLite;
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 CollapseKey;
38 class ConnectionFactory; 39 class ConnectionFactory;
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 {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // Virtual for testing. 184 // Virtual for testing.
184 virtual PersistentId GetNextPersistentId(); 185 virtual PersistentId GetNextPersistentId();
185 186
186 // Helper for the heartbeat manager to signal a connection reset. 187 // Helper for the heartbeat manager to signal a connection reset.
187 void OnConnectionResetByHeartbeat(); 188 void OnConnectionResetByHeartbeat();
188 189
189 // Runs the message_sent_callback_ with send |status| of the |protobuf|. 190 // Runs the message_sent_callback_ with send |status| of the |protobuf|.
190 void NotifyMessageSendStatus(const google::protobuf::MessageLite& protobuf, 191 void NotifyMessageSendStatus(const google::protobuf::MessageLite& protobuf,
191 MessageSendStatus status); 192 MessageSendStatus status);
192 193
194 // Pops the next message from the front of the send queue (cleaning up
195 // any associated state).
196 MCSPacketInternal PopMessageForSend();
197
193 // Clock for enforcing TTL. Passed in for testing. 198 // Clock for enforcing TTL. Passed in for testing.
194 base::Clock* const clock_; 199 base::Clock* const clock_;
195 200
196 // Client state. 201 // Client state.
197 State state_; 202 State state_;
198 203
199 // Callbacks for owner. 204 // Callbacks for owner.
200 ErrorCallback mcs_error_callback_; 205 ErrorCallback mcs_error_callback_;
201 OnMessageReceivedCallback message_received_callback_; 206 OnMessageReceivedCallback message_received_callback_;
202 OnMessageSentCallback message_sent_callback_; 207 OnMessageSentCallback message_sent_callback_;
(...skipping 10 matching lines...) Expand all
213 ConnectionHandler* connection_handler_; 218 ConnectionHandler* connection_handler_;
214 219
215 // ----- Reliablie Message Queue section ----- 220 // ----- Reliablie Message Queue section -----
216 // Note: all queues/maps are ordered from oldest (front/begin) message to 221 // Note: all queues/maps are ordered from oldest (front/begin) message to
217 // most recent (back/end). 222 // most recent (back/end).
218 223
219 // Send/acknowledge queues. 224 // Send/acknowledge queues.
220 std::deque<MCSPacketInternal> to_send_; 225 std::deque<MCSPacketInternal> to_send_;
221 std::deque<MCSPacketInternal> to_resend_; 226 std::deque<MCSPacketInternal> to_resend_;
222 227
228 // Map of collapse keys to their pending messages.
229 std::map<CollapseKey, ReliablePacketInfo*> collapse_key_map_;
230
223 // Last device_to_server stream id acknowledged by the server. 231 // Last device_to_server stream id acknowledged by the server.
224 StreamId last_device_to_server_stream_id_received_; 232 StreamId last_device_to_server_stream_id_received_;
225 // Last server_to_device stream id acknowledged by this device. 233 // Last server_to_device stream id acknowledged by this device.
226 StreamId last_server_to_device_stream_id_received_; 234 StreamId last_server_to_device_stream_id_received_;
227 // The stream id for the last sent message. A new message should consume 235 // The stream id for the last sent message. A new message should consume
228 // stream_id_out_ + 1. 236 // stream_id_out_ + 1.
229 StreamId stream_id_out_; 237 StreamId stream_id_out_;
230 // The stream id of the last received message. The LoginResponse will always 238 // The stream id of the last received message. The LoginResponse will always
231 // have a stream id of 1, and stream ids increment by 1 for each received 239 // have a stream id of 1, and stream ids increment by 1 for each received
232 // message. 240 // message.
(...skipping 21 matching lines...) Expand all
254 HeartbeatManager heartbeat_manager_; 262 HeartbeatManager heartbeat_manager_;
255 263
256 base::WeakPtrFactory<MCSClient> weak_ptr_factory_; 264 base::WeakPtrFactory<MCSClient> weak_ptr_factory_;
257 265
258 DISALLOW_COPY_AND_ASSIGN(MCSClient); 266 DISALLOW_COPY_AND_ASSIGN(MCSClient);
259 }; 267 };
260 268
261 } // namespace gcm 269 } // namespace gcm
262 270
263 #endif // GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ 271 #endif // GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_
OLDNEW
« no previous file with comments | « google_apis/gcm/engine/gcm_store_impl.cc ('k') | google_apis/gcm/engine/mcs_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698