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

Unified Diff: components/timers/alarm_timer.cc

Issue 745123002: Link GCM heartbeat with wake on wifi preference (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix missing include 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
« no previous file with comments | « components/timers/alarm_timer.h ('k') | components/timers/rtc_alarm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/timers/alarm_timer.cc
diff --git a/components/timers/alarm_timer.cc b/components/timers/alarm_timer.cc
index 799a1ec7e98b63c9104b9a88f891cc4e6a9a1d9a..8b46020af5496fe191e405218098defaf1166a75 100644
--- a/components/timers/alarm_timer.cc
+++ b/components/timers/alarm_timer.cc
@@ -38,6 +38,27 @@ AlarmTimer::~AlarmTimer() {
Stop();
}
+void AlarmTimer::OnTimerFired() {
+ if (!base::Timer::IsRunning())
+ return;
+
+ DCHECK(pending_task_.get());
+
+ // Take ownership of the pending user task, which is going to be cleared by
+ // the Stop() or Reset() functions below.
+ scoped_ptr<base::PendingTask> pending_user_task(pending_task_.Pass());
+
+ // Re-schedule or stop the timer as requested.
+ if (base::Timer::is_repeating())
+ Reset();
+ else
+ Stop();
+
+ // Now run the user task.
+ base::MessageLoop::current()->task_annotator()->RunTask(
+ "AlarmTimer::Reset", "AlarmTimer::OnTimerFired", *pending_user_task);
+}
+
void AlarmTimer::Stop() {
if (!can_wake_from_suspend_) {
base::Timer::Stop();
@@ -103,25 +124,4 @@ void AlarmTimer::WillDestroyCurrentMessageLoop() {
Stop();
}
-void AlarmTimer::OnTimerFired() {
- if (!base::Timer::is_running())
- return;
-
- DCHECK(pending_task_.get());
-
- // Take ownership of the pending user task, which is going to be cleared by
- // the Stop() or Reset() functions below.
- scoped_ptr<base::PendingTask> pending_user_task(pending_task_.Pass());
-
- // Re-schedule or stop the timer as requested.
- if (base::Timer::is_repeating())
- Reset();
- else
- Stop();
-
- // Now run the user task.
- base::MessageLoop::current()->task_annotator()->RunTask(
- "AlarmTimer::Reset", "AlarmTimer::OnTimerFired", *pending_user_task);
-}
-
} // namespace timers
« no previous file with comments | « components/timers/alarm_timer.h ('k') | components/timers/rtc_alarm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698