| 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::RequestWakeupAt(LazyNow* lazy_now, | 42 void RealTimeDomain::RequestWakeup(base::TimeTicks now, base::TimeDelta delay) { |
| 43 base::TimeTicks run_time) { | |
| 44 // NOTE this is only called if the scheduled runtime is sooner than any | 43 // NOTE this is only called if the scheduled runtime is sooner than any |
| 45 // previously scheduled runtime, or there is no (outstanding) previously | 44 // previously scheduled runtime, or there is no (outstanding) previously |
| 46 // scheduled runtime. | 45 // scheduled runtime. |
| 47 task_queue_manager_->MaybeScheduleDelayedWork(FROM_HERE, lazy_now, run_time); | 46 task_queue_manager_->MaybeScheduleDelayedWork(FROM_HERE, now, delay); |
| 48 } | |
| 49 | |
| 50 void RealTimeDomain::CancelWakeupAt(base::TimeTicks run_time) { | |
| 51 task_queue_manager_->CancelDelayedWork(run_time); | |
| 52 } | 47 } |
| 53 | 48 |
| 54 base::Optional<base::TimeDelta> RealTimeDomain::DelayTillNextTask( | 49 base::Optional<base::TimeDelta> RealTimeDomain::DelayTillNextTask( |
| 55 LazyNow* lazy_now) { | 50 LazyNow* lazy_now) { |
| 56 base::TimeTicks next_run_time; | 51 base::TimeTicks next_run_time; |
| 57 if (!NextScheduledRunTime(&next_run_time)) | 52 if (!NextScheduledRunTime(&next_run_time)) |
| 58 return base::Optional<base::TimeDelta>(); | 53 return base::Optional<base::TimeDelta>(); |
| 59 | 54 |
| 60 base::TimeTicks now = lazy_now->Now(); | 55 base::TimeTicks now = lazy_now->Now(); |
| 61 if (now >= next_run_time) | 56 if (now >= next_run_time) |
| 62 return base::TimeDelta(); // Makes DoWork post an immediate continuation. | 57 return base::TimeDelta(); // Makes DoWork post an immediate continuation. |
| 63 | 58 |
| 64 base::TimeDelta delay = next_run_time - now; | 59 base::TimeDelta delay = next_run_time - now; |
| 65 TRACE_EVENT1(tracing_category_, "RealTimeDomain::DelayTillNextTask", | 60 TRACE_EVENT1(tracing_category_, "RealTimeDomain::DelayTillNextTask", |
| 66 "delay_ms", delay.InMillisecondsF()); | 61 "delay_ms", delay.InMillisecondsF()); |
| 67 | 62 |
| 68 // The next task is sometime in the future. DoWork will make sure it gets | 63 // The next task is sometime in the future. DoWork will make sure it gets |
| 69 // run at the right time.. | 64 // run at the right time.. |
| 70 return delay; | 65 return delay; |
| 71 } | 66 } |
| 72 | 67 |
| 73 void RealTimeDomain::AsValueIntoInternal( | 68 void RealTimeDomain::AsValueIntoInternal( |
| 74 base::trace_event::TracedValue* state) const {} | 69 base::trace_event::TracedValue* state) const {} |
| 75 | 70 |
| 76 const char* RealTimeDomain::GetName() const { | 71 const char* RealTimeDomain::GetName() const { |
| 77 return "RealTimeDomain"; | 72 return "RealTimeDomain"; |
| 78 } | 73 } |
| 79 } // namespace scheduler | 74 } // namespace scheduler |
| 80 } // namespace blink | 75 } // namespace blink |
| OLD | NEW |