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

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

Issue 2840473002: Worker: Remove WorkerLoaderProxy for clean-up (Closed)
Patch Set: clean up Created 3 years, 6 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 30 matching lines...) Expand all
41 #include "core/inspector/ConsoleMessage.h" 41 #include "core/inspector/ConsoleMessage.h"
42 #include "core/loader/FrameLoadRequest.h" 42 #include "core/loader/FrameLoadRequest.h"
43 #include "core/loader/ThreadableLoadingContext.h" 43 #include "core/loader/ThreadableLoadingContext.h"
44 #include "core/loader/WorkerFetchContext.h" 44 #include "core/loader/WorkerFetchContext.h"
45 #include "core/probe/CoreProbes.h" 45 #include "core/probe/CoreProbes.h"
46 #include "core/workers/ParentFrameTaskRunners.h" 46 #include "core/workers/ParentFrameTaskRunners.h"
47 #include "core/workers/WorkerClients.h" 47 #include "core/workers/WorkerClients.h"
48 #include "core/workers/WorkerContentSettingsClient.h" 48 #include "core/workers/WorkerContentSettingsClient.h"
49 #include "core/workers/WorkerGlobalScope.h" 49 #include "core/workers/WorkerGlobalScope.h"
50 #include "core/workers/WorkerInspectorProxy.h" 50 #include "core/workers/WorkerInspectorProxy.h"
51 #include "core/workers/WorkerLoaderProxy.h"
52 #include "core/workers/WorkerScriptLoader.h" 51 #include "core/workers/WorkerScriptLoader.h"
53 #include "core/workers/WorkerThreadStartupData.h" 52 #include "core/workers/WorkerThreadStartupData.h"
54 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" 53 #include "modules/serviceworkers/ServiceWorkerContainerClient.h"
55 #include "modules/serviceworkers/ServiceWorkerThread.h" 54 #include "modules/serviceworkers/ServiceWorkerThread.h"
56 #include "platform/Histogram.h" 55 #include "platform/Histogram.h"
57 #include "platform/RuntimeEnabledFeatures.h" 56 #include "platform/RuntimeEnabledFeatures.h"
58 #include "platform/SharedBuffer.h" 57 #include "platform/SharedBuffer.h"
59 #include "platform/heap/Handle.h" 58 #include "platform/heap/Handle.h"
60 #include "platform/loader/fetch/SubstituteData.h" 59 #include "platform/loader/fetch/SubstituteData.h"
61 #include "platform/network/ContentSecurityPolicyParsers.h" 60 #include "platform/network/ContentSecurityPolicyParsers.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // Detach the client before closing the view to avoid getting called back. 122 // Detach the client before closing the view to avoid getting called back.
124 main_frame_->SetClient(0); 123 main_frame_->SetClient(0);
125 124
126 if (worker_global_scope_proxy_) { 125 if (worker_global_scope_proxy_) {
127 worker_global_scope_proxy_->Detach(); 126 worker_global_scope_proxy_->Detach();
128 worker_global_scope_proxy_.Clear(); 127 worker_global_scope_proxy_.Clear();
129 } 128 }
130 129
131 web_view_->Close(); 130 web_view_->Close();
132 main_frame_->Close(); 131 main_frame_->Close();
133 if (loader_proxy_)
134 loader_proxy_->DetachProvider(this);
135 } 132 }
136 133
137 void WebEmbeddedWorkerImpl::StartWorkerContext( 134 void WebEmbeddedWorkerImpl::StartWorkerContext(
138 const WebEmbeddedWorkerStartData& data) { 135 const WebEmbeddedWorkerStartData& data) {
139 DCHECK(!asked_to_terminate_); 136 DCHECK(!asked_to_terminate_);
140 DCHECK(!main_script_loader_); 137 DCHECK(!main_script_loader_);
141 DCHECK_EQ(pause_after_download_state_, kDontPauseAfterDownload); 138 DCHECK_EQ(pause_after_download_state_, kDontPauseAfterDownload);
142 worker_start_data_ = data; 139 worker_start_data_ = data;
143 140
144 // TODO(mkwst): This really needs to be piped through from the requesting 141 // TODO(mkwst): This really needs to be piped through from the requesting
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 ConsoleMessage::Create( 256 ConsoleMessage::Create(
260 kOtherMessageSource, web_core_message_level, message.text, 257 kOtherMessageSource, web_core_message_level, message.text,
261 SourceLocation::Create(message.url, message.line_number, 258 SourceLocation::Create(message.url, message.line_number,
262 message.column_number, nullptr))); 259 message.column_number, nullptr)));
263 } 260 }
264 261
265 void WebEmbeddedWorkerImpl::PostMessageToPageInspector(const String& message) { 262 void WebEmbeddedWorkerImpl::PostMessageToPageInspector(const String& message) {
266 worker_inspector_proxy_->DispatchMessageFromWorker(message); 263 worker_inspector_proxy_->DispatchMessageFromWorker(message);
267 } 264 }
268 265
269 ThreadableLoadingContext* WebEmbeddedWorkerImpl::GetThreadableLoadingContext() {
270 if (!loading_context_) {
271 loading_context_ = ThreadableLoadingContext::Create(
272 *main_frame_->GetFrame()->GetDocument());
273 }
274 return loading_context_;
275 }
276
277 void WebEmbeddedWorkerImpl::PrepareShadowPageForLoader() { 266 void WebEmbeddedWorkerImpl::PrepareShadowPageForLoader() {
278 // Create 'shadow page', which is never displayed and is used mainly to 267 // Create 'shadow page', which is never displayed and is used mainly to
279 // provide a context for loading on the main thread. 268 // provide a context for loading on the main thread.
280 // 269 //
281 // FIXME: This does mostly same as WebSharedWorkerImpl::initializeLoader. 270 // FIXME: This does mostly same as WebSharedWorkerImpl::initializeLoader.
282 // This code, and probably most of the code in this class should be shared 271 // This code, and probably most of the code in this class should be shared
283 // with SharedWorker. 272 // with SharedWorker.
284 DCHECK(!web_view_); 273 DCHECK(!web_view_);
285 web_view_ = WebView::Create(nullptr, kWebPageVisibilityStateVisible); 274 web_view_ = WebView::Create(nullptr, kWebPageVisibilityStateVisible);
286 WebSettings* settings = web_view_->GetSettings(); 275 WebSettings* settings = web_view_->GetSettings();
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 document->GetContentSecurityPolicy()->Headers().get(), 453 document->GetContentSecurityPolicy()->Headers().get(),
465 main_script_loader_->GetReferrerPolicy(), starter_origin, 454 main_script_loader_->GetReferrerPolicy(), starter_origin,
466 worker_clients, main_script_loader_->ResponseAddressSpace(), 455 worker_clients, main_script_loader_->ResponseAddressSpace(),
467 main_script_loader_->OriginTrialTokens(), std::move(worker_settings), 456 main_script_loader_->OriginTrialTokens(), std::move(worker_settings),
468 worker_v8_settings); 457 worker_v8_settings);
469 458
470 main_script_loader_.Clear(); 459 main_script_loader_.Clear();
471 460
472 worker_global_scope_proxy_ = 461 worker_global_scope_proxy_ =
473 ServiceWorkerGlobalScopeProxy::Create(*this, *worker_context_client_); 462 ServiceWorkerGlobalScopeProxy::Create(*this, *worker_context_client_);
474 loader_proxy_ = WorkerLoaderProxy::Create(this); 463 worker_thread_ = WTF::MakeUnique<ServiceWorkerThread>(
475 worker_thread_ = 464 ThreadableLoadingContext::Create(*document), *worker_global_scope_proxy_);
476 ServiceWorkerThread::Create(loader_proxy_, *worker_global_scope_proxy_);
477 465
478 // We have a dummy document here for loading but it doesn't really represent 466 // We have a dummy document here for loading but it doesn't really represent
479 // the document/frame of associated document(s) for this worker. Here we 467 // the document/frame of associated document(s) for this worker. Here we
480 // populate the task runners with null document not to confuse the frame 468 // populate the task runners with null document not to confuse the frame
481 // scheduler (which will end up using the thread's default task runner). 469 // scheduler (which will end up using the thread's default task runner).
482 worker_thread_->Start(std::move(startup_data), 470 worker_thread_->Start(std::move(startup_data),
483 ParentFrameTaskRunners::Create(nullptr)); 471 ParentFrameTaskRunners::Create(nullptr));
484 472
485 worker_inspector_proxy_->WorkerThreadCreated(document, worker_thread_.get(), 473 worker_inspector_proxy_->WorkerThreadCreated(document, worker_thread_.get(),
486 script_url); 474 script_url);
487 } 475 }
488 476
489 } // namespace blink 477 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.h ('k') | third_party/WebKit/Source/web/WebSharedWorkerImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698