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

Side by Side 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: use PreviewsState everywhere 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" 7 #include "content/browser/loader/resource_dispatcher_host_impl.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 DCHECK_CURRENTLY_ON(BrowserThread::UI); 351 DCHECK_CURRENTLY_ON(BrowserThread::UI);
352 RenderFrameHostImpl* host = 352 RenderFrameHostImpl* host =
353 RenderFrameHostImpl::FromID(render_process_id, render_frame_id); 353 RenderFrameHostImpl::FromID(render_process_id, render_frame_id);
354 if (host != nullptr) { 354 if (host != nullptr) {
355 DCHECK(host->frame_tree_node()->IsMainFrame()); 355 DCHECK(host->frame_tree_node()->IsMainFrame());
356 host->frame_tree_node()->navigator()->LogResourceRequestTime( 356 host->frame_tree_node()->navigator()->LogResourceRequestTime(
357 timestamp, url); 357 timestamp, url);
358 } 358 }
359 } 359 }
360 360
361 bool IsUsingLoFi(LoFiState lofi_state, 361 PreviewsState GetPreviewsState(PreviewsState previews_state,
362 ResourceDispatcherHostDelegate* delegate, 362 ResourceDispatcherHostDelegate* delegate,
363 const net::URLRequest& request, 363 const net::URLRequest& request,
364 ResourceContext* resource_context, 364 ResourceContext* resource_context,
365 bool is_main_frame) { 365 bool is_main_frame) {
366 if (lofi_state == LOFI_UNSPECIFIED && delegate && is_main_frame) 366 // previews_state is set to PREVIEWS_OFF when reloading with Lo-Fi disabled.
367 return delegate->ShouldEnableLoFiMode(request, resource_context); 367 if (previews_state == PREVIEWS_UNSPECIFIED && delegate && is_main_frame)
368 return lofi_state == LOFI_ON; 368 return delegate->GetPreviewsState(request, resource_context);
369 return previews_state;
369 } 370 }
370 371
371 // The following functions simplify code paths where the UI thread notifies the 372 // The following functions simplify code paths where the UI thread notifies the
372 // ResourceDispatcherHostImpl of information pertaining to loading behavior of 373 // ResourceDispatcherHostImpl of information pertaining to loading behavior of
373 // frame hosts. 374 // frame hosts.
374 void NotifyForRouteOnIO( 375 void NotifyForRouteOnIO(
375 base::Callback<void(ResourceDispatcherHostImpl*, 376 base::Callback<void(ResourceDispatcherHostImpl*,
376 const GlobalFrameRoutingId&)> frame_callback, 377 const GlobalFrameRoutingId&)> frame_callback,
377 const GlobalFrameRoutingId& global_routing_id) { 378 const GlobalFrameRoutingId& global_routing_id) {
378 DCHECK_CURRENTLY_ON(BrowserThread::IO); 379 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 request_data.is_main_frame, request_data.parent_is_main_frame, 1553 request_data.is_main_frame, request_data.parent_is_main_frame,
1553 request_data.resource_type, request_data.transition_type, 1554 request_data.resource_type, request_data.transition_type,
1554 request_data.should_replace_current_entry, 1555 request_data.should_replace_current_entry,
1555 false, // is download 1556 false, // is download
1556 false, // is stream 1557 false, // is stream
1557 allow_download, request_data.has_user_gesture, 1558 allow_download, request_data.has_user_gesture,
1558 request_data.enable_load_timing, request_data.enable_upload_progress, 1559 request_data.enable_load_timing, request_data.enable_upload_progress,
1559 do_not_prompt_for_login, request_data.referrer_policy, 1560 do_not_prompt_for_login, request_data.referrer_policy,
1560 request_data.visibility_state, resource_context, report_raw_headers, 1561 request_data.visibility_state, resource_context, report_raw_headers,
1561 !is_sync_load, 1562 !is_sync_load,
1562 IsUsingLoFi(request_data.lofi_state, delegate_, *new_request, 1563 GetPreviewsState(request_data.previews_state, delegate_, *new_request,
1563 resource_context, 1564 resource_context,
1564 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME), 1565 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME),
1565 support_async_revalidation ? request_data.headers : std::string(), 1566 support_async_revalidation ? request_data.headers : std::string(),
1566 request_data.request_body, request_data.initiated_in_secure_context); 1567 request_data.request_body, request_data.initiated_in_secure_context);
1567 // Request takes ownership. 1568 // Request takes ownership.
1568 extra_info->AssociateWithRequest(new_request.get()); 1569 extra_info->AssociateWithRequest(new_request.get());
1569 1570
1570 if (new_request->url().SchemeIs(url::kBlobScheme)) { 1571 if (new_request->url().SchemeIs(url::kBlobScheme)) {
1571 // Hang on to a reference to ensure the blob is not released prior 1572 // Hang on to a reference to ensure the blob is not released prior
1572 // to the job being started. 1573 // to the job being started.
1573 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 1574 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
1574 new_request.get(), requester_info->blob_storage_context() 1575 new_request.get(), requester_info->blob_storage_context()
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 ResourceRequesterInfo* requester_info, 1845 ResourceRequesterInfo* requester_info,
1845 int request_id) { 1846 int request_id) {
1846 CancelRequestFromRenderer( 1847 CancelRequestFromRenderer(
1847 GlobalRequestID(requester_info->child_id(), request_id)); 1848 GlobalRequestID(requester_info->child_id(), request_id));
1848 } 1849 }
1849 1850
1850 ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo( 1851 ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo(
1851 int child_id, 1852 int child_id,
1852 int render_view_route_id, 1853 int render_view_route_id,
1853 int render_frame_route_id, 1854 int render_frame_route_id,
1855 PreviewsState previews_state,
1854 bool download, 1856 bool download,
1855 ResourceContext* context) { 1857 ResourceContext* context) {
1856 return new ResourceRequestInfoImpl( 1858 return new ResourceRequestInfoImpl(
1857 ResourceRequesterInfo::CreateForDownloadOrPageSave(child_id), 1859 ResourceRequesterInfo::CreateForDownloadOrPageSave(child_id),
1858 render_view_route_id, 1860 render_view_route_id,
1859 -1, // frame_tree_node_id 1861 -1, // frame_tree_node_id
1860 0, MakeRequestID(), render_frame_route_id, 1862 0, MakeRequestID(), render_frame_route_id,
1861 false, // is_main_frame 1863 false, // is_main_frame
1862 false, // parent_is_main_frame 1864 false, // parent_is_main_frame
1863 RESOURCE_TYPE_SUB_RESOURCE, ui::PAGE_TRANSITION_LINK, 1865 RESOURCE_TYPE_SUB_RESOURCE, ui::PAGE_TRANSITION_LINK,
1864 false, // should_replace_current_entry 1866 false, // should_replace_current_entry
1865 download, // is_download 1867 download, // is_download
1866 false, // is_stream 1868 false, // is_stream
1867 download, // allow_download 1869 download, // allow_download
1868 false, // has_user_gesture 1870 false, // has_user_gesture
1869 false, // enable_load_timing 1871 false, // enable_load_timing
1870 false, // enable_upload_progress 1872 false, // enable_upload_progress
1871 false, // do_not_prompt_for_login 1873 false, // do_not_prompt_for_login
1872 blink::WebReferrerPolicyDefault, blink::WebPageVisibilityStateVisible, 1874 blink::WebReferrerPolicyDefault, blink::WebPageVisibilityStateVisible,
1873 context, 1875 context,
1874 false, // report_raw_headers 1876 false, // report_raw_headers
1875 true, // is_async 1877 true, // is_async
1876 false, // is_using_lofi 1878 previews_state, // previews_state
1877 std::string(), // original_headers 1879 std::string(), // original_headers
1878 nullptr, // body 1880 nullptr, // body
1879 false); // initiated_in_secure_context 1881 false); // initiated_in_secure_context
1880 } 1882 }
1881 1883
1882 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id, 1884 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id,
1883 int route_id) { 1885 int route_id) {
1884 scheduler_->OnClientCreated(child_id, route_id); 1886 scheduler_->OnClientCreated(child_id, route_id);
1885 } 1887 }
1886 1888
1887 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted(int child_id, 1889 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted(int child_id,
1888 int route_id) { 1890 int route_id) {
1889 scheduler_->OnClientDeleted(child_id, route_id); 1891 scheduler_->OnClientDeleted(child_id, route_id);
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
2237 info.common_params.gesture == NavigationGestureUser, 2239 info.common_params.gesture == NavigationGestureUser,
2238 true, // enable_load_timing 2240 true, // enable_load_timing
2239 false, // enable_upload_progress 2241 false, // enable_upload_progress
2240 false, // do_not_prompt_for_login 2242 false, // do_not_prompt_for_login
2241 info.common_params.referrer.policy, 2243 info.common_params.referrer.policy,
2242 // TODO(davidben): This is only used for prerenders. Replace 2244 // TODO(davidben): This is only used for prerenders. Replace
2243 // is_showing with something for that. Or maybe it just comes from the 2245 // is_showing with something for that. Or maybe it just comes from the
2244 // same mechanism as the cookie one. 2246 // same mechanism as the cookie one.
2245 blink::WebPageVisibilityStateVisible, resource_context, 2247 blink::WebPageVisibilityStateVisible, resource_context,
2246 info.report_raw_headers, 2248 info.report_raw_headers,
2247 true, // is_async 2249 true, // is_async
2248 IsUsingLoFi(info.common_params.lofi_state, delegate_, *new_request, 2250 GetPreviewsState(info.common_params.previews_state, delegate_,
2249 resource_context, info.is_main_frame), 2251 *new_request, resource_context, info.is_main_frame),
2250 // The original_headers field is for stale-while-revalidate but the 2252 // The original_headers field is for stale-while-revalidate but the
2251 // feature doesn't work with PlzNavigate, so it's just a placeholder 2253 // feature doesn't work with PlzNavigate, so it's just a placeholder
2252 // here. 2254 // here.
2253 // TODO(ricea): Make the feature work with stale-while-revalidate 2255 // TODO(ricea): Make the feature work with stale-while-revalidate
2254 // and clean this up. 2256 // and clean this up.
2255 std::string(), // original_headers 2257 std::string(), // original_headers
2256 info.common_params.post_data, 2258 info.common_params.post_data,
2257 // TODO(mek): Currently initiated_in_secure_context is only used for 2259 // TODO(mek): Currently initiated_in_secure_context is only used for
2258 // subresource requests, so it doesn't matter what value it gets here. 2260 // subresource requests, so it doesn't matter what value it gets here.
2259 // If in the future this changes this should be updated to somehow get a 2261 // If in the future this changes this should be updated to somehow get a
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
2412 StartLoading(info, std::move(loader)); 2414 StartLoading(info, std::move(loader));
2413 } 2415 }
2414 2416
2415 void ResourceDispatcherHostImpl::InitializeURLRequest( 2417 void ResourceDispatcherHostImpl::InitializeURLRequest(
2416 net::URLRequest* request, 2418 net::URLRequest* request,
2417 const Referrer& referrer, 2419 const Referrer& referrer,
2418 bool is_download, 2420 bool is_download,
2419 int render_process_host_id, 2421 int render_process_host_id,
2420 int render_view_routing_id, 2422 int render_view_routing_id,
2421 int render_frame_routing_id, 2423 int render_frame_routing_id,
2424 PreviewsState previews_state,
2422 ResourceContext* context) { 2425 ResourceContext* context) {
2423 DCHECK_CURRENTLY_ON(BrowserThread::IO); 2426 DCHECK_CURRENTLY_ON(BrowserThread::IO);
2424 DCHECK(!request->is_pending()); 2427 DCHECK(!request->is_pending());
2425 2428
2426 SetReferrerForRequest(request, referrer); 2429 SetReferrerForRequest(request, referrer);
2427 2430
2428 ResourceRequestInfoImpl* info = 2431 ResourceRequestInfoImpl* info = CreateRequestInfo(
2429 CreateRequestInfo(render_process_host_id, render_view_routing_id, 2432 render_process_host_id, render_view_routing_id, render_frame_routing_id,
2430 render_frame_routing_id, is_download, context); 2433 previews_state, is_download, context);
2431 // Request takes ownership. 2434 // Request takes ownership.
2432 info->AssociateWithRequest(request); 2435 info->AssociateWithRequest(request);
2433 } 2436 }
2434 2437
2435 void ResourceDispatcherHostImpl::BeginURLRequest( 2438 void ResourceDispatcherHostImpl::BeginURLRequest(
2436 std::unique_ptr<net::URLRequest> request, 2439 std::unique_ptr<net::URLRequest> request,
2437 std::unique_ptr<ResourceHandler> handler, 2440 std::unique_ptr<ResourceHandler> handler,
2438 bool is_download, 2441 bool is_download,
2439 bool is_content_initiated, 2442 bool is_content_initiated,
2440 bool do_not_prompt_for_login, 2443 bool do_not_prompt_for_login,
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
2831 &throttles); 2834 &throttles);
2832 if (!throttles.empty()) { 2835 if (!throttles.empty()) {
2833 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, 2836 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
2834 std::move(throttles))); 2837 std::move(throttles)));
2835 } 2838 }
2836 } 2839 }
2837 return handler; 2840 return handler;
2838 } 2841 }
2839 2842
2840 } // namespace content 2843 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698