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

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 comments Created 7 years 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // in |id_list|. 148 // in |id_list|.
149 void HandleSelectiveAck(const PersistentIdList& id_list); 149 void HandleSelectiveAck(const PersistentIdList& id_list);
150 // Handle server confirmation of a device message, including device's 150 // Handle server confirmation of a device message, including device's
151 // acknowledgment of receipt of messages. 151 // acknowledgment of receipt of messages.
152 void HandleServerConfirmedReceipt(StreamId device_stream_id); 152 void HandleServerConfirmedReceipt(StreamId device_stream_id);
153 153
154 // Generates a new persistent id for messages. 154 // Generates a new persistent id for messages.
155 // Virtual for testing. 155 // Virtual for testing.
156 virtual PersistentId GetNextPersistentId(); 156 virtual PersistentId GetNextPersistentId();
157 157
158 // Helper for the heartbeat manager to signal a connection reset.
159 void OnConnectionResetByHeartbeat();
160
158 // Client state. 161 // Client state.
159 State state_; 162 State state_;
160 163
161 // Callbacks for owner. 164 // Callbacks for owner.
162 InitializationCompleteCallback initialization_callback_; 165 InitializationCompleteCallback initialization_callback_;
163 OnMessageReceivedCallback message_received_callback_; 166 OnMessageReceivedCallback message_received_callback_;
164 OnMessageSentCallback message_sent_callback_; 167 OnMessageSentCallback message_sent_callback_;
165 168
166 // The android id and security token in use by this device. 169 // The android id and security token in use by this device.
167 uint64 android_id_; 170 uint64 android_id_;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 std::map<StreamId, PersistentIdList> acked_server_ids_; 208 std::map<StreamId, PersistentIdList> acked_server_ids_;
206 209
207 // Those server messages from a previous connection that were not fully 210 // Those server messages from a previous connection that were not fully
208 // acknowledged. They do not have associated stream ids, and will be 211 // acknowledged. They do not have associated stream ids, and will be
209 // acknowledged on the next login attempt. 212 // acknowledged on the next login attempt.
210 PersistentIdList restored_unackeds_server_ids_; 213 PersistentIdList restored_unackeds_server_ids_;
211 214
212 // The reliable message queue persistent store. 215 // The reliable message queue persistent store.
213 RMQStore rmq_store_; 216 RMQStore rmq_store_;
214 217
215 // ----- Heartbeats ----- 218 // Manager to handle triggering/detecting heartbeats.
216 // The current heartbeat interval. 219 HeartbeatManager heartbeat_manager_;
217 base::TimeDelta heartbeat_interval_;
218 // Timer for triggering heartbeats.
219 base::Timer heartbeat_timer_;
220 220
221 // The task runner for blocking tasks (i.e. persisting RMQ state to disk). 221 // The task runner for blocking tasks (i.e. persisting RMQ state to disk).
222 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 222 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
223 223
224 base::WeakPtrFactory<MCSClient> weak_ptr_factory_; 224 base::WeakPtrFactory<MCSClient> weak_ptr_factory_;
225 225
226 DISALLOW_COPY_AND_ASSIGN(MCSClient); 226 DISALLOW_COPY_AND_ASSIGN(MCSClient);
227 }; 227 };
228 228
229 } // namespace gcm 229 } // namespace gcm
230 230
231 #endif // GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_ 231 #endif // GOOGLE_APIS_GCM_ENGINE_MCS_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698