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

Side by Side Diff: base/timer/timer.cc

Issue 2557663002: GetTimeToCallback() returns estimated time to callback. (Closed)
Patch Set: Removed an old file that sneaked in the patchest. Created 4 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
« no previous file with comments | « base/timer/timer.h ('k') | base/timer/timer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "base/timer/timer.h" 5 #include "base/timer/timer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 101
102 bool Timer::IsRunning() const { 102 bool Timer::IsRunning() const {
103 return is_running_; 103 return is_running_;
104 } 104 }
105 105
106 TimeDelta Timer::GetCurrentDelay() const { 106 TimeDelta Timer::GetCurrentDelay() const {
107 return delay_; 107 return delay_;
108 } 108 }
109 109
110 TimeDelta Timer::GetTimeToCallback() const {
111 if (!user_task_)
112 return TimeDelta::Max();
113 return scheduled_run_time_ - Now();
114 }
115
110 void Timer::SetTaskRunner(scoped_refptr<SingleThreadTaskRunner> task_runner) { 116 void Timer::SetTaskRunner(scoped_refptr<SingleThreadTaskRunner> task_runner) {
111 // Do not allow changing the task runner once something has been scheduled. 117 // Do not allow changing the task runner once something has been scheduled.
112 DCHECK_EQ(thread_id_, 0); 118 DCHECK_EQ(thread_id_, 0);
113 task_runner_.swap(task_runner); 119 task_runner_.swap(task_runner);
114 } 120 }
115 121
116 void Timer::Start(const tracked_objects::Location& posted_from, 122 void Timer::Start(const tracked_objects::Location& posted_from,
117 TimeDelta delay, 123 TimeDelta delay,
118 const base::Closure& user_task) { 124 const base::Closure& user_task) {
119 SetTaskInfo(posted_from, delay, user_task); 125 SetTaskInfo(posted_from, delay, user_task);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 PostNewScheduledTask(delay_); 231 PostNewScheduledTask(delay_);
226 else 232 else
227 Stop(); 233 Stop();
228 234
229 task.Run(); 235 task.Run();
230 236
231 // No more member accesses here: *this could be deleted at this point. 237 // No more member accesses here: *this could be deleted at this point.
232 } 238 }
233 239
234 } // namespace base 240 } // namespace base
OLDNEW
« no previous file with comments | « base/timer/timer.h ('k') | base/timer/timer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698