Commit 91d0f68d authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

Do not plumb Modulator through ModuleTreeLinkerRegistry

To remove indirect layers around Modulator.

Bug: 842553
Change-Id: Ib4d2d6a3e348723cb9a9bd980b616ea4517dab3b
Reviewed-on: https://chromium-review.googlesource.com/1080007Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567126}
parent 6b91daa8
......@@ -17,7 +17,7 @@
namespace blink {
ModuleTreeLinker* ModuleTreeLinker::Fetch(
void ModuleTreeLinker::Fetch(
const KURL& url,
const FetchClientSettingsObjectSnapshot& fetch_client_settings_object,
const KURL& base_url,
......@@ -28,11 +28,12 @@ ModuleTreeLinker* ModuleTreeLinker::Fetch(
ModuleTreeClient* client) {
ModuleTreeLinker* fetcher = new ModuleTreeLinker(
fetch_client_settings_object, destination, modulator, registry, client);
registry->AddFetcher(fetcher);
fetcher->FetchRoot(url, base_url, options);
return fetcher;
DCHECK(fetcher->IsFetching());
}
ModuleTreeLinker* ModuleTreeLinker::FetchDescendantsForInlineScript(
void ModuleTreeLinker::FetchDescendantsForInlineScript(
ModuleScript* module_script,
const FetchClientSettingsObjectSnapshot& fetch_client_settings_object,
WebURLRequest::RequestContext destination,
......@@ -42,8 +43,9 @@ ModuleTreeLinker* ModuleTreeLinker::FetchDescendantsForInlineScript(
DCHECK(module_script);
ModuleTreeLinker* fetcher = new ModuleTreeLinker(
fetch_client_settings_object, destination, modulator, registry, client);
registry->AddFetcher(fetcher);
fetcher->FetchRootInline(module_script);
return fetcher;
DCHECK(fetcher->IsFetching());
}
ModuleTreeLinker::ModuleTreeLinker(
......
......@@ -40,7 +40,7 @@ class CORE_EXPORT ModuleTreeLinker final : public SingleModuleClient {
//
// TODO(hiroshige): |base_url| is used only for Layered APIs and will be
// removed soon once an upcoming spec change lands.
static ModuleTreeLinker* Fetch(
static void Fetch(
const KURL&,
const FetchClientSettingsObjectSnapshot& fetch_client_settings_object,
const KURL& base_url,
......@@ -51,7 +51,7 @@ class CORE_EXPORT ModuleTreeLinker final : public SingleModuleClient {
ModuleTreeClient*);
// [FDaI] for an inline script.
static ModuleTreeLinker* FetchDescendantsForInlineScript(
static void FetchDescendantsForInlineScript(
ModuleScript*,
const FetchClientSettingsObjectSnapshot& fetch_client_settings_object,
WebURLRequest::RequestContext destination,
......
......@@ -15,34 +15,9 @@ void ModuleTreeLinkerRegistry::Trace(blink::Visitor* visitor) {
visitor->Trace(active_tree_linkers_);
}
ModuleTreeLinker* ModuleTreeLinkerRegistry::Fetch(
const KURL& url,
const FetchClientSettingsObjectSnapshot& fetch_client_settings_object,
const KURL& base_url,
WebURLRequest::RequestContext destination,
const ScriptFetchOptions& options,
Modulator* modulator,
ModuleTreeClient* client) {
ModuleTreeLinker* fetcher =
ModuleTreeLinker::Fetch(url, fetch_client_settings_object, base_url,
destination, options, modulator, this, client);
DCHECK(fetcher->IsFetching());
void ModuleTreeLinkerRegistry::AddFetcher(ModuleTreeLinker* fetcher) {
DCHECK(!active_tree_linkers_.Contains(fetcher));
active_tree_linkers_.insert(fetcher);
return fetcher;
}
ModuleTreeLinker* ModuleTreeLinkerRegistry::FetchDescendantsForInlineScript(
ModuleScript* module_script,
const FetchClientSettingsObjectSnapshot& fetch_client_settings_object,
WebURLRequest::RequestContext destination,
Modulator* modulator,
ModuleTreeClient* client) {
ModuleTreeLinker* fetcher = ModuleTreeLinker::FetchDescendantsForInlineScript(
module_script, fetch_client_settings_object, destination, modulator, this,
client);
DCHECK(fetcher->IsFetching());
active_tree_linkers_.insert(fetcher);
return fetcher;
}
void ModuleTreeLinkerRegistry::ReleaseFinishedFetcher(
......
......@@ -5,21 +5,13 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LOADER_MODULESCRIPT_MODULE_TREE_LINKER_REGISTRY_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LOADER_MODULESCRIPT_MODULE_TREE_LINKER_REGISTRY_H_
#include "third_party/blink/public/platform/web_url_request.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/bindings/trace_wrapper_member.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
namespace blink {
class FetchClientSettingsObjectSnapshot;
class KURL;
class Modulator;
class ModuleTreeClient;
class ModuleTreeLinker;
class ModuleScript;
class ScriptFetchOptions;
// ModuleTreeLinkerRegistry keeps active ModuleTreeLinkers alive.
class CORE_EXPORT ModuleTreeLinkerRegistry
......@@ -34,25 +26,11 @@ class CORE_EXPORT ModuleTreeLinkerRegistry
return "ModuleTreeLinkerRegistry";
}
ModuleTreeLinker* Fetch(
const KURL&,
const FetchClientSettingsObjectSnapshot& fetch_client_settings_object,
const KURL& base_url,
WebURLRequest::RequestContext destination,
const ScriptFetchOptions&,
Modulator*,
ModuleTreeClient*);
ModuleTreeLinker* FetchDescendantsForInlineScript(
ModuleScript*,
const FetchClientSettingsObjectSnapshot& fetch_client_settings_object,
WebURLRequest::RequestContext destination,
Modulator*,
ModuleTreeClient*);
private:
ModuleTreeLinkerRegistry() = default;
friend class ModuleTreeLinker;
void AddFetcher(ModuleTreeLinker*);
void ReleaseFinishedFetcher(ModuleTreeLinker*);
HeapHashSet<TraceWrapperMember<ModuleTreeLinker>> active_tree_linkers_;
......
......@@ -208,9 +208,10 @@ TEST_F(ModuleTreeLinkerTest, FetchTreeNoDeps) {
KURL url("http://example.com/root.js");
TestModuleTreeClient* client = new TestModuleTreeClient;
registry->Fetch(url, FetchClientSettingsObjectSnapshot(GetDocument()),
NullURL(), WebURLRequest::kRequestContextScript,
ScriptFetchOptions(), GetModulator(), client);
ModuleTreeLinker::Fetch(url, FetchClientSettingsObjectSnapshot(GetDocument()),
NullURL(), WebURLRequest::kRequestContextScript,
ScriptFetchOptions(), GetModulator(), registry,
client);
EXPECT_FALSE(client->WasNotifyFinished())
<< "ModuleTreeLinker should always finish asynchronously.";
......@@ -229,9 +230,10 @@ TEST_F(ModuleTreeLinkerTest, FetchTreeInstantiationFailure) {
KURL url("http://example.com/root.js");
TestModuleTreeClient* client = new TestModuleTreeClient;
registry->Fetch(url, FetchClientSettingsObjectSnapshot(GetDocument()),
NullURL(), WebURLRequest::kRequestContextScript,
ScriptFetchOptions(), GetModulator(), client);
ModuleTreeLinker::Fetch(url, FetchClientSettingsObjectSnapshot(GetDocument()),
NullURL(), WebURLRequest::kRequestContextScript,
ScriptFetchOptions(), GetModulator(), registry,
client);
EXPECT_FALSE(client->WasNotifyFinished())
<< "ModuleTreeLinker should always finish asynchronously.";
......@@ -254,9 +256,10 @@ TEST_F(ModuleTreeLinkerTest, FetchTreeWithSingleDependency) {
KURL url("http://example.com/root.js");
TestModuleTreeClient* client = new TestModuleTreeClient;
registry->Fetch(url, FetchClientSettingsObjectSnapshot(GetDocument()),
NullURL(), WebURLRequest::kRequestContextScript,
ScriptFetchOptions(), GetModulator(), client);
ModuleTreeLinker::Fetch(url, FetchClientSettingsObjectSnapshot(GetDocument()),
NullURL(), WebURLRequest::kRequestContextScript,
ScriptFetchOptions(), GetModulator(), registry,
client);
EXPECT_FALSE(client->WasNotifyFinished())
<< "ModuleTreeLinker should always finish asynchronously.";
......@@ -280,9 +283,10 @@ TEST_F(ModuleTreeLinkerTest, FetchTreeWith3Deps) {
KURL url("http://example.com/root.js");
TestModuleTreeClient* client = new TestModuleTreeClient;
registry->Fetch(url, FetchClientSettingsObjectSnapshot(GetDocument()),
NullURL(), WebURLRequest::kRequestContextScript,
ScriptFetchOptions(), GetModulator(), client);
ModuleTreeLinker::Fetch(url, FetchClientSettingsObjectSnapshot(GetDocument()),
NullURL(), WebURLRequest::kRequestContextScript,
ScriptFetchOptions(), GetModulator(), registry,
client);
EXPECT_FALSE(client->WasNotifyFinished())
<< "ModuleTreeLinker should always finish asynchronously.";
......@@ -319,9 +323,10 @@ TEST_F(ModuleTreeLinkerTest, FetchTreeWith3Deps1Fail) {
KURL url("http://example.com/root.js");
TestModuleTreeClient* client = new TestModuleTreeClient;
registry->Fetch(url, FetchClientSettingsObjectSnapshot(GetDocument()),
NullURL(), WebURLRequest::kRequestContextScript,
ScriptFetchOptions(), GetModulator(), client);
ModuleTreeLinker::Fetch(url, FetchClientSettingsObjectSnapshot(GetDocument()),
NullURL(), WebURLRequest::kRequestContextScript,
ScriptFetchOptions(), GetModulator(), registry,
client);
EXPECT_FALSE(client->WasNotifyFinished())
<< "ModuleTreeLinker should always finish asynchronously.";
......@@ -377,9 +382,10 @@ TEST_F(ModuleTreeLinkerTest, FetchDependencyTree) {
KURL url("http://example.com/depth1.js");
TestModuleTreeClient* client = new TestModuleTreeClient;
registry->Fetch(url, FetchClientSettingsObjectSnapshot(GetDocument()),
NullURL(), WebURLRequest::kRequestContextScript,
ScriptFetchOptions(), GetModulator(), client);
ModuleTreeLinker::Fetch(url, FetchClientSettingsObjectSnapshot(GetDocument()),
NullURL(), WebURLRequest::kRequestContextScript,
ScriptFetchOptions(), GetModulator(), registry,
client);
EXPECT_FALSE(client->WasNotifyFinished())
<< "ModuleTreeLinker should always finish asynchronously.";
......@@ -402,9 +408,10 @@ TEST_F(ModuleTreeLinkerTest, FetchDependencyOfCyclicGraph) {
KURL url("http://example.com/a.js");
TestModuleTreeClient* client = new TestModuleTreeClient;
registry->Fetch(url, FetchClientSettingsObjectSnapshot(GetDocument()),
NullURL(), WebURLRequest::kRequestContextScript,
ScriptFetchOptions(), GetModulator(), client);
ModuleTreeLinker::Fetch(url, FetchClientSettingsObjectSnapshot(GetDocument()),
NullURL(), WebURLRequest::kRequestContextScript,
ScriptFetchOptions(), GetModulator(), registry,
client);
EXPECT_FALSE(client->WasNotifyFinished())
<< "ModuleTreeLinker should always finish asynchronously.";
......
......@@ -9,6 +9,7 @@
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/loader/modulescript/module_script_fetch_request.h"
#include "third_party/blink/renderer/core/loader/modulescript/module_script_loader_registry.h"
#include "third_party/blink/renderer/core/loader/modulescript/module_tree_linker.h"
#include "third_party/blink/renderer/core/loader/modulescript/module_tree_linker_registry.h"
#include "third_party/blink/renderer/core/script/dynamic_module_resolver.h"
#include "third_party/blink/renderer/core/script/fetch_client_settings_object_snapshot.h"
......@@ -64,9 +65,9 @@ void ModulatorImplBase::FetchTree(
// of this algorithm specified custom perform the fetch steps, pass those
// along as well.</spec>
tree_linker_registry_->Fetch(url, fetch_client_settings_object,
GetExecutionContext()->BaseURL(), destination,
options, this, client);
ModuleTreeLinker::Fetch(url, fetch_client_settings_object,
GetExecutionContext()->BaseURL(), destination,
options, this, tree_linker_registry_, client);
// <spec label="fetch-a-module-script-tree" step="3">When the internal module
// script graph fetching procedure asynchronously completes with result,
......@@ -84,8 +85,9 @@ void ModulatorImplBase::FetchDescendantsForInlineScript(
const FetchClientSettingsObjectSnapshot& fetch_client_settings_object,
WebURLRequest::RequestContext destination,
ModuleTreeClient* client) {
tree_linker_registry_->FetchDescendantsForInlineScript(
module_script, fetch_client_settings_object, destination, this, client);
ModuleTreeLinker::FetchDescendantsForInlineScript(
module_script, fetch_client_settings_object, destination, this,
tree_linker_registry_, client);
}
void ModulatorImplBase::FetchSingle(
......
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