| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/dom/ScriptedIdleTaskController.h" | 6 #include "core/dom/ScriptedIdleTaskController.h" |
| 7 | 7 |
| 8 #include "core/dom/ExecutionContext.h" | 8 #include "core/dom/ExecutionContext.h" |
| 9 #include "core/dom/IdleRequestCallback.h" | 9 #include "core/dom/IdleRequestCallback.h" |
| 10 #include "platform/Logging.h" | 10 #include "platform/Logging.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 runCallback(id, deadlineSeconds, callbackType); | 112 runCallback(id, deadlineSeconds, callbackType); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void ScriptedIdleTaskController::runCallback(CallbackId id, double deadlineSecon
ds, IdleDeadline::CallbackType callbackType) | 115 void ScriptedIdleTaskController::runCallback(CallbackId id, double deadlineSecon
ds, IdleDeadline::CallbackType callbackType) |
| 116 { | 116 { |
| 117 ASSERT(!m_suspended); | 117 ASSERT(!m_suspended); |
| 118 auto callback = m_callbacks.take(id); | 118 auto callback = m_callbacks.take(id); |
| 119 if (!callback) | 119 if (!callback) |
| 120 return; | 120 return; |
| 121 | 121 |
| 122 double allotedTimeMillis = std::max((deadlineSeconds - monotonicallyIncreasi
ngTime()) * 1000, 0.0); |
| 123 Platform::current()->histogramCustomCounts("WebCore.ScriptedIdleTaskControll
er.IdleCallbackDeadline", allotedTimeMillis, 0, 50, 50); |
| 124 |
| 122 // TODO(rmcilroy): Add devtools tracing. | 125 // TODO(rmcilroy): Add devtools tracing. |
| 123 callback->handleEvent(IdleDeadline::create(deadlineSeconds, callbackType)); | 126 callback->handleEvent(IdleDeadline::create(deadlineSeconds, callbackType)); |
| 127 |
| 128 double overrunMillis = std::max((monotonicallyIncreasingTime() - deadlineSec
onds) * 1000, 0.0); |
| 129 Platform::current()->histogramCustomCounts("WebCore.ScriptedIdleTaskControll
er.IdleCallbackOverrun", overrunMillis, 0, 10000, 50); |
| 124 } | 130 } |
| 125 | 131 |
| 126 void ScriptedIdleTaskController::stop() | 132 void ScriptedIdleTaskController::stop() |
| 127 { | 133 { |
| 128 m_callbacks.clear(); | 134 m_callbacks.clear(); |
| 129 } | 135 } |
| 130 | 136 |
| 131 void ScriptedIdleTaskController::suspend() | 137 void ScriptedIdleTaskController::suspend() |
| 132 { | 138 { |
| 133 m_suspended = true; | 139 m_suspended = true; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 150 m_scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(&internal::IdleRe
questCallbackWrapper::idleTaskFired, callbackWrapper)); | 156 m_scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(&internal::IdleRe
questCallbackWrapper::idleTaskFired, callbackWrapper)); |
| 151 } | 157 } |
| 152 } | 158 } |
| 153 | 159 |
| 154 bool ScriptedIdleTaskController::hasPendingActivity() const | 160 bool ScriptedIdleTaskController::hasPendingActivity() const |
| 155 { | 161 { |
| 156 return !m_callbacks.isEmpty(); | 162 return !m_callbacks.isEmpty(); |
| 157 } | 163 } |
| 158 | 164 |
| 159 } // namespace blink | 165 } // namespace blink |
| OLD | NEW |