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

Side by Side Diff: third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp

Issue 2806623004: Worker: Introduce per-global-scope task scheduler (Closed)
Patch Set: wip Created 3 years, 8 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 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "web/WebSharedWorkerImpl.h" 31 #include "web/WebSharedWorkerImpl.h"
32 32
33 #include <memory> 33 #include <memory>
34 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/dom/TaskRunnerHelper.h"
35 #include "core/events/MessageEvent.h" 36 #include "core/events/MessageEvent.h"
36 #include "core/inspector/ConsoleMessage.h" 37 #include "core/inspector/ConsoleMessage.h"
37 #include "core/loader/FrameLoadRequest.h" 38 #include "core/loader/FrameLoadRequest.h"
38 #include "core/loader/FrameLoader.h" 39 #include "core/loader/FrameLoader.h"
39 #include "core/loader/ThreadableLoadingContext.h" 40 #include "core/loader/ThreadableLoadingContext.h"
40 #include "core/probe/CoreProbes.h" 41 #include "core/probe/CoreProbes.h"
41 #include "core/workers/ParentFrameTaskRunners.h" 42 #include "core/workers/ParentFrameTaskRunners.h"
42 #include "core/workers/SharedWorkerGlobalScope.h" 43 #include "core/workers/SharedWorkerGlobalScope.h"
43 #include "core/workers/SharedWorkerThread.h" 44 #include "core/workers/SharedWorkerThread.h"
44 #include "core/workers/WorkerClients.h" 45 #include "core/workers/WorkerClients.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 std::unique_ptr<WTF::CrossThreadClosure> task) { 248 std::unique_ptr<WTF::CrossThreadClosure> task) {
248 DCHECK(m_workerThread->isCurrentThread()); 249 DCHECK(m_workerThread->isCurrentThread());
249 m_parentFrameTaskRunners->get(TaskType::Networking) 250 m_parentFrameTaskRunners->get(TaskType::Networking)
250 ->postTask(FROM_HERE, std::move(task)); 251 ->postTask(FROM_HERE, std::move(task));
251 } 252 }
252 253
253 void WebSharedWorkerImpl::postTaskToWorkerGlobalScope( 254 void WebSharedWorkerImpl::postTaskToWorkerGlobalScope(
254 const WebTraceLocation& location, 255 const WebTraceLocation& location,
255 std::unique_ptr<WTF::CrossThreadClosure> task) { 256 std::unique_ptr<WTF::CrossThreadClosure> task) {
256 DCHECK(isMainThread()); 257 DCHECK(isMainThread());
257 m_workerThread->postTask(location, std::move(task)); 258 TaskRunnerHelper::get(TaskType::Networking, m_workerThread.get())
259 ->postTask(location, std::move(task));
258 } 260 }
259 261
260 ThreadableLoadingContext* WebSharedWorkerImpl::getThreadableLoadingContext() { 262 ThreadableLoadingContext* WebSharedWorkerImpl::getThreadableLoadingContext() {
261 if (!m_loadingContext) { 263 if (!m_loadingContext) {
262 m_loadingContext = 264 m_loadingContext =
263 ThreadableLoadingContext::create(*toDocument(m_loadingDocument.get())); 265 ThreadableLoadingContext::create(*toDocument(m_loadingDocument.get()));
264 } 266 }
265 return m_loadingContext; 267 return m_loadingContext;
266 } 268 }
267 269
268 void WebSharedWorkerImpl::connect( 270 void WebSharedWorkerImpl::connect(
269 std::unique_ptr<WebMessagePortChannel> webChannel) { 271 std::unique_ptr<WebMessagePortChannel> webChannel) {
270 DCHECK(isMainThread()); 272 DCHECK(isMainThread());
271 workerThread()->postTask( 273 TaskRunnerHelper::get(TaskType::DOMManipulation, workerThread())
272 BLINK_FROM_HERE, 274 ->postTask(
273 crossThreadBind(&WebSharedWorkerImpl::connectTaskOnWorkerThread, 275 BLINK_FROM_HERE,
274 WTF::crossThreadUnretained(this), 276 crossThreadBind(&WebSharedWorkerImpl::connectTaskOnWorkerThread,
275 WTF::passed(std::move(webChannel)))); 277 WTF::crossThreadUnretained(this),
278 WTF::passed(std::move(webChannel))));
276 } 279 }
277 280
278 void WebSharedWorkerImpl::connectTaskOnWorkerThread( 281 void WebSharedWorkerImpl::connectTaskOnWorkerThread(
279 std::unique_ptr<WebMessagePortChannel> channel) { 282 std::unique_ptr<WebMessagePortChannel> channel) {
280 // Wrap the passed-in channel in a MessagePort, and send it off via a connect 283 // Wrap the passed-in channel in a MessagePort, and send it off via a connect
281 // event. 284 // event.
282 DCHECK(m_workerThread->isCurrentThread()); 285 DCHECK(m_workerThread->isCurrentThread());
283 WorkerGlobalScope* workerGlobalScope = 286 WorkerGlobalScope* workerGlobalScope =
284 toWorkerGlobalScope(m_workerThread->globalScope()); 287 toWorkerGlobalScope(m_workerThread->globalScope());
285 MessagePort* port = MessagePort::create(*workerGlobalScope); 288 MessagePort* port = MessagePort::create(*workerGlobalScope);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 if (devtoolsAgent) 423 if (devtoolsAgent)
421 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, 424 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method,
422 message); 425 message);
423 } 426 }
424 427
425 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) { 428 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) {
426 return new WebSharedWorkerImpl(client); 429 return new WebSharedWorkerImpl(client);
427 } 430 }
428 431
429 } // namespace blink 432 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698