Index: third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp |
diff --git a/third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp b/third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp |
index 46ed512c8ce2add9d6392a19d1beeadca8ada0ed..6c3109ec6a821a2ac17b34bc6c06bc7399410a18 100644 |
--- a/third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp |
+++ b/third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp |
@@ -40,6 +40,7 @@ |
#include "core/loader/FrameLoader.h" |
#include "core/loader/ThreadableLoadingContext.h" |
#include "core/loader/WorkerFetchContext.h" |
+#include "core/loader/appcache/ApplicationCacheHost.h" |
#include "core/probe/CoreProbes.h" |
#include "core/workers/ParentFrameTaskRunners.h" |
#include "core/workers/SharedWorkerGlobalScope.h" |
@@ -50,6 +51,7 @@ |
#include "core/workers/WorkerInspectorProxy.h" |
#include "core/workers/WorkerLoaderProxy.h" |
#include "core/workers/WorkerScriptLoader.h" |
+#include "core/workers/WorkerShadowFetchContext.h" |
#include "core/workers/WorkerThreadStartupData.h" |
#include "platform/CrossThreadFunctional.h" |
#include "platform/RuntimeEnabledFeatures.h" |
@@ -96,12 +98,18 @@ WebSharedWorkerImpl::WebSharedWorkerImpl(WebSharedWorkerClient* client) |
WebSharedWorkerImpl::~WebSharedWorkerImpl() { |
DCHECK(IsMainThread()); |
- DCHECK(web_view_); |
- // Detach the client before closing the view to avoid getting called back. |
- main_frame_->SetClient(0); |
+ // DCHECK(web_view_); |
+ |
+ if (shadow_fetch_context_) { |
+ shadow_fetch_context_->Detach(); |
+ } else { |
+ // Detach the client before closing the view to avoid getting called back. |
+ main_frame_->SetClient(0); |
+ |
+ web_view_->Close(); |
+ main_frame_->Close(); |
+ } |
- web_view_->Close(); |
- main_frame_->Close(); |
if (loader_proxy_) |
loader_proxy_->DetachProvider(this); |
} |
@@ -120,7 +128,7 @@ void WebSharedWorkerImpl::TerminateWorkerThread() { |
} |
if (worker_thread_) |
worker_thread_->Terminate(); |
- worker_inspector_proxy_->WorkerThreadTerminated(); |
+ // worker_inspector_proxy_->WorkerThreadTerminated(); |
} |
void WebSharedWorkerImpl::InitializeLoader() { |
@@ -228,7 +236,7 @@ void WebSharedWorkerImpl::CountFeature(UseCounter::Feature feature) { |
void WebSharedWorkerImpl::PostMessageToPageInspector(const String& message) { |
DCHECK(IsMainThread()); |
- worker_inspector_proxy_->DispatchMessageFromWorker(message); |
+ // worker_inspector_proxy_->DispatchMessageFromWorker(message); |
} |
void WebSharedWorkerImpl::DidCloseWorkerGlobalScope() { |
@@ -289,7 +297,45 @@ void WebSharedWorkerImpl::StartWorkerContext( |
url_ = url; |
name_ = name; |
creation_address_space_ = creation_address_space; |
- InitializeLoader(); |
+ |
+ InitializeShadowFetchContext(); |
+ |
+ // InitializeLoader(); |
+} |
+ |
+void WebSharedWorkerImpl::InitializeShadowFetchContext() { |
+ DCHECK(IsMainThread()); |
+ /* |
+ SetDevToolsAgentClient(this); |
+ client_->WorkerReadyForInspection(); |
+ if (pause_worker_context_on_start_) { |
+ is_paused_on_start_ = true; |
+ return; |
+ } |
+ */ |
+ ApplicationCacheHost* app_cache_host = ApplicationCacheHost::Create(nullptr); |
+ app_cache_host->SetWebApplicationCacheHost( |
+ client_->CreateApplicationCacheHost(app_cache_host)); |
+ shadow_fetch_context_ = WorkerShadowFetchContext::Create( |
+ url_, Platform::Current()->UserAgent(), creation_address_space_, |
+ app_cache_host, client_->CreateServiceWorkerNetworkProvider(), |
+ Settings::Create(), ParentFrameTaskRunners::Create(nullptr)); |
+ |
+ loading_document_ = &shadow_fetch_context_->GetExecutionContext(); |
+ |
+ main_script_loader_ = WorkerScriptLoader::Create(); |
+ main_script_loader_->SetRequestContext( |
+ WebURLRequest::kRequestContextSharedWorker); |
+ CrossOriginRequestPolicy cross_origin_request_policy = |
+ (static_cast<KURL>(url_)).ProtocolIsData() ? kAllowCrossOriginRequests |
+ : kDenyCrossOriginRequests; |
+ main_script_loader_->LoadAsynchronously( |
+ *loading_document_, url_, cross_origin_request_policy, |
+ creation_address_space_, |
+ Bind(&WebSharedWorkerImpl::DidReceiveScriptLoaderResponse, |
+ WTF::Unretained(this)), |
+ Bind(&WebSharedWorkerImpl::OnScriptLoaderFinished, |
+ WTF::Unretained(this))); |
} |
void WebSharedWorkerImpl::DidReceiveScriptLoaderResponse() { |
@@ -315,15 +361,19 @@ void WebSharedWorkerImpl::OnScriptLoaderFinished() { |
return; |
} |
+ /* |
Document* document = main_frame_->GetFrame()->GetDocument(); |
// FIXME: this document's origin is pristine and without any extra privileges. |
// (crbug.com/254993) |
SecurityOrigin* starter_origin = document->GetSecurityOrigin(); |
+ */ |
+ SecurityOrigin* starter_origin = |
+ shadow_fetch_context_->GetSecurityContext().GetSecurityOrigin(); |
WorkerClients* worker_clients = WorkerClients::Create(); |
ProvideLocalFileSystemToWorker(worker_clients, |
LocalFileSystemClient::Create()); |
- WebSecurityOrigin web_security_origin(loading_document_->GetSecurityOrigin()); |
+ WebSecurityOrigin web_security_origin(starter_origin); |
ProvideContentSettingsClientToWorker( |
worker_clients, |
WTF::WrapUnique(client_->CreateWorkerContentSettingsClientProxy( |
@@ -346,10 +396,13 @@ void WebSharedWorkerImpl::OnScriptLoaderFinished() { |
ContentSecurityPolicy* content_security_policy = |
main_script_loader_->ReleaseContentSecurityPolicy(); |
+ /* |
WorkerThreadStartMode start_mode = |
- worker_inspector_proxy_->WorkerStartMode(document); |
+ worker_inspector_proxy_->WorkerStartMode(loading_document_); |
+ */ |
+ WorkerThreadStartMode start_mode = kDontPauseWorkerGlobalScopeOnStart; |
std::unique_ptr<WorkerSettings> worker_settings = |
- WTF::WrapUnique(new WorkerSettings(document->GetSettings())); |
+ WTF::WrapUnique(new WorkerSettings(shadow_fetch_context_->GetSettings())); |
WorkerV8Settings worker_v8_settings = WorkerV8Settings::Default(); |
worker_v8_settings.atomics_wait_mode_ = |
WorkerV8Settings::AtomicsWaitMode::kAllow; |
@@ -382,8 +435,10 @@ void WebSharedWorkerImpl::OnScriptLoaderFinished() { |
main_script_loader_.Clear(); |
GetWorkerThread()->Start(std::move(startup_data), task_runners); |
- worker_inspector_proxy_->WorkerThreadCreated(ToDocument(loading_document_), |
+ /* |
+ worker_inspector_proxy_->WorkerThreadCreated(loading_document_, |
GetWorkerThread(), url_); |
+ */ |
client_->WorkerScriptLoaded(); |
} |