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

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: add back previews_unspecified 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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 DCHECK_CURRENTLY_ON(BrowserThread::UI); 350 DCHECK_CURRENTLY_ON(BrowserThread::UI);
351 RenderFrameHostImpl* host = 351 RenderFrameHostImpl* host =
352 RenderFrameHostImpl::FromID(render_process_id, render_frame_id); 352 RenderFrameHostImpl::FromID(render_process_id, render_frame_id);
353 if (host != nullptr) { 353 if (host != nullptr) {
354 DCHECK(host->frame_tree_node()->IsMainFrame()); 354 DCHECK(host->frame_tree_node()->IsMainFrame());
355 host->frame_tree_node()->navigator()->LogResourceRequestTime( 355 host->frame_tree_node()->navigator()->LogResourceRequestTime(
356 timestamp, url); 356 timestamp, url);
357 } 357 }
358 } 358 }
359 359
360 bool IsUsingLoFi(LoFiState lofi_state, 360 int GetPreviewsState(int previews_state,
nasko 2016/12/08 22:19:32 PreviewsState
megjablon 2016/12/09 20:35:54 Done.
361 ResourceDispatcherHostDelegate* delegate, 361 ResourceDispatcherHostDelegate* delegate,
362 const net::URLRequest& request, 362 const net::URLRequest& request,
363 ResourceContext* resource_context, 363 ResourceContext* resource_context,
364 bool is_main_frame) { 364 bool is_main_frame) {
365 if (lofi_state == LOFI_UNSPECIFIED && delegate && is_main_frame) 365 // previews_state is set to PREVIEWS_OFF when reloading with Lo-Fi disabled.
366 return delegate->ShouldEnableLoFiMode(request, resource_context); 366 // A previews_state of zero means that the state has not been set, and the
367 return lofi_state == LOFI_ON; 367 // browser process should decide whether or not to request Preview types.
368 if (previews_state == 0 && delegate && is_main_frame)
369 return delegate->GetPreviewsState(request, resource_context);
370 return previews_state;
368 } 371 }
369 372
370 // The following functions simplify code paths where the UI thread notifies the 373 // The following functions simplify code paths where the UI thread notifies the
371 // ResourceDispatcherHostImpl of information pertaining to loading behavior of 374 // ResourceDispatcherHostImpl of information pertaining to loading behavior of
372 // frame hosts. 375 // frame hosts.
373 void NotifyForRouteOnIO( 376 void NotifyForRouteOnIO(
374 base::Callback<void(ResourceDispatcherHostImpl*, 377 base::Callback<void(ResourceDispatcherHostImpl*,
375 const GlobalFrameRoutingId&)> frame_callback, 378 const GlobalFrameRoutingId&)> frame_callback,
376 const GlobalFrameRoutingId& global_routing_id) { 379 const GlobalFrameRoutingId& global_routing_id) {
377 DCHECK_CURRENTLY_ON(BrowserThread::IO); 380 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 request_data.is_main_frame, request_data.parent_is_main_frame, 1544 request_data.is_main_frame, request_data.parent_is_main_frame,
1542 request_data.resource_type, request_data.transition_type, 1545 request_data.resource_type, request_data.transition_type,
1543 request_data.should_replace_current_entry, 1546 request_data.should_replace_current_entry,
1544 false, // is download 1547 false, // is download
1545 false, // is stream 1548 false, // is stream
1546 allow_download, request_data.has_user_gesture, 1549 allow_download, request_data.has_user_gesture,
1547 request_data.enable_load_timing, request_data.enable_upload_progress, 1550 request_data.enable_load_timing, request_data.enable_upload_progress,
1548 do_not_prompt_for_login, request_data.referrer_policy, 1551 do_not_prompt_for_login, request_data.referrer_policy,
1549 request_data.visibility_state, resource_context, report_raw_headers, 1552 request_data.visibility_state, resource_context, report_raw_headers,
1550 !is_sync_load, 1553 !is_sync_load,
1551 IsUsingLoFi(request_data.lofi_state, delegate_, *new_request, 1554 GetPreviewsState(request_data.previews_state, delegate_, *new_request,
1552 resource_context, 1555 resource_context,
1553 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME), 1556 request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME),
1554 support_async_revalidation ? request_data.headers : std::string(), 1557 support_async_revalidation ? request_data.headers : std::string(),
1555 request_data.request_body, request_data.initiated_in_secure_context); 1558 request_data.request_body, request_data.initiated_in_secure_context);
1556 // Request takes ownership. 1559 // Request takes ownership.
1557 extra_info->AssociateWithRequest(new_request.get()); 1560 extra_info->AssociateWithRequest(new_request.get());
1558 1561
1559 if (new_request->url().SchemeIs(url::kBlobScheme)) { 1562 if (new_request->url().SchemeIs(url::kBlobScheme)) {
1560 // Hang on to a reference to ensure the blob is not released prior 1563 // Hang on to a reference to ensure the blob is not released prior
1561 // to the job being started. 1564 // to the job being started.
1562 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 1565 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
1563 new_request.get(), requester_info->blob_storage_context() 1566 new_request.get(), requester_info->blob_storage_context()
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 ResourceRequesterInfo* requester_info, 1835 ResourceRequesterInfo* requester_info,
1833 int request_id) { 1836 int request_id) {
1834 CancelRequestFromRenderer( 1837 CancelRequestFromRenderer(
1835 GlobalRequestID(requester_info->child_id(), request_id)); 1838 GlobalRequestID(requester_info->child_id(), request_id));
1836 } 1839 }
1837 1840
1838 ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo( 1841 ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo(
1839 int child_id, 1842 int child_id,
1840 int render_view_route_id, 1843 int render_view_route_id,
1841 int render_frame_route_id, 1844 int render_frame_route_id,
1845 int previews_state,
nasko 2016/12/08 22:19:33 PreviewsState
megjablon 2016/12/09 20:35:54 Done.
1842 bool download, 1846 bool download,
1843 ResourceContext* context) { 1847 ResourceContext* context) {
1844 return new ResourceRequestInfoImpl( 1848 return new ResourceRequestInfoImpl(
1845 ResourceRequesterInfo::CreateForDownloadOrPageSave(child_id), 1849 ResourceRequesterInfo::CreateForDownloadOrPageSave(child_id),
1846 render_view_route_id, 1850 render_view_route_id,
1847 -1, // frame_tree_node_id 1851 -1, // frame_tree_node_id
1848 0, MakeRequestID(), render_frame_route_id, 1852 0, MakeRequestID(), render_frame_route_id,
1849 false, // is_main_frame 1853 false, // is_main_frame
1850 false, // parent_is_main_frame 1854 false, // parent_is_main_frame
1851 RESOURCE_TYPE_SUB_RESOURCE, ui::PAGE_TRANSITION_LINK, 1855 RESOURCE_TYPE_SUB_RESOURCE, ui::PAGE_TRANSITION_LINK,
1852 false, // should_replace_current_entry 1856 false, // should_replace_current_entry
1853 download, // is_download 1857 download, // is_download
1854 false, // is_stream 1858 false, // is_stream
1855 download, // allow_download 1859 download, // allow_download
1856 false, // has_user_gesture 1860 false, // has_user_gesture
1857 false, // enable_load_timing 1861 false, // enable_load_timing
1858 false, // enable_upload_progress 1862 false, // enable_upload_progress
1859 false, // do_not_prompt_for_login 1863 false, // do_not_prompt_for_login
1860 blink::WebReferrerPolicyDefault, blink::WebPageVisibilityStateVisible, 1864 blink::WebReferrerPolicyDefault, blink::WebPageVisibilityStateVisible,
1861 context, 1865 context,
1862 false, // report_raw_headers 1866 false, // report_raw_headers
1863 true, // is_async 1867 true, // is_async
1864 false, // is_using_lofi 1868 previews_state, // previews_state
1865 std::string(), // original_headers 1869 std::string(), // original_headers
1866 nullptr, // body 1870 nullptr, // body
1867 false); // initiated_in_secure_context 1871 false); // initiated_in_secure_context
1868 } 1872 }
1869 1873
1870 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id, 1874 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id,
1871 int route_id) { 1875 int route_id) {
1872 scheduler_->OnClientCreated(child_id, route_id); 1876 scheduler_->OnClientCreated(child_id, route_id);
1873 } 1877 }
1874 1878
1875 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted(int child_id, 1879 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted(int child_id,
1876 int route_id) { 1880 int route_id) {
1877 scheduler_->OnClientDeleted(child_id, route_id); 1881 scheduler_->OnClientDeleted(child_id, route_id);
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
2224 info.common_params.gesture == NavigationGestureUser, 2228 info.common_params.gesture == NavigationGestureUser,
2225 true, // enable_load_timing 2229 true, // enable_load_timing
2226 false, // enable_upload_progress 2230 false, // enable_upload_progress
2227 false, // do_not_prompt_for_login 2231 false, // do_not_prompt_for_login
2228 info.common_params.referrer.policy, 2232 info.common_params.referrer.policy,
2229 // TODO(davidben): This is only used for prerenders. Replace 2233 // TODO(davidben): This is only used for prerenders. Replace
2230 // is_showing with something for that. Or maybe it just comes from the 2234 // is_showing with something for that. Or maybe it just comes from the
2231 // same mechanism as the cookie one. 2235 // same mechanism as the cookie one.
2232 blink::WebPageVisibilityStateVisible, resource_context, 2236 blink::WebPageVisibilityStateVisible, resource_context,
2233 info.report_raw_headers, 2237 info.report_raw_headers,
2234 true, // is_async 2238 true, // is_async
2235 IsUsingLoFi(info.common_params.lofi_state, delegate_, *new_request, 2239 GetPreviewsState(info.common_params.previews_state, delegate_,
2236 resource_context, info.is_main_frame), 2240 *new_request, resource_context, info.is_main_frame),
2237 // The original_headers field is for stale-while-revalidate but the 2241 // The original_headers field is for stale-while-revalidate but the
2238 // feature doesn't work with PlzNavigate, so it's just a placeholder 2242 // feature doesn't work with PlzNavigate, so it's just a placeholder
2239 // here. 2243 // here.
2240 // TODO(ricea): Make the feature work with stale-while-revalidate 2244 // TODO(ricea): Make the feature work with stale-while-revalidate
2241 // and clean this up. 2245 // and clean this up.
2242 std::string(), // original_headers 2246 std::string(), // original_headers
2243 info.common_params.post_data, 2247 info.common_params.post_data,
2244 // TODO(mek): Currently initiated_in_secure_context is only used for 2248 // TODO(mek): Currently initiated_in_secure_context is only used for
2245 // subresource requests, so it doesn't matter what value it gets here. 2249 // subresource requests, so it doesn't matter what value it gets here.
2246 // If in the future this changes this should be updated to somehow get a 2250 // If in the future this changes this should be updated to somehow get a
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 StartLoading(info, std::move(loader)); 2399 StartLoading(info, std::move(loader));
2396 } 2400 }
2397 2401
2398 void ResourceDispatcherHostImpl::InitializeURLRequest( 2402 void ResourceDispatcherHostImpl::InitializeURLRequest(
2399 net::URLRequest* request, 2403 net::URLRequest* request,
2400 const Referrer& referrer, 2404 const Referrer& referrer,
2401 bool is_download, 2405 bool is_download,
2402 int render_process_host_id, 2406 int render_process_host_id,
2403 int render_view_routing_id, 2407 int render_view_routing_id,
2404 int render_frame_routing_id, 2408 int render_frame_routing_id,
2409 int previews_state,
nasko 2016/12/08 22:19:32 PreviewsState
megjablon 2016/12/09 20:35:54 Done.
2405 ResourceContext* context) { 2410 ResourceContext* context) {
2406 DCHECK_CURRENTLY_ON(BrowserThread::IO); 2411 DCHECK_CURRENTLY_ON(BrowserThread::IO);
2407 DCHECK(!request->is_pending()); 2412 DCHECK(!request->is_pending());
2408 2413
2409 SetReferrerForRequest(request, referrer); 2414 SetReferrerForRequest(request, referrer);
2410 2415
2411 ResourceRequestInfoImpl* info = 2416 ResourceRequestInfoImpl* info = CreateRequestInfo(
2412 CreateRequestInfo(render_process_host_id, render_view_routing_id, 2417 render_process_host_id, render_view_routing_id, render_frame_routing_id,
2413 render_frame_routing_id, is_download, context); 2418 previews_state, is_download, context);
2414 // Request takes ownership. 2419 // Request takes ownership.
2415 info->AssociateWithRequest(request); 2420 info->AssociateWithRequest(request);
2416 } 2421 }
2417 2422
2418 void ResourceDispatcherHostImpl::BeginURLRequest( 2423 void ResourceDispatcherHostImpl::BeginURLRequest(
2419 std::unique_ptr<net::URLRequest> request, 2424 std::unique_ptr<net::URLRequest> request,
2420 std::unique_ptr<ResourceHandler> handler, 2425 std::unique_ptr<ResourceHandler> handler,
2421 bool is_download, 2426 bool is_download,
2422 bool is_content_initiated, 2427 bool is_content_initiated,
2423 bool do_not_prompt_for_login, 2428 bool do_not_prompt_for_login,
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
2814 &throttles); 2819 &throttles);
2815 if (!throttles.empty()) { 2820 if (!throttles.empty()) {
2816 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, 2821 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
2817 std::move(throttles))); 2822 std::move(throttles)));
2818 } 2823 }
2819 } 2824 }
2820 return handler; 2825 return handler;
2821 } 2826 }
2822 2827
2823 } // namespace content 2828 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698