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

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

Powered by Google App Engine
This is Rietveld 408576698