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

Filesystem: Supply LocalFileSystem to WorkerGlobalScope, not WorkerClients

Before this CL, LocalFileSystem was supplied to WorkerClients on the
main thread, and then it was passed to a worker thread.

After this CL, LocalFileSystem is supplied to WorkerGlobalScope on the worker
thread. This reduces the usage of WorkerClients, and slightly simplifies
worker startup sequence.

Bug: 1009854
Change-Id: If02556fd161fd90f3f84d3d02f253f1e842dc3e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1833014Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702290}
parent d14d8545
......@@ -56,7 +56,7 @@ class WebMediaPlayerClient;
class WebMediaPlayerSource;
class WebRemotePlaybackClient;
class WebViewClient;
class WorkerClients;
class WorkerGlobalScope;
class CORE_EXPORT CoreInitializer {
USING_FAST_MALLOC(CoreInitializer);
......@@ -83,7 +83,7 @@ class CORE_EXPORT CoreInitializer {
virtual void InitLocalFrame(LocalFrame&) const = 0;
// Supplements installed on a frame using ChromeClient
virtual void InstallSupplements(LocalFrame&) const = 0;
virtual void ProvideLocalFileSystemToWorker(WorkerClients&) const = 0;
virtual void ProvideLocalFileSystemToWorker(WorkerGlobalScope&) const = 0;
virtual MediaControls* CreateMediaControls(HTMLMediaElement&,
ShadowRoot&) const = 0;
virtual PictureInPictureController* CreatePictureInPictureController(
......
......@@ -46,7 +46,6 @@
#include "third_party/blink/public/platform/web_worker_fetch_context.h"
#include "third_party/blink/public/web/web_settings.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_cache_options.h"
#include "third_party/blink/renderer/core/core_initializer.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/events/message_event.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
......@@ -215,7 +214,8 @@ void WebSharedWorkerImpl::StartWorkerContext(
std::move(web_worker_fetch_context), Vector<CSPHeaderAndType>(),
outside_settings_object->GetReferrerPolicy(),
outside_settings_object->GetSecurityOrigin(), starter_secure_context,
outside_settings_object->GetHttpsState(), CreateWorkerClients(),
outside_settings_object->GetHttpsState(),
MakeGarbageCollected<WorkerClients>(),
std::make_unique<SharedWorkerContentSettingsProxy>(
mojo::PendingRemote<mojom::blink::WorkerContentSettingsProxy>(
std::move(content_settings_handle), 0u)),
......@@ -262,13 +262,6 @@ void WebSharedWorkerImpl::StartWorkerContext(
devtools_agent_host_receiver.PassPipe());
}
WorkerClients* WebSharedWorkerImpl::CreateWorkerClients() {
auto* worker_clients = MakeGarbageCollected<WorkerClients>();
CoreInitializer::GetInstance().ProvideLocalFileSystemToWorker(
*worker_clients);
return worker_clients;
}
void WebSharedWorkerImpl::TerminateWorkerContext() {
DCHECK(IsMainThread());
TerminateWorkerThread();
......
......@@ -96,8 +96,6 @@ class CORE_EXPORT WebSharedWorkerImpl final : public WebSharedWorker {
// Shuts down the worker thread. This may synchronously destroy |this|.
void TerminateWorkerThread();
WorkerClients* CreateWorkerClients();
void ConnectTaskOnWorkerThread(MessagePortChannel);
Persistent<SharedWorkerReportingProxy> reporting_proxy_;
......
......@@ -16,7 +16,6 @@
#include "third_party/blink/public/mojom/worker/dedicated_worker_host_factory.mojom-blink.h"
#include "third_party/blink/public/platform/web_content_settings_client.h"
#include "third_party/blink/renderer/bindings/core/v8/serialization/post_message_helper.h"
#include "third_party/blink/renderer/core/core_initializer.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/events/message_event.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
......@@ -362,13 +361,6 @@ void DedicatedWorker::DispatchErrorEventForScriptFetchFailure() {
DispatchEvent(*Event::CreateCancelable(event_type_names::kError));
}
WorkerClients* DedicatedWorker::CreateWorkerClients() {
auto* worker_clients = MakeGarbageCollected<WorkerClients>();
CoreInitializer::GetInstance().ProvideLocalFileSystemToWorker(
*worker_clients);
return worker_clients;
}
std::unique_ptr<WebContentSettingsClient>
DedicatedWorker::CreateWebContentSettingsClient() {
std::unique_ptr<WebContentSettingsClient> content_settings_client;
......@@ -466,8 +458,9 @@ DedicatedWorker::CreateGlobalScopeCreationParams(
GetExecutionContext()->GetContentSecurityPolicy()->Headers(),
referrer_policy, GetExecutionContext()->GetSecurityOrigin(),
GetExecutionContext()->IsSecureContext(),
GetExecutionContext()->GetHttpsState(), CreateWorkerClients(),
CreateWebContentSettingsClient(), response_address_space,
GetExecutionContext()->GetHttpsState(),
MakeGarbageCollected<WorkerClients>(), CreateWebContentSettingsClient(),
response_address_space,
OriginTrialContext::GetTokens(GetExecutionContext()).get(),
parent_devtools_token, std::move(settings), kV8CacheOptionsDefault,
nullptr /* worklet_module_responses_map */,
......
......@@ -32,7 +32,6 @@ class ExecutionContext;
class PostMessageOptions;
class ScriptState;
class WorkerClassicScriptLoader;
class WorkerClients;
// Implementation of the Worker interface defined in the WebWorker HTML spec:
// https://html.spec.whatwg.org/C/#worker
......@@ -112,7 +111,6 @@ class CORE_EXPORT DedicatedWorker final
network::mojom::ReferrerPolicy,
base::Optional<network::mojom::IPAddressSpace> response_address_space);
scoped_refptr<WebWorkerFetchContext> CreateWebWorkerFetchContext();
WorkerClients* CreateWorkerClients();
// May return nullptr.
std::unique_ptr<WebContentSettingsClient> CreateWebContentSettingsClient();
......
......@@ -37,6 +37,7 @@
#include "third_party/blink/renderer/bindings/core/v8/serialization/post_message_helper.h"
#include "third_party/blink/renderer/bindings/core/v8/serialization/serialized_script_value.h"
#include "third_party/blink/renderer/bindings/core/v8/worker_or_worklet_script_controller.h"
#include "third_party/blink/renderer/core/core_initializer.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.h"
#include "third_party/blink/renderer/core/inspector/worker_thread_debugger.h"
......@@ -109,6 +110,8 @@ DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(
MakeGarbageCollected<WorkerAnimationFrameProvider>(
this,
begin_frame_provider_params)) {
CoreInitializer::GetInstance().ProvideLocalFileSystemToWorker(*this);
// Dedicated workers don't need to pause after script fetch.
ReadyToRunWorkerScript();
// Inherit the outside's origin trial tokens.
......
......@@ -35,6 +35,7 @@
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/bindings/core/v8/source_location.h"
#include "third_party/blink/renderer/bindings/core/v8/worker_or_worklet_script_controller.h"
#include "third_party/blink/renderer/core/core_initializer.h"
#include "third_party/blink/renderer/core/events/message_event.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
......@@ -75,6 +76,8 @@ void SharedWorkerGlobalScope::Initialize(
const Vector<CSPHeaderAndType>& response_csp_headers,
const Vector<String>* response_origin_trial_tokens,
int64_t appcache_id) {
CoreInitializer::GetInstance().ProvideLocalFileSystemToWorker(*this);
// Step 12.3. "Set worker global scope's url to response's url."
InitializeURL(response_url);
......
......@@ -44,7 +44,6 @@
#include "third_party/blink/renderer/core/fileapi/file_error.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_client.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/modules/filesystem/dom_file_system.h"
#include "third_party/blink/renderer/modules/filesystem/file_system_callbacks.h"
#include "third_party/blink/renderer/modules/filesystem/file_system_dispatcher.h"
......@@ -180,12 +179,12 @@ void LocalFileSystem::ResolveURLInternal(
LocalFileSystem::LocalFileSystem(LocalFrame& frame)
: Supplement<LocalFrame>(frame) {}
LocalFileSystem::LocalFileSystem(WorkerClients& worker_clients)
: Supplement<WorkerClients>(worker_clients) {}
LocalFileSystem::LocalFileSystem(WorkerGlobalScope& worker_global_scope)
: Supplement<WorkerGlobalScope>(worker_global_scope) {}
void LocalFileSystem::Trace(blink::Visitor* visitor) {
Supplement<LocalFrame>::Trace(visitor);
Supplement<WorkerClients>::Trace(visitor);
Supplement<WorkerGlobalScope>::Trace(visitor);
}
const char LocalFileSystem::kSupplementName[] = "LocalFileSystem";
......@@ -198,10 +197,9 @@ LocalFileSystem* LocalFileSystem::From(ExecutionContext& context) {
return file_system;
}
WorkerClients* clients = To<WorkerGlobalScope>(context).Clients();
DCHECK(clients);
LocalFileSystem* file_system =
Supplement<WorkerClients>::From<LocalFileSystem>(clients);
Supplement<WorkerGlobalScope>::From<LocalFileSystem>(
To<WorkerGlobalScope>(context));
DCHECK(file_system);
return file_system;
}
......@@ -210,9 +208,10 @@ void ProvideLocalFileSystemTo(LocalFrame& frame) {
frame.ProvideSupplement(MakeGarbageCollected<LocalFileSystem>(frame));
}
void ProvideLocalFileSystemToWorker(WorkerClients& worker_clients) {
worker_clients.ProvideSupplement(
MakeGarbageCollected<LocalFileSystem>(worker_clients));
void ProvideLocalFileSystemToWorker(WorkerGlobalScope& worker_global_scope) {
Supplement<WorkerGlobalScope>::ProvideTo(
worker_global_scope,
MakeGarbageCollected<LocalFileSystem>(worker_global_scope));
}
} // namespace blink
......@@ -37,7 +37,7 @@
#include "base/macros.h"
#include "third_party/blink/public/mojom/filesystem/file_system.mojom-blink.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/workers/worker_clients.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/platform/bindings/name_client.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/supplementable.h"
......@@ -53,7 +53,7 @@ class ResolveURICallbacks;
class LocalFileSystem final : public GarbageCollected<LocalFileSystem>,
public Supplement<LocalFrame>,
public Supplement<WorkerClients>,
public Supplement<WorkerGlobalScope>,
public NameClient {
USING_GARBAGE_COLLECTED_MIXIN(LocalFileSystem);
......@@ -63,7 +63,7 @@ class LocalFileSystem final : public GarbageCollected<LocalFileSystem>,
static const char kSupplementName[];
explicit LocalFileSystem(LocalFrame&);
explicit LocalFileSystem(WorkerClients&);
explicit LocalFileSystem(WorkerGlobalScope&);
~LocalFileSystem();
void ResolveURL(ExecutionContext*,
......@@ -111,7 +111,7 @@ class LocalFileSystem final : public GarbageCollected<LocalFileSystem>,
};
void ProvideLocalFileSystemTo(LocalFrame&);
void ProvideLocalFileSystemToWorker(WorkerClients&);
void ProvideLocalFileSystemToWorker(WorkerGlobalScope&);
} // namespace blink
......
......@@ -28,7 +28,6 @@
#include "third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.h"
#include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/workers/worker_clients.h"
#include "third_party/blink/renderer/modules/accessibility/ax_object_cache_impl.h"
#include "third_party/blink/renderer/modules/accessibility/inspector_accessibility_agent.h"
#include "third_party/blink/renderer/modules/app_banner/app_banner_controller.h"
......@@ -199,8 +198,8 @@ void ModulesInitializer::InstallSupplements(LocalFrame& frame) const {
}
void ModulesInitializer::ProvideLocalFileSystemToWorker(
WorkerClients& worker_clients) const {
::blink::ProvideLocalFileSystemToWorker(worker_clients);
WorkerGlobalScope& worker_global_scope) const {
::blink::ProvideLocalFileSystemToWorker(worker_global_scope);
}
MediaControls* ModulesInitializer::CreateMediaControls(
......
......@@ -22,7 +22,7 @@ class MODULES_EXPORT ModulesInitializer : public CoreInitializer {
private:
void InstallSupplements(LocalFrame&) const override;
void ProvideLocalFileSystemToWorker(WorkerClients&) const override;
void ProvideLocalFileSystemToWorker(WorkerGlobalScope&) const override;
MediaControls* CreateMediaControls(HTMLMediaElement&,
ShadowRoot&) const override;
PictureInPictureController* CreatePictureInPictureController(
......
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