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

Side by Side Diff: components/scheduler/base/lazy_now.h

Issue 1424053002: Adds a flag to support "Virtual Time" to the blink scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a test Created 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef COMPONENTS_SCHEDULER_BASE_LAZY_NOW_H_ 5 #ifndef COMPONENTS_SCHEDULER_BASE_LAZY_NOW_H_
6 #define COMPONENTS_SCHEDULER_BASE_LAZY_NOW_H_ 6 #define COMPONENTS_SCHEDULER_BASE_LAZY_NOW_H_
7 7
8 #include "base/time/time.h" 8 #include "base/time/tick_clock.h"
Sami 2015/10/28 20:00:34 nit: Forward decl instead?
alex clarke (OOO till 29th) 2015/10/29 18:07:30 Done.
9 9
10 namespace scheduler { 10 namespace scheduler {
11 class TaskQueueManager;
12
13 namespace internal { 11 namespace internal {
14 12
15 // Now() is somewhat expensive so it makes sense not to call Now() unless we 13 // Now() is somewhat expensive so it makes sense not to call Now() unless we
16 // really need to. 14 // really need to.
17 class LazyNow { 15 class LazyNow {
18 public: 16 public:
19 explicit LazyNow(base::TimeTicks now) 17 explicit LazyNow(base::TimeTicks now) : tick_clock_(nullptr), now_(now) {
20 : task_queue_manager_(nullptr), now_(now) {
21 DCHECK(!now.is_null()); 18 DCHECK(!now.is_null());
22 } 19 }
23 20
24 explicit LazyNow(TaskQueueManager* task_queue_manager) 21 explicit LazyNow(base::TickClock* tick_clock) : tick_clock_(tick_clock) {}
25 : task_queue_manager_(task_queue_manager) {}
26 22
27 base::TimeTicks Now(); 23 base::TimeTicks Now();
28 24
29 private: 25 private:
30 TaskQueueManager* task_queue_manager_; // NOT OWNED 26 base::TickClock* tick_clock_; // NOT OWNED
31 base::TimeTicks now_; 27 base::TimeTicks now_;
32 }; 28 };
33 29
34 } // namespace internal 30 } // namespace internal
35 } // namespace scheduler 31 } // namespace scheduler
36 32
37 #endif // COMPONENTS_SCHEDULER_BASE_LAZY_NOW_H_ 33 #endif // COMPONENTS_SCHEDULER_BASE_LAZY_NOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698