OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #include "content/browser/loader/navigation_url_loader_network_service.h" | 5 #include "content/browser/loader/navigation_url_loader_network_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 mojom::URLLoaderFactoryPtrInfo factory_for_webui, | 118 mojom::URLLoaderFactoryPtrInfo factory_for_webui, |
119 const base::Callback<WebContents*(void)>& web_contents_getter, | 119 const base::Callback<WebContents*(void)>& web_contents_getter, |
120 std::unique_ptr<service_manager::Connector> connector) { | 120 std::unique_ptr<service_manager::Connector> connector) { |
121 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 121 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
122 web_contents_getter_ = web_contents_getter; | 122 web_contents_getter_ = web_contents_getter; |
123 const ResourceType resource_type = request_info->is_main_frame | 123 const ResourceType resource_type = request_info->is_main_frame |
124 ? RESOURCE_TYPE_MAIN_FRAME | 124 ? RESOURCE_TYPE_MAIN_FRAME |
125 : RESOURCE_TYPE_SUB_FRAME; | 125 : RESOURCE_TYPE_SUB_FRAME; |
126 | 126 |
127 if (resource_request_->request_body) { | 127 if (resource_request_->request_body) { |
128 AttachRequestBodyBlobDataHandles(resource_request_->request_body.get(), | 128 GetBodyBlobDataHandles(resource_request_->request_body.get(), |
129 resource_context_); | 129 resource_context_, &blob_handles_); |
130 } | 130 } |
131 | 131 |
132 // Requests to WebUI scheme won't get redirected to/from other schemes | 132 // Requests to WebUI scheme won't get redirected to/from other schemes |
133 // or be intercepted, so we just let it go here. | 133 // or be intercepted, so we just let it go here. |
134 if (factory_for_webui.is_valid()) { | 134 if (factory_for_webui.is_valid()) { |
135 webui_factory_ptr_.Bind(std::move(factory_for_webui)); | 135 webui_factory_ptr_.Bind(std::move(factory_for_webui)); |
136 url_loader_ = ThrottlingURLLoader::CreateLoaderAndStart( | 136 url_loader_ = ThrottlingURLLoader::CreateLoaderAndStart( |
137 webui_factory_ptr_.get(), | 137 webui_factory_ptr_.get(), |
138 GetContentClient()->browser()->CreateURLLoaderThrottles( | 138 GetContentClient()->browser()->CreateURLLoaderThrottles( |
139 web_contents_getter_), | 139 web_contents_getter_), |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 std::unique_ptr<ResourceRequest> resource_request_; | 290 std::unique_ptr<ResourceRequest> resource_request_; |
291 ResourceContext* resource_context_; | 291 ResourceContext* resource_context_; |
292 base::Callback<WebContents*()> web_contents_getter_; | 292 base::Callback<WebContents*()> web_contents_getter_; |
293 | 293 |
294 scoped_refptr<URLLoaderFactoryGetter> default_url_loader_factory_getter_; | 294 scoped_refptr<URLLoaderFactoryGetter> default_url_loader_factory_getter_; |
295 | 295 |
296 mojom::URLLoaderFactoryPtr webui_factory_ptr_; | 296 mojom::URLLoaderFactoryPtr webui_factory_ptr_; |
297 | 297 |
298 std::unique_ptr<ThrottlingURLLoader> url_loader_; | 298 std::unique_ptr<ThrottlingURLLoader> url_loader_; |
299 | 299 |
300 // This is referenced only on the UI thread. | 300 BlobHandles blob_handles_; |
301 base::WeakPtr<NavigationURLLoaderNetworkService> owner_; | |
302 | 301 |
303 // Currently used by the AppCache loader to pass its factory to the | 302 // Currently used by the AppCache loader to pass its factory to the |
304 // renderer which enables it to handle subresources. | 303 // renderer which enables it to handle subresources. |
305 mojom::URLLoaderFactoryPtrInfo subresource_url_loader_factory_ptr_info_; | 304 mojom::URLLoaderFactoryPtrInfo subresource_url_loader_factory_ptr_info_; |
306 | 305 |
| 306 // This is referenced only on the UI thread. |
| 307 base::WeakPtr<NavigationURLLoaderNetworkService> owner_; |
| 308 |
307 DISALLOW_COPY_AND_ASSIGN(URLLoaderRequestController); | 309 DISALLOW_COPY_AND_ASSIGN(URLLoaderRequestController); |
308 }; | 310 }; |
309 | 311 |
310 NavigationURLLoaderNetworkService::NavigationURLLoaderNetworkService( | 312 NavigationURLLoaderNetworkService::NavigationURLLoaderNetworkService( |
311 ResourceContext* resource_context, | 313 ResourceContext* resource_context, |
312 StoragePartition* storage_partition, | 314 StoragePartition* storage_partition, |
313 std::unique_ptr<NavigationRequestInfo> request_info, | 315 std::unique_ptr<NavigationRequestInfo> request_info, |
314 std::unique_ptr<NavigationUIData> navigation_ui_data, | 316 std::unique_ptr<NavigationUIData> navigation_ui_data, |
315 ServiceWorkerNavigationHandle* service_worker_navigation_handle, | 317 ServiceWorkerNavigationHandle* service_worker_navigation_handle, |
316 AppCacheNavigationHandle* appcache_handle, | 318 AppCacheNavigationHandle* appcache_handle, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", | 454 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", |
453 this, "&NavigationURLLoaderNetworkService", this, | 455 this, "&NavigationURLLoaderNetworkService", this, |
454 "success", false); | 456 "success", false); |
455 | 457 |
456 delegate_->OnRequestFailed(completion_status.exists_in_cache, | 458 delegate_->OnRequestFailed(completion_status.exists_in_cache, |
457 completion_status.error_code); | 459 completion_status.error_code); |
458 } | 460 } |
459 } | 461 } |
460 | 462 |
461 } // namespace content | 463 } // namespace content |
OLD | NEW |