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

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

Issue 745123002: Link GCM heartbeat with wake on wifi preference (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up includes Created 6 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 side-by-side diff with in-line comments
Download patch
Index: google_apis/gcm/engine/heartbeat_manager.cc
diff --git a/google_apis/gcm/engine/heartbeat_manager.cc b/google_apis/gcm/engine/heartbeat_manager.cc
index b6b0e8892ebb91d357d54365054f6531a8086dfa..74e6e4b746131a461266e8c622266b82dc5b7708 100644
--- a/google_apis/gcm/engine/heartbeat_manager.cc
+++ b/google_apis/gcm/engine/heartbeat_manager.cc
@@ -4,7 +4,9 @@
#include "google_apis/gcm/engine/heartbeat_manager.h"
+#include "base/callback.h"
#include "base/metrics/histogram.h"
+#include "base/time/time.h"
#include "base/timer/timer.h"
#include "google_apis/gcm/protocol/mcs.pb.h"
#include "net/base/network_change_notifier.h"
@@ -80,6 +82,19 @@ base::TimeTicks HeartbeatManager::GetNextHeartbeatTime() const {
return base::TimeTicks();
}
+void HeartbeatManager::UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer) {
+ bool was_running = heartbeat_timer_->IsRunning();
+ base::TimeDelta remaining_delay =
+ heartbeat_timer_->desired_run_time() - base::TimeTicks::Now();
+ base::Closure timer_task(heartbeat_timer_->user_task());
+
+ heartbeat_timer_->Stop();
+ heartbeat_timer_ = timer.Pass();
+
+ if (was_running)
+ heartbeat_timer_->Start(FROM_HERE, remaining_delay, timer_task);
+}
+
void HeartbeatManager::OnHeartbeatTriggered() {
// Reset the weak pointers used for heartbeat checks.
weak_ptr_factory_.InvalidateWeakPtrs();

Powered by Google App Engine
This is Rietveld 408576698