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

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

Issue 1303153005: Introduce WebTaskRunner Patch 3/5 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add missing #include Created 5 years, 3 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
« no previous file with comments | « Source/core/dom/ScriptRunnerTest.cpp ('k') | Source/core/fetch/MemoryCacheTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "platform/Logging.h" 10 #include "platform/Logging.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 76 }
77 77
78 ScriptedIdleTaskController::CallbackId ScriptedIdleTaskController::registerCallb ack(IdleRequestCallback* callback, double timeoutMillis) 78 ScriptedIdleTaskController::CallbackId ScriptedIdleTaskController::registerCallb ack(IdleRequestCallback* callback, double timeoutMillis)
79 { 79 {
80 CallbackId id = ++m_nextCallbackId; 80 CallbackId id = ++m_nextCallbackId;
81 m_callbacks.set(id, callback); 81 m_callbacks.set(id, callback);
82 82
83 RefPtr<internal::IdleRequestCallbackWrapper> callbackWrapper = internal::Idl eRequestCallbackWrapper::create(id, this); 83 RefPtr<internal::IdleRequestCallbackWrapper> callbackWrapper = internal::Idl eRequestCallbackWrapper::create(id, this);
84 m_scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(&internal::IdleReques tCallbackWrapper::idleTaskFired, callbackWrapper)); 84 m_scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(&internal::IdleReques tCallbackWrapper::idleTaskFired, callbackWrapper));
85 if (timeoutMillis > 0) 85 if (timeoutMillis > 0)
86 m_scheduler->postTimerTask(FROM_HERE, WTF::bind(&internal::IdleRequestCa llbackWrapper::timeoutFired, callbackWrapper), static_cast<long long>(timeoutMil lis)); 86 m_scheduler->timerTaskRunner()->postDelayedTask(FROM_HERE, WTF::bind(&in ternal::IdleRequestCallbackWrapper::timeoutFired, callbackWrapper), static_cast< long long>(timeoutMillis));
87 87
88 // TODO(rmcilroy): Add devtools tracing. 88 // TODO(rmcilroy): Add devtools tracing.
89 return id; 89 return id;
90 } 90 }
91 91
92 void ScriptedIdleTaskController::cancelCallback(CallbackId id) 92 void ScriptedIdleTaskController::cancelCallback(CallbackId id)
93 { 93 {
94 // TODO(rmcilroy): Add devtools tracing. 94 // TODO(rmcilroy): Add devtools tracing.
95 m_callbacks.remove(id); 95 m_callbacks.remove(id);
96 } 96 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 m_scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(&internal::IdleRe questCallbackWrapper::idleTaskFired, callbackWrapper)); 150 m_scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(&internal::IdleRe questCallbackWrapper::idleTaskFired, callbackWrapper));
151 } 151 }
152 } 152 }
153 153
154 bool ScriptedIdleTaskController::hasPendingActivity() const 154 bool ScriptedIdleTaskController::hasPendingActivity() const
155 { 155 {
156 return !m_callbacks.isEmpty(); 156 return !m_callbacks.isEmpty();
157 } 157 }
158 158
159 } // namespace blink 159 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/ScriptRunnerTest.cpp ('k') | Source/core/fetch/MemoryCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698