Chromium Code Reviews| 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 28 matching lines...) Expand all Loading... | |
| 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::RequestWakeup(base::TimeTicks now, base::TimeDelta delay) { |
| 43 // 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 |
| 44 // previously scheduled runtime, or there is no (outstanding) previously | 44 // previously scheduled runtime, or there is no (outstanding) previously |
| 45 // scheduled runtime. | 45 // scheduled runtime. |
| 46 task_queue_manager_->MaybeScheduleDelayedWork(FROM_HERE, now, delay); | 46 task_queue_manager_->MaybeScheduleDelayedWork(FROM_HERE, now, delay); |
| 47 } | 47 } |
| 48 | 48 |
| 49 bool RealTimeDomain::MaybeAdvanceTime() { | 49 base::Optional<base::TimeDelta> RealTimeDomain::DelayTillNextTask( |
| 50 LazyNow* lazy_now) { | |
| 50 base::TimeTicks next_run_time; | 51 base::TimeTicks next_run_time; |
| 51 if (!NextScheduledRunTime(&next_run_time)) | 52 if (!NextScheduledRunTime(&next_run_time)) |
| 52 return false; | 53 return base::Optional<base::TimeDelta>(); |
| 53 | 54 |
| 54 base::TimeTicks now = Now(); | 55 base::TimeTicks now = lazy_now->Now(); |
| 55 if (now >= next_run_time) | 56 if (now >= next_run_time) |
| 56 return true; // Causes DoWork to post a continuation. | 57 return base::TimeDelta(); // Makes DoWork post an immediate continuation. |
| 57 | 58 |
| 58 base::TimeDelta delay = next_run_time - now; | 59 base::TimeDelta delay = next_run_time - now; |
| 59 TRACE_EVENT1(tracing_category_, "RealTimeDomain::MaybeAdvanceTime", | 60 TRACE_EVENT1(tracing_category_, "RealTimeDomain::DelayTillNextTask", |
| 60 "delay_ms", delay.InMillisecondsF()); | 61 "delay_ms", delay.InMillisecondsF()); |
| 61 | 62 |
| 62 // The next task is sometime in the future, make sure we schedule a DoWork to | 63 // The next task is sometime in the future. DoWork will make sure it gets |
| 63 // run it. | 64 // run at the right time.. |
|
Sami
2017/01/18 18:45:57
nit: s/.././
alex clarke (OOO till 29th)
2017/01/19 08:56:10
Done.
| |
| 64 task_queue_manager_->MaybeScheduleDelayedWork(FROM_HERE, now, delay); | 65 return delay; |
| 65 return false; | |
| 66 } | 66 } |
| 67 | 67 |
| 68 void RealTimeDomain::AsValueIntoInternal( | 68 void RealTimeDomain::AsValueIntoInternal( |
| 69 base::trace_event::TracedValue* state) const {} | 69 base::trace_event::TracedValue* state) const {} |
| 70 | 70 |
| 71 const char* RealTimeDomain::GetName() const { | 71 const char* RealTimeDomain::GetName() const { |
| 72 return "RealTimeDomain"; | 72 return "RealTimeDomain"; |
| 73 } | 73 } |
| 74 } // namespace scheduler | 74 } // namespace scheduler |
| 75 } // namespace blink | 75 } // namespace blink |
| OLD | NEW |