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

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 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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
2233 false, 2235 false,
2234 false, // is download 2236 false, // is download
2235 false, // is stream 2237 false, // is stream
2236 info.common_params.allow_download, info.begin_params.has_user_gesture, 2238 info.common_params.allow_download, info.begin_params.has_user_gesture,
2237 true, // enable_load_timing 2239 true, // enable_load_timing
2238 false, // enable_upload_progress 2240 false, // enable_upload_progress
2239 false, // do_not_prompt_for_login 2241 false, // do_not_prompt_for_login
2240 info.common_params.referrer.policy, info.page_visibility_state, 2242 info.common_params.referrer.policy, info.page_visibility_state,
2241 resource_context, info.report_raw_headers, 2243 resource_context, info.report_raw_headers,
2242 true, // is_async 2244 true, // is_async
2243 IsUsingLoFi(info.common_params.lofi_state, delegate_, *new_request, 2245 GetPreviewsState(info.common_params.previews_state, delegate_,
2244 resource_context, info.is_main_frame), 2246 *new_request, resource_context, info.is_main_frame),
2245 // The original_headers field is for stale-while-revalidate but the 2247 // The original_headers field is for stale-while-revalidate but the
2246 // feature doesn't work with PlzNavigate, so it's just a placeholder 2248 // feature doesn't work with PlzNavigate, so it's just a placeholder
2247 // here. 2249 // here.
2248 // TODO(ricea): Make the feature work with stale-while-revalidate 2250 // TODO(ricea): Make the feature work with stale-while-revalidate
2249 // and clean this up. 2251 // and clean this up.
2250 std::string(), // original_headers 2252 std::string(), // original_headers
2251 info.common_params.post_data, 2253 info.common_params.post_data,
2252 // TODO(mek): Currently initiated_in_secure_context is only used for 2254 // TODO(mek): Currently initiated_in_secure_context is only used for
2253 // subresource requests, so it doesn't matter what value it gets here. 2255 // subresource requests, so it doesn't matter what value it gets here.
2254 // If in the future this changes this should be updated to somehow get a 2256 // 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
2407 StartLoading(info, std::move(loader)); 2409 StartLoading(info, std::move(loader));
2408 } 2410 }
2409 2411
2410 void ResourceDispatcherHostImpl::InitializeURLRequest( 2412 void ResourceDispatcherHostImpl::InitializeURLRequest(
2411 net::URLRequest* request, 2413 net::URLRequest* request,
2412 const Referrer& referrer, 2414 const Referrer& referrer,
2413 bool is_download, 2415 bool is_download,
2414 int render_process_host_id, 2416 int render_process_host_id,
2415 int render_view_routing_id, 2417 int render_view_routing_id,
2416 int render_frame_routing_id, 2418 int render_frame_routing_id,
2419 PreviewsState previews_state,
2417 ResourceContext* context) { 2420 ResourceContext* context) {
2418 DCHECK_CURRENTLY_ON(BrowserThread::IO); 2421 DCHECK_CURRENTLY_ON(BrowserThread::IO);
2419 DCHECK(!request->is_pending()); 2422 DCHECK(!request->is_pending());
2420 2423
2421 SetReferrerForRequest(request, referrer); 2424 SetReferrerForRequest(request, referrer);
2422 2425
2423 ResourceRequestInfoImpl* info = 2426 ResourceRequestInfoImpl* info = CreateRequestInfo(
2424 CreateRequestInfo(render_process_host_id, render_view_routing_id, 2427 render_process_host_id, render_view_routing_id, render_frame_routing_id,
2425 render_frame_routing_id, is_download, context); 2428 previews_state, is_download, context);
2426 // Request takes ownership. 2429 // Request takes ownership.
2427 info->AssociateWithRequest(request); 2430 info->AssociateWithRequest(request);
2428 } 2431 }
2429 2432
2430 void ResourceDispatcherHostImpl::BeginURLRequest( 2433 void ResourceDispatcherHostImpl::BeginURLRequest(
2431 std::unique_ptr<net::URLRequest> request, 2434 std::unique_ptr<net::URLRequest> request,
2432 std::unique_ptr<ResourceHandler> handler, 2435 std::unique_ptr<ResourceHandler> handler,
2433 bool is_download, 2436 bool is_download,
2434 bool is_content_initiated, 2437 bool is_content_initiated,
2435 bool do_not_prompt_for_login, 2438 bool do_not_prompt_for_login,
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
2826 &throttles); 2829 &throttles);
2827 if (!throttles.empty()) { 2830 if (!throttles.empty()) {
2828 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, 2831 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
2829 std::move(throttles))); 2832 std::move(throttles)));
2830 } 2833 }
2831 } 2834 }
2832 return handler; 2835 return handler;
2833 } 2836 }
2834 2837
2835 } // namespace content 2838 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698