Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: third_party/WebKit/Source/core/dom/ScriptedIdleTaskController.cpp

Issue 1367023002: Replace timeout argument with IdleRequestOptions in requestIdleCallback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rIC_histograms
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "core/dom/IdleRequestOptions.h"
10 #include "core/inspector/InspectorTraceEvents.h" 11 #include "core/inspector/InspectorTraceEvents.h"
11 #include "platform/Logging.h" 12 #include "platform/Logging.h"
12 #include "platform/TraceEvent.h" 13 #include "platform/TraceEvent.h"
13 #include "public/platform/Platform.h" 14 #include "public/platform/Platform.h"
14 #include "public/platform/WebScheduler.h" 15 #include "public/platform/WebScheduler.h"
15 #include "public/platform/WebTraceLocation.h" 16 #include "public/platform/WebTraceLocation.h"
16 #include "wtf/CurrentTime.h" 17 #include "wtf/CurrentTime.h"
17 #include "wtf/Functional.h" 18 #include "wtf/Functional.h"
18 19
19 namespace blink { 20 namespace blink {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 ScriptedIdleTaskController::~ScriptedIdleTaskController() 70 ScriptedIdleTaskController::~ScriptedIdleTaskController()
70 { 71 {
71 } 72 }
72 73
73 DEFINE_TRACE(ScriptedIdleTaskController) 74 DEFINE_TRACE(ScriptedIdleTaskController)
74 { 75 {
75 visitor->trace(m_callbacks); 76 visitor->trace(m_callbacks);
76 ActiveDOMObject::trace(visitor); 77 ActiveDOMObject::trace(visitor);
77 } 78 }
78 79
79 ScriptedIdleTaskController::CallbackId ScriptedIdleTaskController::registerCallb ack(IdleRequestCallback* callback, double timeoutMillis) 80 ScriptedIdleTaskController::CallbackId ScriptedIdleTaskController::registerCallb ack(IdleRequestCallback* callback, const IdleRequestOptions& options)
80 { 81 {
81 CallbackId id = ++m_nextCallbackId; 82 CallbackId id = ++m_nextCallbackId;
82 m_callbacks.set(id, callback); 83 m_callbacks.set(id, callback);
84 long long timeoutMillis = options.timeout();
83 85
84 RefPtr<internal::IdleRequestCallbackWrapper> callbackWrapper = internal::Idl eRequestCallbackWrapper::create(id, this); 86 RefPtr<internal::IdleRequestCallbackWrapper> callbackWrapper = internal::Idl eRequestCallbackWrapper::create(id, this);
85 m_scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(&internal::IdleReques tCallbackWrapper::idleTaskFired, callbackWrapper)); 87 m_scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(&internal::IdleReques tCallbackWrapper::idleTaskFired, callbackWrapper));
86 if (timeoutMillis > 0) 88 if (timeoutMillis > 0)
87 m_scheduler->timerTaskRunner()->postDelayedTask(FROM_HERE, WTF::bind(&in ternal::IdleRequestCallbackWrapper::timeoutFired, callbackWrapper), static_cast< long long>(timeoutMillis)); 89 m_scheduler->timerTaskRunner()->postDelayedTask(FROM_HERE, WTF::bind(&in ternal::IdleRequestCallbackWrapper::timeoutFired, callbackWrapper), timeoutMilli s);
88 TRACE_EVENT_INSTANT1("devtools.timeline", "RequestIdleCallback", TRACE_EVENT _SCOPE_THREAD, "data", InspectorIdleCallbackRequestEvent::data(executionContext( ), id, timeoutMillis)); 90 TRACE_EVENT_INSTANT1("devtools.timeline", "RequestIdleCallback", TRACE_EVENT _SCOPE_THREAD, "data", InspectorIdleCallbackRequestEvent::data(executionContext( ), id, timeoutMillis));
89 return id; 91 return id;
90 } 92 }
91 93
92 void ScriptedIdleTaskController::cancelCallback(CallbackId id) 94 void ScriptedIdleTaskController::cancelCallback(CallbackId id)
93 { 95 {
94 TRACE_EVENT_INSTANT1("devtools.timeline", "CancelIdleCallback", TRACE_EVENT_ SCOPE_THREAD, "data", InspectorIdleCallbackCancelEvent::data(executionContext(), id)); 96 TRACE_EVENT_INSTANT1("devtools.timeline", "CancelIdleCallback", TRACE_EVENT_ SCOPE_THREAD, "data", InspectorIdleCallbackCancelEvent::data(executionContext(), id));
95 m_callbacks.remove(id); 97 m_callbacks.remove(id);
96 } 98 }
97 99
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 m_scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(&internal::IdleRe questCallbackWrapper::idleTaskFired, callbackWrapper)); 159 m_scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(&internal::IdleRe questCallbackWrapper::idleTaskFired, callbackWrapper));
158 } 160 }
159 } 161 }
160 162
161 bool ScriptedIdleTaskController::hasPendingActivity() const 163 bool ScriptedIdleTaskController::hasPendingActivity() const
162 { 164 {
163 return !m_callbacks.isEmpty(); 165 return !m_callbacks.isEmpty();
164 } 166 }
165 167
166 } // namespace blink 168 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/ScriptedIdleTaskController.h ('k') | third_party/WebKit/Source/core/frame/DOMWindow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698