Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Unified Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 2484633004: Change Lo-Fi bool to bitmask to support multiple Previews types (Closed)
Patch Set: add back previews_unspecified Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/loader/resource_dispatcher_host_impl.cc
diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc
index fad7d214783f44ff611a9918f0859c664bbd2166..04beff9f1a66f383040c1523bd152bb218626b06 100644
--- a/content/browser/loader/resource_dispatcher_host_impl.cc
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc
@@ -357,14 +357,17 @@ void LogResourceRequestTimeOnUI(
}
}
-bool IsUsingLoFi(LoFiState lofi_state,
- ResourceDispatcherHostDelegate* delegate,
- const net::URLRequest& request,
- ResourceContext* resource_context,
- bool is_main_frame) {
- if (lofi_state == LOFI_UNSPECIFIED && delegate && is_main_frame)
- return delegate->ShouldEnableLoFiMode(request, resource_context);
- return lofi_state == LOFI_ON;
+int GetPreviewsState(int previews_state,
nasko 2016/12/08 22:19:32 PreviewsState
megjablon 2016/12/09 20:35:54 Done.
+ ResourceDispatcherHostDelegate* delegate,
+ const net::URLRequest& request,
+ ResourceContext* resource_context,
+ bool is_main_frame) {
+ // previews_state is set to PREVIEWS_OFF when reloading with Lo-Fi disabled.
+ // A previews_state of zero means that the state has not been set, and the
+ // browser process should decide whether or not to request Preview types.
+ if (previews_state == 0 && delegate && is_main_frame)
+ return delegate->GetPreviewsState(request, resource_context);
+ return previews_state;
}
// The following functions simplify code paths where the UI thread notifies the
@@ -1548,9 +1551,9 @@ void ResourceDispatcherHostImpl::ContinuePendingBeginRequest(
do_not_prompt_for_login, request_data.referrer_policy,
request_data.visibility_state, resource_context, report_raw_headers,
!is_sync_load,
- IsUsingLoFi(request_data.lofi_state, delegate_, *new_request,
- resource_context,
- request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME),
+ GetPreviewsState(request_data.previews_state, delegate_, *new_request,
+ resource_context,
+ request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME),
support_async_revalidation ? request_data.headers : std::string(),
request_data.request_body, request_data.initiated_in_secure_context);
// Request takes ownership.
@@ -1839,6 +1842,7 @@ ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo(
int child_id,
int render_view_route_id,
int render_frame_route_id,
+ int previews_state,
nasko 2016/12/08 22:19:33 PreviewsState
megjablon 2016/12/09 20:35:54 Done.
bool download,
ResourceContext* context) {
return new ResourceRequestInfoImpl(
@@ -1859,12 +1863,12 @@ ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo(
false, // do_not_prompt_for_login
blink::WebReferrerPolicyDefault, blink::WebPageVisibilityStateVisible,
context,
- false, // report_raw_headers
- true, // is_async
- false, // is_using_lofi
- std::string(), // original_headers
- nullptr, // body
- false); // initiated_in_secure_context
+ false, // report_raw_headers
+ true, // is_async
+ previews_state, // previews_state
+ std::string(), // original_headers
+ nullptr, // body
+ false); // initiated_in_secure_context
}
void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id,
@@ -2231,9 +2235,9 @@ void ResourceDispatcherHostImpl::BeginNavigationRequest(
// same mechanism as the cookie one.
blink::WebPageVisibilityStateVisible, resource_context,
info.report_raw_headers,
- true, // is_async
- IsUsingLoFi(info.common_params.lofi_state, delegate_, *new_request,
- resource_context, info.is_main_frame),
+ true, // is_async
+ GetPreviewsState(info.common_params.previews_state, delegate_,
+ *new_request, resource_context, info.is_main_frame),
// The original_headers field is for stale-while-revalidate but the
// feature doesn't work with PlzNavigate, so it's just a placeholder
// here.
@@ -2402,15 +2406,16 @@ void ResourceDispatcherHostImpl::InitializeURLRequest(
int render_process_host_id,
int render_view_routing_id,
int render_frame_routing_id,
+ int previews_state,
nasko 2016/12/08 22:19:32 PreviewsState
megjablon 2016/12/09 20:35:54 Done.
ResourceContext* context) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(!request->is_pending());
SetReferrerForRequest(request, referrer);
- ResourceRequestInfoImpl* info =
- CreateRequestInfo(render_process_host_id, render_view_routing_id,
- render_frame_routing_id, is_download, context);
+ ResourceRequestInfoImpl* info = CreateRequestInfo(
+ render_process_host_id, render_view_routing_id, render_frame_routing_id,
+ previews_state, is_download, context);
// Request takes ownership.
info->AssociateWithRequest(request);
}

Powered by Google App Engine
This is Rietveld 408576698