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

Unified Diff: google_apis/gcm/engine/heartbeat_manager.h

Issue 641943002: components: Introduce AlarmTimer class and use it for GCM heartbeat (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gyp files Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: google_apis/gcm/engine/heartbeat_manager.h
diff --git a/google_apis/gcm/engine/heartbeat_manager.h b/google_apis/gcm/engine/heartbeat_manager.h
index 9266b98c8d4b21f02935002cd106dd314c27e40a..ea19bd14806bb287ba34cc47e24844e87ecb0418 100644
--- a/google_apis/gcm/engine/heartbeat_manager.h
+++ b/google_apis/gcm/engine/heartbeat_manager.h
@@ -7,10 +7,14 @@
#include "base/callback.h"
#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "base/timer/timer.h"
#include "google_apis/gcm/base/gcm_export.h"
+namespace base {
+class Timer;
+}
+
namespace mcs_proto {
class HeartbeatConfig;
}
@@ -48,6 +52,10 @@ class GCM_EXPORT HeartbeatManager {
// pending.
base::TimeTicks GetNextHeartbeatTime() const;
+ // Sets the Timer that will be used for heartbeat messages. Can only be
+ // called before the first time Start() is called.
+ void SetHeartbeatTimer(scoped_ptr<base::Timer> timer);
Nicolas Zea 2014/10/22 17:32:16 Why not just pass it in at construction time?
Chirantan Ekbote 2014/10/22 18:47:14 I originally tried that. But to pass it in at con
Nicolas Zea 2014/10/23 17:49:02 IMO its worse to have the possibility of someone c
Chirantan Ekbote 2014/10/23 23:53:30 Done.
+
protected:
// Helper method to send heartbeat on timer trigger.
void OnHeartbeatTriggered();
@@ -56,6 +64,9 @@ class GCM_EXPORT HeartbeatManager {
// Restarts the heartbeat timer.
void RestartTimer();
+ // Whether the HeartbeatManager has started sending heartbeats.
+ bool started_;
+
// Whether the last heartbeat ping sent has been acknowledged or not.
bool waiting_for_ack_;
@@ -66,7 +77,7 @@ class GCM_EXPORT HeartbeatManager {
int server_interval_ms_;
// Timer for triggering heartbeats.
- base::Timer heartbeat_timer_;
+ scoped_ptr<base::Timer> heartbeat_timer_;
// Callbacks for interacting with the the connection.
base::Closure send_heartbeat_callback_;

Powered by Google App Engine
This is Rietveld 408576698