| 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 "core/dom/IdleDeadline.h" | 5 #include "core/dom/IdleDeadline.h" |
| 6 | 6 |
| 7 #include "core/timing/PerformanceBase.h" | 7 #include "core/timing/PerformanceBase.h" |
| 8 #include "platform/scheduler/child/web_scheduler.h" |
| 8 #include "platform/wtf/CurrentTime.h" | 9 #include "platform/wtf/CurrentTime.h" |
| 9 #include "public/platform/Platform.h" | 10 #include "public/platform/Platform.h" |
| 10 #include "public/platform/WebScheduler.h" | |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 IdleDeadline::IdleDeadline(double deadline_seconds, CallbackType callback_type) | 14 IdleDeadline::IdleDeadline(double deadline_seconds, CallbackType callback_type) |
| 15 : deadline_seconds_(deadline_seconds), callback_type_(callback_type) {} | 15 : deadline_seconds_(deadline_seconds), callback_type_(callback_type) {} |
| 16 | 16 |
| 17 double IdleDeadline::timeRemaining() const { | 17 double IdleDeadline::timeRemaining() const { |
| 18 double time_remaining = deadline_seconds_ - MonotonicallyIncreasingTime(); | 18 double time_remaining = deadline_seconds_ - MonotonicallyIncreasingTime(); |
| 19 if (time_remaining < 0) { | 19 if (time_remaining < 0) { |
| 20 time_remaining = 0; | 20 time_remaining = 0; |
| 21 } else if (Platform::Current() | 21 } else if (Platform::Current() |
| 22 ->CurrentThread() | 22 ->CurrentThread() |
| 23 ->Scheduler() | 23 ->Scheduler() |
| 24 ->ShouldYieldForHighPriorityWork()) { | 24 ->ShouldYieldForHighPriorityWork()) { |
| 25 time_remaining = 0; | 25 time_remaining = 0; |
| 26 } | 26 } |
| 27 | 27 |
| 28 return 1000.0 * PerformanceBase::ClampTimeResolution(time_remaining); | 28 return 1000.0 * PerformanceBase::ClampTimeResolution(time_remaining); |
| 29 } | 29 } |
| 30 | 30 |
| 31 } // namespace blink | 31 } // namespace blink |
| OLD | NEW |