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

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

Issue 118133003: [GCM] Add heartbeat manager and reconnection logic due to heartbeat failure (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Jian's comments Created 6 years, 12 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
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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/memory/linked_ptr.h" 14 #include "base/memory/linked_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/timer/timer.h"
17 #include "google_apis/gcm/base/gcm_export.h" 16 #include "google_apis/gcm/base/gcm_export.h"
18 #include "google_apis/gcm/base/mcs_message.h" 17 #include "google_apis/gcm/base/mcs_message.h"
19 #include "google_apis/gcm/engine/connection_handler.h" 18 #include "google_apis/gcm/engine/connection_handler.h"
19 #include "google_apis/gcm/engine/heartbeat_manager.h"
20 #include "google_apis/gcm/engine/rmq_store.h" 20 #include "google_apis/gcm/engine/rmq_store.h"
21 21
22 namespace google { 22 namespace google {
23 namespace protobuf { 23 namespace protobuf {
24 class MessageLite; 24 class MessageLite;
25 } // namespace protobuf 25 } // namespace protobuf
26 } // namespace google 26 } // namespace google
27 27
28 namespace mcs_proto { 28 namespace mcs_proto {
29 class LoginRequest; 29 class LoginRequest;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // in |id_list|. 145 // in |id_list|.
146 void HandleSelectiveAck(const PersistentIdList& id_list); 146 void HandleSelectiveAck(const PersistentIdList& id_list);
147 // Handle server confirmation of a device message, including device's 147 // Handle server confirmation of a device message, including device's
148 // acknowledgment of receipt of messages. 148 // acknowledgment of receipt of messages.
149 void HandleServerConfirmedReceipt(StreamId device_stream_id); 149 void HandleServerConfirmedReceipt(StreamId device_stream_id);
150 150
151 // Generates a new persistent id for messages. 151 // Generates a new persistent id for messages.
152 // Virtual for testing. 152 // Virtual for testing.
153 virtual PersistentId GetNextPersistentId(); 153 virtual PersistentId GetNextPersistentId();
154 154
155 // Helper for the heartbeat manager to signal a connection reset.
156 void OnConnectionResetByHeartbeat();
157
155 // Client state. 158 // Client state.
156 State state_; 159 State state_;
157 160
158 // Callbacks for owner. 161 // Callbacks for owner.
159 InitializationCompleteCallback initialization_callback_; 162 InitializationCompleteCallback initialization_callback_;
160 OnMessageReceivedCallback message_received_callback_; 163 OnMessageReceivedCallback message_received_callback_;
161 OnMessageSentCallback message_sent_callback_; 164 OnMessageSentCallback message_sent_callback_;
162 165
163 // The android id and security token in use by this device. 166 // The android id and security token in use by this device.
164 uint64 android_id_; 167 uint64 android_id_;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 std::map<StreamId, PersistentIdList> acked_server_ids_; 205 std::map<StreamId, PersistentIdList> acked_server_ids_;
203 206
204 // Those server messages from a previous connection that were not fully 207 // Those server messages from a previous connection that were not fully
205 // acknowledged. They do not have associated stream ids, and will be 208 // acknowledged. They do not have associated stream ids, and will be
206 // acknowledged on the next login attempt. 209 // acknowledged on the next login attempt.
207 PersistentIdList restored_unackeds_server_ids_; 210 PersistentIdList restored_unackeds_server_ids_;
208 211
209 // The reliable message queue persistent store. Owned by the caller. 212 // The reliable message queue persistent store. Owned by the caller.
210 RMQStore* rmq_store_; 213 RMQStore* rmq_store_;
211 214
212 // ----- Heartbeats ----- 215 // Manager to handle triggering/detecting heartbeats.
213 // The current heartbeat interval. 216 HeartbeatManager heartbeat_manager_;
214 base::TimeDelta heartbeat_interval_;
215 // Timer for triggering heartbeats.
216 base::Timer heartbeat_timer_;
217 217
218 base::WeakPtrFactory<MCSClient> weak_ptr_factory_; 218 base::WeakPtrFactory<MCSClient> weak_ptr_factory_;
219 219
220 DISALLOW_COPY_AND_ASSIGN(MCSClient); 220 DISALLOW_COPY_AND_ASSIGN(MCSClient);
221 }; 221 };
222 222
223 } // namespace gcm 223 } // namespace gcm
224 224
225 #endif // GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ 225 #endif // GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698