OLD | NEW |
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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 429 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
430 RenderFrameHostImpl* host = | 430 RenderFrameHostImpl* host = |
431 RenderFrameHostImpl::FromID(render_process_id, render_frame_id); | 431 RenderFrameHostImpl::FromID(render_process_id, render_frame_id); |
432 if (host != NULL) { | 432 if (host != NULL) { |
433 DCHECK(host->frame_tree_node()->IsMainFrame()); | 433 DCHECK(host->frame_tree_node()->IsMainFrame()); |
434 host->frame_tree_node()->navigator()->LogResourceRequestTime( | 434 host->frame_tree_node()->navigator()->LogResourceRequestTime( |
435 timestamp, url); | 435 timestamp, url); |
436 } | 436 } |
437 } | 437 } |
438 | 438 |
| 439 bool IsUsingLoFi(LoFiState lofi_state, |
| 440 ResourceDispatcherHostDelegate* delegate, |
| 441 const net::URLRequest& request, |
| 442 ResourceContext* resource_context) { |
| 443 if (lofi_state == LOFI_UNSPECIFIED && delegate) |
| 444 return delegate->ShouldEnableLoFiMode(request, resource_context); |
| 445 return lofi_state == LOFI_ON; |
| 446 } |
| 447 |
439 } // namespace | 448 } // namespace |
440 | 449 |
441 // static | 450 // static |
442 ResourceDispatcherHost* ResourceDispatcherHost::Get() { | 451 ResourceDispatcherHost* ResourceDispatcherHost::Get() { |
443 return g_resource_dispatcher_host; | 452 return g_resource_dispatcher_host; |
444 } | 453 } |
445 | 454 |
446 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() | 455 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() |
447 : save_file_manager_(new SaveFileManager()), | 456 : save_file_manager_(new SaveFileManager()), |
448 request_id_(-1), | 457 request_id_(-1), |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1339 false, // is stream | 1348 false, // is stream |
1340 allow_download, | 1349 allow_download, |
1341 request_data.has_user_gesture, | 1350 request_data.has_user_gesture, |
1342 request_data.enable_load_timing, | 1351 request_data.enable_load_timing, |
1343 request_data.enable_upload_progress, | 1352 request_data.enable_upload_progress, |
1344 do_not_prompt_for_login, | 1353 do_not_prompt_for_login, |
1345 request_data.referrer_policy, | 1354 request_data.referrer_policy, |
1346 request_data.visiblity_state, | 1355 request_data.visiblity_state, |
1347 resource_context, filter_->GetWeakPtr(), | 1356 resource_context, filter_->GetWeakPtr(), |
1348 report_raw_headers, | 1357 report_raw_headers, |
1349 !is_sync_load); | 1358 !is_sync_load, |
| 1359 IsUsingLoFi(request_data.lofi_state, delegate_, |
| 1360 *new_request, resource_context)); |
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 Loading... |
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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2047 // TODO(davidben): Associate the request with the FrameTreeNode and/or tab so | 2059 // TODO(davidben): Associate the request with the FrameTreeNode and/or tab so |
2048 // that IO thread -> UI thread hops will work. | 2060 // that IO thread -> UI thread hops will work. |
2049 ResourceRequestInfoImpl* extra_info = new ResourceRequestInfoImpl( | 2061 ResourceRequestInfoImpl* extra_info = new ResourceRequestInfoImpl( |
2050 PROCESS_TYPE_BROWSER, | 2062 PROCESS_TYPE_BROWSER, |
2051 -1, // child_id | 2063 -1, // child_id |
2052 -1, // route_id | 2064 -1, // route_id |
2053 info.frame_tree_node_id, | 2065 info.frame_tree_node_id, |
2054 -1, // request_data.origin_pid, | 2066 -1, // request_data.origin_pid, |
2055 request_id_, | 2067 request_id_, |
2056 -1, // request_data.render_frame_id, | 2068 -1, // request_data.render_frame_id, |
2057 info.is_main_frame, | 2069 info.is_main_frame, info.parent_is_main_frame, |
2058 info.parent_is_main_frame, | |
2059 -1, // request_data.parent_render_frame_id, | 2070 -1, // request_data.parent_render_frame_id, |
2060 resource_type, | 2071 resource_type, info.common_params.transition, |
2061 info.common_params.transition, | |
2062 // should_replace_current_entry. This was only maintained at layer for | 2072 // should_replace_current_entry. This was only maintained at layer for |
2063 // request transfers and isn't needed for browser-side navigations. | 2073 // request transfers and isn't needed for browser-side navigations. |
2064 false, | 2074 false, |
2065 false, // is download | 2075 false, // is download |
2066 false, // is stream | 2076 false, // is stream |
2067 info.common_params.allow_download, | 2077 info.common_params.allow_download, info.begin_params.has_user_gesture, |
2068 info.begin_params.has_user_gesture, | |
2069 true, // enable_load_timing | 2078 true, // enable_load_timing |
2070 false, // enable_upload_progress | 2079 false, // enable_upload_progress |
2071 false, // do_not_prompt_for_login | 2080 false, // do_not_prompt_for_login |
2072 info.common_params.referrer.policy, | 2081 info.common_params.referrer.policy, |
2073 // TODO(davidben): This is only used for prerenders. Replace | 2082 // TODO(davidben): This is only used for prerenders. Replace |
2074 // is_showing with something for that. Or maybe it just comes from the | 2083 // is_showing with something for that. Or maybe it just comes from the |
2075 // same mechanism as the cookie one. | 2084 // same mechanism as the cookie one. |
2076 blink::WebPageVisibilityStateVisible, | 2085 blink::WebPageVisibilityStateVisible, resource_context, |
2077 resource_context, | |
2078 base::WeakPtr<ResourceMessageFilter>(), // filter | 2086 base::WeakPtr<ResourceMessageFilter>(), // filter |
2079 false, // request_data.report_raw_headers | 2087 false, // request_data.report_raw_headers |
2080 true); | 2088 true, |
| 2089 IsUsingLoFi(info.common_params.lofi_state, delegate_, |
| 2090 *new_request, resource_context)); |
2081 // Request takes ownership. | 2091 // Request takes ownership. |
2082 extra_info->AssociateWithRequest(new_request.get()); | 2092 extra_info->AssociateWithRequest(new_request.get()); |
2083 | 2093 |
2084 if (new_request->url().SchemeIs(url::kBlobScheme)) { | 2094 if (new_request->url().SchemeIs(url::kBlobScheme)) { |
2085 // Hang on to a reference to ensure the blob is not released prior | 2095 // Hang on to a reference to ensure the blob is not released prior |
2086 // to the job being started. | 2096 // to the job being started. |
2087 ChromeBlobStorageContext* blob_context = | 2097 ChromeBlobStorageContext* blob_context = |
2088 GetChromeBlobStorageContextForResourceContext(resource_context); | 2098 GetChromeBlobStorageContextForResourceContext(resource_context); |
2089 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | 2099 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( |
2090 new_request.get(), | 2100 new_request.get(), |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2426 load_flags |= net::LOAD_PREFETCH; | 2436 load_flags |= net::LOAD_PREFETCH; |
2427 } | 2437 } |
2428 | 2438 |
2429 if (is_sync_load) | 2439 if (is_sync_load) |
2430 load_flags |= net::LOAD_IGNORE_LIMITS; | 2440 load_flags |= net::LOAD_IGNORE_LIMITS; |
2431 | 2441 |
2432 return load_flags; | 2442 return load_flags; |
2433 } | 2443 } |
2434 | 2444 |
2435 } // namespace content | 2445 } // namespace content |
OLD | NEW |