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 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1834 const ResourceRequesterInfo* requester_info, | 1834 const ResourceRequesterInfo* requester_info, |
1835 int request_id) { | 1835 int request_id) { |
1836 CancelRequestFromRenderer( | 1836 CancelRequestFromRenderer( |
1837 GlobalRequestID(requester_info->child_id(), request_id)); | 1837 GlobalRequestID(requester_info->child_id(), request_id)); |
1838 } | 1838 } |
1839 | 1839 |
1840 ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo( | 1840 ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo( |
1841 int child_id, | 1841 int child_id, |
1842 int render_view_route_id, | 1842 int render_view_route_id, |
1843 int render_frame_route_id, | 1843 int render_frame_route_id, |
| 1844 int service_worker_provider_id, |
1844 bool download, | 1845 bool download, |
1845 ResourceContext* context) { | 1846 ResourceContext* context, |
| 1847 ServiceWorkerContextWrapper* service_worker_context) { |
1846 return new ResourceRequestInfoImpl( | 1848 return new ResourceRequestInfoImpl( |
1847 ResourceRequesterInfo::CreateForDownloadOrPageSave(child_id), | 1849 ResourceRequesterInfo::CreateForDownloadOrPageSave( |
| 1850 child_id, service_worker_context), |
1848 render_view_route_id, | 1851 render_view_route_id, |
1849 -1, // frame_tree_node_id | 1852 -1, // frame_tree_node_id |
1850 0, MakeRequestID(), render_frame_route_id, | 1853 0, MakeRequestID(), render_frame_route_id, |
1851 false, // is_main_frame | 1854 false, // is_main_frame |
1852 false, // parent_is_main_frame | 1855 false, // parent_is_main_frame |
1853 RESOURCE_TYPE_SUB_RESOURCE, ui::PAGE_TRANSITION_LINK, | 1856 RESOURCE_TYPE_SUB_RESOURCE, ui::PAGE_TRANSITION_LINK, |
1854 false, // should_replace_current_entry | 1857 false, // should_replace_current_entry |
1855 download, // is_download | 1858 download, // is_download |
1856 false, // is_stream | 1859 false, // is_stream |
1857 download, // allow_download | 1860 download, // allow_download |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2396 StartLoading(info, std::move(loader)); | 2399 StartLoading(info, std::move(loader)); |
2397 } | 2400 } |
2398 | 2401 |
2399 void ResourceDispatcherHostImpl::InitializeURLRequest( | 2402 void ResourceDispatcherHostImpl::InitializeURLRequest( |
2400 net::URLRequest* request, | 2403 net::URLRequest* request, |
2401 const Referrer& referrer, | 2404 const Referrer& referrer, |
2402 bool is_download, | 2405 bool is_download, |
2403 int render_process_host_id, | 2406 int render_process_host_id, |
2404 int render_view_routing_id, | 2407 int render_view_routing_id, |
2405 int render_frame_routing_id, | 2408 int render_frame_routing_id, |
2406 ResourceContext* context) { | 2409 int service_worker_provider_id, |
| 2410 ResourceContext* context, |
| 2411 ServiceWorkerContextWrapper* service_worker_context) { |
2407 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 2412 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
2408 DCHECK(!request->is_pending()); | 2413 DCHECK(!request->is_pending()); |
2409 | 2414 |
2410 SetReferrerForRequest(request, referrer); | 2415 SetReferrerForRequest(request, referrer); |
2411 | 2416 |
2412 ResourceRequestInfoImpl* info = | 2417 ResourceRequestInfoImpl* info = CreateRequestInfo( |
2413 CreateRequestInfo(render_process_host_id, render_view_routing_id, | 2418 render_process_host_id, render_view_routing_id, render_frame_routing_id, |
2414 render_frame_routing_id, is_download, context); | 2419 service_worker_provider_id, is_download, context, service_worker_context); |
2415 // Request takes ownership. | 2420 // Request takes ownership. |
2416 info->AssociateWithRequest(request); | 2421 info->AssociateWithRequest(request); |
| 2422 |
| 2423 if (!service_worker_context || service_worker_provider_id == -1) |
| 2424 return; |
| 2425 |
| 2426 ChromeBlobStorageContext* blob_context = |
| 2427 GetChromeBlobStorageContextForResourceContext(context); |
| 2428 |
| 2429 ServiceWorkerRequestHandler::InitializeHandler( |
| 2430 request, service_worker_context, blob_context->context(), |
| 2431 render_process_host_id, service_worker_provider_id, false, |
| 2432 FETCH_REQUEST_MODE_NO_CORS, FETCH_CREDENTIALS_MODE_INCLUDE, |
| 2433 FetchRedirectMode::FOLLOW_MODE, |
| 2434 RESOURCE_TYPE_SUB_RESOURCE /* TODO(horo) */, |
| 2435 REQUEST_CONTEXT_TYPE_DOWNLOAD, REQUEST_CONTEXT_FRAME_TYPE_NONE, |
| 2436 scoped_refptr<ResourceRequestBodyImpl>() /* TODO(horo) */); |
2417 } | 2437 } |
2418 | 2438 |
2419 void ResourceDispatcherHostImpl::BeginURLRequest( | 2439 void ResourceDispatcherHostImpl::BeginURLRequest( |
2420 std::unique_ptr<net::URLRequest> request, | 2440 std::unique_ptr<net::URLRequest> request, |
2421 std::unique_ptr<ResourceHandler> handler, | 2441 std::unique_ptr<ResourceHandler> handler, |
2422 bool is_download, | 2442 bool is_download, |
2423 bool is_content_initiated, | 2443 bool is_content_initiated, |
2424 bool do_not_prompt_for_login, | 2444 bool do_not_prompt_for_login, |
2425 ResourceContext* context) { | 2445 ResourceContext* context) { |
2426 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 2446 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2815 &throttles); | 2835 &throttles); |
2816 if (!throttles.empty()) { | 2836 if (!throttles.empty()) { |
2817 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, | 2837 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, |
2818 std::move(throttles))); | 2838 std::move(throttles))); |
2819 } | 2839 } |
2820 } | 2840 } |
2821 return handler; | 2841 return handler; |
2822 } | 2842 } |
2823 | 2843 |
2824 } // namespace content | 2844 } // namespace content |
OLD | NEW |