Commit b305873b authored by Hiroki Nakagawa's avatar Hiroki Nakagawa Committed by Commit Bot

Worker: Rename WorkerScriptLoader to WorkerClassicScriptLoader

This CL renames WorkerScriptLoader to WorkerClassicScriptLoader for clarifying
the loader is used for classic scripts, not for module scripts.

Bug: 680046
Change-Id: I037de4772e8323e4176989427fa6c2529c7fdab0
Reviewed-on: https://chromium-review.googlesource.com/965662Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543651}
parent eec47a70
...@@ -52,7 +52,7 @@ class SharedWorkerWebApplicationCacheHostImpl ...@@ -52,7 +52,7 @@ class SharedWorkerWebApplicationCacheHostImpl
kAppCacheNoHostId) {} kAppCacheNoHostId) {}
// Main resource loading is different for workers. The main resource is // Main resource loading is different for workers. The main resource is
// loaded by the worker using WorkerScriptLoader. // loaded by the worker using WorkerClassicScriptLoader.
// These overrides are stubbed out. // These overrides are stubbed out.
void WillStartMainResourceRequest( void WillStartMainResourceRequest(
const blink::WebURL& url, const blink::WebURL& url,
......
...@@ -46,10 +46,10 @@ ...@@ -46,10 +46,10 @@
#include "core/workers/SharedWorkerContentSettingsProxy.h" #include "core/workers/SharedWorkerContentSettingsProxy.h"
#include "core/workers/SharedWorkerGlobalScope.h" #include "core/workers/SharedWorkerGlobalScope.h"
#include "core/workers/SharedWorkerThread.h" #include "core/workers/SharedWorkerThread.h"
#include "core/workers/WorkerClassicScriptLoader.h"
#include "core/workers/WorkerContentSettingsClient.h" #include "core/workers/WorkerContentSettingsClient.h"
#include "core/workers/WorkerGlobalScope.h" #include "core/workers/WorkerGlobalScope.h"
#include "core/workers/WorkerInspectorProxy.h" #include "core/workers/WorkerInspectorProxy.h"
#include "core/workers/WorkerScriptLoader.h"
#include "platform/CrossThreadFunctional.h" #include "platform/CrossThreadFunctional.h"
#include "platform/heap/Handle.h" #include "platform/heap/Handle.h"
#include "platform/heap/Persistent.h" #include "platform/heap/Persistent.h"
...@@ -118,7 +118,7 @@ void WebSharedWorkerImpl::OnShadowPageInitialized() { ...@@ -118,7 +118,7 @@ void WebSharedWorkerImpl::OnShadowPageInitialized() {
DCHECK(!main_script_loader_); DCHECK(!main_script_loader_);
shadow_page_->DocumentLoader()->SetServiceWorkerNetworkProvider( shadow_page_->DocumentLoader()->SetServiceWorkerNetworkProvider(
client_->CreateServiceWorkerNetworkProvider()); client_->CreateServiceWorkerNetworkProvider());
main_script_loader_ = WorkerScriptLoader::Create(); main_script_loader_ = WorkerClassicScriptLoader::Create();
network::mojom::FetchRequestMode fetch_request_mode = network::mojom::FetchRequestMode fetch_request_mode =
network::mojom::FetchRequestMode::kSameOrigin; network::mojom::FetchRequestMode::kSameOrigin;
......
...@@ -54,8 +54,8 @@ class WebServiceWorkerNetworkProvider; ...@@ -54,8 +54,8 @@ class WebServiceWorkerNetworkProvider;
class WebSharedWorkerClient; class WebSharedWorkerClient;
class WebString; class WebString;
class WebURL; class WebURL;
class WorkerClassicScriptLoader;
class WorkerInspectorProxy; class WorkerInspectorProxy;
class WorkerScriptLoader;
// This class is used by the worker process code to talk to the SharedWorker // This class is used by the worker process code to talk to the SharedWorker
// implementation. This is basically accessed on the main thread, but some // implementation. This is basically accessed on the main thread, but some
...@@ -131,7 +131,7 @@ class CORE_EXPORT WebSharedWorkerImpl final : public WebSharedWorker, ...@@ -131,7 +131,7 @@ class CORE_EXPORT WebSharedWorkerImpl final : public WebSharedWorker,
bool is_paused_on_start_ = false; bool is_paused_on_start_ = false;
// Kept around only while main script loading is ongoing. // Kept around only while main script loading is ongoing.
scoped_refptr<WorkerScriptLoader> main_script_loader_; scoped_refptr<WorkerClassicScriptLoader> main_script_loader_;
WebURL url_; WebURL url_;
WebString name_; WebString name_;
......
...@@ -52,6 +52,8 @@ blink_core_sources("workers") { ...@@ -52,6 +52,8 @@ blink_core_sources("workers") {
"WorkerBackingThread.cpp", "WorkerBackingThread.cpp",
"WorkerBackingThread.h", "WorkerBackingThread.h",
"WorkerBackingThreadStartupData.h", "WorkerBackingThreadStartupData.h",
"WorkerClassicScriptLoader.cpp",
"WorkerClassicScriptLoader.h",
"WorkerClients.cpp", "WorkerClients.cpp",
"WorkerClients.h", "WorkerClients.h",
"WorkerContentSettingsClient.cpp", "WorkerContentSettingsClient.cpp",
...@@ -73,8 +75,6 @@ blink_core_sources("workers") { ...@@ -73,8 +75,6 @@ blink_core_sources("workers") {
"WorkerOrWorkletModuleFetchCoordinatorProxy.cpp", "WorkerOrWorkletModuleFetchCoordinatorProxy.cpp",
"WorkerOrWorkletModuleFetchCoordinatorProxy.h", "WorkerOrWorkletModuleFetchCoordinatorProxy.h",
"WorkerReportingProxy.h", "WorkerReportingProxy.h",
"WorkerScriptLoader.cpp",
"WorkerScriptLoader.h",
"WorkerSettings.cpp", "WorkerSettings.cpp",
"WorkerSettings.h", "WorkerSettings.h",
"WorkerThread.cpp", "WorkerThread.cpp",
......
...@@ -17,10 +17,10 @@ ...@@ -17,10 +17,10 @@
#include "core/origin_trials/OriginTrialContext.h" #include "core/origin_trials/OriginTrialContext.h"
#include "core/probe/CoreProbes.h" #include "core/probe/CoreProbes.h"
#include "core/workers/DedicatedWorkerMessagingProxy.h" #include "core/workers/DedicatedWorkerMessagingProxy.h"
#include "core/workers/WorkerClassicScriptLoader.h"
#include "core/workers/WorkerClients.h" #include "core/workers/WorkerClients.h"
#include "core/workers/WorkerContentSettingsClient.h" #include "core/workers/WorkerContentSettingsClient.h"
#include "core/workers/WorkerOrWorkletModuleFetchCoordinator.h" #include "core/workers/WorkerOrWorkletModuleFetchCoordinator.h"
#include "core/workers/WorkerScriptLoader.h"
#include "platform/bindings/ScriptState.h" #include "platform/bindings/ScriptState.h"
#include "platform/weborigin/SecurityPolicy.h" #include "platform/weborigin/SecurityPolicy.h"
#include "public/platform/WebContentSettingsClient.h" #include "public/platform/WebContentSettingsClient.h"
...@@ -124,8 +124,8 @@ void DedicatedWorker::Start() { ...@@ -124,8 +124,8 @@ void DedicatedWorker::Start() {
fetch_request_mode = network::mojom::FetchRequestMode::kNoCORS; fetch_request_mode = network::mojom::FetchRequestMode::kNoCORS;
fetch_credentials_mode = network::mojom::FetchCredentialsMode::kInclude; fetch_credentials_mode = network::mojom::FetchCredentialsMode::kInclude;
} }
script_loader_ = WorkerScriptLoader::Create(); classic_script_loader_ = WorkerClassicScriptLoader::Create();
script_loader_->LoadAsynchronously( classic_script_loader_->LoadAsynchronously(
*GetExecutionContext(), script_url_, *GetExecutionContext(), script_url_,
WebURLRequest::kRequestContextWorker, fetch_request_mode, WebURLRequest::kRequestContextWorker, fetch_request_mode,
fetch_credentials_mode, fetch_credentials_mode,
...@@ -154,8 +154,8 @@ void DedicatedWorker::terminate() { ...@@ -154,8 +154,8 @@ void DedicatedWorker::terminate() {
void DedicatedWorker::ContextDestroyed(ExecutionContext*) { void DedicatedWorker::ContextDestroyed(ExecutionContext*) {
DCHECK(IsMainThread()); DCHECK(IsMainThread());
if (script_loader_) if (classic_script_loader_)
script_loader_->Cancel(); classic_script_loader_->Cancel();
terminate(); terminate();
} }
...@@ -163,7 +163,7 @@ bool DedicatedWorker::HasPendingActivity() const { ...@@ -163,7 +163,7 @@ bool DedicatedWorker::HasPendingActivity() const {
DCHECK(IsMainThread()); DCHECK(IsMainThread());
// The worker context does not exist while loading, so we must ensure that the // The worker context does not exist while loading, so we must ensure that the
// worker object is not collected, nor are its event listeners. // worker object is not collected, nor are its event listeners.
return context_proxy_->HasPendingActivity() || script_loader_; return context_proxy_->HasPendingActivity() || classic_script_loader_;
} }
WorkerClients* DedicatedWorker::CreateWorkerClients() { WorkerClients* DedicatedWorker::CreateWorkerClients() {
...@@ -185,32 +185,33 @@ WorkerClients* DedicatedWorker::CreateWorkerClients() { ...@@ -185,32 +185,33 @@ WorkerClients* DedicatedWorker::CreateWorkerClients() {
void DedicatedWorker::OnResponse() { void DedicatedWorker::OnResponse() {
DCHECK(IsMainThread()); DCHECK(IsMainThread());
probe::didReceiveScriptResponse(GetExecutionContext(), probe::didReceiveScriptResponse(GetExecutionContext(),
script_loader_->Identifier()); classic_script_loader_->Identifier());
} }
void DedicatedWorker::OnFinished(const v8_inspector::V8StackTraceId& stack_id) { void DedicatedWorker::OnFinished(const v8_inspector::V8StackTraceId& stack_id) {
DCHECK(IsMainThread()); DCHECK(IsMainThread());
if (script_loader_->Canceled()) { if (classic_script_loader_->Canceled()) {
// Do nothing. // Do nothing.
} else if (script_loader_->Failed()) { } else if (classic_script_loader_->Failed()) {
DispatchEvent(Event::CreateCancelable(EventTypeNames::error)); DispatchEvent(Event::CreateCancelable(EventTypeNames::error));
} else { } else {
ReferrerPolicy referrer_policy = kReferrerPolicyDefault; ReferrerPolicy referrer_policy = kReferrerPolicyDefault;
if (!script_loader_->GetReferrerPolicy().IsNull()) { if (!classic_script_loader_->GetReferrerPolicy().IsNull()) {
SecurityPolicy::ReferrerPolicyFromHeaderValue( SecurityPolicy::ReferrerPolicyFromHeaderValue(
script_loader_->GetReferrerPolicy(), classic_script_loader_->GetReferrerPolicy(),
kDoNotSupportReferrerPolicyLegacyKeywords, &referrer_policy); kDoNotSupportReferrerPolicyLegacyKeywords, &referrer_policy);
} }
std::unique_ptr<GlobalScopeCreationParams> creation_params = std::unique_ptr<GlobalScopeCreationParams> creation_params =
CreateGlobalScopeCreationParams(); CreateGlobalScopeCreationParams();
creation_params->referrer_policy = referrer_policy; creation_params->referrer_policy = referrer_policy;
context_proxy_->StartWorkerGlobalScope(std::move(creation_params), options_, context_proxy_->StartWorkerGlobalScope(
script_url_, stack_id, std::move(creation_params), options_, script_url_, stack_id,
script_loader_->SourceText()); classic_script_loader_->SourceText());
probe::scriptImported(GetExecutionContext(), script_loader_->Identifier(), probe::scriptImported(GetExecutionContext(),
script_loader_->SourceText()); classic_script_loader_->Identifier(),
classic_script_loader_->SourceText());
} }
script_loader_ = nullptr; classic_script_loader_ = nullptr;
} }
std::unique_ptr<GlobalScopeCreationParams> std::unique_ptr<GlobalScopeCreationParams>
......
...@@ -26,8 +26,8 @@ class DedicatedWorkerMessagingProxy; ...@@ -26,8 +26,8 @@ class DedicatedWorkerMessagingProxy;
class ExceptionState; class ExceptionState;
class ExecutionContext; class ExecutionContext;
class ScriptState; class ScriptState;
class WorkerClassicScriptLoader;
class WorkerClients; class WorkerClients;
class WorkerScriptLoader;
struct GlobalScopeCreationParams; struct GlobalScopeCreationParams;
// Implementation of the Worker interface defined in the WebWorker HTML spec: // Implementation of the Worker interface defined in the WebWorker HTML spec:
...@@ -81,8 +81,7 @@ class CORE_EXPORT DedicatedWorker final ...@@ -81,8 +81,7 @@ class CORE_EXPORT DedicatedWorker final
WorkerClients* CreateWorkerClients(); WorkerClients* CreateWorkerClients();
// [classic script only] // Callbacks for |classic_script_loader_|.
// Callbacks for |script_loader_|.
void OnResponse(); void OnResponse();
void OnFinished(const v8_inspector::V8StackTraceId&); void OnFinished(const v8_inspector::V8StackTraceId&);
...@@ -93,7 +92,7 @@ class CORE_EXPORT DedicatedWorker final ...@@ -93,7 +92,7 @@ class CORE_EXPORT DedicatedWorker final
const WorkerOptions options_; const WorkerOptions options_;
const Member<DedicatedWorkerMessagingProxy> context_proxy_; const Member<DedicatedWorkerMessagingProxy> context_proxy_;
scoped_refptr<WorkerScriptLoader> script_loader_; scoped_refptr<WorkerClassicScriptLoader> classic_script_loader_;
}; };
} // namespace blink } // namespace blink
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* *
*/ */
#include "core/workers/WorkerScriptLoader.h" #include "core/workers/WorkerClassicScriptLoader.h"
#include <memory> #include <memory>
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
...@@ -48,19 +48,19 @@ ...@@ -48,19 +48,19 @@
namespace blink { namespace blink {
WorkerScriptLoader::WorkerScriptLoader() WorkerClassicScriptLoader::WorkerClassicScriptLoader()
: response_address_space_(mojom::IPAddressSpace::kPublic) {} : response_address_space_(mojom::IPAddressSpace::kPublic) {}
WorkerScriptLoader::~WorkerScriptLoader() { WorkerClassicScriptLoader::~WorkerClassicScriptLoader() {
// If |m_threadableLoader| is still working, we have to cancel it here. // If |m_threadableLoader| is still working, we have to cancel it here.
// Otherwise WorkerScriptLoader::didFail() of the deleted |this| will be // Otherwise didFail() of the deleted |this| will be called from
// called from DocumentThreadableLoader::notifyFinished() when the frame // DocumentThreadableLoader::notifyFinished() when the frame will be
// will be destroyed. // destroyed.
if (need_to_cancel_) if (need_to_cancel_)
Cancel(); Cancel();
} }
void WorkerScriptLoader::LoadSynchronously( void WorkerClassicScriptLoader::LoadSynchronously(
ExecutionContext& execution_context, ExecutionContext& execution_context,
const KURL& url, const KURL& url,
WebURLRequest::RequestContext request_context, WebURLRequest::RequestContext request_context,
...@@ -87,7 +87,7 @@ void WorkerScriptLoader::LoadSynchronously( ...@@ -87,7 +87,7 @@ void WorkerScriptLoader::LoadSynchronously(
resource_loader_options); resource_loader_options);
} }
void WorkerScriptLoader::LoadAsynchronously( void WorkerClassicScriptLoader::LoadAsynchronously(
ExecutionContext& execution_context, ExecutionContext& execution_context,
const KURL& url, const KURL& url,
WebURLRequest::RequestContext request_context, WebURLRequest::RequestContext request_context,
...@@ -118,7 +118,7 @@ void WorkerScriptLoader::LoadAsynchronously( ...@@ -118,7 +118,7 @@ void WorkerScriptLoader::LoadAsynchronously(
// to this object, while some of the callchain assumes that the client and // to this object, while some of the callchain assumes that the client and
// loader wouldn't be deleted within callbacks. // loader wouldn't be deleted within callbacks.
// (E.g. see crbug.com/524694 for why we can't easily remove this protect) // (E.g. see crbug.com/524694 for why we can't easily remove this protect)
scoped_refptr<WorkerScriptLoader> protect(this); scoped_refptr<WorkerClassicScriptLoader> protect(this);
need_to_cancel_ = true; need_to_cancel_ = true;
threadable_loader_ = ThreadableLoader::Create( threadable_loader_ = ThreadableLoader::Create(
execution_context, this, options, resource_loader_options); execution_context, this, options, resource_loader_options);
...@@ -127,12 +127,12 @@ void WorkerScriptLoader::LoadAsynchronously( ...@@ -127,12 +127,12 @@ void WorkerScriptLoader::LoadAsynchronously(
NotifyFinished(); NotifyFinished();
} }
const KURL& WorkerScriptLoader::ResponseURL() const { const KURL& WorkerClassicScriptLoader::ResponseURL() const {
DCHECK(!Failed()); DCHECK(!Failed());
return response_url_; return response_url_;
} }
void WorkerScriptLoader::DidReceiveResponse( void WorkerClassicScriptLoader::DidReceiveResponse(
unsigned long identifier, unsigned long identifier,
const ResourceResponse& response, const ResourceResponse& response,
std::unique_ptr<WebDataConsumerHandle> handle) { std::unique_ptr<WebDataConsumerHandle> handle) {
...@@ -166,7 +166,7 @@ void WorkerScriptLoader::DidReceiveResponse( ...@@ -166,7 +166,7 @@ void WorkerScriptLoader::DidReceiveResponse(
std::move(response_callback_).Run(); std::move(response_callback_).Run();
} }
void WorkerScriptLoader::DidReceiveData(const char* data, unsigned len) { void WorkerClassicScriptLoader::DidReceiveData(const char* data, unsigned len) {
if (failed_) if (failed_)
return; return;
...@@ -183,12 +183,14 @@ void WorkerScriptLoader::DidReceiveData(const char* data, unsigned len) { ...@@ -183,12 +183,14 @@ void WorkerScriptLoader::DidReceiveData(const char* data, unsigned len) {
source_text_.Append(decoder_->Decode(data, len)); source_text_.Append(decoder_->Decode(data, len));
} }
void WorkerScriptLoader::DidReceiveCachedMetadata(const char* data, int size) { void WorkerClassicScriptLoader::DidReceiveCachedMetadata(const char* data,
int size) {
cached_metadata_ = std::make_unique<Vector<char>>(size); cached_metadata_ = std::make_unique<Vector<char>>(size);
memcpy(cached_metadata_->data(), data, size); memcpy(cached_metadata_->data(), data, size);
} }
void WorkerScriptLoader::DidFinishLoading(unsigned long identifier, double) { void WorkerClassicScriptLoader::DidFinishLoading(unsigned long identifier,
double) {
need_to_cancel_ = false; need_to_cancel_ = false;
if (!failed_ && decoder_) if (!failed_ && decoder_)
source_text_.Append(decoder_->Flush()); source_text_.Append(decoder_->Flush());
...@@ -196,29 +198,29 @@ void WorkerScriptLoader::DidFinishLoading(unsigned long identifier, double) { ...@@ -196,29 +198,29 @@ void WorkerScriptLoader::DidFinishLoading(unsigned long identifier, double) {
NotifyFinished(); NotifyFinished();
} }
void WorkerScriptLoader::DidFail(const ResourceError& error) { void WorkerClassicScriptLoader::DidFail(const ResourceError& error) {
need_to_cancel_ = false; need_to_cancel_ = false;
canceled_ = error.IsCancellation(); canceled_ = error.IsCancellation();
NotifyError(); NotifyError();
} }
void WorkerScriptLoader::DidFailRedirectCheck() { void WorkerClassicScriptLoader::DidFailRedirectCheck() {
// When didFailRedirectCheck() is called, the ResourceLoader for the script // When didFailRedirectCheck() is called, the ResourceLoader for the script
// is not canceled yet. So we don't reset |m_needToCancel| here. // is not canceled yet. So we don't reset |m_needToCancel| here.
NotifyError(); NotifyError();
} }
void WorkerScriptLoader::Cancel() { void WorkerClassicScriptLoader::Cancel() {
need_to_cancel_ = false; need_to_cancel_ = false;
if (threadable_loader_) if (threadable_loader_)
threadable_loader_->Cancel(); threadable_loader_->Cancel();
} }
String WorkerScriptLoader::SourceText() { String WorkerClassicScriptLoader::SourceText() {
return source_text_.ToString(); return source_text_.ToString();
} }
void WorkerScriptLoader::NotifyError() { void WorkerClassicScriptLoader::NotifyError() {
failed_ = true; failed_ = true;
// notifyError() could be called before ThreadableLoader::create() returns // notifyError() could be called before ThreadableLoader::create() returns
// e.g. from didFail(), and in that case m_threadableLoader is not yet set // e.g. from didFail(), and in that case m_threadableLoader is not yet set
...@@ -230,14 +232,14 @@ void WorkerScriptLoader::NotifyError() { ...@@ -230,14 +232,14 @@ void WorkerScriptLoader::NotifyError() {
NotifyFinished(); NotifyFinished();
} }
void WorkerScriptLoader::NotifyFinished() { void WorkerClassicScriptLoader::NotifyFinished() {
if (!finished_callback_) if (!finished_callback_)
return; return;
std::move(finished_callback_).Run(); std::move(finished_callback_).Run();
} }
void WorkerScriptLoader::ProcessContentSecurityPolicy( void WorkerClassicScriptLoader::ProcessContentSecurityPolicy(
const ResourceResponse& response) { const ResourceResponse& response) {
// Per http://www.w3.org/TR/CSP2/#processing-model-workers, if the Worker's // Per http://www.w3.org/TR/CSP2/#processing-model-workers, if the Worker's
// URL is not a GUID, then it grabs its CSP from the response headers // URL is not a GUID, then it grabs its CSP from the response headers
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
* *
*/ */
#ifndef WorkerScriptLoader_h #ifndef WorkerClassicScriptLoader_h
#define WorkerScriptLoader_h #define WorkerClassicScriptLoader_h
#include <memory> #include <memory>
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
...@@ -51,14 +51,14 @@ class ResourceResponse; ...@@ -51,14 +51,14 @@ class ResourceResponse;
class ExecutionContext; class ExecutionContext;
class TextResourceDecoder; class TextResourceDecoder;
class CORE_EXPORT WorkerScriptLoader final class CORE_EXPORT WorkerClassicScriptLoader final
: public RefCounted<WorkerScriptLoader>, : public RefCounted<WorkerClassicScriptLoader>,
public ThreadableLoaderClient { public ThreadableLoaderClient {
USING_FAST_MALLOC(WorkerScriptLoader); USING_FAST_MALLOC(WorkerClassicScriptLoader);
public: public:
static scoped_refptr<WorkerScriptLoader> Create() { static scoped_refptr<WorkerClassicScriptLoader> Create() {
return base::AdoptRef(new WorkerScriptLoader()); return base::AdoptRef(new WorkerClassicScriptLoader());
} }
void LoadSynchronously(ExecutionContext&, void LoadSynchronously(ExecutionContext&,
...@@ -121,10 +121,10 @@ class CORE_EXPORT WorkerScriptLoader final ...@@ -121,10 +121,10 @@ class CORE_EXPORT WorkerScriptLoader final
void DidFailRedirectCheck() override; void DidFailRedirectCheck() override;
private: private:
friend class WTF::RefCounted<WorkerScriptLoader>; friend class WTF::RefCounted<WorkerClassicScriptLoader>;
WorkerScriptLoader(); WorkerClassicScriptLoader();
~WorkerScriptLoader() override; ~WorkerClassicScriptLoader() override;
void NotifyError(); void NotifyError();
void NotifyFinished(); void NotifyFinished();
...@@ -159,4 +159,4 @@ class CORE_EXPORT WorkerScriptLoader final ...@@ -159,4 +159,4 @@ class CORE_EXPORT WorkerScriptLoader final
} // namespace blink } // namespace blink
#endif // WorkerScriptLoader_h #endif // WorkerClassicScriptLoader_h
...@@ -50,11 +50,11 @@ ...@@ -50,11 +50,11 @@
#include "core/script/Modulator.h" #include "core/script/Modulator.h"
#include "core/workers/GlobalScopeCreationParams.h" #include "core/workers/GlobalScopeCreationParams.h"
#include "core/workers/InstalledScriptsManager.h" #include "core/workers/InstalledScriptsManager.h"
#include "core/workers/WorkerClassicScriptLoader.h"
#include "core/workers/WorkerLocation.h" #include "core/workers/WorkerLocation.h"
#include "core/workers/WorkerModuleTreeClient.h" #include "core/workers/WorkerModuleTreeClient.h"
#include "core/workers/WorkerNavigator.h" #include "core/workers/WorkerNavigator.h"
#include "core/workers/WorkerReportingProxy.h" #include "core/workers/WorkerReportingProxy.h"
#include "core/workers/WorkerScriptLoader.h"
#include "core/workers/WorkerThread.h" #include "core/workers/WorkerThread.h"
#include "platform/CrossThreadFunctional.h" #include "platform/CrossThreadFunctional.h"
#include "platform/InstanceCounters.h" #include "platform/InstanceCounters.h"
...@@ -167,7 +167,7 @@ void WorkerGlobalScope::importScripts(const Vector<String>& urls, ...@@ -167,7 +167,7 @@ void WorkerGlobalScope::importScripts(const Vector<String>& urls,
// If the script wasn't provided by the InstalledScriptsManager, load from // If the script wasn't provided by the InstalledScriptsManager, load from
// ResourceLoader. // ResourceLoader.
if (result == LoadResult::kNotHandled) { if (result == LoadResult::kNotHandled) {
result = LoadingScriptFromWorkerScriptLoader( result = LoadingScriptFromClassicScriptLoader(
complete_url, &response_url, &source_code, &cached_meta_data); complete_url, &response_url, &source_code, &cached_meta_data);
} }
...@@ -227,27 +227,28 @@ WorkerGlobalScope::LoadingScriptFromInstalledScriptsManager( ...@@ -227,27 +227,28 @@ WorkerGlobalScope::LoadingScriptFromInstalledScriptsManager(
} }
WorkerGlobalScope::LoadResult WorkerGlobalScope::LoadResult
WorkerGlobalScope::LoadingScriptFromWorkerScriptLoader( WorkerGlobalScope::LoadingScriptFromClassicScriptLoader(
const KURL& script_url, const KURL& script_url,
KURL* out_response_url, KURL* out_response_url,
String* out_source_code, String* out_source_code,
std::unique_ptr<Vector<char>>* out_cached_meta_data) { std::unique_ptr<Vector<char>>* out_cached_meta_data) {
ExecutionContext* execution_context = GetExecutionContext(); ExecutionContext* execution_context = GetExecutionContext();
scoped_refptr<WorkerScriptLoader> script_loader(WorkerScriptLoader::Create()); scoped_refptr<WorkerClassicScriptLoader> classic_script_loader(
script_loader->LoadSynchronously( WorkerClassicScriptLoader::Create());
classic_script_loader->LoadSynchronously(
*execution_context, script_url, WebURLRequest::kRequestContextScript, *execution_context, script_url, WebURLRequest::kRequestContextScript,
execution_context->GetSecurityContext().AddressSpace()); execution_context->GetSecurityContext().AddressSpace());
// If the fetching attempt failed, throw a NetworkError exception and // If the fetching attempt failed, throw a NetworkError exception and
// abort all these steps. // abort all these steps.
if (script_loader->Failed()) if (classic_script_loader->Failed())
return LoadResult::kFailed; return LoadResult::kFailed;
*out_response_url = script_loader->ResponseURL(); *out_response_url = classic_script_loader->ResponseURL();
*out_source_code = script_loader->SourceText(); *out_source_code = classic_script_loader->SourceText();
*out_cached_meta_data = script_loader->ReleaseCachedMetadata(); *out_cached_meta_data = classic_script_loader->ReleaseCachedMetadata();
probe::scriptImported(execution_context, script_loader->Identifier(), probe::scriptImported(execution_context, classic_script_loader->Identifier(),
script_loader->SourceText()); classic_script_loader->SourceText());
return LoadResult::kSuccess; return LoadResult::kSuccess;
} }
......
...@@ -176,10 +176,10 @@ class CORE_EXPORT WorkerGlobalScope ...@@ -176,10 +176,10 @@ class CORE_EXPORT WorkerGlobalScope
KURL* out_response_url, KURL* out_response_url,
String* out_source_code, String* out_source_code,
std::unique_ptr<Vector<char>>* out_cached_meta_data); std::unique_ptr<Vector<char>>* out_cached_meta_data);
// Tries to load the script synchronously from the WorkerScriptLoader, which // Tries to load the script synchronously from the WorkerClassicScriptLoader,
// requests the script from the browser. This // which requests the script from the browser. This blocks until the script is
// blocks until the script is received. // received.
LoadResult LoadingScriptFromWorkerScriptLoader( LoadResult LoadingScriptFromClassicScriptLoader(
const KURL& script_url, const KURL& script_url,
KURL* out_response_url, KURL* out_response_url,
String* out_source_code, String* out_source_code,
......
...@@ -41,10 +41,10 @@ ...@@ -41,10 +41,10 @@
#include "core/probe/CoreProbes.h" #include "core/probe/CoreProbes.h"
#include "core/workers/ParentFrameTaskRunners.h" #include "core/workers/ParentFrameTaskRunners.h"
#include "core/workers/WorkerBackingThreadStartupData.h" #include "core/workers/WorkerBackingThreadStartupData.h"
#include "core/workers/WorkerClassicScriptLoader.h"
#include "core/workers/WorkerContentSettingsClient.h" #include "core/workers/WorkerContentSettingsClient.h"
#include "core/workers/WorkerGlobalScope.h" #include "core/workers/WorkerGlobalScope.h"
#include "core/workers/WorkerInspectorProxy.h" #include "core/workers/WorkerInspectorProxy.h"
#include "core/workers/WorkerScriptLoader.h"
#include "modules/indexeddb/IndexedDBClient.h" #include "modules/indexeddb/IndexedDBClient.h"
#include "modules/serviceworkers/ServiceWorkerContainerClient.h" #include "modules/serviceworkers/ServiceWorkerContainerClient.h"
#include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
...@@ -267,7 +267,7 @@ void WebEmbeddedWorkerImpl::OnShadowPageInitialized() { ...@@ -267,7 +267,7 @@ void WebEmbeddedWorkerImpl::OnShadowPageInitialized() {
} }
DCHECK(!main_script_loader_); DCHECK(!main_script_loader_);
main_script_loader_ = WorkerScriptLoader::Create(); main_script_loader_ = WorkerClassicScriptLoader::Create();
main_script_loader_->LoadAsynchronously( main_script_loader_->LoadAsynchronously(
*shadow_page_->GetDocument(), worker_start_data_.script_url, *shadow_page_->GetDocument(), worker_start_data_.script_url,
WebURLRequest::kRequestContextServiceWorker, WebURLRequest::kRequestContextServiceWorker,
......
...@@ -47,8 +47,8 @@ namespace blink { ...@@ -47,8 +47,8 @@ namespace blink {
class ContentSecurityPolicy; class ContentSecurityPolicy;
class ServiceWorkerInstalledScriptsManager; class ServiceWorkerInstalledScriptsManager;
class WorkerClassicScriptLoader;
class WorkerInspectorProxy; class WorkerInspectorProxy;
class WorkerScriptLoader;
class WorkerThread; class WorkerThread;
class MODULES_EXPORT WebEmbeddedWorkerImpl final class MODULES_EXPORT WebEmbeddedWorkerImpl final
...@@ -105,7 +105,7 @@ class MODULES_EXPORT WebEmbeddedWorkerImpl final ...@@ -105,7 +105,7 @@ class MODULES_EXPORT WebEmbeddedWorkerImpl final
std::unique_ptr<ServiceWorkerContentSettingsProxy> content_settings_client_; std::unique_ptr<ServiceWorkerContentSettingsProxy> content_settings_client_;
// Kept around only while main script loading is ongoing. // Kept around only while main script loading is ongoing.
scoped_refptr<WorkerScriptLoader> main_script_loader_; scoped_refptr<WorkerClassicScriptLoader> main_script_loader_;
std::unique_ptr<WorkerThread> worker_thread_; std::unique_ptr<WorkerThread> worker_thread_;
Persistent<WorkerInspectorProxy> worker_inspector_proxy_; Persistent<WorkerInspectorProxy> worker_inspector_proxy_;
......
...@@ -38,7 +38,7 @@ ServiceWorkerInstalledScriptsManager::GetScriptData( ...@@ -38,7 +38,7 @@ ServiceWorkerInstalledScriptsManager::GetScriptData(
return ScriptStatus::kFailed; return ScriptStatus::kFailed;
} }
// This is from WorkerScriptLoader::DidReceiveData. // This is from WorkerClassicScriptLoader::DidReceiveData.
std::unique_ptr<TextResourceDecoder> decoder = std::unique_ptr<TextResourceDecoder> decoder =
TextResourceDecoder::Create(TextResourceDecoderOptions( TextResourceDecoder::Create(TextResourceDecoderOptions(
TextResourceDecoderOptions::kPlainTextContent, TextResourceDecoderOptions::kPlainTextContent,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment