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

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: fix ContentResourceProviderTest Created 3 years, 11 months 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 // Returns the PreviewsState after requesting it from the delegate. The
362 ResourceDispatcherHostDelegate* delegate, 362 // PreviewsState is a bitmask of potentially several Previews optimizations.
363 const net::URLRequest& request, 363 PreviewsState GetPreviewsState(PreviewsState previews_state,
364 ResourceContext* resource_context, 364 ResourceDispatcherHostDelegate* delegate,
365 bool is_main_frame) { 365 const net::URLRequest& request,
366 if (lofi_state == LOFI_UNSPECIFIED && delegate && is_main_frame) 366 ResourceContext* resource_context,
367 return delegate->ShouldEnableLoFiMode(request, resource_context); 367 bool is_main_frame) {
368 return lofi_state == LOFI_ON; 368 // previews_state is set to PREVIEWS_OFF when reloading with Lo-Fi disabled.
369 if (previews_state == PREVIEWS_UNSPECIFIED && 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 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 request_data.is_main_frame, request_data.parent_is_main_frame, 1552 request_data.is_main_frame, request_data.parent_is_main_frame,
1550 request_data.resource_type, request_data.transition_type, 1553 request_data.resource_type, request_data.transition_type,
1551 request_data.should_replace_current_entry, 1554 request_data.should_replace_current_entry,
1552 false, // is download 1555 false, // is download
1553 false, // is stream 1556 false, // is stream
1554 allow_download, request_data.has_user_gesture, 1557 allow_download, request_data.has_user_gesture,
1555 request_data.enable_load_timing, request_data.enable_upload_progress, 1558 request_data.enable_load_timing, request_data.enable_upload_progress,
1556 do_not_prompt_for_login, request_data.referrer_policy, 1559 do_not_prompt_for_login, request_data.referrer_policy,
1557 request_data.visibility_state, resource_context, report_raw_headers, 1560 request_data.visibility_state, resource_context, report_raw_headers,
1558 !is_sync_load, 1561 !is_sync_load,
1559 IsUsingLoFi(request_data.lofi_state, delegate_, *new_request, 1562 GetPreviewsState(request_data.previews_state, delegate_, *new_request,
1560 resource_context, 1563 resource_context,
1561 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME), 1564 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME),
1562 support_async_revalidation ? request_data.headers : std::string(), 1565 support_async_revalidation ? request_data.headers : std::string(),
1563 request_data.request_body, request_data.initiated_in_secure_context); 1566 request_data.request_body, request_data.initiated_in_secure_context);
1564 // Request takes ownership. 1567 // Request takes ownership.
1565 extra_info->AssociateWithRequest(new_request.get()); 1568 extra_info->AssociateWithRequest(new_request.get());
1566 1569
1567 if (new_request->url().SchemeIs(url::kBlobScheme)) { 1570 if (new_request->url().SchemeIs(url::kBlobScheme)) {
1568 // Hang on to a reference to ensure the blob is not released prior 1571 // Hang on to a reference to ensure the blob is not released prior
1569 // to the job being started. 1572 // to the job being started.
1570 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 1573 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
1571 new_request.get(), requester_info->blob_storage_context() 1574 new_request.get(), requester_info->blob_storage_context()
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1839 ResourceRequesterInfo* requester_info, 1842 ResourceRequesterInfo* requester_info,
1840 int request_id) { 1843 int request_id) {
1841 CancelRequestFromRenderer( 1844 CancelRequestFromRenderer(
1842 GlobalRequestID(requester_info->child_id(), request_id)); 1845 GlobalRequestID(requester_info->child_id(), request_id));
1843 } 1846 }
1844 1847
1845 ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo( 1848 ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo(
1846 int child_id, 1849 int child_id,
1847 int render_view_route_id, 1850 int render_view_route_id,
1848 int render_frame_route_id, 1851 int render_frame_route_id,
1852 PreviewsState previews_state,
1849 bool download, 1853 bool download,
1850 ResourceContext* context) { 1854 ResourceContext* context) {
1851 return new ResourceRequestInfoImpl( 1855 return new ResourceRequestInfoImpl(
1852 ResourceRequesterInfo::CreateForDownloadOrPageSave(child_id), 1856 ResourceRequesterInfo::CreateForDownloadOrPageSave(child_id),
1853 render_view_route_id, 1857 render_view_route_id,
1854 -1, // frame_tree_node_id 1858 -1, // frame_tree_node_id
1855 0, MakeRequestID(), render_frame_route_id, 1859 0, MakeRequestID(), render_frame_route_id,
1856 false, // is_main_frame 1860 false, // is_main_frame
1857 false, // parent_is_main_frame 1861 false, // parent_is_main_frame
1858 RESOURCE_TYPE_SUB_RESOURCE, ui::PAGE_TRANSITION_LINK, 1862 RESOURCE_TYPE_SUB_RESOURCE, ui::PAGE_TRANSITION_LINK,
1859 false, // should_replace_current_entry 1863 false, // should_replace_current_entry
1860 download, // is_download 1864 download, // is_download
1861 false, // is_stream 1865 false, // is_stream
1862 download, // allow_download 1866 download, // allow_download
1863 false, // has_user_gesture 1867 false, // has_user_gesture
1864 false, // enable_load_timing 1868 false, // enable_load_timing
1865 false, // enable_upload_progress 1869 false, // enable_upload_progress
1866 false, // do_not_prompt_for_login 1870 false, // do_not_prompt_for_login
1867 blink::WebReferrerPolicyDefault, blink::WebPageVisibilityStateVisible, 1871 blink::WebReferrerPolicyDefault, blink::WebPageVisibilityStateVisible,
1868 context, 1872 context,
1869 false, // report_raw_headers 1873 false, // report_raw_headers
1870 true, // is_async 1874 true, // is_async
1871 false, // is_using_lofi 1875 previews_state, // previews_state
1872 std::string(), // original_headers 1876 std::string(), // original_headers
1873 nullptr, // body 1877 nullptr, // body
1874 false); // initiated_in_secure_context 1878 false); // initiated_in_secure_context
1875 } 1879 }
1876 1880
1877 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id, 1881 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id,
1878 int route_id) { 1882 int route_id) {
1879 scheduler_->OnClientCreated(child_id, route_id); 1883 scheduler_->OnClientCreated(child_id, route_id);
1880 } 1884 }
1881 1885
1882 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted(int child_id, 1886 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted(int child_id,
1883 int route_id) { 1887 int route_id) {
1884 scheduler_->OnClientDeleted(child_id, route_id); 1888 scheduler_->OnClientDeleted(child_id, route_id);
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
2228 false, 2232 false,
2229 false, // is download 2233 false, // is download
2230 false, // is stream 2234 false, // is stream
2231 info.common_params.allow_download, info.begin_params.has_user_gesture, 2235 info.common_params.allow_download, info.begin_params.has_user_gesture,
2232 true, // enable_load_timing 2236 true, // enable_load_timing
2233 false, // enable_upload_progress 2237 false, // enable_upload_progress
2234 false, // do_not_prompt_for_login 2238 false, // do_not_prompt_for_login
2235 info.common_params.referrer.policy, info.page_visibility_state, 2239 info.common_params.referrer.policy, info.page_visibility_state,
2236 resource_context, info.report_raw_headers, 2240 resource_context, info.report_raw_headers,
2237 true, // is_async 2241 true, // is_async
2238 IsUsingLoFi(info.common_params.lofi_state, delegate_, *new_request, 2242 GetPreviewsState(info.common_params.previews_state, delegate_,
2239 resource_context, info.is_main_frame), 2243 *new_request, resource_context, info.is_main_frame),
2240 // The original_headers field is for stale-while-revalidate but the 2244 // The original_headers field is for stale-while-revalidate but the
2241 // feature doesn't work with PlzNavigate, so it's just a placeholder 2245 // feature doesn't work with PlzNavigate, so it's just a placeholder
2242 // here. 2246 // here.
2243 // TODO(ricea): Make the feature work with stale-while-revalidate 2247 // TODO(ricea): Make the feature work with stale-while-revalidate
2244 // and clean this up. 2248 // and clean this up.
2245 std::string(), // original_headers 2249 std::string(), // original_headers
2246 info.common_params.post_data, 2250 info.common_params.post_data,
2247 // TODO(mek): Currently initiated_in_secure_context is only used for 2251 // TODO(mek): Currently initiated_in_secure_context is only used for
2248 // subresource requests, so it doesn't matter what value it gets here. 2252 // subresource requests, so it doesn't matter what value it gets here.
2249 // If in the future this changes this should be updated to somehow get a 2253 // If in the future this changes this should be updated to somehow get a
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2403 StartLoading(info, std::move(loader)); 2407 StartLoading(info, std::move(loader));
2404 } 2408 }
2405 2409
2406 void ResourceDispatcherHostImpl::InitializeURLRequest( 2410 void ResourceDispatcherHostImpl::InitializeURLRequest(
2407 net::URLRequest* request, 2411 net::URLRequest* request,
2408 const Referrer& referrer, 2412 const Referrer& referrer,
2409 bool is_download, 2413 bool is_download,
2410 int render_process_host_id, 2414 int render_process_host_id,
2411 int render_view_routing_id, 2415 int render_view_routing_id,
2412 int render_frame_routing_id, 2416 int render_frame_routing_id,
2417 PreviewsState previews_state,
2413 ResourceContext* context) { 2418 ResourceContext* context) {
2414 DCHECK_CURRENTLY_ON(BrowserThread::IO); 2419 DCHECK_CURRENTLY_ON(BrowserThread::IO);
2415 DCHECK(!request->is_pending()); 2420 DCHECK(!request->is_pending());
2416 2421
2417 SetReferrerForRequest(request, referrer); 2422 SetReferrerForRequest(request, referrer);
2418 2423
2419 ResourceRequestInfoImpl* info = 2424 ResourceRequestInfoImpl* info = CreateRequestInfo(
2420 CreateRequestInfo(render_process_host_id, render_view_routing_id, 2425 render_process_host_id, render_view_routing_id, render_frame_routing_id,
2421 render_frame_routing_id, is_download, context); 2426 previews_state, is_download, context);
2422 // Request takes ownership. 2427 // Request takes ownership.
2423 info->AssociateWithRequest(request); 2428 info->AssociateWithRequest(request);
2424 } 2429 }
2425 2430
2426 void ResourceDispatcherHostImpl::BeginURLRequest( 2431 void ResourceDispatcherHostImpl::BeginURLRequest(
2427 std::unique_ptr<net::URLRequest> request, 2432 std::unique_ptr<net::URLRequest> request,
2428 std::unique_ptr<ResourceHandler> handler, 2433 std::unique_ptr<ResourceHandler> handler,
2429 bool is_download, 2434 bool is_download,
2430 bool is_content_initiated, 2435 bool is_content_initiated,
2431 bool do_not_prompt_for_login, 2436 bool do_not_prompt_for_login,
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
2822 &throttles); 2827 &throttles);
2823 if (!throttles.empty()) { 2828 if (!throttles.empty()) {
2824 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, 2829 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
2825 std::move(throttles))); 2830 std::move(throttles)));
2826 } 2831 }
2827 } 2832 }
2828 return handler; 2833 return handler;
2829 } 2834 }
2830 2835
2831 } // namespace content 2836 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | content/browser/loader/resource_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698