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

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

Issue 2621663002: Revert of GetTimeToCallback() returns estimated time to callback. (Closed)
Patch Set: Created 3 years, 11 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 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
116 void Timer::SetTaskRunner(scoped_refptr<SingleThreadTaskRunner> task_runner) { 110 void Timer::SetTaskRunner(scoped_refptr<SingleThreadTaskRunner> task_runner) {
117 // Do not allow changing the task runner once something has been scheduled. 111 // Do not allow changing the task runner once something has been scheduled.
118 DCHECK_EQ(thread_id_, 0); 112 DCHECK_EQ(thread_id_, 0);
119 task_runner_.swap(task_runner); 113 task_runner_.swap(task_runner);
120 } 114 }
121 115
122 void Timer::Start(const tracked_objects::Location& posted_from, 116 void Timer::Start(const tracked_objects::Location& posted_from,
123 TimeDelta delay, 117 TimeDelta delay,
124 const base::Closure& user_task) { 118 const base::Closure& user_task) {
125 SetTaskInfo(posted_from, delay, user_task); 119 SetTaskInfo(posted_from, delay, user_task);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 PostNewScheduledTask(delay_); 225 PostNewScheduledTask(delay_);
232 else 226 else
233 Stop(); 227 Stop();
234 228
235 task.Run(); 229 task.Run();
236 230
237 // No more member accesses here: *this could be deleted at this point. 231 // No more member accesses here: *this could be deleted at this point.
238 } 232 }
239 233
240 } // namespace base 234 } // 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