| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 mojom::URLLoaderFactoryPtrInfo factory_for_webui, | 93 mojom::URLLoaderFactoryPtrInfo factory_for_webui, |
| 94 const base::Callback<WebContents*(void)>& web_contents_getter, | 94 const base::Callback<WebContents*(void)>& web_contents_getter, |
| 95 std::unique_ptr<service_manager::Connector> connector) { | 95 std::unique_ptr<service_manager::Connector> connector) { |
| 96 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 96 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 97 web_contents_getter_ = web_contents_getter; | 97 web_contents_getter_ = web_contents_getter; |
| 98 const ResourceType resource_type = request_info->is_main_frame | 98 const ResourceType resource_type = request_info->is_main_frame |
| 99 ? RESOURCE_TYPE_MAIN_FRAME | 99 ? RESOURCE_TYPE_MAIN_FRAME |
| 100 : RESOURCE_TYPE_SUB_FRAME; | 100 : RESOURCE_TYPE_SUB_FRAME; |
| 101 | 101 |
| 102 if (resource_request_->request_body) { | 102 if (resource_request_->request_body) { |
| 103 AttachRequestBodyBlobDataHandles(resource_request_->request_body.get(), | 103 blob_handles_ = GetBodyBlobDataHandles( |
| 104 resource_context_); | 104 resource_request_->request_body.get(), resource_context_); |
| 105 } | 105 } |
| 106 | 106 |
| 107 // Requests to WebUI scheme won't get redirected to/from other schemes | 107 // Requests to WebUI scheme won't get redirected to/from other schemes |
| 108 // or be intercepted, so we just let it go here. | 108 // or be intercepted, so we just let it go here. |
| 109 if (factory_for_webui.is_valid()) { | 109 if (factory_for_webui.is_valid()) { |
| 110 webui_factory_ptr_.Bind(std::move(factory_for_webui)); | 110 webui_factory_ptr_.Bind(std::move(factory_for_webui)); |
| 111 url_loader_ = ThrottlingURLLoader::CreateLoaderAndStart( | 111 url_loader_ = ThrottlingURLLoader::CreateLoaderAndStart( |
| 112 webui_factory_ptr_.get(), | 112 webui_factory_ptr_.get(), |
| 113 GetContentClient()->browser()->CreateURLLoaderThrottles( | 113 GetContentClient()->browser()->CreateURLLoaderThrottles( |
| 114 web_contents_getter_), | 114 web_contents_getter_), |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 std::unique_ptr<ResourceRequest> resource_request_; | 265 std::unique_ptr<ResourceRequest> resource_request_; |
| 266 ResourceContext* resource_context_; | 266 ResourceContext* resource_context_; |
| 267 base::Callback<WebContents*()> web_contents_getter_; | 267 base::Callback<WebContents*()> web_contents_getter_; |
| 268 | 268 |
| 269 scoped_refptr<URLLoaderFactoryGetter> default_url_loader_factory_getter_; | 269 scoped_refptr<URLLoaderFactoryGetter> default_url_loader_factory_getter_; |
| 270 | 270 |
| 271 mojom::URLLoaderFactoryPtr webui_factory_ptr_; | 271 mojom::URLLoaderFactoryPtr webui_factory_ptr_; |
| 272 | 272 |
| 273 std::unique_ptr<ThrottlingURLLoader> url_loader_; | 273 std::unique_ptr<ThrottlingURLLoader> url_loader_; |
| 274 | 274 |
| 275 // This is referenced only on the UI thread. | 275 std::unique_ptr<BlobHandles> blob_handles_; |
| 276 base::WeakPtr<NavigationURLLoaderNetworkService> owner_; | |
| 277 | 276 |
| 278 // Currently used by the AppCache loader to pass its factory to the | 277 // Currently used by the AppCache loader to pass its factory to the |
| 279 // renderer which enables it to handle subresources. | 278 // renderer which enables it to handle subresources. |
| 280 mojom::URLLoaderFactoryPtrInfo subresource_url_loader_factory_ptr_info_; | 279 mojom::URLLoaderFactoryPtrInfo subresource_url_loader_factory_ptr_info_; |
| 281 | 280 |
| 281 // This is referenced only on the UI thread. |
| 282 base::WeakPtr<NavigationURLLoaderNetworkService> owner_; |
| 283 |
| 282 DISALLOW_COPY_AND_ASSIGN(URLLoaderRequestController); | 284 DISALLOW_COPY_AND_ASSIGN(URLLoaderRequestController); |
| 283 }; | 285 }; |
| 284 | 286 |
| 285 NavigationURLLoaderNetworkService::NavigationURLLoaderNetworkService( | 287 NavigationURLLoaderNetworkService::NavigationURLLoaderNetworkService( |
| 286 ResourceContext* resource_context, | 288 ResourceContext* resource_context, |
| 287 StoragePartition* storage_partition, | 289 StoragePartition* storage_partition, |
| 288 std::unique_ptr<NavigationRequestInfo> request_info, | 290 std::unique_ptr<NavigationRequestInfo> request_info, |
| 289 std::unique_ptr<NavigationUIData> navigation_ui_data, | 291 std::unique_ptr<NavigationUIData> navigation_ui_data, |
| 290 ServiceWorkerNavigationHandle* service_worker_navigation_handle, | 292 ServiceWorkerNavigationHandle* service_worker_navigation_handle, |
| 291 AppCacheNavigationHandle* appcache_handle, | 293 AppCacheNavigationHandle* appcache_handle, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", | 429 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", |
| 428 this, "&NavigationURLLoaderNetworkService", this, | 430 this, "&NavigationURLLoaderNetworkService", this, |
| 429 "success", false); | 431 "success", false); |
| 430 | 432 |
| 431 delegate_->OnRequestFailed(completion_status.exists_in_cache, | 433 delegate_->OnRequestFailed(completion_status.exists_in_cache, |
| 432 completion_status.error_code); | 434 completion_status.error_code); |
| 433 } | 435 } |
| 434 } | 436 } |
| 435 | 437 |
| 436 } // namespace content | 438 } // namespace content |
| OLD | NEW |