| 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" | |
| 43 #include "core/workers/WorkerClients.h" | 42 #include "core/workers/WorkerClients.h" |
| 44 #include "core/workers/WorkerGlobalScope.h" | 43 #include "core/workers/WorkerGlobalScope.h" |
| 45 #include "core/workers/WorkerInspectorProxy.h" | 44 #include "core/workers/WorkerInspectorProxy.h" |
| 46 #include "core/workers/WorkerLoaderProxy.h" | 45 #include "core/workers/WorkerLoaderProxy.h" |
| 47 #include "core/workers/WorkerScriptLoader.h" | 46 #include "core/workers/WorkerScriptLoader.h" |
| 48 #include "core/workers/WorkerThreadStartupData.h" | 47 #include "core/workers/WorkerThreadStartupData.h" |
| 49 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" | 48 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" |
| 50 #include "modules/serviceworkers/ServiceWorkerThread.h" | 49 #include "modules/serviceworkers/ServiceWorkerThread.h" |
| 51 #include "platform/Histogram.h" | 50 #include "platform/Histogram.h" |
| 52 #include "platform/SharedBuffer.h" | 51 #include "platform/SharedBuffer.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 m_mainFrame->frame()->document()->addConsoleMessage(ConsoleMessage::create(O
therMessageSource, webCoreMessageLevel, message.text, SourceLocation::create(mes
sage.url, message.lineNumber, message.columnNumber, nullptr))); | 248 m_mainFrame->frame()->document()->addConsoleMessage(ConsoleMessage::create(O
therMessageSource, webCoreMessageLevel, message.text, SourceLocation::create(mes
sage.url, message.lineNumber, message.columnNumber, nullptr))); |
| 250 } | 249 } |
| 251 | 250 |
| 252 void WebEmbeddedWorkerImpl::postMessageToPageInspector(const String& message) | 251 void WebEmbeddedWorkerImpl::postMessageToPageInspector(const String& message) |
| 253 { | 252 { |
| 254 m_workerInspectorProxy->dispatchMessageFromWorker(message); | 253 m_workerInspectorProxy->dispatchMessageFromWorker(message); |
| 255 } | 254 } |
| 256 | 255 |
| 257 void WebEmbeddedWorkerImpl::postTaskToLoader(const WebTraceLocation& location, s
td::unique_ptr<ExecutionContextTask> task) | 256 void WebEmbeddedWorkerImpl::postTaskToLoader(const WebTraceLocation& location, s
td::unique_ptr<ExecutionContextTask> task) |
| 258 { | 257 { |
| 259 // TODO(hiroshige,yuryu): Make this not use ExecutionContextTask and | |
| 260 // consider using m_mainThreadTaskRunners->getLoadingTaskRunner() instead. | |
| 261 m_mainFrame->frame()->document()->postTask(location, std::move(task)); | 258 m_mainFrame->frame()->document()->postTask(location, std::move(task)); |
| 262 } | 259 } |
| 263 | 260 |
| 264 bool WebEmbeddedWorkerImpl::postTaskToWorkerGlobalScope(const WebTraceLocation&
location, std::unique_ptr<ExecutionContextTask> task) | 261 bool WebEmbeddedWorkerImpl::postTaskToWorkerGlobalScope(const WebTraceLocation&
location, std::unique_ptr<ExecutionContextTask> task) |
| 265 { | 262 { |
| 266 if (m_askedToTerminate || !m_workerThread) | 263 if (m_askedToTerminate || !m_workerThread) |
| 267 return false; | 264 return false; |
| 268 | 265 |
| 269 m_workerThread->postTask(location, std::move(task)); | 266 m_workerThread->postTask(location, std::move(task)); |
| 270 return !m_workerThread->terminated(); | 267 return !m_workerThread->terminated(); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 m_mainScriptLoader->referrerPolicy(), | 429 m_mainScriptLoader->referrerPolicy(), |
| 433 starterOrigin, | 430 starterOrigin, |
| 434 workerClients, | 431 workerClients, |
| 435 m_mainScriptLoader->responseAddressSpace(), | 432 m_mainScriptLoader->responseAddressSpace(), |
| 436 m_mainScriptLoader->originTrialTokens(), | 433 m_mainScriptLoader->originTrialTokens(), |
| 437 std::move(workerSettings), | 434 std::move(workerSettings), |
| 438 static_cast<V8CacheOptions>(m_workerStartData.v8CacheOptions)); | 435 static_cast<V8CacheOptions>(m_workerStartData.v8CacheOptions)); |
| 439 | 436 |
| 440 m_mainScriptLoader.clear(); | 437 m_mainScriptLoader.clear(); |
| 441 | 438 |
| 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 | |
| 448 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc
ument, *m_workerContextClient); | 439 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc
ument, *m_workerContextClient); |
| 449 m_loaderProxy = WorkerLoaderProxy::create(this); | 440 m_loaderProxy = WorkerLoaderProxy::create(this); |
| 450 m_workerThread = ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalS
copeProxy); | 441 m_workerThread = ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalS
copeProxy); |
| 451 m_workerThread->start(std::move(startupData)); | 442 m_workerThread->start(std::move(startupData)); |
| 452 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(),
scriptURL); | 443 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(),
scriptURL); |
| 453 } | 444 } |
| 454 | 445 |
| 455 } // namespace blink | 446 } // namespace blink |
| OLD | NEW |