Commit 97725cce authored by Hiroki Nakagawa's avatar Hiroki Nakagawa Committed by Commit Bot

Revert "Worker: Implement WorkerGlobalScope::ImportModuleScript()"

This reverts commit 715a1c5f.

Reason for revert:
This causes compile failures on some bots.

Original change's description:
> Worker: Implement WorkerGlobalScope::ImportModuleScript()
> 
> This CL implements WorkerGlobalScope::ImportModuleScript() that imports module
> scripts using WorkerModulatorImpl, and wires up DedicatedWorkerMessagingProxy
> via WorkerThread.
> 
> Note that module workers are still not available because WorkerOptions is not
> exposed on the ctor of Worker and WorkerModulatorImpl is not fully implemented
> yet.
> 
> Design doc: https://docs.google.com/a/chromium.org/document/d/1IMGWAK7Wq37mLehwkbysNRBBnhQBo3z2MbYyMkViEnY/edit?usp=sharing
> 
> Bug: 680046
> Change-Id: I0c616b7a1b79abb02c1085be356293510dd4c04b
> Reviewed-on: https://chromium-review.googlesource.com/807675
> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
> Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
> Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#525270}

TBR=kinuko@chromium.org,kouhei@chromium.org,nhiroki@chromium.org

Change-Id: I253df9d13bbb8bc63cae7bb018fd10c4ee311d25
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 680046
Reviewed-on: https://chromium-review.googlesource.com/836187Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#525273}
parent 3877cff0
......@@ -63,8 +63,6 @@ blink_core_sources("workers") {
"WorkerInspectorProxy.cpp",
"WorkerInspectorProxy.h",
"WorkerLocation.h",
"WorkerModuleTreeClient.cpp",
"WorkerModuleTreeClient.h",
"WorkerNavigator.cpp",
"WorkerNavigator.h",
"WorkerOrWorkletGlobalScope.cpp",
......
......@@ -24,24 +24,6 @@
namespace blink {
namespace {
// TODO(nhiroki): Merge this into ParseCredentialsOption() in Worklet.cpp, or
// move this into core/fetch (see https://crbug.com/794837).
network::mojom::FetchCredentialsMode ParseCredentialsOption(
const String& credentials_option) {
if (credentials_option == "omit")
return network::mojom::FetchCredentialsMode::kOmit;
if (credentials_option == "same-origin")
return network::mojom::FetchCredentialsMode::kSameOrigin;
if (credentials_option == "include")
return network::mojom::FetchCredentialsMode::kInclude;
NOTREACHED();
return network::mojom::FetchCredentialsMode::kOmit;
}
} // namespace
struct DedicatedWorkerMessagingProxy::QueuedTask {
scoped_refptr<SerializedScriptValue> message;
Vector<MessagePortChannel> channels;
......@@ -80,15 +62,10 @@ void DedicatedWorkerMessagingProxy::StartWorkerGlobalScope(
std::move(creation_params),
CreateBackingThreadStartupData(ToIsolate(GetExecutionContext())));
if (options.type() == "classic") {
GetWorkerThread()->EvaluateClassicScript(
script_url, source_code, nullptr /* cached_meta_data */, stack_id);
} else if (options.type() == "module") {
GetWorkerThread()->ImportModuleScript(
script_url, ParseCredentialsOption(options.credentials()));
} else {
NOTREACHED();
}
// TODO(nhiroki): Support module scripts (https://crbug.com/680046).
DCHECK_EQ("classic", options.type());
GetWorkerThread()->EvaluateClassicScript(
script_url, source_code, nullptr /* cached_meta_data */, stack_id);
// Post all queued tasks to the worker.
for (auto& queued_task : queued_early_tasks_) {
......
......@@ -36,7 +36,6 @@
#include "core/css/OffscreenFontSelector.h"
#include "core/dom/ContextLifecycleNotifier.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/Modulator.h"
#include "core/dom/PausableObject.h"
#include "core/dom/events/Event.h"
#include "core/events/ErrorEvent.h"
......@@ -51,7 +50,6 @@
#include "core/workers/GlobalScopeCreationParams.h"
#include "core/workers/InstalledScriptsManager.h"
#include "core/workers/WorkerLocation.h"
#include "core/workers/WorkerModuleTreeClient.h"
#include "core/workers/WorkerNavigator.h"
#include "core/workers/WorkerReportingProxy.h"
#include "core/workers/WorkerScriptLoader.h"
......@@ -313,14 +311,6 @@ ExecutionContext* WorkerGlobalScope::GetExecutionContext() const {
return const_cast<WorkerGlobalScope*>(this);
}
void WorkerGlobalScope::ImportModuleScript(
const KURL& module_url_record,
network::mojom::FetchCredentialsMode credentials_mode) {
Modulator* modulator = Modulator::From(ScriptController()->GetScriptState());
FetchModuleScript(module_url_record, credentials_mode,
new WorkerModuleTreeClient(modulator));
}
WorkerGlobalScope::WorkerGlobalScope(
std::unique_ptr<GlobalScopeCreationParams> creation_params,
WorkerThread* thread,
......
......@@ -40,7 +40,6 @@
#include "platform/heap/Handle.h"
#include "platform/loader/fetch/CachedMetadataHandler.h"
#include "platform/wtf/ListHashSet.h"
#include "services/network/public/interfaces/fetch_api.mojom-shared.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "services/service_manager/public/interfaces/interface_provider.mojom-blink.h"
......@@ -127,9 +126,6 @@ class CORE_EXPORT WorkerGlobalScope
// EventTarget
ExecutionContext* GetExecutionContext() const final;
void ImportModuleScript(const KURL& module_url_record,
network::mojom::FetchCredentialsMode);
double TimeOrigin() const { return time_origin_; }
WorkerSettings* GetWorkerSettings() const { return worker_settings_.get(); }
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "core/workers/WorkerModuleTreeClient.h"
#include "core/dom/ExecutionContext.h"
#include "core/dom/ModuleScript.h"
#include "core/workers/WorkerGlobalScope.h"
#include "core/workers/WorkerReportingProxy.h"
namespace blink {
WorkerModuleTreeClient::WorkerModuleTreeClient(Modulator* modulator)
: modulator_(modulator) {}
// A partial implementation of the "Processing model" algorithm in the HTML
// WebWorker spec:
// https://html.spec.whatwg.org/multipage/workers.html#worker-processing-model
void WorkerModuleTreeClient::NotifyModuleTreeLoadFinished(
ModuleScript* module_script) {
if (!module_script) {
// Step 11: ... "If the algorithm asynchronously completes with null, queue
// a task to fire an event named error at worker, and abort these steps."
// ...
// TODO(nhiroki): Throw an ErrorEvent at the Worker object on the owner
// Document.
return;
}
// Step 11: ... "Otherwise, continue the rest of these steps after the
// algorithm's asynchronous completion, with script being the asynchronous
// completion value." ...
// TODO(nhiroki): Call WorkerReportingProxy::WillEvaluateWorkerScript() or
// something like that (e.g., WillEvaluateModuleScript()).
modulator_->ExecuteModule(module_script,
Modulator::CaptureEvalErrorFlag::kReport);
WorkerGlobalScope* global_scope =
ToWorkerGlobalScope(ExecutionContext::From(modulator_->GetScriptState()));
global_scope->ReportingProxy().DidEvaluateModuleScript(
!module_script->IsErrored());
}
void WorkerModuleTreeClient::Trace(blink::Visitor* visitor) {
visitor->Trace(modulator_);
ModuleTreeClient::Trace(visitor);
}
} // namespace blink
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WorkerModuleTreeClient_h
#define WorkerModuleTreeClient_h
#include "core/dom/Modulator.h"
#include "platform/heap/GarbageCollected.h"
namespace blink {
class ModuleScript;
// A ModuleTreeClient that lives on the worker context's thread.
class WorkerModuleTreeClient final : public ModuleTreeClient {
public:
explicit WorkerModuleTreeClient(Modulator*);
// Implements ModuleTreeClient.
void NotifyModuleTreeLoadFinished(ModuleScript*) final;
void Trace(blink::Visitor*) override;
private:
Member<Modulator> modulator_;
};
} // namespace blink
#endif // WorkerModuleTreeClient_h
......@@ -127,7 +127,6 @@ void WorkerThread::EvaluateClassicScript(
const String& source_code,
std::unique_ptr<Vector<char>> cached_meta_data,
const v8_inspector::V8StackTraceId& stack_id) {
DCHECK(IsMainThread());
GetTaskRunner(TaskType::kUnthrottled)
->PostTask(
FROM_HERE,
......@@ -136,17 +135,6 @@ void WorkerThread::EvaluateClassicScript(
WTF::Passed(std::move(cached_meta_data)), stack_id));
}
void WorkerThread::ImportModuleScript(
const KURL& script_url,
network::mojom::FetchCredentialsMode credentials_mode) {
DCHECK(IsMainThread());
GetTaskRunner(TaskType::kUnthrottled)
->PostTask(FROM_HERE, CrossThreadBind(
&WorkerThread::ImportModuleScriptOnWorkerThread,
CrossThreadUnretained(this), script_url,
credentials_mode));
}
void WorkerThread::Terminate() {
DCHECK(IsMainThread());
......@@ -466,16 +454,6 @@ void WorkerThread::EvaluateClassicScriptOnWorkerThread(
debugger->ExternalAsyncTaskFinished(stack_id);
}
void WorkerThread::ImportModuleScriptOnWorkerThread(
const KURL& script_url,
network::mojom::FetchCredentialsMode credentials_mode) {
// Worklets have a different code path to import module scripts.
// TODO(nhiroki): Consider excluding this code path from WorkerThread like
// Worklets.
ToWorkerGlobalScope(GlobalScope())
->ImportModuleScript(script_url, credentials_mode);
}
void WorkerThread::PrepareForShutdownOnWorkerThread() {
DCHECK(IsCurrentThread());
{
......
......@@ -45,7 +45,6 @@
#include "platform/wtf/Functional.h"
#include "platform/wtf/Optional.h"
#include "public/platform/WebThread.h"
#include "services/network/public/interfaces/fetch_api.mojom-shared.h"
#include "v8/include/v8.h"
namespace blink {
......@@ -106,10 +105,8 @@ class CORE_EXPORT WorkerThread : public WebThread::TaskObserver {
std::unique_ptr<Vector<char>> cached_meta_data,
const v8_inspector::V8StackTraceId& stack_id);
// Posts a task to import a top-level module script on the worker thread.
// Called on the main thread after start().
void ImportModuleScript(const KURL& script_url,
network::mojom::FetchCredentialsMode);
// TODO(nhiroki): Implement ImportModuleScript() for module workers.
// (https://crbug.com/680046)
// Closes the global scope and terminates the underlying thread. Called on the
// main thread.
......@@ -256,8 +253,6 @@ class CORE_EXPORT WorkerThread : public WebThread::TaskObserver {
String source_code,
std::unique_ptr<Vector<char>> cached_meta_data,
const v8_inspector::V8StackTraceId& stack_id);
void ImportModuleScriptOnWorkerThread(const KURL& script_url,
network::mojom::FetchCredentialsMode);
// These are called in this order during worker thread termination.
void PrepareForShutdownOnWorkerThread();
......
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