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

Side by Side Diff: third_party/WebKit/Source/web/WebSharedWorkerImpl.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
« no previous file with comments | « third_party/WebKit/Source/web/WebSharedWorkerImpl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "core/loader/ThreadableLoadingContext.h" 42 #include "core/loader/ThreadableLoadingContext.h"
43 #include "core/loader/WorkerFetchContext.h" 43 #include "core/loader/WorkerFetchContext.h"
44 #include "core/probe/CoreProbes.h" 44 #include "core/probe/CoreProbes.h"
45 #include "core/workers/ParentFrameTaskRunners.h" 45 #include "core/workers/ParentFrameTaskRunners.h"
46 #include "core/workers/SharedWorkerGlobalScope.h" 46 #include "core/workers/SharedWorkerGlobalScope.h"
47 #include "core/workers/SharedWorkerThread.h" 47 #include "core/workers/SharedWorkerThread.h"
48 #include "core/workers/WorkerClients.h" 48 #include "core/workers/WorkerClients.h"
49 #include "core/workers/WorkerContentSettingsClient.h" 49 #include "core/workers/WorkerContentSettingsClient.h"
50 #include "core/workers/WorkerGlobalScope.h" 50 #include "core/workers/WorkerGlobalScope.h"
51 #include "core/workers/WorkerInspectorProxy.h" 51 #include "core/workers/WorkerInspectorProxy.h"
52 #include "core/workers/WorkerLoaderProxy.h"
53 #include "core/workers/WorkerScriptLoader.h" 52 #include "core/workers/WorkerScriptLoader.h"
54 #include "core/workers/WorkerThreadStartupData.h" 53 #include "core/workers/WorkerThreadStartupData.h"
55 #include "platform/CrossThreadFunctional.h" 54 #include "platform/CrossThreadFunctional.h"
56 #include "platform/RuntimeEnabledFeatures.h" 55 #include "platform/RuntimeEnabledFeatures.h"
57 #include "platform/heap/Handle.h" 56 #include "platform/heap/Handle.h"
58 #include "platform/heap/Persistent.h" 57 #include "platform/heap/Persistent.h"
59 #include "platform/loader/fetch/ResourceResponse.h" 58 #include "platform/loader/fetch/ResourceResponse.h"
60 #include "platform/network/ContentSecurityPolicyParsers.h" 59 #include "platform/network/ContentSecurityPolicyParsers.h"
61 #include "platform/weborigin/KURL.h" 60 #include "platform/weborigin/KURL.h"
62 #include "platform/weborigin/SecurityOrigin.h" 61 #include "platform/weborigin/SecurityOrigin.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 94 }
96 95
97 WebSharedWorkerImpl::~WebSharedWorkerImpl() { 96 WebSharedWorkerImpl::~WebSharedWorkerImpl() {
98 DCHECK(IsMainThread()); 97 DCHECK(IsMainThread());
99 DCHECK(web_view_); 98 DCHECK(web_view_);
100 // Detach the client before closing the view to avoid getting called back. 99 // Detach the client before closing the view to avoid getting called back.
101 main_frame_->SetClient(0); 100 main_frame_->SetClient(0);
102 101
103 web_view_->Close(); 102 web_view_->Close();
104 main_frame_->Close(); 103 main_frame_->Close();
105 if (loader_proxy_)
106 loader_proxy_->DetachProvider(this);
107 } 104 }
108 105
109 void WebSharedWorkerImpl::TerminateWorkerThread() { 106 void WebSharedWorkerImpl::TerminateWorkerThread() {
110 DCHECK(IsMainThread()); 107 DCHECK(IsMainThread());
111 if (asked_to_terminate_) 108 if (asked_to_terminate_)
112 return; 109 return;
113 asked_to_terminate_ = true; 110 asked_to_terminate_ = true;
114 if (main_script_loader_) { 111 if (main_script_loader_) {
115 main_script_loader_->Cancel(); 112 main_script_loader_->Cancel();
116 main_script_loader_.Clear(); 113 main_script_loader_.Clear();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 TerminateWorkerThread(); 242 TerminateWorkerThread();
246 } 243 }
247 244
248 void WebSharedWorkerImpl::DidTerminateWorkerThread() { 245 void WebSharedWorkerImpl::DidTerminateWorkerThread() {
249 DCHECK(IsMainThread()); 246 DCHECK(IsMainThread());
250 client_->WorkerContextDestroyed(); 247 client_->WorkerContextDestroyed();
251 // The lifetime of this proxy is controlled by the worker context. 248 // The lifetime of this proxy is controlled by the worker context.
252 delete this; 249 delete this;
253 } 250 }
254 251
255 ThreadableLoadingContext* WebSharedWorkerImpl::GetThreadableLoadingContext() {
256 if (!loading_context_) {
257 loading_context_ =
258 ThreadableLoadingContext::Create(*ToDocument(loading_document_.Get()));
259 }
260 return loading_context_;
261 }
262
263 void WebSharedWorkerImpl::Connect( 252 void WebSharedWorkerImpl::Connect(
264 std::unique_ptr<WebMessagePortChannel> web_channel) { 253 std::unique_ptr<WebMessagePortChannel> web_channel) {
265 DCHECK(IsMainThread()); 254 DCHECK(IsMainThread());
266 // The HTML spec requires to queue a connect event using the DOM manipulation 255 // The HTML spec requires to queue a connect event using the DOM manipulation
267 // task source. 256 // task source.
268 // https://html.spec.whatwg.org/multipage/workers.html#shared-workers-and-the- sharedworker-interface 257 // https://html.spec.whatwg.org/multipage/workers.html#shared-workers-and-the- sharedworker-interface
269 TaskRunnerHelper::Get(TaskType::kDOMManipulation, GetWorkerThread()) 258 TaskRunnerHelper::Get(TaskType::kDOMManipulation, GetWorkerThread())
270 ->PostTask( 259 ->PostTask(
271 BLINK_FROM_HERE, 260 BLINK_FROM_HERE,
272 CrossThreadBind(&WebSharedWorkerImpl::ConnectTaskOnWorkerThread, 261 CrossThreadBind(&WebSharedWorkerImpl::ConnectTaskOnWorkerThread,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 366
378 // SharedWorker can sometimes run tasks that are initiated by/associated with 367 // SharedWorker can sometimes run tasks that are initiated by/associated with
379 // a document's frame but these documents can be from a different process. So 368 // a document's frame but these documents can be from a different process. So
380 // we intentionally populate the task runners with null document in order to 369 // we intentionally populate the task runners with null document in order to
381 // use the thread's default task runner. Note that |m_document| should not be 370 // use the thread's default task runner. Note that |m_document| should not be
382 // used as it's a dummy document for loading that doesn't represent the frame 371 // used as it's a dummy document for loading that doesn't represent the frame
383 // of any associated document. 372 // of any associated document.
384 ParentFrameTaskRunners* task_runners = 373 ParentFrameTaskRunners* task_runners =
385 ParentFrameTaskRunners::Create(nullptr); 374 ParentFrameTaskRunners::Create(nullptr);
386 375
387 loader_proxy_ = WorkerLoaderProxy::Create(this);
388 reporting_proxy_ = new WebSharedWorkerReportingProxyImpl(this, task_runners); 376 reporting_proxy_ = new WebSharedWorkerReportingProxyImpl(this, task_runners);
389 worker_thread_ = 377 worker_thread_ = WTF::MakeUnique<SharedWorkerThread>(
390 SharedWorkerThread::Create(name_, loader_proxy_, *reporting_proxy_); 378 name_,
379 ThreadableLoadingContext::Create(*ToDocument(loading_document_.Get())),
380 *reporting_proxy_);
391 probe::scriptImported(loading_document_, main_script_loader_->Identifier(), 381 probe::scriptImported(loading_document_, main_script_loader_->Identifier(),
392 main_script_loader_->SourceText()); 382 main_script_loader_->SourceText());
393 main_script_loader_.Clear(); 383 main_script_loader_.Clear();
394 384
395 GetWorkerThread()->Start(std::move(startup_data), task_runners); 385 GetWorkerThread()->Start(std::move(startup_data), task_runners);
396 worker_inspector_proxy_->WorkerThreadCreated(ToDocument(loading_document_), 386 worker_inspector_proxy_->WorkerThreadCreated(ToDocument(loading_document_),
397 GetWorkerThread(), url_); 387 GetWorkerThread(), url_);
398 client_->WorkerScriptLoaded(); 388 client_->WorkerScriptLoaded();
399 } 389 }
400 390
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 if (devtools_agent) 429 if (devtools_agent)
440 devtools_agent->DispatchOnInspectorBackend(session_id, call_id, method, 430 devtools_agent->DispatchOnInspectorBackend(session_id, call_id, method,
441 message); 431 message);
442 } 432 }
443 433
444 WebSharedWorker* WebSharedWorker::Create(WebSharedWorkerClient* client) { 434 WebSharedWorker* WebSharedWorker::Create(WebSharedWorkerClient* client) {
445 return new WebSharedWorkerImpl(client); 435 return new WebSharedWorkerImpl(client);
446 } 436 }
447 437
448 } // namespace blink 438 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebSharedWorkerImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698