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

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

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

Powered by Google App Engine
This is Rietveld 408576698