Commit 2b716a94 authored by Hiroki Nakagawa's avatar Hiroki Nakagawa Committed by Chromium LUCI CQ

NoStatePrefetch: Remove mojom::PrerenderMode from PrerenderURLLoaderThrottle

PrerenderURLLoaderThrottle::mode_ is always
mojom::PrerenderMode::kPrefetchOnly, so the field is not necessary.

Even after this change, the constructor of PrerenderURLLoaderThrottle
still takes the mode as an argument just for validation check. This will
be removed by follow-up CLs that remove the mode from callers of the
constructor.

Bug: 755921
Change-Id: I72c5cb9ca3c1d03e9316fbf60aa067d3bff02cbc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2592237Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837099}
parent aca54053
...@@ -41,10 +41,11 @@ PrerenderURLLoaderThrottle::PrerenderURLLoaderThrottle( ...@@ -41,10 +41,11 @@ PrerenderURLLoaderThrottle::PrerenderURLLoaderThrottle(
prerender::mojom::PrerenderMode mode, prerender::mojom::PrerenderMode mode,
const std::string& histogram_prefix, const std::string& histogram_prefix,
mojo::PendingRemote<prerender::mojom::PrerenderCanceler> canceler) mojo::PendingRemote<prerender::mojom::PrerenderCanceler> canceler)
: mode_(mode), : histogram_prefix_(histogram_prefix), canceler_(std::move(canceler)) {
histogram_prefix_(histogram_prefix),
canceler_(std::move(canceler)) {
DCHECK(canceler_); DCHECK(canceler_);
// TODO(https://crbug.com/755921): Remove the `mode` param. This is now kept
// just for validation check until mojom::PrerenderMode is completely removed.
DCHECK_EQ(mode, mojom::PrerenderMode::kPrefetchOnly);
} }
PrerenderURLLoaderThrottle::~PrerenderURLLoaderThrottle() { PrerenderURLLoaderThrottle::~PrerenderURLLoaderThrottle() {
...@@ -68,11 +69,9 @@ void PrerenderURLLoaderThrottle::DetachFromCurrentSequence() { ...@@ -68,11 +69,9 @@ void PrerenderURLLoaderThrottle::DetachFromCurrentSequence() {
void PrerenderURLLoaderThrottle::WillStartRequest( void PrerenderURLLoaderThrottle::WillStartRequest(
network::ResourceRequest* request, network::ResourceRequest* request,
bool* defer) { bool* defer) {
if (mode_ == prerender::mojom::PrerenderMode::kPrefetchOnly) { request->load_flags |= net::LOAD_PREFETCH;
request->load_flags |= net::LOAD_PREFETCH; request->cors_exempt_headers.SetHeader(kPurposeHeaderName,
request->cors_exempt_headers.SetHeader(kPurposeHeaderName, kPurposeHeaderValue);
kPurposeHeaderValue);
}
resource_type_ = resource_type_ =
static_cast<blink::mojom::ResourceType>(request->resource_type); static_cast<blink::mojom::ResourceType>(request->resource_type);
...@@ -122,12 +121,10 @@ void PrerenderURLLoaderThrottle::WillStartRequest( ...@@ -122,12 +121,10 @@ void PrerenderURLLoaderThrottle::WillStartRequest(
} }
#endif // OS_ANDROID #endif // OS_ANDROID
if (mode_ == prerender::mojom::PrerenderMode::kPrefetchOnly) { detached_timer_.Start(FROM_HERE,
detached_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(
base::TimeDelta::FromMilliseconds( content::kDefaultDetachableCancelDelayMs),
content::kDefaultDetachableCancelDelayMs), this, &PrerenderURLLoaderThrottle::OnTimedOut);
this, &PrerenderURLLoaderThrottle::OnTimedOut);
}
} }
void PrerenderURLLoaderThrottle::WillRedirectRequest( void PrerenderURLLoaderThrottle::WillRedirectRequest(
...@@ -138,11 +135,9 @@ void PrerenderURLLoaderThrottle::WillRedirectRequest( ...@@ -138,11 +135,9 @@ void PrerenderURLLoaderThrottle::WillRedirectRequest(
net::HttpRequestHeaders* /* modified_headers */, net::HttpRequestHeaders* /* modified_headers */,
net::HttpRequestHeaders* /* modified_cors_exempt_headers */) { net::HttpRequestHeaders* /* modified_cors_exempt_headers */) {
redirect_count_++; redirect_count_++;
if (mode_ == prerender::mojom::PrerenderMode::kPrefetchOnly) { RecordPrefetchResponseReceived(
RecordPrefetchResponseReceived( histogram_prefix_, blink::IsResourceTypeFrame(resource_type_),
histogram_prefix_, blink::IsResourceTypeFrame(resource_type_), true /* is_redirect */, IsNoStoreResponse(response_head));
true /* is_redirect */, IsNoStoreResponse(response_head));
}
std::string follow_only_when_prerender_shown_header; std::string follow_only_when_prerender_shown_header;
if (response_head.headers) { if (response_head.headers) {
...@@ -167,10 +162,6 @@ void PrerenderURLLoaderThrottle::WillProcessResponse( ...@@ -167,10 +162,6 @@ void PrerenderURLLoaderThrottle::WillProcessResponse(
const GURL& response_url, const GURL& response_url,
network::mojom::URLResponseHead* response_head, network::mojom::URLResponseHead* response_head,
bool* defer) { bool* defer) {
if (mode_ != prerender::mojom::PrerenderMode::kPrefetchOnly) {
return;
}
bool is_main_resource = blink::IsResourceTypeFrame(resource_type_); bool is_main_resource = blink::IsResourceTypeFrame(resource_type_);
RecordPrefetchResponseReceived(histogram_prefix_, is_main_resource, RecordPrefetchResponseReceived(histogram_prefix_, is_main_resource,
true /* is_redirect */, true /* is_redirect */,
......
...@@ -54,7 +54,6 @@ class PrerenderURLLoaderThrottle ...@@ -54,7 +54,6 @@ class PrerenderURLLoaderThrottle
void OnTimedOut(); void OnTimedOut();
prerender::mojom::PrerenderMode mode_;
std::string histogram_prefix_; std::string histogram_prefix_;
bool deferred_ = false; bool deferred_ = false;
......
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