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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 1310743003: Consistently use LoFi for an entire page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test fix Created 5 years, 2 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 <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 // Sync loads should have maximum priority and should be the only 1315 // Sync loads should have maximum priority and should be the only
1316 // requets that have the ignore limits flag set. 1316 // requets that have the ignore limits flag set.
1317 if (is_sync_load) { 1317 if (is_sync_load) {
1318 DCHECK_EQ(request_data.priority, net::MAXIMUM_PRIORITY); 1318 DCHECK_EQ(request_data.priority, net::MAXIMUM_PRIORITY);
1319 DCHECK_NE(load_flags & net::LOAD_IGNORE_LIMITS, 0); 1319 DCHECK_NE(load_flags & net::LOAD_IGNORE_LIMITS, 0);
1320 } else { 1320 } else {
1321 DCHECK_EQ(load_flags & net::LOAD_IGNORE_LIMITS, 0); 1321 DCHECK_EQ(load_flags & net::LOAD_IGNORE_LIMITS, 0);
1322 } 1322 }
1323 new_request->SetLoadFlags(load_flags); 1323 new_request->SetLoadFlags(load_flags);
1324 1324
1325 bool is_using_lofi;
1326 if (request_data.lofi_state == LOFI_UNSPECIFIED && delegate_) {
1327 is_using_lofi =
1328 delegate_->ShouldEnableLoFiMode(new_request.get(), resource_context);
1329 } else if (request_data.lofi_state == LOFI_ON) {
1330 is_using_lofi = true;
1331 } else {
1332 is_using_lofi = false;
1333 }
1334
1325 // Make extra info and read footer (contains request ID). 1335 // Make extra info and read footer (contains request ID).
1326 ResourceRequestInfoImpl* extra_info = new ResourceRequestInfoImpl( 1336 ResourceRequestInfoImpl* extra_info = new ResourceRequestInfoImpl(
1327 process_type, child_id, route_id, 1337 process_type, child_id, route_id,
1328 -1, // frame_tree_node_id 1338 -1, // frame_tree_node_id
1329 request_data.origin_pid, 1339 request_data.origin_pid,
1330 request_id, 1340 request_id,
1331 request_data.render_frame_id, 1341 request_data.render_frame_id,
1332 request_data.is_main_frame, 1342 request_data.is_main_frame,
1333 request_data.parent_is_main_frame, 1343 request_data.parent_is_main_frame,
1334 request_data.parent_render_frame_id, 1344 request_data.parent_render_frame_id,
1335 request_data.resource_type, 1345 request_data.resource_type,
1336 request_data.transition_type, 1346 request_data.transition_type,
1337 request_data.should_replace_current_entry, 1347 request_data.should_replace_current_entry,
1338 false, // is download 1348 false, // is download
1339 false, // is stream 1349 false, // is stream
1340 allow_download, 1350 allow_download,
1341 request_data.has_user_gesture, 1351 request_data.has_user_gesture,
1342 request_data.enable_load_timing, 1352 request_data.enable_load_timing,
1343 request_data.enable_upload_progress, 1353 request_data.enable_upload_progress,
1344 do_not_prompt_for_login, 1354 do_not_prompt_for_login,
1345 request_data.referrer_policy, 1355 request_data.referrer_policy,
1346 request_data.visiblity_state, 1356 request_data.visiblity_state,
1347 resource_context, filter_->GetWeakPtr(), 1357 resource_context, filter_->GetWeakPtr(),
1348 report_raw_headers, 1358 report_raw_headers,
1349 !is_sync_load); 1359 !is_sync_load,
1360 is_using_lofi);
1350 // Request takes ownership. 1361 // Request takes ownership.
1351 extra_info->AssociateWithRequest(new_request.get()); 1362 extra_info->AssociateWithRequest(new_request.get());
1352 1363
1353 if (new_request->url().SchemeIs(url::kBlobScheme)) { 1364 if (new_request->url().SchemeIs(url::kBlobScheme)) {
1354 // Hang on to a reference to ensure the blob is not released prior 1365 // Hang on to a reference to ensure the blob is not released prior
1355 // to the job being started. 1366 // to the job being started.
1356 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 1367 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
1357 new_request.get(), 1368 new_request.get(),
1358 filter_->blob_storage_context()->context()->GetBlobDataFromPublicURL( 1369 filter_->blob_storage_context()->context()->GetBlobDataFromPublicURL(
1359 new_request->url())); 1370 new_request->url()));
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 download, // allow_download 1636 download, // allow_download
1626 false, // has_user_gesture 1637 false, // has_user_gesture
1627 false, // enable_load_timing 1638 false, // enable_load_timing
1628 false, // enable_upload_progress 1639 false, // enable_upload_progress
1629 false, // do_not_prompt_for_login 1640 false, // do_not_prompt_for_login
1630 blink::WebReferrerPolicyDefault, 1641 blink::WebReferrerPolicyDefault,
1631 blink::WebPageVisibilityStateVisible, 1642 blink::WebPageVisibilityStateVisible,
1632 context, 1643 context,
1633 base::WeakPtr<ResourceMessageFilter>(), // filter 1644 base::WeakPtr<ResourceMessageFilter>(), // filter
1634 false, // report_raw_headers 1645 false, // report_raw_headers
1635 true); // is_async 1646 true, // is_async
1647 false); // is_using_lofi
1636 } 1648 }
1637 1649
1638 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id, 1650 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id,
1639 int route_id, 1651 int route_id,
1640 bool is_visible, 1652 bool is_visible,
1641 bool is_audible) { 1653 bool is_audible) {
1642 scheduler_->OnClientCreated(child_id, route_id, is_visible, is_audible); 1654 scheduler_->OnClientCreated(child_id, route_id, is_visible, is_audible);
1643 } 1655 }
1644 1656
1645 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted( 1657 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted(
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
2035 new_request->set_upload(UploadDataStreamBuilder::Build( 2047 new_request->set_upload(UploadDataStreamBuilder::Build(
2036 info.request_body.get(), 2048 info.request_body.get(),
2037 blob_context, 2049 blob_context,
2038 nullptr, // file_system_context 2050 nullptr, // file_system_context
2039 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) 2051 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)
2040 .get())); 2052 .get()));
2041 } 2053 }
2042 2054
2043 request_id_--; 2055 request_id_--;
2044 2056
2057 bool is_using_lofi;
2058 if (info.common_params.lofi_state == LOFI_UNSPECIFIED && delegate_) {
2059 is_using_lofi =
2060 delegate_->ShouldEnableLoFiMode(new_request.get(), resource_context);
2061 } else if (info.common_params.lofi_state == LOFI_ON) {
2062 is_using_lofi = true;
2063 } else {
2064 is_using_lofi = false;
2065 }
2066
2045 // Make extra info and read footer (contains request ID). 2067 // Make extra info and read footer (contains request ID).
2046 // 2068 //
2047 // TODO(davidben): Associate the request with the FrameTreeNode and/or tab so 2069 // TODO(davidben): Associate the request with the FrameTreeNode and/or tab so
2048 // that IO thread -> UI thread hops will work. 2070 // that IO thread -> UI thread hops will work.
2049 ResourceRequestInfoImpl* extra_info = new ResourceRequestInfoImpl( 2071 ResourceRequestInfoImpl* extra_info = new ResourceRequestInfoImpl(
2050 PROCESS_TYPE_BROWSER, 2072 PROCESS_TYPE_BROWSER,
2051 -1, // child_id 2073 -1, // child_id
2052 -1, // route_id 2074 -1, // route_id
2053 info.frame_tree_node_id, 2075 info.frame_tree_node_id,
2054 -1, // request_data.origin_pid, 2076 -1, // request_data.origin_pid,
(...skipping 15 matching lines...) Expand all
2070 false, // enable_upload_progress 2092 false, // enable_upload_progress
2071 false, // do_not_prompt_for_login 2093 false, // do_not_prompt_for_login
2072 info.common_params.referrer.policy, 2094 info.common_params.referrer.policy,
2073 // TODO(davidben): This is only used for prerenders. Replace 2095 // TODO(davidben): This is only used for prerenders. Replace
2074 // is_showing with something for that. Or maybe it just comes from the 2096 // is_showing with something for that. Or maybe it just comes from the
2075 // same mechanism as the cookie one. 2097 // same mechanism as the cookie one.
2076 blink::WebPageVisibilityStateVisible, 2098 blink::WebPageVisibilityStateVisible,
2077 resource_context, 2099 resource_context,
2078 base::WeakPtr<ResourceMessageFilter>(), // filter 2100 base::WeakPtr<ResourceMessageFilter>(), // filter
2079 false, // request_data.report_raw_headers 2101 false, // request_data.report_raw_headers
2080 true); 2102 true,
2103 is_using_lofi);
2081 // Request takes ownership. 2104 // Request takes ownership.
2082 extra_info->AssociateWithRequest(new_request.get()); 2105 extra_info->AssociateWithRequest(new_request.get());
2083 2106
2084 if (new_request->url().SchemeIs(url::kBlobScheme)) { 2107 if (new_request->url().SchemeIs(url::kBlobScheme)) {
2085 // Hang on to a reference to ensure the blob is not released prior 2108 // Hang on to a reference to ensure the blob is not released prior
2086 // to the job being started. 2109 // to the job being started.
2087 ChromeBlobStorageContext* blob_context = 2110 ChromeBlobStorageContext* blob_context =
2088 GetChromeBlobStorageContextForResourceContext(resource_context); 2111 GetChromeBlobStorageContextForResourceContext(resource_context);
2089 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 2112 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
2090 new_request.get(), 2113 new_request.get(),
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 load_flags |= net::LOAD_PREFETCH; 2449 load_flags |= net::LOAD_PREFETCH;
2427 } 2450 }
2428 2451
2429 if (is_sync_load) 2452 if (is_sync_load)
2430 load_flags |= net::LOAD_IGNORE_LIMITS; 2453 load_flags |= net::LOAD_IGNORE_LIMITS;
2431 2454
2432 return load_flags; 2455 return load_flags;
2433 } 2456 }
2434 2457
2435 } // namespace content 2458 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698