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

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

Issue 681713002: Update from chromium https://crrev.com/301315 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/sys_info_android.cc ('k') | base/win/win_util.h » ('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 // OneShotTimer and RepeatingTimer provide a simple timer API. As the names 5 // OneShotTimer and RepeatingTimer provide a simple timer API. As the names
6 // suggest, OneShotTimer calls you back once after a time delay expires. 6 // suggest, OneShotTimer calls you back once after a time delay expires.
7 // RepeatingTimer on the other hand calls you back periodically with the 7 // RepeatingTimer on the other hand calls you back periodically with the
8 // prescribed time interval. 8 // prescribed time interval.
9 // 9 //
10 // OneShotTimer and RepeatingTimer both cancel the timer when they go out of 10 // OneShotTimer and RepeatingTimer both cancel the timer when they go out of
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 const base::Closure& user_task() const { return user_task_; } 104 const base::Closure& user_task() const { return user_task_; }
105 const TimeTicks& desired_run_time() const { return desired_run_time_; } 105 const TimeTicks& desired_run_time() const { return desired_run_time_; }
106 106
107 protected: 107 protected:
108 // Used to initiate a new delayed task. This has the side-effect of disabling 108 // Used to initiate a new delayed task. This has the side-effect of disabling
109 // scheduled_task_ if it is non-null. 109 // scheduled_task_ if it is non-null.
110 void SetTaskInfo(const tracked_objects::Location& posted_from, 110 void SetTaskInfo(const tracked_objects::Location& posted_from,
111 TimeDelta delay, 111 TimeDelta delay,
112 const base::Closure& user_task); 112 const base::Closure& user_task);
113 113
114 void set_user_task(const Closure& task) { user_task_ = task; }
115 void set_desired_run_time(TimeTicks desired) { desired_run_time_ = desired; }
116 void set_is_running(bool running) { is_running_ = running; }
117
118 const tracked_objects::Location& posted_from() const { return posted_from_; }
114 bool retain_user_task() const { return retain_user_task_; } 119 bool retain_user_task() const { return retain_user_task_; }
115 bool is_repeating() const { return is_repeating_; } 120 bool is_repeating() const { return is_repeating_; }
121 bool is_running() const { return is_running_; }
116 122
117 private: 123 private:
118 friend class BaseTimerTaskInternal; 124 friend class BaseTimerTaskInternal;
119 125
120 // Allocates a new scheduled_task_ and posts it on the current MessageLoop 126 // Allocates a new scheduled_task_ and posts it on the current MessageLoop
121 // with the given |delay|. scheduled_task_ must be NULL. scheduled_run_time_ 127 // with the given |delay|. scheduled_task_ must be NULL. scheduled_run_time_
122 // and desired_run_time_ are reset to Now() + delay. 128 // and desired_run_time_ are reset to Now() + delay.
123 void PostNewScheduledTask(TimeDelta delay); 129 void PostNewScheduledTask(TimeDelta delay);
124 130
125 // Disable scheduled_task_ and abandon it so that it no longer refers back to 131 // Disable scheduled_task_ and abandon it so that it no longer refers back to
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 : Timer(posted_from, delay, 244 : Timer(posted_from, delay,
239 base::Bind(method, base::Unretained(receiver)), 245 base::Bind(method, base::Unretained(receiver)),
240 false) {} 246 false) {}
241 247
242 void Reset() { Timer::Reset(); } 248 void Reset() { Timer::Reset(); }
243 }; 249 };
244 250
245 } // namespace base 251 } // namespace base
246 252
247 #endif // BASE_TIMER_TIMER_H_ 253 #endif // BASE_TIMER_TIMER_H_
OLDNEW
« no previous file with comments | « base/sys_info_android.cc ('k') | base/win/win_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698