OLD | NEW |
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 #include "components/scheduler/child/virtual_time_tqm_delegate.h" | 5 #include "components/scheduler/child/virtual_time_tqm_delegate.h" |
6 | 6 |
7 namespace scheduler { | 7 namespace scheduler { |
8 | 8 |
9 // static | 9 // static |
10 scoped_refptr<VirtualTimeTqmDelegate> VirtualTimeTqmDelegate::Create( | 10 scoped_refptr<VirtualTimeTqmDelegate> VirtualTimeTqmDelegate::Create( |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 | 59 |
60 bool VirtualTimeTqmDelegate::IsNested() const { | 60 bool VirtualTimeTqmDelegate::IsNested() const { |
61 return message_loop_->IsNested(); | 61 return message_loop_->IsNested(); |
62 } | 62 } |
63 | 63 |
64 base::TimeTicks VirtualTimeTqmDelegate::NowTicks() { | 64 base::TimeTicks VirtualTimeTqmDelegate::NowTicks() { |
65 return now_; | 65 return now_; |
66 } | 66 } |
67 | 67 |
| 68 double VirtualTimeTqmDelegate::currentTime() const { |
| 69 return (now_ - base::TimeTicks::UnixEpoch()).InSecondsF(); |
| 70 } |
| 71 |
68 void VirtualTimeTqmDelegate::AdvancedTimeTo(base::TimeTicks now) { | 72 void VirtualTimeTqmDelegate::AdvancedTimeTo(base::TimeTicks now) { |
69 now_ = now; | 73 now_ = now; |
70 DCHECK_GE(now, now_); | 74 DCHECK_GE(now, now_); |
71 while (!delayed_wakeup_multimap_.empty()) { | 75 while (!delayed_wakeup_multimap_.empty()) { |
72 DelayedWakeupMultimap::iterator next_wakeup = | 76 DelayedWakeupMultimap::iterator next_wakeup = |
73 delayed_wakeup_multimap_.begin(); | 77 delayed_wakeup_multimap_.begin(); |
74 if (next_wakeup->first > now) | 78 if (next_wakeup->first > now) |
75 break; | 79 break; |
76 message_loop_task_runner_->PostDelayedTask(FROM_HERE, next_wakeup->second, | 80 message_loop_task_runner_->PostDelayedTask(FROM_HERE, next_wakeup->second, |
77 base::TimeDelta()); | 81 base::TimeDelta()); |
78 delayed_wakeup_multimap_.erase(next_wakeup); | 82 delayed_wakeup_multimap_.erase(next_wakeup); |
79 } | 83 } |
80 } | 84 } |
81 | 85 |
82 void VirtualTimeTqmDelegate::OnNoMoreImmediateWork() { | 86 void VirtualTimeTqmDelegate::OnNoMoreImmediateWork() { |
83 if (delayed_wakeup_multimap_.empty()) | 87 if (delayed_wakeup_multimap_.empty()) |
84 return; | 88 return; |
85 | 89 |
86 AdvancedTimeTo(delayed_wakeup_multimap_.begin()->first); | 90 AdvancedTimeTo(delayed_wakeup_multimap_.begin()->first); |
87 } | 91 } |
88 | 92 |
89 } // namespace scheduler | 93 } // namespace scheduler |
OLD | NEW |