Commit 5482b1af authored by Yutaka Hirano's avatar Yutaka Hirano Committed by Commit Bot

Provide FrameOrImportedDocument to FrameResourceFetcherProperties

As a preparation to move more properties to
FrameResourceFetcherProperties, this CL passes FrameOrImportedDocument,
not LocalFrame, to FrameResourceFetcherProperties.

Bug: 914739
Change-Id: Ib56c7013eeb2c7cb66d5d6651e832f7d475bd58c
Reviewed-on: https://chromium-review.googlesource.com/c/1405161
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: default avatarHiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/master@{#621967}
parent 0ce53765
......@@ -225,7 +225,15 @@ mojom::FetchCacheMode DetermineFrameCacheMode(Frame* frame,
MainResourceType::kIsNotMainResource, load_type);
}
FetchClientSettingsObject& CreateFetchClientSettingsObjectForNavigation() {
FetchClientSettingsObject& CreateFetchClientSettingsObject(
FrameOrImportedDocument& frame_or_imported_document) {
if (frame_or_imported_document.GetDocument()) {
// HTML imports case
DCHECK(!frame_or_imported_document.GetDocumentLoader());
return *MakeGarbageCollected<FetchClientSettingsObjectImpl>(
*frame_or_imported_document.GetDocument());
}
// This FetchClientSettingsObject can be used only for navigation, as
// at the creation of the corresponding Document a new
// FetchClientSettingsObject is set.
......@@ -305,10 +313,16 @@ struct FrameFetchContext::FrozenState final
ResourceFetcher* FrameFetchContext::CreateFetcher(DocumentLoader* loader) {
DCHECK(loader);
LocalFrame* frame = loader->GetFrame();
auto* frame_or_imported_document =
MakeGarbageCollected<FrameOrImportedDocument>(*loader);
LocalFrame& frame = frame_or_imported_document->GetFrame();
ResourceFetcherInit init(
*MakeGarbageCollected<FrameResourceFetcherProperties>(frame),
MakeGarbageCollected<FrameFetchContext>(loader), frame->Console());
*MakeGarbageCollected<FrameResourceFetcherProperties>(
*frame_or_imported_document),
MakeGarbageCollected<FrameFetchContext>(
frame.GetTaskRunner(TaskType::kNetworking),
*frame_or_imported_document),
frame.Console());
// Frame loading should normally start with |kTight| throttling, as the
// frame will be in layout-blocking state until the <body> tag is inserted
init.initial_throttling_policy =
......@@ -318,8 +332,8 @@ ResourceFetcher* FrameFetchContext::CreateFetcher(DocumentLoader* loader) {
// in multiple processes. In that case, which process should parse it and how
// should the output be spread back across multiple processes?
if (!init.properties->IsMainFrame() &&
frame->Tree().Parent()->IsLocalFrame()) {
init.archive = ToLocalFrame(frame->Tree().Parent())
frame.Tree().Parent()->IsLocalFrame()) {
init.archive = ToLocalFrame(frame.Tree().Parent())
->Loader()
.GetDocumentLoader()
->Fetcher()
......@@ -333,31 +347,27 @@ ResourceFetcher* FrameFetchContext::CreateFetcherForImportedDocument(
DCHECK(document);
// |document| is detached.
DCHECK(!document->GetFrame());
LocalFrame* frame = document->ImportsController()->Master()->GetFrame();
auto* frame_or_imported_document =
MakeGarbageCollected<FrameOrImportedDocument>(*document);
ResourceFetcherInit init(
*MakeGarbageCollected<FrameResourceFetcherProperties>(frame),
MakeGarbageCollected<FrameFetchContext>(document), frame->Console());
*MakeGarbageCollected<FrameResourceFetcherProperties>(
*frame_or_imported_document),
MakeGarbageCollected<FrameFetchContext>(
document->GetTaskRunner(blink::TaskType::kNetworking),
*frame_or_imported_document),
frame_or_imported_document->GetFrame().Console());
return MakeGarbageCollected<ResourceFetcher>(init);
}
FrameFetchContext::FrameFetchContext(DocumentLoader* loader)
FrameFetchContext::FrameFetchContext(
scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner,
FrameOrImportedDocument& frame_or_imported_document)
: BaseFetchContext(
loader->GetFrame()->GetTaskRunner(blink::TaskType::kNetworking),
CreateFetchClientSettingsObjectForNavigation()),
frame_or_imported_document_(
*MakeGarbageCollected<FrameOrImportedDocument>(*loader)),
loading_task_runner,
CreateFetchClientSettingsObject(frame_or_imported_document)),
frame_or_imported_document_(frame_or_imported_document),
save_data_enabled_(GetNetworkStateNotifier().SaveDataEnabled() &&
!GetSettings()->GetDataSaverHoldbackWebApi()) {}
FrameFetchContext::FrameFetchContext(Document* document)
: BaseFetchContext(
document->GetTaskRunner(blink::TaskType::kNetworking),
*MakeGarbageCollected<FetchClientSettingsObjectImpl>(*document)),
frame_or_imported_document_(
*MakeGarbageCollected<FrameOrImportedDocument>(*document)),
save_data_enabled_(GetNetworkStateNotifier().SaveDataEnabled() &&
!GetSettings()->GetDataSaverHoldbackWebApi()) {}
void FrameFetchContext::ProvideDocumentToContext(Document* document) {
DCHECK(document);
frame_or_imported_document_->UpdateDocument(*document);
......
......@@ -72,8 +72,9 @@ class CORE_EXPORT FrameFetchContext final : public BaseFetchContext {
void ProvideDocumentToContext(Document*);
explicit FrameFetchContext(DocumentLoader*);
explicit FrameFetchContext(Document*);
FrameFetchContext(
scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner,
FrameOrImportedDocument&);
~FrameFetchContext() override = default;
bool IsFrameFetchContext() const override { return true; }
......
......@@ -5,22 +5,21 @@
#include "third_party/blink/renderer/core/loader/frame_resource_fetcher_properties.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/loader/frame_or_imported_document.h"
namespace blink {
FrameResourceFetcherProperties::FrameResourceFetcherProperties(
LocalFrame* frame)
: frame_(frame) {
DCHECK(frame);
}
FrameOrImportedDocument& frame_or_imported_document)
: frame_or_imported_document_(frame_or_imported_document) {}
void FrameResourceFetcherProperties::Trace(Visitor* visitor) {
visitor->Trace(frame_);
visitor->Trace(frame_or_imported_document_);
ResourceFetcherProperties::Trace(visitor);
}
bool FrameResourceFetcherProperties::IsMainFrame() const {
return frame_->IsMainFrame();
return frame_or_imported_document_->GetFrame().IsMainFrame();
}
} // namespace blink
......@@ -10,14 +10,13 @@
namespace blink {
class LocalFrame;
class FrameOrImportedDocument;
// FrameResourceFetcherProperties is a ResourceFetcherProperties implementation
// for Frame.
class FrameResourceFetcherProperties final : public ResourceFetcherProperties {
public:
// |frame| must not be null.
explicit FrameResourceFetcherProperties(LocalFrame* frame);
explicit FrameResourceFetcherProperties(FrameOrImportedDocument&);
~FrameResourceFetcherProperties() override = default;
void Trace(Visitor*) override;
......@@ -26,7 +25,7 @@ class FrameResourceFetcherProperties final : public ResourceFetcherProperties {
bool IsMainFrame() const override;
private:
const Member<LocalFrame> frame_;
const Member<FrameOrImportedDocument> frame_or_imported_document_;
};
} // namespace blink
......
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