Commit 15250751 authored by Yutaka Hirano's avatar Yutaka Hirano Committed by Commit Bot

Remove FrameOrImportedDocument

https://crrev.com/c/2103998 removed the only call to
FrameFetchContext::CreateFetcherforImportedDocument. Now we don't need
FrameOrImportedDocument any more.

Bug: 961614
Change-Id: I712d18edaaa5747b0f35d778240a26c0c8f477a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2105685
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Auto-Submit: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760446}
parent ffd2e9cc
......@@ -41,8 +41,6 @@ blink_core_sources("loader") {
"frame_loader_state_machine.cc",
"frame_loader_state_machine.h",
"frame_loader_types.h",
"frame_or_imported_document.cc",
"frame_or_imported_document.h",
"frame_resource_fetcher_properties.cc",
"frame_resource_fetcher_properties.h",
"history_item.cc",
......
......@@ -54,7 +54,6 @@ class ContentSecurityPolicy;
class CoreProbeSink;
class Document;
class DocumentLoader;
class FrameOrImportedDocument;
class LocalFrame;
class LocalFrameClient;
class Settings;
......@@ -64,11 +63,8 @@ class CORE_EXPORT FrameFetchContext final : public BaseFetchContext {
public:
static ResourceFetcher* CreateFetcherForCommittedDocument(DocumentLoader&,
Document&);
// Used for creating a FrameFetchContext for an imported Document.
// |document_loader_| will be set to nullptr.
static ResourceFetcher* CreateFetcherForImportedDocument(Document* document);
FrameFetchContext(const FrameOrImportedDocument&,
FrameFetchContext(DocumentLoader& document_loader,
Document& document,
const DetachableResourceFetcherProperties&);
~FrameFetchContext() override = default;
......@@ -195,7 +191,8 @@ class CORE_EXPORT FrameFetchContext final : public BaseFetchContext {
CoreProbeSink* Probe() const;
Member<const FrameOrImportedDocument> frame_or_imported_document_;
Member<DocumentLoader> document_loader_;
Member<Document> document_;
// The value of |save_data_enabled_| is read once per frame from
// NetworkStateNotifier, which is guarded by a mutex lock, and cached locally
......
// Copyright 2019 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 "third_party/blink/renderer/core/loader/frame_or_imported_document.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/html/imports/html_imports_controller.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/loader/frame_loader.h"
namespace blink {
LocalFrame& FrameOrImportedDocument::GetFrame() const {
DCHECK(document_);
if (document_loader_) {
LocalFrame* frame = document_->GetFrame();
DCHECK(frame);
return *frame;
}
// HTML imports case
// It's guaranteed that imports_controller is not nullptr since:
// - only ClearImportsController() clears it
// - ClearImportsController() also calls ResourceFethcer::ClearContext().
HTMLImportsController* imports_controller = document_->ImportsController();
DCHECK(imports_controller);
// It's guaranteed that Master() is not yet Shutdown()-ed since when Master()
// is Shutdown()-ed:
// - Master()'s HTMLImportsController is disposed.
// - All the HTMLImportLoader instances of the HTMLImportsController are
// disposed.
// - ClearImportsController() is called on the Document.
// HTMLImportsController is created only when the master Document's
// GetFrame() doesn't return nullptr, this is guaranteed to be not nullptr
// here.
LocalFrame* frame = imports_controller->Master()->GetFrame();
DCHECK(frame);
return *frame;
}
DocumentLoader& FrameOrImportedDocument::GetMasterDocumentLoader() const {
if (document_loader_)
return *document_loader_;
// HTML imports case
// GetDocumentLoader() here always returns a non-nullptr value that is the
// DocumentLoader for |document_| because:
// - A Document is created with a LocalFrame only after the
// DocumentLoader is committed
// - When another DocumentLoader is committed, the FrameLoader
// Shutdown()-s |document_|.
auto* loader = GetFrame().Loader().GetDocumentLoader();
DCHECK(loader);
return *loader;
}
void FrameOrImportedDocument::Trace(Visitor* visitor) {
visitor->Trace(document_loader_);
visitor->Trace(document_);
}
} // namespace blink
// Copyright 2019 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 THIRD_PARTY_BLINK_RENDERER_CORE_LOADER_FRAME_OR_IMPORTED_DOCUMENT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LOADER_FRAME_OR_IMPORTED_DOCUMENT_H_
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
namespace blink {
class Document;
class DocumentLoader;
class LocalFrame;
// FrameOrImportedDocument is a thin wrapper that represents and absorbs
// the differences between Document-ish things behind FrameFetchContext:
// - An imported Document
// (document_loader_ is null, document_ is non-null),
// - A DocumentLoader that has committed its navigation
// (document_loader_ is non-null, document_ is non-null).
//
// A FrameOrImportedDocument is indirectly used with a ResourceFetcher, and
// works until ResourceFetcher::ClearContext is called. Do not use this class
// outside of core/loader.
class CORE_EXPORT FrameOrImportedDocument final
: public GarbageCollected<FrameOrImportedDocument> {
public:
// Creates a FrameOrImportedDocument associated with a LocalFrame (which is,
// loader.GetFrame() which cannot be null). This object works until the
// associated frame is detached.
FrameOrImportedDocument(DocumentLoader& loader, Document& committed_document)
: document_loader_(loader), document_(committed_document) {}
// Creates a FrameOrImportedDocument associated with an imported document.
// This object works until |document| is shut-down.
explicit FrameOrImportedDocument(Document& imported_document)
: document_(imported_document) {}
// When this object is associated with a frame, returns it.
// When this object is associated with an imported document, returns the
// frame associated with the imports controller.
LocalFrame& GetFrame() const;
// When this object is associated with a frame, returns the document loader
// given to the constructor (note that there may be multiple document loaders
// in a LocalFrame).
// When this object is associated with an imported document, returns the
// document loader associated with the frame associated with the imports
// controller.
DocumentLoader& GetMasterDocumentLoader() const;
// When this object is associated with a frame, returns the document loader
// given to the constructor (note that there may be multiple document loaders
// in a LocalFrame). Otherwise, returns null.
DocumentLoader* GetDocumentLoader() const { return document_loader_; }
// When this object is associated with a frame with a committed document,
// returns it.
// When this object is associated with an imported document, returns it.
Document& GetDocument() const { return *document_; }
void Trace(Visitor* visitor);
private:
const Member<DocumentLoader> document_loader_;
const Member<Document> document_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LOADER_FRAME_OR_IMPORTED_DOCUMENT_H_
......@@ -10,7 +10,6 @@
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/loader/frame_or_imported_document.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/script/fetch_client_settings_object_impl.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_client_settings_object.h"
......@@ -20,30 +19,32 @@
namespace blink {
FrameResourceFetcherProperties::FrameResourceFetcherProperties(
FrameOrImportedDocument& frame_or_imported_document)
: frame_or_imported_document_(frame_or_imported_document),
DocumentLoader& document_loader,
Document& document)
: document_loader_(document_loader),
document_(document),
fetch_client_settings_object_(
MakeGarbageCollected<FetchClientSettingsObjectImpl>(
*frame_or_imported_document.GetDocument().ToExecutionContext())),
web_bundle_physical_url_(
frame_or_imported_document_->GetMasterDocumentLoader()
.WebBundlePhysicalUrl()) {}
*document.ToExecutionContext())),
web_bundle_physical_url_(document_loader.WebBundlePhysicalUrl()) {}
void FrameResourceFetcherProperties::Trace(Visitor* visitor) {
visitor->Trace(frame_or_imported_document_);
visitor->Trace(document_loader_);
visitor->Trace(document_);
visitor->Trace(fetch_client_settings_object_);
ResourceFetcherProperties::Trace(visitor);
}
bool FrameResourceFetcherProperties::IsMainFrame() const {
return frame_or_imported_document_->GetFrame().IsMainFrame();
LocalFrame* frame = document_->GetFrame();
DCHECK(frame);
return frame->IsMainFrame();
}
mojom::ControllerServiceWorkerMode
FrameResourceFetcherProperties::GetControllerServiceWorkerMode() const {
auto* service_worker_network_provider =
frame_or_imported_document_->GetMasterDocumentLoader()
.GetServiceWorkerNetworkProvider();
document_loader_->GetServiceWorkerNetworkProvider();
if (!service_worker_network_provider)
return blink::mojom::ControllerServiceWorkerMode::kNoController;
return service_worker_network_provider->GetControllerServiceWorkerMode();
......@@ -53,32 +54,31 @@ int64_t FrameResourceFetcherProperties::ServiceWorkerId() const {
DCHECK_NE(GetControllerServiceWorkerMode(),
blink::mojom::ControllerServiceWorkerMode::kNoController);
auto* service_worker_network_provider =
frame_or_imported_document_->GetMasterDocumentLoader()
.GetServiceWorkerNetworkProvider();
document_loader_->GetServiceWorkerNetworkProvider();
DCHECK(service_worker_network_provider);
return service_worker_network_provider->ControllerServiceWorkerID();
}
bool FrameResourceFetcherProperties::IsPaused() const {
return frame_or_imported_document_->GetFrame().GetPage()->Paused();
LocalFrame* frame = document_->GetFrame();
DCHECK(frame);
return frame->GetPage()->Paused();
}
bool FrameResourceFetcherProperties::IsLoadComplete() const {
return frame_or_imported_document_->GetDocument().LoadEventFinished();
return document_->LoadEventFinished();
}
bool FrameResourceFetcherProperties::ShouldBlockLoadingSubResource() const {
DocumentLoader* document_loader =
frame_or_imported_document_->GetDocumentLoader();
if (!document_loader)
return false;
FrameLoader& loader = frame_or_imported_document_->GetFrame().Loader();
return document_loader != loader.GetDocumentLoader();
LocalFrame* frame = document_->GetFrame();
DCHECK(frame);
return document_loader_ != frame->Loader().GetDocumentLoader();
}
bool FrameResourceFetcherProperties::IsSubframeDeprioritizationEnabled() const {
Settings* settings = frame_or_imported_document_->GetFrame().GetSettings();
LocalFrame* frame = document_->GetFrame();
DCHECK(frame);
Settings* settings = frame->GetSettings();
if (!settings) {
return false;
}
......@@ -105,8 +105,9 @@ bool FrameResourceFetcherProperties::IsSubframeDeprioritizationEnabled() const {
}
scheduler::FrameStatus FrameResourceFetcherProperties::GetFrameStatus() const {
return scheduler::GetFrameStatus(
frame_or_imported_document_->GetFrame().GetFrameScheduler());
LocalFrame* frame = document_->GetFrame();
DCHECK(frame);
return scheduler::GetFrameStatus(frame->GetFrameScheduler());
}
const KURL& FrameResourceFetcherProperties::WebBundlePhysicalUrl() const {
......
......@@ -12,22 +12,20 @@
namespace blink {
class FrameOrImportedDocument;
class Document;
class DocumentLoader;
// FrameResourceFetcherProperties is a ResourceFetcherProperties implementation
// for Frame.
class CORE_EXPORT FrameResourceFetcherProperties final
: public ResourceFetcherProperties {
public:
explicit FrameResourceFetcherProperties(FrameOrImportedDocument&);
FrameResourceFetcherProperties(DocumentLoader& document_loader,
Document& document);
~FrameResourceFetcherProperties() override = default;
void Trace(Visitor*) override;
const FrameOrImportedDocument& GetFrameOrImportedDocument() const {
return *frame_or_imported_document_;
}
// ResourceFetcherProperties implementation
const FetchClientSettingsObject& GetFetchClientSettingsObject()
const override {
......@@ -45,7 +43,8 @@ class CORE_EXPORT FrameResourceFetcherProperties final
const KURL& WebBundlePhysicalUrl() const override;
private:
const Member<FrameOrImportedDocument> frame_or_imported_document_;
const Member<DocumentLoader> document_loader_;
const Member<Document> document_;
Member<const FetchClientSettingsObject> fetch_client_settings_object_;
const KURL web_bundle_physical_url_;
};
......
......@@ -7,7 +7,6 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/loader/frame_or_imported_document.h"
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
#include "third_party/blink/renderer/platform/network/network_state_notifier.h"
......@@ -18,9 +17,8 @@ class FrameResourceFetcherPropertiesTest : public testing::Test {
FrameResourceFetcherPropertiesTest()
: dummy_page_holder_(std::make_unique<DummyPageHolder>(IntSize(1, 1))),
properties_(MakeGarbageCollected<FrameResourceFetcherProperties>(
*MakeGarbageCollected<FrameOrImportedDocument>(
*dummy_page_holder_->GetDocument().Loader(),
dummy_page_holder_->GetDocument()))) {}
*dummy_page_holder_->GetDocument().Loader(),
dummy_page_holder_->GetDocument())) {}
protected:
const std::unique_ptr<DummyPageHolder> dummy_page_holder_;
......
......@@ -16,24 +16,22 @@
#include "third_party/blink/renderer/core/fileapi/public_url_manager.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/loader/frame_or_imported_document.h"
#include "third_party/blink/renderer/core/loader/prefetched_signed_exchange_manager.h"
#include "third_party/blink/renderer/platform/exported/wrapped_resource_request.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
namespace blink {
LoaderFactoryForFrame::LoaderFactoryForFrame(
const FrameOrImportedDocument& frame_or_imported_document)
: frame_or_imported_document_(frame_or_imported_document),
LoaderFactoryForFrame::LoaderFactoryForFrame(DocumentLoader& document_loader,
Document& document)
: document_loader_(document_loader),
document_(document),
prefetched_signed_exchange_manager_(
frame_or_imported_document_->GetDocumentLoader()
? frame_or_imported_document_->GetDocumentLoader()
->GetPrefetchedSignedExchangeManager()
: nullptr) {}
document_loader.GetPrefetchedSignedExchangeManager()) {}
void LoaderFactoryForFrame::Trace(Visitor* visitor) {
visitor->Trace(frame_or_imported_document_);
visitor->Trace(document_loader_);
visitor->Trace(document_);
visitor->Trace(prefetched_signed_exchange_manager_);
LoaderFactory::Trace(visitor);
}
......@@ -71,11 +69,12 @@ std::unique_ptr<WebURLLoader> LoaderFactoryForFrame::CreateURLLoader(
// callsite when we make Shared Worker loading off-main-thread.
if (request.Url().ProtocolIs("blob") && !url_loader_factory &&
request.GetRequestContext() != mojom::RequestContextType::SHARED_WORKER) {
frame_or_imported_document_->GetDocument().GetPublicURLManager().Resolve(
document_->GetPublicURLManager().Resolve(
request.Url(), url_loader_factory.InitWithNewPipeAndPassReceiver());
}
LocalFrame& frame = frame_or_imported_document_->GetFrame();
FrameScheduler* frame_scheduler = frame.GetFrameScheduler();
LocalFrame* frame = document_->GetFrame();
DCHECK(frame);
FrameScheduler* frame_scheduler = frame->GetFrameScheduler();
DCHECK(frame_scheduler);
// TODO(altimin): frame_scheduler->CreateResourceLoadingTaskRunnerHandle is
......@@ -90,11 +89,9 @@ std::unique_ptr<WebURLLoader> LoaderFactoryForFrame::CreateURLLoader(
webreq, frame_scheduler->CreateResourceLoadingTaskRunnerHandle());
}
DocumentLoader& document_loader =
frame_or_imported_document_->GetMasterDocumentLoader();
if (document_loader.GetServiceWorkerNetworkProvider()) {
if (document_loader_->GetServiceWorkerNetworkProvider()) {
auto loader =
document_loader.GetServiceWorkerNetworkProvider()->CreateURLLoader(
document_loader_->GetServiceWorkerNetworkProvider()->CreateURLLoader(
webreq, frame_scheduler->CreateResourceLoadingTaskRunnerHandle());
if (loader)
return loader;
......@@ -106,7 +103,7 @@ std::unique_ptr<WebURLLoader> LoaderFactoryForFrame::CreateURLLoader(
if (loader)
return loader;
}
return frame.GetURLLoaderFactory()->CreateURLLoader(
return frame->GetURLLoaderFactory()->CreateURLLoader(
webreq, frame_scheduler->CreateResourceLoadingTaskRunnerHandle());
}
......
......@@ -12,12 +12,13 @@
namespace blink {
class FrameOrImportedDocument;
class Document;
class DocumentLoader;
class PrefetchedSignedExchangeManager;
class LoaderFactoryForFrame final : public ResourceFetcher::LoaderFactory {
public:
explicit LoaderFactoryForFrame(const FrameOrImportedDocument&);
LoaderFactoryForFrame(DocumentLoader& loader, Document& document);
void Trace(Visitor*) override;
......@@ -29,7 +30,8 @@ class LoaderFactoryForFrame final : public ResourceFetcher::LoaderFactory {
std::unique_ptr<CodeCacheLoader> CreateCodeCacheLoader() override;
private:
const Member<const FrameOrImportedDocument> frame_or_imported_document_;
const Member<DocumentLoader> document_loader_;
const Member<Document> document_;
const Member<PrefetchedSignedExchangeManager>
prefetched_signed_exchange_manager_;
};
......
......@@ -15,16 +15,17 @@
namespace blink {
class CoreProbeSink;
class FrameOrImportedDocument;
class Document;
class DocumentLoader;
class ResourceFetcherProperties;
// ResourceLoadObserver implementation associated with a frame.
class CORE_EXPORT ResourceLoadObserverForFrame final
: public ResourceLoadObserver {
public:
ResourceLoadObserverForFrame(
const FrameOrImportedDocument& frame_or_imported_document,
const ResourceFetcherProperties& properties);
ResourceLoadObserverForFrame(DocumentLoader& loader,
Document& document,
const ResourceFetcherProperties& properties);
~ResourceLoadObserverForFrame() override;
// ResourceLoadObserver implementation.
......@@ -63,11 +64,10 @@ class CORE_EXPORT ResourceLoadObserverForFrame final
CoreProbeSink* GetProbe();
void CountUsage(WebFeature);
// There are some overlap between |frame_or_imported_document| and
// |fetcher_properties_|.
// Use this when you want to access frame, document, etc. directly.
const Member<const FrameOrImportedDocument> frame_or_imported_document_;
// Use this whenever possible.
// There are some overlap between |document_loader_|, |document_| and
// |fetcher_properties_|. Use |fetcher_properties_| whenever possible.
const Member<DocumentLoader> document_loader_;
const Member<Document> document_;
const Member<const ResourceFetcherProperties> fetcher_properties_;
};
......
......@@ -6,7 +6,6 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/loader/empty_clients.h"
#include "third_party/blink/renderer/core/loader/frame_or_imported_document.h"
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource.h"
......@@ -39,8 +38,7 @@ TEST(ResourceLoadObserverForFrameTest, MemoryCacheCertificateError) {
std::make_unique<DummyPageHolder>(IntSize(), nullptr, client);
LocalFrame& frame = dummy_page_holder->GetFrame();
auto* observer = MakeGarbageCollected<ResourceLoadObserverForFrame>(
*MakeGarbageCollected<FrameOrImportedDocument>(
*frame.GetDocument()->Loader(), *frame.GetDocument()),
*frame.GetDocument()->Loader(), *frame.GetDocument(),
*MakeGarbageCollected<TestResourceFetcherProperties>());
KURL url("https://www.example.com/");
ResourceRequest resource_request(url);
......
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