OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_SCHEDULER_CHILD_LAZY_NOW_H_ |
| 6 #define COMPONENTS_SCHEDULER_CHILD_LAZY_NOW_H_ |
| 7 |
| 8 #include "base/time/time.h" |
| 9 |
| 10 namespace scheduler { |
| 11 class TaskQueueManager; |
| 12 |
| 13 namespace internal { |
| 14 |
| 15 // Now() is somewhat expensive so it makes sense not to call Now() unless we |
| 16 // really need to. |
| 17 class LazyNow { |
| 18 public: |
| 19 explicit LazyNow(base::TimeTicks now) |
| 20 : task_queue_manager_(nullptr), now_(now) { |
| 21 DCHECK(!now.is_null()); |
| 22 } |
| 23 |
| 24 explicit LazyNow(TaskQueueManager* task_queue_manager) |
| 25 : task_queue_manager_(task_queue_manager) {} |
| 26 |
| 27 base::TimeTicks Now(); |
| 28 |
| 29 private: |
| 30 TaskQueueManager* task_queue_manager_; // NOT OWNED |
| 31 base::TimeTicks now_; |
| 32 }; |
| 33 |
| 34 } // namespace internal |
| 35 } // namespace scheduler |
| 36 |
| 37 #endif // COMPONENTS_SCHEDULER_CHILD_LAZY_NOW_H_ |
OLD | NEW |