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

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

Issue 2163983004: Pass per-frame task runners to Workers (when possible) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 4 years, 4 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 | « third_party/WebKit/Source/web/WebSharedWorkerImpl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 21 matching lines...) Expand all
32 32
33 #include "core/dom/CrossThreadTask.h" 33 #include "core/dom/CrossThreadTask.h"
34 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/events/MessageEvent.h" 35 #include "core/events/MessageEvent.h"
36 #include "core/html/HTMLFormElement.h" 36 #include "core/html/HTMLFormElement.h"
37 #include "core/inspector/ConsoleMessage.h" 37 #include "core/inspector/ConsoleMessage.h"
38 #include "core/inspector/InspectorInstrumentation.h" 38 #include "core/inspector/InspectorInstrumentation.h"
39 #include "core/loader/FrameLoadRequest.h" 39 #include "core/loader/FrameLoadRequest.h"
40 #include "core/loader/FrameLoader.h" 40 #include "core/loader/FrameLoader.h"
41 #include "core/page/Page.h" 41 #include "core/page/Page.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"
45 #include "core/workers/WorkerGlobalScope.h" 46 #include "core/workers/WorkerGlobalScope.h"
46 #include "core/workers/WorkerInspectorProxy.h" 47 #include "core/workers/WorkerInspectorProxy.h"
47 #include "core/workers/WorkerLoaderProxy.h" 48 #include "core/workers/WorkerLoaderProxy.h"
48 #include "core/workers/WorkerScriptLoader.h" 49 #include "core/workers/WorkerScriptLoader.h"
49 #include "core/workers/WorkerThreadStartupData.h" 50 #include "core/workers/WorkerThreadStartupData.h"
50 #include "platform/CrossThreadFunctional.h" 51 #include "platform/CrossThreadFunctional.h"
51 #include "platform/RuntimeEnabledFeatures.h" 52 #include "platform/RuntimeEnabledFeatures.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 { 265 {
265 m_client->workerContextDestroyed(); 266 m_client->workerContextDestroyed();
266 // The lifetime of this proxy is controlled by the worker context. 267 // The lifetime of this proxy is controlled by the worker context.
267 delete this; 268 delete this;
268 } 269 }
269 270
270 // WorkerLoaderProxyProvider --------------------------------------------------- -------- 271 // WorkerLoaderProxyProvider --------------------------------------------------- --------
271 272
272 void WebSharedWorkerImpl::postTaskToLoader(std::unique_ptr<ExecutionContextTask> task) 273 void WebSharedWorkerImpl::postTaskToLoader(std::unique_ptr<ExecutionContextTask> task)
273 { 274 {
275 // TODO(hiroshige,yuryu): Make this not use ExecutionContextTask and
276 // consider using m_mainThreadTaskRunners->getLoadingTaskRunner() instead.
274 m_mainFrame->frame()->document()->postTask(BLINK_FROM_HERE, std::move(task)) ; 277 m_mainFrame->frame()->document()->postTask(BLINK_FROM_HERE, std::move(task)) ;
275 } 278 }
276 279
277 bool WebSharedWorkerImpl::postTaskToWorkerGlobalScope(std::unique_ptr<ExecutionC ontextTask> task) 280 bool WebSharedWorkerImpl::postTaskToWorkerGlobalScope(std::unique_ptr<ExecutionC ontextTask> task)
278 { 281 {
279 m_workerThread->postTask(BLINK_FROM_HERE, std::move(task)); 282 m_workerThread->postTask(BLINK_FROM_HERE, std::move(task));
280 return true; 283 return true;
281 } 284 }
282 285
283 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel) 286 void WebSharedWorkerImpl::connect(WebMessagePortChannel* webChannel)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 m_mainScriptLoader->script(), 347 m_mainScriptLoader->script(),
345 nullptr, 348 nullptr,
346 startMode, 349 startMode,
347 contentSecurityPolicy ? contentSecurityPolicy->headers().get() : nullptr , 350 contentSecurityPolicy ? contentSecurityPolicy->headers().get() : nullptr ,
348 m_mainScriptLoader->referrerPolicy(), 351 m_mainScriptLoader->referrerPolicy(),
349 starterOrigin, 352 starterOrigin,
350 workerClients, 353 workerClients,
351 m_mainScriptLoader->responseAddressSpace(), 354 m_mainScriptLoader->responseAddressSpace(),
352 m_mainScriptLoader->originTrialTokens(), 355 m_mainScriptLoader->originTrialTokens(),
353 std::move(workerSettings)); 356 std::move(workerSettings));
357
358 // We have a dummy document here for loading but it doesn't really represent
359 // the document/frame of associated document(s) for this worker. Here we
360 // populate the task runners with null document not to confuse the frame
361 // scheduler (which will end up using the thread's default task runner).
362 m_mainThreadTaskRunners = ParentFrameTaskRunners::create(nullptr);
363
354 m_loaderProxy = WorkerLoaderProxy::create(this); 364 m_loaderProxy = WorkerLoaderProxy::create(this);
355 m_workerThread = SharedWorkerThread::create(m_name, m_loaderProxy, *this); 365 m_workerThread = SharedWorkerThread::create(m_name, m_loaderProxy, *this);
356 InspectorInstrumentation::scriptImported(m_loadingDocument.get(), m_mainScri ptLoader->identifier(), m_mainScriptLoader->script()); 366 InspectorInstrumentation::scriptImported(m_loadingDocument.get(), m_mainScri ptLoader->identifier(), m_mainScriptLoader->script());
357 m_mainScriptLoader.clear(); 367 m_mainScriptLoader.clear();
358 368
359 workerThread()->start(std::move(startupData)); 369 workerThread()->start(std::move(startupData));
360 m_workerInspectorProxy->workerThreadCreated(toDocument(m_loadingDocument.get ()), workerThread(), m_url); 370 m_workerInspectorProxy->workerThreadCreated(toDocument(m_loadingDocument.get ()), workerThread(), m_url);
361 m_client->workerScriptLoaded(); 371 m_client->workerScriptLoaded();
362 } 372 }
363 373
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 if (devtoolsAgent) 411 if (devtoolsAgent)
402 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, mes sage); 412 devtoolsAgent->dispatchOnInspectorBackend(sessionId, callId, method, mes sage);
403 } 413 }
404 414
405 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) 415 WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client)
406 { 416 {
407 return new WebSharedWorkerImpl(client); 417 return new WebSharedWorkerImpl(client);
408 } 418 }
409 419
410 } // namespace blink 420 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebSharedWorkerImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698