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 <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 1777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1788 loader->CancelRequest(true); | 1788 loader->CancelRequest(true); |
1789 } | 1789 } |
1790 | 1790 |
1791 ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo( | 1791 ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo( |
1792 int child_id, | 1792 int child_id, |
1793 int render_view_route_id, | 1793 int render_view_route_id, |
1794 int render_frame_route_id, | 1794 int render_frame_route_id, |
1795 bool download, | 1795 bool download, |
1796 ResourceContext* context) { | 1796 ResourceContext* context) { |
1797 return new ResourceRequestInfoImpl( | 1797 return new ResourceRequestInfoImpl( |
1798 PROCESS_TYPE_RENDERER, | 1798 PROCESS_TYPE_RENDERER, child_id, render_view_route_id, |
1799 child_id, | |
1800 render_view_route_id, | |
1801 -1, // frame_tree_node_id | 1799 -1, // frame_tree_node_id |
1802 0, | 1800 0, MakeRequestID(), render_frame_route_id, |
1803 request_id_, | 1801 false, // is_main_frame |
1804 render_frame_route_id, | 1802 false, // parent_is_main_frame |
1805 false, // is_main_frame | 1803 RESOURCE_TYPE_SUB_RESOURCE, ui::PAGE_TRANSITION_LINK, |
1806 false, // parent_is_main_frame | |
1807 RESOURCE_TYPE_SUB_RESOURCE, | |
1808 ui::PAGE_TRANSITION_LINK, | |
1809 false, // should_replace_current_entry | 1804 false, // should_replace_current_entry |
1810 download, // is_download | 1805 download, // is_download |
1811 false, // is_stream | 1806 false, // is_stream |
1812 download, // allow_download | 1807 download, // allow_download |
1813 false, // has_user_gesture | 1808 false, // has_user_gesture |
1814 false, // enable_load_timing | 1809 false, // enable_load_timing |
1815 false, // enable_upload_progress | 1810 false, // enable_upload_progress |
1816 false, // do_not_prompt_for_login | 1811 false, // do_not_prompt_for_login |
1817 blink::WebReferrerPolicyDefault, | 1812 blink::WebReferrerPolicyDefault, blink::WebPageVisibilityStateVisible, |
1818 blink::WebPageVisibilityStateVisible, | |
1819 context, | 1813 context, |
1820 base::WeakPtr<ResourceMessageFilter>(), // filter | 1814 base::WeakPtr<ResourceMessageFilter>(), // filter |
1821 false, // report_raw_headers | 1815 false, // report_raw_headers |
1822 true, // is_async | 1816 true, // is_async |
1823 false, // is_using_lofi | 1817 false, // is_using_lofi |
1824 std::string(), // original_headers | 1818 std::string(), // original_headers |
1825 nullptr, // body | 1819 nullptr, // body |
1826 false); // initiated_in_secure_context | 1820 false); // initiated_in_secure_context |
1827 } | 1821 } |
1828 | 1822 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2151 AttachRequestBodyBlobDataHandles(body, blob_context); | 2145 AttachRequestBodyBlobDataHandles(body, blob_context); |
2152 // TODO(davidben): The FileSystemContext is null here. In the case where | 2146 // TODO(davidben): The FileSystemContext is null here. In the case where |
2153 // another renderer requested this navigation, this should be the same | 2147 // another renderer requested this navigation, this should be the same |
2154 // FileSystemContext passed into ShouldServiceRequest. | 2148 // FileSystemContext passed into ShouldServiceRequest. |
2155 new_request->set_upload(UploadDataStreamBuilder::Build( | 2149 new_request->set_upload(UploadDataStreamBuilder::Build( |
2156 body, blob_context, | 2150 body, blob_context, |
2157 nullptr, // file_system_context | 2151 nullptr, // file_system_context |
2158 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get())); | 2152 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get())); |
2159 } | 2153 } |
2160 | 2154 |
2161 request_id_--; | |
2162 | |
2163 // Make extra info and read footer (contains request ID). | 2155 // Make extra info and read footer (contains request ID). |
2164 // | 2156 // |
2165 // TODO(davidben): Associate the request with the FrameTreeNode and/or tab so | 2157 // TODO(davidben): Associate the request with the FrameTreeNode and/or tab so |
2166 // that IO thread -> UI thread hops will work. | 2158 // that IO thread -> UI thread hops will work. |
2167 ResourceRequestInfoImpl* extra_info = new ResourceRequestInfoImpl( | 2159 ResourceRequestInfoImpl* extra_info = new ResourceRequestInfoImpl( |
2168 PROCESS_TYPE_BROWSER, | 2160 PROCESS_TYPE_BROWSER, |
2169 -1, // child_id | 2161 -1, // child_id |
2170 -1, // route_id | 2162 -1, // route_id |
2171 info.frame_tree_node_id, | 2163 info.frame_tree_node_id, |
2172 -1, // request_data.origin_pid, | 2164 -1, // request_data.origin_pid, |
2173 request_id_, | 2165 MakeRequestID(), |
2174 -1, // request_data.render_frame_id, | 2166 -1, // request_data.render_frame_id, |
2175 info.is_main_frame, info.parent_is_main_frame, resource_type, | 2167 info.is_main_frame, info.parent_is_main_frame, resource_type, |
2176 info.common_params.transition, | 2168 info.common_params.transition, |
2177 // should_replace_current_entry. This was only maintained at layer for | 2169 // should_replace_current_entry. This was only maintained at layer for |
2178 // request transfers and isn't needed for browser-side navigations. | 2170 // request transfers and isn't needed for browser-side navigations. |
2179 false, | 2171 false, |
2180 false, // is download | 2172 false, // is download |
2181 false, // is stream | 2173 false, // is stream |
2182 info.common_params.allow_download, info.begin_params.has_user_gesture, | 2174 info.common_params.allow_download, info.begin_params.has_user_gesture, |
2183 true, // enable_load_timing | 2175 true, // enable_load_timing |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2353 bool is_download, | 2345 bool is_download, |
2354 int render_process_host_id, | 2346 int render_process_host_id, |
2355 int render_view_routing_id, | 2347 int render_view_routing_id, |
2356 int render_frame_routing_id, | 2348 int render_frame_routing_id, |
2357 ResourceContext* context) { | 2349 ResourceContext* context) { |
2358 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 2350 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
2359 DCHECK(!request->is_pending()); | 2351 DCHECK(!request->is_pending()); |
2360 | 2352 |
2361 SetReferrerForRequest(request, referrer); | 2353 SetReferrerForRequest(request, referrer); |
2362 | 2354 |
2363 request_id_--; | |
2364 | |
2365 ResourceRequestInfoImpl* info = | 2355 ResourceRequestInfoImpl* info = |
2366 CreateRequestInfo(render_process_host_id, render_view_routing_id, | 2356 CreateRequestInfo(render_process_host_id, render_view_routing_id, |
2367 render_frame_routing_id, is_download, context); | 2357 render_frame_routing_id, is_download, context); |
2368 // Request takes ownership. | 2358 // Request takes ownership. |
2369 info->AssociateWithRequest(request); | 2359 info->AssociateWithRequest(request); |
2370 } | 2360 } |
2371 | 2361 |
2372 void ResourceDispatcherHostImpl::BeginURLRequest( | 2362 void ResourceDispatcherHostImpl::BeginURLRequest( |
2373 std::unique_ptr<net::URLRequest> request, | 2363 std::unique_ptr<net::URLRequest> request, |
2374 std::unique_ptr<ResourceHandler> handler, | 2364 std::unique_ptr<ResourceHandler> handler, |
(...skipping 25 matching lines...) Expand all Loading... |
2400 blob_context->context()->GetBlobDataFromPublicURL( | 2390 blob_context->context()->GetBlobDataFromPublicURL( |
2401 request->original_url())); | 2391 request->original_url())); |
2402 } | 2392 } |
2403 handler = HandleDownloadStarted( | 2393 handler = HandleDownloadStarted( |
2404 request.get(), std::move(handler), is_content_initiated, | 2394 request.get(), std::move(handler), is_content_initiated, |
2405 true /* force_download */, true /* is_new_request */); | 2395 true /* force_download */, true /* is_new_request */); |
2406 } | 2396 } |
2407 BeginRequestInternal(std::move(request), std::move(handler)); | 2397 BeginRequestInternal(std::move(request), std::move(handler)); |
2408 } | 2398 } |
2409 | 2399 |
| 2400 int ResourceDispatcherHostImpl::MakeRequestID() { |
| 2401 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 2402 return --request_id_; |
| 2403 } |
| 2404 |
2410 void ResourceDispatcherHostImpl::StartLoading( | 2405 void ResourceDispatcherHostImpl::StartLoading( |
2411 ResourceRequestInfoImpl* info, | 2406 ResourceRequestInfoImpl* info, |
2412 std::unique_ptr<ResourceLoader> loader) { | 2407 std::unique_ptr<ResourceLoader> loader) { |
2413 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed. | 2408 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed. |
2414 tracked_objects::ScopedTracker tracking_profile( | 2409 tracked_objects::ScopedTracker tracking_profile( |
2415 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 2410 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
2416 "456331 ResourceDispatcherHostImpl::StartLoading")); | 2411 "456331 ResourceDispatcherHostImpl::StartLoading")); |
2417 | 2412 |
2418 ResourceLoader* loader_ptr = loader.get(); | 2413 ResourceLoader* loader_ptr = loader.get(); |
2419 DCHECK(pending_loaders_[info->GetGlobalRequestID()] == nullptr); | 2414 DCHECK(pending_loaders_[info->GetGlobalRequestID()] == nullptr); |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2744 &throttles); | 2739 &throttles); |
2745 if (!throttles.empty()) { | 2740 if (!throttles.empty()) { |
2746 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, | 2741 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, |
2747 std::move(throttles))); | 2742 std::move(throttles))); |
2748 } | 2743 } |
2749 } | 2744 } |
2750 return handler; | 2745 return handler; |
2751 } | 2746 } |
2752 | 2747 |
2753 } // namespace content | 2748 } // namespace content |
OLD | NEW |