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

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: rebase 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 int GetPreviewsState(int 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 // A previews_state of zero means that the state has not been set, and the
368 return lofi_state == LOFI_ON; 368 // browser process should decide whether or not to request Preview types.
369 if (previews_state == 0 && delegate && is_main_frame)
370 return delegate->GetPreviewsState(request, resource_context);
371 return previews_state;
369 } 372 }
370 373
371 // The following functions simplify code paths where the UI thread notifies the 374 // The following functions simplify code paths where the UI thread notifies the
372 // ResourceDispatcherHostImpl of information pertaining to loading behavior of 375 // ResourceDispatcherHostImpl of information pertaining to loading behavior of
373 // frame hosts. 376 // frame hosts.
374 void NotifyForRouteOnIO( 377 void NotifyForRouteOnIO(
375 base::Callback<void(ResourceDispatcherHostImpl*, 378 base::Callback<void(ResourceDispatcherHostImpl*,
376 const GlobalFrameRoutingId&)> frame_callback, 379 const GlobalFrameRoutingId&)> frame_callback,
377 const GlobalFrameRoutingId& global_routing_id) { 380 const GlobalFrameRoutingId& global_routing_id) {
378 DCHECK_CURRENTLY_ON(BrowserThread::IO); 381 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, 1555 request_data.is_main_frame, request_data.parent_is_main_frame,
1553 request_data.resource_type, request_data.transition_type, 1556 request_data.resource_type, request_data.transition_type,
1554 request_data.should_replace_current_entry, 1557 request_data.should_replace_current_entry,
1555 false, // is download 1558 false, // is download
1556 false, // is stream 1559 false, // is stream
1557 allow_download, request_data.has_user_gesture, 1560 allow_download, request_data.has_user_gesture,
1558 request_data.enable_load_timing, request_data.enable_upload_progress, 1561 request_data.enable_load_timing, request_data.enable_upload_progress,
1559 do_not_prompt_for_login, request_data.referrer_policy, 1562 do_not_prompt_for_login, request_data.referrer_policy,
1560 request_data.visibility_state, resource_context, report_raw_headers, 1563 request_data.visibility_state, resource_context, report_raw_headers,
1561 !is_sync_load, 1564 !is_sync_load,
1562 IsUsingLoFi(request_data.lofi_state, delegate_, *new_request, 1565 GetPreviewsState(request_data.previews_state, delegate_, *new_request,
1563 resource_context, 1566 resource_context,
1564 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME), 1567 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME),
1565 support_async_revalidation ? request_data.headers : std::string(), 1568 support_async_revalidation ? request_data.headers : std::string(),
1566 request_data.request_body, request_data.initiated_in_secure_context); 1569 request_data.request_body, request_data.initiated_in_secure_context);
1567 // Request takes ownership. 1570 // Request takes ownership.
1568 extra_info->AssociateWithRequest(new_request.get()); 1571 extra_info->AssociateWithRequest(new_request.get());
1569 1572
1570 if (new_request->url().SchemeIs(url::kBlobScheme)) { 1573 if (new_request->url().SchemeIs(url::kBlobScheme)) {
1571 // Hang on to a reference to ensure the blob is not released prior 1574 // Hang on to a reference to ensure the blob is not released prior
1572 // to the job being started. 1575 // to the job being started.
1573 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 1576 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
1574 new_request.get(), requester_info->blob_storage_context() 1577 new_request.get(), requester_info->blob_storage_context()
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 ResourceRequesterInfo* requester_info, 1847 ResourceRequesterInfo* requester_info,
1845 int request_id) { 1848 int request_id) {
1846 CancelRequestFromRenderer( 1849 CancelRequestFromRenderer(
1847 GlobalRequestID(requester_info->child_id(), request_id)); 1850 GlobalRequestID(requester_info->child_id(), request_id));
1848 } 1851 }
1849 1852
1850 ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo( 1853 ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo(
1851 int child_id, 1854 int child_id,
1852 int render_view_route_id, 1855 int render_view_route_id,
1853 int render_frame_route_id, 1856 int render_frame_route_id,
1857 int previews_state,
1854 bool download, 1858 bool download,
1855 ResourceContext* context) { 1859 ResourceContext* context) {
1856 return new ResourceRequestInfoImpl( 1860 return new ResourceRequestInfoImpl(
1857 ResourceRequesterInfo::CreateForDownloadOrPageSave(child_id), 1861 ResourceRequesterInfo::CreateForDownloadOrPageSave(child_id),
1858 render_view_route_id, 1862 render_view_route_id,
1859 -1, // frame_tree_node_id 1863 -1, // frame_tree_node_id
1860 0, MakeRequestID(), render_frame_route_id, 1864 0, MakeRequestID(), render_frame_route_id,
1861 false, // is_main_frame 1865 false, // is_main_frame
1862 false, // parent_is_main_frame 1866 false, // parent_is_main_frame
1863 RESOURCE_TYPE_SUB_RESOURCE, ui::PAGE_TRANSITION_LINK, 1867 RESOURCE_TYPE_SUB_RESOURCE, ui::PAGE_TRANSITION_LINK,
1864 false, // should_replace_current_entry 1868 false, // should_replace_current_entry
1865 download, // is_download 1869 download, // is_download
1866 false, // is_stream 1870 false, // is_stream
1867 download, // allow_download 1871 download, // allow_download
1868 false, // has_user_gesture 1872 false, // has_user_gesture
1869 false, // enable_load_timing 1873 false, // enable_load_timing
1870 false, // enable_upload_progress 1874 false, // enable_upload_progress
1871 false, // do_not_prompt_for_login 1875 false, // do_not_prompt_for_login
1872 blink::WebReferrerPolicyDefault, blink::WebPageVisibilityStateVisible, 1876 blink::WebReferrerPolicyDefault, blink::WebPageVisibilityStateVisible,
1873 context, 1877 context,
1874 false, // report_raw_headers 1878 false, // report_raw_headers
1875 true, // is_async 1879 true, // is_async
1876 false, // is_using_lofi 1880 previews_state, // previews_state
1877 std::string(), // original_headers 1881 std::string(), // original_headers
1878 nullptr, // body 1882 nullptr, // body
1879 false); // initiated_in_secure_context 1883 false); // initiated_in_secure_context
1880 } 1884 }
1881 1885
1882 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id, 1886 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id,
1883 int route_id) { 1887 int route_id) {
1884 scheduler_->OnClientCreated(child_id, route_id); 1888 scheduler_->OnClientCreated(child_id, route_id);
1885 } 1889 }
1886 1890
1887 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted(int child_id, 1891 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted(int child_id,
1888 int route_id) { 1892 int route_id) {
1889 scheduler_->OnClientDeleted(child_id, route_id); 1893 scheduler_->OnClientDeleted(child_id, route_id);
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
2237 info.common_params.gesture == NavigationGestureUser, 2241 info.common_params.gesture == NavigationGestureUser,
2238 true, // enable_load_timing 2242 true, // enable_load_timing
2239 false, // enable_upload_progress 2243 false, // enable_upload_progress
2240 false, // do_not_prompt_for_login 2244 false, // do_not_prompt_for_login
2241 info.common_params.referrer.policy, 2245 info.common_params.referrer.policy,
2242 // TODO(davidben): This is only used for prerenders. Replace 2246 // TODO(davidben): This is only used for prerenders. Replace
2243 // is_showing with something for that. Or maybe it just comes from the 2247 // is_showing with something for that. Or maybe it just comes from the
2244 // same mechanism as the cookie one. 2248 // same mechanism as the cookie one.
2245 blink::WebPageVisibilityStateVisible, resource_context, 2249 blink::WebPageVisibilityStateVisible, resource_context,
2246 info.report_raw_headers, 2250 info.report_raw_headers,
2247 true, // is_async 2251 true, // is_async
2248 IsUsingLoFi(info.common_params.lofi_state, delegate_, *new_request, 2252 GetPreviewsState(info.common_params.previews_state, delegate_,
2249 resource_context, info.is_main_frame), 2253 *new_request, resource_context, info.is_main_frame),
2250 // The original_headers field is for stale-while-revalidate but the 2254 // The original_headers field is for stale-while-revalidate but the
2251 // feature doesn't work with PlzNavigate, so it's just a placeholder 2255 // feature doesn't work with PlzNavigate, so it's just a placeholder
2252 // here. 2256 // here.
2253 // TODO(ricea): Make the feature work with stale-while-revalidate 2257 // TODO(ricea): Make the feature work with stale-while-revalidate
2254 // and clean this up. 2258 // and clean this up.
2255 std::string(), // original_headers 2259 std::string(), // original_headers
2256 info.common_params.post_data, 2260 info.common_params.post_data,
2257 // TODO(mek): Currently initiated_in_secure_context is only used for 2261 // TODO(mek): Currently initiated_in_secure_context is only used for
2258 // subresource requests, so it doesn't matter what value it gets here. 2262 // 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 2263 // 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)); 2416 StartLoading(info, std::move(loader));
2413 } 2417 }
2414 2418
2415 void ResourceDispatcherHostImpl::InitializeURLRequest( 2419 void ResourceDispatcherHostImpl::InitializeURLRequest(
2416 net::URLRequest* request, 2420 net::URLRequest* request,
2417 const Referrer& referrer, 2421 const Referrer& referrer,
2418 bool is_download, 2422 bool is_download,
2419 int render_process_host_id, 2423 int render_process_host_id,
2420 int render_view_routing_id, 2424 int render_view_routing_id,
2421 int render_frame_routing_id, 2425 int render_frame_routing_id,
2426 int previews_state,
2422 ResourceContext* context) { 2427 ResourceContext* context) {
2423 DCHECK_CURRENTLY_ON(BrowserThread::IO); 2428 DCHECK_CURRENTLY_ON(BrowserThread::IO);
2424 DCHECK(!request->is_pending()); 2429 DCHECK(!request->is_pending());
2425 2430
2426 SetReferrerForRequest(request, referrer); 2431 SetReferrerForRequest(request, referrer);
2427 2432
2428 ResourceRequestInfoImpl* info = 2433 ResourceRequestInfoImpl* info = CreateRequestInfo(
2429 CreateRequestInfo(render_process_host_id, render_view_routing_id, 2434 render_process_host_id, render_view_routing_id, render_frame_routing_id,
2430 render_frame_routing_id, is_download, context); 2435 previews_state, is_download, context);
2431 // Request takes ownership. 2436 // Request takes ownership.
2432 info->AssociateWithRequest(request); 2437 info->AssociateWithRequest(request);
2433 } 2438 }
2434 2439
2435 void ResourceDispatcherHostImpl::BeginURLRequest( 2440 void ResourceDispatcherHostImpl::BeginURLRequest(
2436 std::unique_ptr<net::URLRequest> request, 2441 std::unique_ptr<net::URLRequest> request,
2437 std::unique_ptr<ResourceHandler> handler, 2442 std::unique_ptr<ResourceHandler> handler,
2438 bool is_download, 2443 bool is_download,
2439 bool is_content_initiated, 2444 bool is_content_initiated,
2440 bool do_not_prompt_for_login, 2445 bool do_not_prompt_for_login,
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
2831 &throttles); 2836 &throttles);
2832 if (!throttles.empty()) { 2837 if (!throttles.empty()) {
2833 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, 2838 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
2834 std::move(throttles))); 2839 std::move(throttles)));
2835 } 2840 }
2836 } 2841 }
2837 return handler; 2842 return handler;
2838 } 2843 }
2839 2844
2840 } // namespace content 2845 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698