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 "platform/scheduler/base/real_time_domain.h" | 5 #include "platform/scheduler/base/real_time_domain.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "platform/scheduler/base/task_queue_impl.h" | 8 #include "platform/scheduler/base/task_queue_impl.h" |
9 #include "platform/scheduler/base/task_queue_manager.h" | 9 #include "platform/scheduler/base/task_queue_manager.h" |
10 #include "platform/scheduler/base/task_queue_manager_delegate.h" | 10 #include "platform/scheduler/base/task_queue_manager_delegate.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 } | 32 } |
33 | 33 |
34 LazyNow RealTimeDomain::CreateLazyNow() const { | 34 LazyNow RealTimeDomain::CreateLazyNow() const { |
35 return task_queue_manager_->CreateLazyNow(); | 35 return task_queue_manager_->CreateLazyNow(); |
36 } | 36 } |
37 | 37 |
38 base::TimeTicks RealTimeDomain::Now() const { | 38 base::TimeTicks RealTimeDomain::Now() const { |
39 return task_queue_manager_->delegate()->NowTicks(); | 39 return task_queue_manager_->delegate()->NowTicks(); |
40 } | 40 } |
41 | 41 |
42 void RealTimeDomain::RequestWakeup(base::TimeTicks now, base::TimeDelta delay) { | 42 void RealTimeDomain::RequestWakeupAt(base::TimeTicks now, |
| 43 base::TimeTicks run_time) { |
43 // NOTE this is only called if the scheduled runtime is sooner than any | 44 // NOTE this is only called if the scheduled runtime is sooner than any |
44 // previously scheduled runtime, or there is no (outstanding) previously | 45 // previously scheduled runtime, or there is no (outstanding) previously |
45 // scheduled runtime. | 46 // scheduled runtime. |
46 task_queue_manager_->MaybeScheduleDelayedWork(FROM_HERE, now, delay); | 47 task_queue_manager_->MaybeScheduleDelayedWork(FROM_HERE, this, now, run_time); |
| 48 } |
| 49 |
| 50 void RealTimeDomain::CancelWakeupAt(base::TimeTicks run_time) { |
| 51 task_queue_manager_->CancelDelayedWork(this, run_time); |
47 } | 52 } |
48 | 53 |
49 base::Optional<base::TimeDelta> RealTimeDomain::DelayTillNextTask( | 54 base::Optional<base::TimeDelta> RealTimeDomain::DelayTillNextTask( |
50 LazyNow* lazy_now) { | 55 LazyNow* lazy_now) { |
51 base::TimeTicks next_run_time; | 56 base::TimeTicks next_run_time; |
52 if (!NextScheduledRunTime(&next_run_time)) | 57 if (!NextScheduledRunTime(&next_run_time)) |
53 return base::nullopt; | 58 return base::nullopt; |
54 | 59 |
55 base::TimeTicks now = lazy_now->Now(); | 60 base::TimeTicks now = lazy_now->Now(); |
56 if (now >= next_run_time) | 61 if (now >= next_run_time) |
57 return base::TimeDelta(); // Makes DoWork post an immediate continuation. | 62 return base::TimeDelta(); // Makes DoWork post an immediate continuation. |
58 | 63 |
59 base::TimeDelta delay = next_run_time - now; | 64 base::TimeDelta delay = next_run_time - now; |
60 TRACE_EVENT1(tracing_category_, "RealTimeDomain::DelayTillNextTask", | 65 TRACE_EVENT1(tracing_category_, "RealTimeDomain::DelayTillNextTask", |
61 "delay_ms", delay.InMillisecondsF()); | 66 "delay_ms", delay.InMillisecondsF()); |
62 | 67 |
63 // The next task is sometime in the future. DoWork will make sure it gets | 68 // The next task is sometime in the future. DoWork will make sure it gets |
64 // run at the right time. | 69 // run at the right time. |
65 return delay; | 70 return delay; |
66 } | 71 } |
67 | 72 |
68 void RealTimeDomain::AsValueIntoInternal( | 73 void RealTimeDomain::AsValueIntoInternal( |
69 base::trace_event::TracedValue* state) const {} | 74 base::trace_event::TracedValue* state) const {} |
70 | 75 |
71 const char* RealTimeDomain::GetName() const { | 76 const char* RealTimeDomain::GetName() const { |
72 return "RealTimeDomain"; | 77 return "RealTimeDomain"; |
73 } | 78 } |
74 } // namespace scheduler | 79 } // namespace scheduler |
75 } // namespace blink | 80 } // namespace blink |
OLD | NEW |