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

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

Issue 2118243002: [proof-of-concept] SW thread independent of the main thread Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "core/workers/WorkerThreadStartupData.h" 48 #include "core/workers/WorkerThreadStartupData.h"
49 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" 49 #include "modules/serviceworkers/ServiceWorkerContainerClient.h"
50 #include "modules/serviceworkers/ServiceWorkerThread.h" 50 #include "modules/serviceworkers/ServiceWorkerThread.h"
51 #include "platform/Histogram.h" 51 #include "platform/Histogram.h"
52 #include "platform/SharedBuffer.h" 52 #include "platform/SharedBuffer.h"
53 #include "platform/heap/Handle.h" 53 #include "platform/heap/Handle.h"
54 #include "platform/network/ContentSecurityPolicyParsers.h" 54 #include "platform/network/ContentSecurityPolicyParsers.h"
55 #include "platform/network/ContentSecurityPolicyResponseHeaders.h" 55 #include "platform/network/ContentSecurityPolicyResponseHeaders.h"
56 #include "platform/network/NetworkUtils.h" 56 #include "platform/network/NetworkUtils.h"
57 #include "platform/weborigin/SecurityOrigin.h" 57 #include "platform/weborigin/SecurityOrigin.h"
58 #include "platform/TraceEvent.h"
58 #include "public/platform/Platform.h" 59 #include "public/platform/Platform.h"
59 #include "public/platform/WebURLRequest.h" 60 #include "public/platform/WebURLRequest.h"
60 #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h" 61 #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h"
61 #include "public/web/WebConsoleMessage.h" 62 #include "public/web/WebConsoleMessage.h"
62 #include "public/web/WebDevToolsAgent.h" 63 #include "public/web/WebDevToolsAgent.h"
63 #include "public/web/WebSettings.h" 64 #include "public/web/WebSettings.h"
64 #include "public/web/WebView.h" 65 #include "public/web/WebView.h"
65 #include "public/web/WebWorkerContentSettingsClientProxy.h" 66 #include "public/web/WebWorkerContentSettingsClientProxy.h"
66 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" 67 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h"
67 #include "public/web/modules/serviceworker/WebServiceWorkerNetworkProvider.h" 68 #include "public/web/modules/serviceworker/WebServiceWorkerNetworkProvider.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 m_mainFrame->frame()->document()->addConsoleMessage(ConsoleMessage::create(O therMessageSource, webCoreMessageLevel, message.text, SourceLocation::create(mes sage.url, message.lineNumber, message.columnNumber, nullptr))); 250 m_mainFrame->frame()->document()->addConsoleMessage(ConsoleMessage::create(O therMessageSource, webCoreMessageLevel, message.text, SourceLocation::create(mes sage.url, message.lineNumber, message.columnNumber, nullptr)));
250 } 251 }
251 252
252 void WebEmbeddedWorkerImpl::postMessageToPageInspector(const String& message) 253 void WebEmbeddedWorkerImpl::postMessageToPageInspector(const String& message)
253 { 254 {
254 m_workerInspectorProxy->dispatchMessageFromWorker(message); 255 m_workerInspectorProxy->dispatchMessageFromWorker(message);
255 } 256 }
256 257
257 void WebEmbeddedWorkerImpl::postTaskToLoader(const WebTraceLocation& location, s td::unique_ptr<ExecutionContextTask> task) 258 void WebEmbeddedWorkerImpl::postTaskToLoader(const WebTraceLocation& location, s td::unique_ptr<ExecutionContextTask> task)
258 { 259 {
260 TRACE_EVENT0("ServiceWorker", "WebEmbeddedWorkerImpl::postTaskToLoader");
259 // TODO(hiroshige,yuryu): Make this not use ExecutionContextTask and 261 // TODO(hiroshige,yuryu): Make this not use ExecutionContextTask and
260 // consider using m_mainThreadTaskRunners->get(TaskType::Networking) 262 // consider using m_mainThreadTaskRunners->get(TaskType::Networking)
261 // instead. 263 // instead.
262 m_mainFrame->frame()->document()->postTask(location, std::move(task)); 264 m_mainFrame->frame()->document()->postTask(location, std::move(task));
263 } 265 }
264 266
265 void WebEmbeddedWorkerImpl::postTaskToWorkerGlobalScope(const WebTraceLocation& location, std::unique_ptr<ExecutionContextTask> task) 267 void WebEmbeddedWorkerImpl::postTaskToWorkerGlobalScope(const WebTraceLocation& location, std::unique_ptr<ExecutionContextTask> task)
266 { 268 {
269 TRACE_EVENT0("ServiceWorker", "WebEmbeddedWorkerImpl::postTaskToWorkerGlobal Scope");
270 // LOG(ERROR) << "WebEmbeddedWorkerImpl::postTaskToWorkerGlobalScope";
267 if (m_askedToTerminate || !m_workerThread) 271 if (m_askedToTerminate || !m_workerThread)
268 return; 272 return;
269 m_workerThread->postTask(location, std::move(task)); 273 m_workerThread->postTask(location, std::move(task));
270 } 274 }
271 275
272 void WebEmbeddedWorkerImpl::prepareShadowPageForLoader() 276 void WebEmbeddedWorkerImpl::prepareShadowPageForLoader()
273 { 277 {
274 // Create 'shadow page', which is never displayed and is used mainly to 278 // Create 'shadow page', which is never displayed and is used mainly to
275 // provide a context for loading on the main thread. 279 // provide a context for loading on the main thread.
276 // 280 //
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 m_mainThreadTaskRunners = ParentFrameTaskRunners::create(nullptr); 448 m_mainThreadTaskRunners = ParentFrameTaskRunners::create(nullptr);
445 449
446 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc ument, *m_workerContextClient); 450 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc ument, *m_workerContextClient);
447 m_loaderProxy = WorkerLoaderProxy::create(this); 451 m_loaderProxy = WorkerLoaderProxy::create(this);
448 m_workerThread = ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalS copeProxy); 452 m_workerThread = ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalS copeProxy);
449 m_workerThread->start(std::move(startupData)); 453 m_workerThread->start(std::move(startupData));
450 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), scriptURL); 454 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), scriptURL);
451 } 455 }
452 456
453 } // namespace blink 457 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698