Commit 85d7067d authored by Hiroki Nakagawa's avatar Hiroki Nakagawa Committed by Commit Bot

OptimizationGuide: Pass BlinkOptimizationGuideHints regardless of subresource blocking

Before this CL, BlinkOptimizationGuideHints were wrongly filtered out
when there are no subresources to block. This CL fixes it.

Bug: 1113980
Change-Id: Ie1f449f0cc5d8beab3b94eaa6cf94c60e67711e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2359659Reviewed-by: default avatarSophie Chang <sophiechang@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798986}
parent 988e2c0f
...@@ -70,22 +70,21 @@ void ResourceLoadingHintsAgent::DidCreateNewDocument() { ...@@ -70,22 +70,21 @@ void ResourceLoadingHintsAgent::DidCreateNewDocument() {
if (!GetDocumentURL().SchemeIsHTTPOrHTTPS()) if (!GetDocumentURL().SchemeIsHTTPOrHTTPS())
return; return;
if (subresource_patterns_to_block_.empty())
return;
blink::WebLocalFrame* web_frame = render_frame()->GetWebFrame(); blink::WebLocalFrame* web_frame = render_frame()->GetWebFrame();
DCHECK(web_frame); DCHECK(web_frame);
std::unique_ptr<blink::WebLoadingHintsProvider> loading_hints = if (!subresource_patterns_to_block_.empty()) {
std::make_unique<blink::WebLoadingHintsProvider>( std::unique_ptr<blink::WebLoadingHintsProvider> loading_hints =
ukm_source_id_.value(), std::make_unique<blink::WebLoadingHintsProvider>(
convert_to_web_vector(subresource_patterns_to_block_)); ukm_source_id_.value(),
convert_to_web_vector(subresource_patterns_to_block_));
web_frame->GetDocumentLoader()->SetLoadingHintsProvider(
std::move(loading_hints)); web_frame->GetDocumentLoader()->SetLoadingHintsProvider(
// Once the hints are sent to the document loader, clear the local copy to std::move(loading_hints));
// prevent accidental reuse. // Once the hints are sent to the document loader, clear the local copy to
subresource_patterns_to_block_.clear(); // prevent accidental reuse.
subresource_patterns_to_block_.clear();
}
// Pass the optimization hints for Blink to LocalFrame. // Pass the optimization hints for Blink to LocalFrame.
// TODO(https://crbug.com/1113980): Onion-soupify the optimization guide for // TODO(https://crbug.com/1113980): Onion-soupify the optimization guide for
...@@ -96,8 +95,10 @@ void ResourceLoadingHintsAgent::DidCreateNewDocument() { ...@@ -96,8 +95,10 @@ void ResourceLoadingHintsAgent::DidCreateNewDocument() {
web_frame->SetOptimizationGuideHints( web_frame->SetOptimizationGuideHints(
blink_optimization_guide_hints_->delay_async_script_execution_hints blink_optimization_guide_hints_->delay_async_script_execution_hints
->delay_type); ->delay_type);
blink_optimization_guide_hints_.reset();
} }
// Once the hints are sent to the local frame, clear the local copy to prevent
// accidental reuse.
blink_optimization_guide_hints_.reset();
} }
void ResourceLoadingHintsAgent::OnDestruct() { void ResourceLoadingHintsAgent::OnDestruct() {
......
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