OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 Loading... |
32 | 32 |
33 #include "bindings/core/v8/SourceLocation.h" | 33 #include "bindings/core/v8/SourceLocation.h" |
34 #include "core/dom/CrossThreadTask.h" | 34 #include "core/dom/CrossThreadTask.h" |
35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
36 #include "core/dom/SecurityContext.h" | 36 #include "core/dom/SecurityContext.h" |
37 #include "core/fetch/SubstituteData.h" | 37 #include "core/fetch/SubstituteData.h" |
38 #include "core/frame/csp/ContentSecurityPolicy.h" | 38 #include "core/frame/csp/ContentSecurityPolicy.h" |
39 #include "core/inspector/ConsoleMessage.h" | 39 #include "core/inspector/ConsoleMessage.h" |
40 #include "core/inspector/InspectorInstrumentation.h" | 40 #include "core/inspector/InspectorInstrumentation.h" |
41 #include "core/loader/FrameLoadRequest.h" | 41 #include "core/loader/FrameLoadRequest.h" |
| 42 #include "core/workers/ParentFrameTaskRunners.h" |
42 #include "core/workers/WorkerClients.h" | 43 #include "core/workers/WorkerClients.h" |
43 #include "core/workers/WorkerGlobalScope.h" | 44 #include "core/workers/WorkerGlobalScope.h" |
44 #include "core/workers/WorkerInspectorProxy.h" | 45 #include "core/workers/WorkerInspectorProxy.h" |
45 #include "core/workers/WorkerLoaderProxy.h" | 46 #include "core/workers/WorkerLoaderProxy.h" |
46 #include "core/workers/WorkerScriptLoader.h" | 47 #include "core/workers/WorkerScriptLoader.h" |
47 #include "core/workers/WorkerThreadStartupData.h" | 48 #include "core/workers/WorkerThreadStartupData.h" |
48 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" | 49 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" |
49 #include "modules/serviceworkers/ServiceWorkerThread.h" | 50 #include "modules/serviceworkers/ServiceWorkerThread.h" |
50 #include "platform/Histogram.h" | 51 #include "platform/Histogram.h" |
51 #include "platform/SharedBuffer.h" | 52 #include "platform/SharedBuffer.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 m_mainFrame->frame()->document()->addConsoleMessage(ConsoleMessage::create(O
therMessageSource, webCoreMessageLevel, message.text, SourceLocation::create(mes
sage.url, message.lineNumber, message.columnNumber, nullptr))); | 249 m_mainFrame->frame()->document()->addConsoleMessage(ConsoleMessage::create(O
therMessageSource, webCoreMessageLevel, message.text, SourceLocation::create(mes
sage.url, message.lineNumber, message.columnNumber, nullptr))); |
249 } | 250 } |
250 | 251 |
251 void WebEmbeddedWorkerImpl::postMessageToPageInspector(const String& message) | 252 void WebEmbeddedWorkerImpl::postMessageToPageInspector(const String& message) |
252 { | 253 { |
253 m_workerInspectorProxy->dispatchMessageFromWorker(message); | 254 m_workerInspectorProxy->dispatchMessageFromWorker(message); |
254 } | 255 } |
255 | 256 |
256 void WebEmbeddedWorkerImpl::postTaskToLoader(std::unique_ptr<ExecutionContextTas
k> task) | 257 void WebEmbeddedWorkerImpl::postTaskToLoader(std::unique_ptr<ExecutionContextTas
k> task) |
257 { | 258 { |
| 259 // TODO(hiroshige,yuryu): Make this not use ExecutionContextTask and |
| 260 // consider using m_mainThreadTaskRunners->getLoadingTaskRunner() instead. |
258 m_mainFrame->frame()->document()->postTask(BLINK_FROM_HERE, std::move(task))
; | 261 m_mainFrame->frame()->document()->postTask(BLINK_FROM_HERE, std::move(task))
; |
259 } | 262 } |
260 | 263 |
261 bool WebEmbeddedWorkerImpl::postTaskToWorkerGlobalScope(std::unique_ptr<Executio
nContextTask> task) | 264 bool WebEmbeddedWorkerImpl::postTaskToWorkerGlobalScope(std::unique_ptr<Executio
nContextTask> task) |
262 { | 265 { |
263 if (m_askedToTerminate || !m_workerThread) | 266 if (m_askedToTerminate || !m_workerThread) |
264 return false; | 267 return false; |
265 | 268 |
266 m_workerThread->postTask(BLINK_FROM_HERE, std::move(task)); | 269 m_workerThread->postTask(BLINK_FROM_HERE, std::move(task)); |
267 return !m_workerThread->terminated(); | 270 return !m_workerThread->terminated(); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 m_mainScriptLoader->referrerPolicy(), | 432 m_mainScriptLoader->referrerPolicy(), |
430 starterOrigin, | 433 starterOrigin, |
431 workerClients, | 434 workerClients, |
432 m_mainScriptLoader->responseAddressSpace(), | 435 m_mainScriptLoader->responseAddressSpace(), |
433 m_mainScriptLoader->originTrialTokens(), | 436 m_mainScriptLoader->originTrialTokens(), |
434 std::move(workerSettings), | 437 std::move(workerSettings), |
435 static_cast<V8CacheOptions>(m_workerStartData.v8CacheOptions)); | 438 static_cast<V8CacheOptions>(m_workerStartData.v8CacheOptions)); |
436 | 439 |
437 m_mainScriptLoader.clear(); | 440 m_mainScriptLoader.clear(); |
438 | 441 |
| 442 // We have a dummy document here for loading but it doesn't really represent |
| 443 // the document/frame of associated document(s) for this worker. Here we |
| 444 // populate the task runners with null document not to confuse the frame |
| 445 // scheduler (which will end up using the thread's default task runner). |
| 446 m_mainThreadTaskRunners = ParentFrameTaskRunners::create(nullptr); |
| 447 |
439 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc
ument, *m_workerContextClient); | 448 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc
ument, *m_workerContextClient); |
440 m_loaderProxy = WorkerLoaderProxy::create(this); | 449 m_loaderProxy = WorkerLoaderProxy::create(this); |
441 m_workerThread = ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalS
copeProxy); | 450 m_workerThread = ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalS
copeProxy); |
442 m_workerThread->start(std::move(startupData)); | 451 m_workerThread->start(std::move(startupData)); |
443 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(),
scriptURL); | 452 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(),
scriptURL); |
444 } | 453 } |
445 | 454 |
446 } // namespace blink | 455 } // namespace blink |
OLD | NEW |