Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_HEARTBEAT_MANAGER_H_ | 5 #ifndef GOOGLE_APIS_GCM_ENGINE_HEARTBEAT_MANAGER_H_ |
| 6 #define GOOGLE_APIS_GCM_ENGINE_HEARTBEAT_MANAGER_H_ | 6 #define GOOGLE_APIS_GCM_ENGINE_HEARTBEAT_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 11 #include "base/timer/timer.h" | |
| 12 #include "google_apis/gcm/base/gcm_export.h" | 12 #include "google_apis/gcm/base/gcm_export.h" |
| 13 | 13 |
| 14 namespace base { | |
| 15 class Timer; | |
| 16 } | |
| 17 | |
| 14 namespace mcs_proto { | 18 namespace mcs_proto { |
| 15 class HeartbeatConfig; | 19 class HeartbeatConfig; |
| 16 } | 20 } |
| 17 | 21 |
| 18 namespace gcm { | 22 namespace gcm { |
| 19 | 23 |
| 20 // A heartbeat management class, capable of sending and handling heartbeat | 24 // A heartbeat management class, capable of sending and handling heartbeat |
| 21 // receipt/failures and triggering reconnection as necessary. | 25 // receipt/failures and triggering reconnection as necessary. |
| 22 class GCM_EXPORT HeartbeatManager { | 26 class GCM_EXPORT HeartbeatManager { |
| 23 public: | 27 public: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 | 62 |
| 59 // Whether the last heartbeat ping sent has been acknowledged or not. | 63 // Whether the last heartbeat ping sent has been acknowledged or not. |
| 60 bool waiting_for_ack_; | 64 bool waiting_for_ack_; |
| 61 | 65 |
| 62 // The current heartbeat interval. | 66 // The current heartbeat interval. |
| 63 int heartbeat_interval_ms_; | 67 int heartbeat_interval_ms_; |
| 64 // The most recent server-provided heartbeat interval (0 if none has been | 68 // The most recent server-provided heartbeat interval (0 if none has been |
| 65 // provided). | 69 // provided). |
| 66 int server_interval_ms_; | 70 int server_interval_ms_; |
| 67 | 71 |
| 68 // Timer for triggering heartbeats. | 72 // Timer for triggering heartbeats. Owned by HeartbeatManager. |
|
Nicolas Zea
2014/10/21 17:57:54
nit: Since you're using a scoped_ptr now, ownershi
Chirantan Ekbote
2014/10/21 21:13:48
Done.
| |
| 69 base::Timer heartbeat_timer_; | 73 scoped_ptr<base::Timer> heartbeat_timer_; |
| 70 | 74 |
| 71 // Callbacks for interacting with the the connection. | 75 // Callbacks for interacting with the the connection. |
| 72 base::Closure send_heartbeat_callback_; | 76 base::Closure send_heartbeat_callback_; |
| 73 base::Closure trigger_reconnect_callback_; | 77 base::Closure trigger_reconnect_callback_; |
| 74 | 78 |
| 75 base::WeakPtrFactory<HeartbeatManager> weak_ptr_factory_; | 79 base::WeakPtrFactory<HeartbeatManager> weak_ptr_factory_; |
| 76 | 80 |
| 77 DISALLOW_COPY_AND_ASSIGN(HeartbeatManager); | 81 DISALLOW_COPY_AND_ASSIGN(HeartbeatManager); |
| 78 }; | 82 }; |
| 79 | 83 |
| 80 } // namespace gcm | 84 } // namespace gcm |
| 81 | 85 |
| 82 #endif // GOOGLE_APIS_GCM_ENGINE_HEARTBEAT_MANAGER_H_ | 86 #endif // GOOGLE_APIS_GCM_ENGINE_HEARTBEAT_MANAGER_H_ |
| OLD | NEW |