Chromium Code Reviews| 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/debug/stack_trace.h" | |
| 9 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 10 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
| 11 #include "content/browser/appcache/appcache_navigation_handle.h" | 12 #include "content/browser/appcache/appcache_navigation_handle.h" |
| 12 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 13 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
| 13 #include "content/browser/frame_host/frame_tree_node.h" | 14 #include "content/browser/frame_host/frame_tree_node.h" |
| 14 #include "content/browser/frame_host/navigation_request_info.h" | 15 #include "content/browser/frame_host/navigation_request_info.h" |
| 15 #include "content/browser/loader/navigation_resource_handler.h" | 16 #include "content/browser/loader/navigation_resource_handler.h" |
| 16 #include "content/browser/loader/navigation_resource_throttle.h" | 17 #include "content/browser/loader/navigation_resource_throttle.h" |
| 17 #include "content/browser/loader/navigation_url_loader_delegate.h" | 18 #include "content/browser/loader/navigation_url_loader_delegate.h" |
| 19 #include "content/browser/loader/url_loader_request_handler.h" | |
| 18 #include "content/browser/resource_context_impl.h" | 20 #include "content/browser/resource_context_impl.h" |
| 19 #include "content/browser/service_worker/service_worker_navigation_handle.h" | 21 #include "content/browser/service_worker/service_worker_navigation_handle.h" |
| 20 #include "content/browser/service_worker/service_worker_navigation_handle_core.h " | 22 #include "content/browser/service_worker/service_worker_navigation_handle_core.h " |
| 21 #include "content/browser/service_worker/service_worker_request_handler.h" | 23 #include "content/browser/service_worker/service_worker_request_handler.h" |
| 22 #include "content/browser/storage_partition_impl.h" | 24 #include "content/browser/storage_partition_impl.h" |
| 23 #include "content/browser/url_loader_factory_getter.h" | 25 #include "content/browser/url_loader_factory_getter.h" |
| 24 #include "content/browser/web_contents/web_contents_impl.h" | 26 #include "content/browser/web_contents/web_contents_impl.h" |
| 25 #include "content/browser/webui/url_data_manager_backend.h" | 27 #include "content/browser/webui/url_data_manager_backend.h" |
| 26 #include "content/browser/webui/web_ui_url_loader_factory.h" | 28 #include "content/browser/webui/web_ui_url_loader_factory.h" |
| 27 #include "content/public/browser/browser_context.h" | 29 #include "content/public/browser/browser_context.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 47 WebContents* GetWebContentsFromFrameTreeNodeID(int frame_tree_node_id) { | 49 WebContents* GetWebContentsFromFrameTreeNodeID(int frame_tree_node_id) { |
| 48 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 50 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 49 FrameTreeNode* frame_tree_node = | 51 FrameTreeNode* frame_tree_node = |
| 50 FrameTreeNode::GloballyFindByID(frame_tree_node_id); | 52 FrameTreeNode::GloballyFindByID(frame_tree_node_id); |
| 51 if (!frame_tree_node) | 53 if (!frame_tree_node) |
| 52 return nullptr; | 54 return nullptr; |
| 53 | 55 |
| 54 return WebContentsImpl::FromFrameTreeNode(frame_tree_node); | 56 return WebContentsImpl::FromFrameTreeNode(frame_tree_node); |
| 55 } | 57 } |
| 56 | 58 |
| 57 void PrepareNavigationStartOnIO( | |
| 58 std::unique_ptr<ResourceRequest> resource_request, | |
| 59 ResourceContext* resource_context, | |
| 60 ServiceWorkerNavigationHandleCore* service_worker_navigation_handle_core, | |
| 61 AppCacheNavigationHandleCore* appcache_handle_core, | |
| 62 NavigationRequestInfo* request_info, | |
| 63 mojom::URLLoaderFactoryPtrInfo factory_from_ui, | |
| 64 scoped_refptr<URLLoaderFactoryGetter> url_loader_factory_getter, | |
| 65 const base::Callback<WebContents*(void)>& web_contents_getter, | |
| 66 mojom::URLLoaderAssociatedRequest url_loader_request, | |
| 67 mojom::URLLoaderClientPtr url_loader_client_to_pass, | |
| 68 std::unique_ptr<service_manager::Connector> connector) { | |
| 69 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 70 | |
| 71 const ResourceType resource_type = request_info->is_main_frame | |
| 72 ? RESOURCE_TYPE_MAIN_FRAME | |
| 73 : RESOURCE_TYPE_SUB_FRAME; | |
| 74 | |
| 75 if (resource_request->request_body) { | |
| 76 AttachRequestBodyBlobDataHandles(resource_request->request_body.get(), | |
| 77 resource_context); | |
| 78 } | |
| 79 | |
| 80 mojom::URLLoaderFactoryPtr url_loader_factory_ptr; | |
| 81 if (service_worker_navigation_handle_core) { | |
| 82 RequestContextFrameType frame_type = | |
| 83 request_info->is_main_frame ? REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL | |
| 84 : REQUEST_CONTEXT_FRAME_TYPE_NESTED; | |
| 85 | |
| 86 storage::BlobStorageContext* blob_storage_context = GetBlobStorageContext( | |
| 87 GetChromeBlobStorageContextForResourceContext(resource_context)); | |
| 88 url_loader_factory_ptr = | |
| 89 ServiceWorkerRequestHandler::InitializeForNavigationNetworkService( | |
| 90 *resource_request, resource_context, | |
| 91 service_worker_navigation_handle_core, blob_storage_context, | |
| 92 request_info->begin_params.skip_service_worker, resource_type, | |
| 93 request_info->begin_params.request_context_type, frame_type, | |
| 94 request_info->are_ancestors_secure, | |
| 95 request_info->common_params.post_data, web_contents_getter); | |
| 96 } | |
| 97 | |
| 98 // If we haven't gotten one from the above, then use the one the UI thread | |
| 99 // gave us, or otherwise fallback to the default. | |
| 100 mojom::URLLoaderFactory* factory; | |
| 101 if (url_loader_factory_ptr) { | |
| 102 factory = url_loader_factory_ptr.get(); | |
| 103 } else { | |
| 104 if (factory_from_ui.is_valid()) { | |
| 105 url_loader_factory_ptr.Bind(std::move(factory_from_ui)); | |
| 106 factory = url_loader_factory_ptr.get(); | |
| 107 } else { | |
| 108 if (appcache_handle_core) { | |
| 109 factory = url_loader_factory_getter->GetAppCacheFactory()->get(); | |
| 110 } else { | |
| 111 factory = url_loader_factory_getter->GetNetworkFactory()->get(); | |
| 112 } | |
| 113 } | |
| 114 } | |
| 115 | |
| 116 factory->CreateLoaderAndStart( | |
| 117 std::move(url_loader_request), 0 /* routing_id? */, 0 /* request_id? */, | |
| 118 mojom::kURLLoadOptionSendSSLInfo, *resource_request, | |
| 119 std::move(url_loader_client_to_pass)); | |
| 120 } | |
| 121 | |
| 122 } // namespace | 59 } // namespace |
| 123 | 60 |
| 61 class NavigationURLLoaderNetworkService::URLLoaderRequestController | |
| 62 : public URLLoaderRequestHandler::Controller { | |
| 63 public: | |
| 64 URLLoaderRequestController(std::unique_ptr<ResourceRequest> resource_request, | |
| 65 ResourceContext* resource_context) | |
| 66 : resource_request_(std::move(resource_request)), | |
| 67 resource_context_(resource_context) {} | |
| 68 | |
| 69 virtual ~URLLoaderRequestController() { | |
| 70 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 71 } | |
| 72 | |
| 73 void Start( | |
| 74 ServiceWorkerNavigationHandleCore* service_worker_navigation_handle_core, | |
| 75 AppCacheNavigationHandleCore* appcache_handle_core, | |
| 76 std::unique_ptr<NavigationRequestInfo> request_info, | |
| 77 mojom::URLLoaderFactoryPtrInfo factory_for_webui, | |
| 78 scoped_refptr<URLLoaderFactoryGetter> url_loader_factory_getter, | |
| 79 const base::Callback<WebContents*(void)>& web_contents_getter, | |
| 80 mojom::URLLoaderAssociatedRequest url_loader_request, | |
| 81 mojom::URLLoaderClientPtr url_loader_client_ptr, | |
| 82 std::unique_ptr<service_manager::Connector> connector) { | |
| 83 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 84 const ResourceType resource_type = request_info->is_main_frame | |
| 85 ? RESOURCE_TYPE_MAIN_FRAME | |
| 86 : RESOURCE_TYPE_SUB_FRAME; | |
| 87 | |
| 88 if (resource_request_->request_body) { | |
| 89 AttachRequestBodyBlobDataHandles(resource_request_->request_body.get(), | |
| 90 resource_context_); | |
| 91 } | |
| 92 | |
| 93 // Requests to WebUI scheme won't get redirected to/from other schemes | |
| 94 // or be intercepted, so we just let it go here. | |
|
michaeln
2017/05/26 01:28:31
nice clarifying change to rearrange the order
| |
| 95 if (factory_for_webui.is_valid()) { | |
| 96 fallback_factory_ptr_.Bind(std::move(factory_for_webui)); | |
| 97 fallback_factory_ = fallback_factory_ptr_.get(); | |
| 98 Restart(std::move(url_loader_request), std::move(url_loader_client_ptr)); | |
| 99 return; | |
| 100 } | |
| 101 | |
|
michaeln
2017/05/26 01:28:30
i think blob scheme handling will goes here too, m
| |
| 102 DCHECK(handlers_.empty()); | |
| 103 if (service_worker_navigation_handle_core) { | |
| 104 RequestContextFrameType frame_type = | |
| 105 request_info->is_main_frame ? REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL | |
| 106 : REQUEST_CONTEXT_FRAME_TYPE_NESTED; | |
| 107 | |
| 108 storage::BlobStorageContext* blob_storage_context = GetBlobStorageContext( | |
| 109 GetChromeBlobStorageContextForResourceContext(resource_context_)); | |
| 110 std::unique_ptr<URLLoaderRequestHandler> service_worker_handler = | |
| 111 ServiceWorkerRequestHandler::InitializeForNavigationNetworkService( | |
| 112 *resource_request_, resource_context_, | |
| 113 service_worker_navigation_handle_core, blob_storage_context, | |
| 114 request_info->begin_params.skip_service_worker, resource_type, | |
| 115 request_info->begin_params.request_context_type, frame_type, | |
| 116 request_info->are_ancestors_secure, | |
| 117 request_info->common_params.post_data, web_contents_getter); | |
| 118 if (service_worker_handler) | |
| 119 handlers_.push_back(std::move(service_worker_handler)); | |
| 120 } | |
| 121 | |
| 122 if (appcache_handle_core) { | |
| 123 // TODO: add appcache code here. | |
| 124 } | |
| 125 | |
| 126 DCHECK(!fallback_factory_); | |
| 127 fallback_factory_ = url_loader_factory_getter->GetNetworkFactory()->get(); | |
| 128 | |
| 129 Restart(std::move(url_loader_request), std::move(url_loader_client_ptr)); | |
| 130 } | |
| 131 | |
| 132 // This could be called multiple times. | |
| 133 void Restart(mojom::URLLoaderAssociatedRequest url_loader_request, | |
| 134 mojom::URLLoaderClientPtr url_loader_client_ptr) { | |
| 135 handler_index_ = 0; | |
| 136 DCHECK(url_loader_client_ptr.is_bound()); | |
| 137 Forward(std::move(url_loader_request), std::move(url_loader_client_ptr)); | |
| 138 } | |
| 139 | |
| 140 // This could be called multiple times. | |
|
scottmg
2017/05/25 15:12:24
nit; comment that this is URLLoaderRH::Controller.
kinuko
2017/05/26 14:30:05
(Removed the Controller interface)
| |
| 141 void Forward(mojom::URLLoaderAssociatedRequest url_loader_request, | |
| 142 mojom::URLLoaderClientPtr url_loader_client_ptr) override { | |
| 143 DCHECK(url_loader_client_ptr.is_bound()); | |
| 144 | |
| 145 if (handler_index_ < handlers_.size()) { | |
| 146 handlers_[handler_index_++]->Start( | |
| 147 *resource_request_, this, resource_context_, | |
| 148 std::move(url_loader_request), std::move(url_loader_client_ptr)); | |
| 149 return; | |
| 150 } | |
| 151 | |
| 152 if (!url_loader_client_ptr.is_bound()) { | |
| 153 base::debug::StackTrace trace; | |
|
jam
2017/05/25 16:06:37
nit: is this still needed?
kinuko
2017/05/26 02:34:20
Of course not :)
kinuko
2017/05/26 14:30:05
Removed.
| |
| 154 LOG(ERROR) << trace.ToString(); | |
| 155 } | |
| 156 DCHECK_EQ(handlers_.size(), handler_index_); | |
| 157 fallback_factory_->CreateLoaderAndStart( | |
| 158 std::move(url_loader_request), 0 /* routing_id? */, 0 /* request_id? */, | |
| 159 mojom::kURLLoadOptionSendSSLInfo, *resource_request_, | |
| 160 std::move(url_loader_client_ptr)); | |
| 161 } | |
| 162 | |
| 163 private: | |
| 164 std::vector<std::unique_ptr<URLLoaderRequestHandler>> handlers_; | |
| 165 size_t handler_index_ = 0; | |
| 166 | |
| 167 std::unique_ptr<ResourceRequest> resource_request_; | |
| 168 ResourceContext* resource_context_; | |
| 169 | |
| 170 mojom::URLLoaderFactoryPtr fallback_factory_ptr_; | |
| 171 mojom::URLLoaderFactory* fallback_factory_; | |
| 172 | |
| 173 DISALLOW_COPY_AND_ASSIGN(URLLoaderRequestController); | |
| 174 }; | |
| 175 | |
| 124 NavigationURLLoaderNetworkService::NavigationURLLoaderNetworkService( | 176 NavigationURLLoaderNetworkService::NavigationURLLoaderNetworkService( |
| 125 ResourceContext* resource_context, | 177 ResourceContext* resource_context, |
| 126 StoragePartition* storage_partition, | 178 StoragePartition* storage_partition, |
| 127 std::unique_ptr<NavigationRequestInfo> request_info, | 179 std::unique_ptr<NavigationRequestInfo> request_info, |
| 128 std::unique_ptr<NavigationUIData> navigation_ui_data, | 180 std::unique_ptr<NavigationUIData> navigation_ui_data, |
| 129 ServiceWorkerNavigationHandle* service_worker_navigation_handle, | 181 ServiceWorkerNavigationHandle* service_worker_navigation_handle, |
| 130 AppCacheNavigationHandle* appcache_handle, | 182 AppCacheNavigationHandle* appcache_handle, |
| 131 NavigationURLLoaderDelegate* delegate) | 183 NavigationURLLoaderDelegate* delegate) |
| 132 : delegate_(delegate), | 184 : delegate_(delegate), binding_(this) { |
| 133 binding_(this), | |
| 134 request_info_(std::move(request_info)) { | |
| 135 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 185 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 136 | 186 |
| 137 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( | 187 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( |
| 138 "navigation", "Navigation timeToResponseStarted", this, | 188 "navigation", "Navigation timeToResponseStarted", this, |
| 139 request_info_->common_params.navigation_start, "FrameTreeNode id", | 189 request_info->common_params.navigation_start, "FrameTreeNode id", |
| 140 request_info_->frame_tree_node_id); | 190 request_info->frame_tree_node_id); |
| 141 | 191 |
| 142 // TODO(scottmg): Port over stuff from RDHI::BeginNavigationRequest() here. | 192 // TODO(scottmg): Port over stuff from RDHI::BeginNavigationRequest() here. |
| 143 auto new_request = base::MakeUnique<ResourceRequest>(); | 193 auto new_request = base::MakeUnique<ResourceRequest>(); |
| 144 | 194 |
| 145 new_request->method = request_info_->common_params.method; | 195 new_request->method = request_info->common_params.method; |
| 146 new_request->url = request_info_->common_params.url; | 196 new_request->url = request_info->common_params.url; |
| 147 new_request->first_party_for_cookies = request_info_->first_party_for_cookies; | 197 new_request->first_party_for_cookies = request_info->first_party_for_cookies; |
| 148 new_request->priority = net::HIGHEST; | 198 new_request->priority = net::HIGHEST; |
| 149 | 199 |
| 150 // The code below to set fields like request_initiator, referrer, etc has | 200 // The code below to set fields like request_initiator, referrer, etc has |
| 151 // been copied from ResourceDispatcherHostImpl. We did not refactor the | 201 // been copied from ResourceDispatcherHostImpl. We did not refactor the |
| 152 // common code into a function, because RDHI uses accessor functions on the | 202 // common code into a function, because RDHI uses accessor functions on the |
| 153 // URLRequest class to set these fields. whereas we use ResourceRequest here. | 203 // URLRequest class to set these fields. whereas we use ResourceRequest here. |
| 154 new_request->request_initiator = request_info_->begin_params.initiator_origin; | 204 new_request->request_initiator = request_info->begin_params.initiator_origin; |
| 155 new_request->referrer = request_info_->common_params.referrer.url; | 205 new_request->referrer = request_info->common_params.referrer.url; |
| 156 new_request->referrer_policy = request_info_->common_params.referrer.policy; | 206 new_request->referrer_policy = request_info->common_params.referrer.policy; |
| 157 new_request->headers = request_info_->begin_params.headers; | 207 new_request->headers = request_info->begin_params.headers; |
| 158 | 208 |
| 159 int load_flags = request_info_->begin_params.load_flags; | 209 int load_flags = request_info->begin_params.load_flags; |
| 160 load_flags |= net::LOAD_VERIFY_EV_CERT; | 210 load_flags |= net::LOAD_VERIFY_EV_CERT; |
| 161 if (request_info_->is_main_frame) | 211 if (request_info->is_main_frame) |
| 162 load_flags |= net::LOAD_MAIN_FRAME_DEPRECATED; | 212 load_flags |= net::LOAD_MAIN_FRAME_DEPRECATED; |
| 163 | 213 |
| 164 // Sync loads should have maximum priority and should be the only | 214 // Sync loads should have maximum priority and should be the only |
| 165 // requests that have the ignore limits flag set. | 215 // requests that have the ignore limits flag set. |
| 166 DCHECK(!(load_flags & net::LOAD_IGNORE_LIMITS)); | 216 DCHECK(!(load_flags & net::LOAD_IGNORE_LIMITS)); |
| 167 | 217 |
| 168 new_request->load_flags = load_flags; | 218 new_request->load_flags = load_flags; |
| 169 | 219 |
| 170 new_request->request_body = request_info_->common_params.post_data.get(); | 220 new_request->request_body = request_info->common_params.post_data.get(); |
| 221 | |
| 222 int frame_tree_node_id = request_info->frame_tree_node_id; | |
| 171 | 223 |
| 172 mojom::URLLoaderAssociatedRequest loader_associated_request = | 224 mojom::URLLoaderAssociatedRequest loader_associated_request = |
| 173 mojo::MakeRequest(&url_loader_associated_ptr_); | 225 mojo::MakeRequest(&url_loader_associated_ptr_); |
| 174 mojom::URLLoaderClientPtr url_loader_client_ptr_to_pass; | 226 mojom::URLLoaderClientPtr url_loader_client_ptr_to_pass; |
| 175 binding_.Bind(mojo::MakeRequest(&url_loader_client_ptr_to_pass)); | 227 binding_.Bind(mojo::MakeRequest(&url_loader_client_ptr_to_pass)); |
| 176 | 228 |
| 177 // Check if a web UI scheme wants to handle this request. | 229 // Check if a web UI scheme wants to handle this request. |
| 178 mojom::URLLoaderFactoryPtrInfo factory_ptr_info; | 230 mojom::URLLoaderFactoryPtrInfo factory_ptr_info; |
| 179 | 231 |
| 180 const auto& schemes = URLDataManagerBackend::GetWebUISchemes(); | 232 const auto& schemes = URLDataManagerBackend::GetWebUISchemes(); |
| 181 if (std::find(schemes.begin(), schemes.end(), new_request->url.scheme()) != | 233 if (std::find(schemes.begin(), schemes.end(), new_request->url.scheme()) != |
| 182 schemes.end()) { | 234 schemes.end()) { |
| 183 FrameTreeNode* frame_tree_node = | 235 FrameTreeNode* frame_tree_node = |
| 184 FrameTreeNode::GloballyFindByID(request_info_->frame_tree_node_id); | 236 FrameTreeNode::GloballyFindByID(frame_tree_node_id); |
| 185 factory_ptr_info = GetWebUIURLLoader(frame_tree_node).PassInterface(); | 237 factory_ptr_info = GetWebUIURLLoader(frame_tree_node).PassInterface(); |
| 186 } | 238 } |
| 187 | 239 |
| 188 g_next_request_id--; | 240 g_next_request_id--; |
| 189 | 241 |
| 242 DCHECK(!request_controller_); | |
| 243 request_controller_ = base::MakeUnique<URLLoaderRequestController>( | |
| 244 std::move(new_request), resource_context); | |
| 190 BrowserThread::PostTask( | 245 BrowserThread::PostTask( |
| 191 BrowserThread::IO, FROM_HERE, | 246 BrowserThread::IO, FROM_HERE, |
| 192 base::Bind(&PrepareNavigationStartOnIO, | 247 base::Bind( |
| 193 base::Passed(std::move(new_request)), resource_context, | 248 &URLLoaderRequestController::Start, |
| 194 service_worker_navigation_handle | 249 base::Unretained(request_controller_.get()), |
| 195 ? service_worker_navigation_handle->core() | 250 service_worker_navigation_handle |
| 196 : nullptr, | 251 ? service_worker_navigation_handle->core() |
| 197 appcache_handle ? appcache_handle->core() : nullptr, | 252 : nullptr, |
| 198 request_info_.get(), base::Passed(std::move(factory_ptr_info)), | 253 appcache_handle ? appcache_handle->core() : nullptr, |
| 199 static_cast<StoragePartitionImpl*>(storage_partition) | 254 base::Passed(std::move(request_info)), |
| 200 ->url_loader_factory_getter(), | 255 base::Passed(std::move(factory_ptr_info)), |
| 201 base::Bind(&GetWebContentsFromFrameTreeNodeID, | 256 static_cast<StoragePartitionImpl*>(storage_partition) |
| 202 request_info_->frame_tree_node_id), | 257 ->url_loader_factory_getter(), |
| 203 base::Passed(std::move(loader_associated_request)), | 258 base::Bind(&GetWebContentsFromFrameTreeNodeID, frame_tree_node_id), |
| 204 base::Passed(std::move(url_loader_client_ptr_to_pass)), | 259 base::Passed(std::move(loader_associated_request)), |
| 205 base::Passed(ServiceManagerConnection::GetForProcess() | 260 base::Passed(std::move(url_loader_client_ptr_to_pass)), |
| 206 ->GetConnector() | 261 base::Passed(ServiceManagerConnection::GetForProcess() |
| 207 ->Clone()))); | 262 ->GetConnector() |
| 263 ->Clone()))); | |
| 208 } | 264 } |
| 209 | 265 |
| 210 NavigationURLLoaderNetworkService::~NavigationURLLoaderNetworkService() {} | 266 NavigationURLLoaderNetworkService::~NavigationURLLoaderNetworkService() { |
| 267 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, | |
| 268 request_controller_.release()); | |
| 269 } | |
| 211 | 270 |
| 212 void NavigationURLLoaderNetworkService::FollowRedirect() { | 271 void NavigationURLLoaderNetworkService::FollowRedirect() { |
| 213 url_loader_associated_ptr_->FollowRedirect(); | 272 url_loader_associated_ptr_->FollowRedirect(); |
| 214 } | 273 } |
| 215 | 274 |
| 216 void NavigationURLLoaderNetworkService::ProceedWithResponse() {} | 275 void NavigationURLLoaderNetworkService::ProceedWithResponse() {} |
| 217 | 276 |
| 218 void NavigationURLLoaderNetworkService::OnReceiveResponse( | 277 void NavigationURLLoaderNetworkService::OnReceiveResponse( |
| 219 const ResourceResponseHead& head, | 278 const ResourceResponseHead& head, |
| 220 const base::Optional<net::SSLInfo>& ssl_info, | 279 const base::Optional<net::SSLInfo>& ssl_info, |
| 221 mojom::DownloadedTempFilePtr downloaded_file) { | 280 mojom::DownloadedTempFilePtr downloaded_file) { |
| 222 // TODO(scottmg): This needs to do more of what | 281 // TODO(scottmg): This needs to do more of what |
| 223 // NavigationResourceHandler::OnReponseStarted() does. Or maybe in | 282 // NavigationResourceHandler::OnReponseStarted() does. Or maybe in |
| 224 // OnStartLoadingResponseBody(). | 283 // OnStartLoadingResponseBody(). |
| 225 if (ssl_info && ssl_info->cert) | 284 if (ssl_info && ssl_info->cert) |
| 226 NavigationResourceHandler::GetSSLStatusForRequest(*ssl_info, &ssl_status_); | 285 NavigationResourceHandler::GetSSLStatusForRequest(*ssl_info, &ssl_status_); |
| 227 response_ = base::MakeRefCounted<ResourceResponse>(); | 286 response_ = base::MakeRefCounted<ResourceResponse>(); |
| 228 response_->head = head; | 287 response_->head = head; |
| 229 } | 288 } |
| 230 | 289 |
| 231 void NavigationURLLoaderNetworkService::OnReceiveRedirect( | 290 void NavigationURLLoaderNetworkService::OnReceiveRedirect( |
| 232 const net::RedirectInfo& redirect_info, | 291 const net::RedirectInfo& redirect_info, |
| 233 const ResourceResponseHead& head) { | 292 const ResourceResponseHead& head) { |
| 234 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 293 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 294 // TODO(kinuko): Perform the necessary check and call | |
| 295 // URLLoaderRequestController::Restart with the new URL?? | |
| 235 scoped_refptr<ResourceResponse> response(new ResourceResponse()); | 296 scoped_refptr<ResourceResponse> response(new ResourceResponse()); |
| 236 response->head = head; | 297 response->head = head; |
| 237 delegate_->OnRequestRedirected(redirect_info, response); | 298 delegate_->OnRequestRedirected(redirect_info, response); |
| 238 } | 299 } |
| 239 | 300 |
| 240 void NavigationURLLoaderNetworkService::OnDataDownloaded( | 301 void NavigationURLLoaderNetworkService::OnDataDownloaded( |
| 241 int64_t data_length, | 302 int64_t data_length, |
| 242 int64_t encoded_length) {} | 303 int64_t encoded_length) {} |
| 243 | 304 |
| 244 void NavigationURLLoaderNetworkService::OnUploadProgress( | 305 void NavigationURLLoaderNetworkService::OnUploadProgress( |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 275 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", | 336 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", |
| 276 this, "&NavigationURLLoaderNetworkService", this, | 337 this, "&NavigationURLLoaderNetworkService", this, |
| 277 "success", false); | 338 "success", false); |
| 278 | 339 |
| 279 delegate_->OnRequestFailed(completion_status.exists_in_cache, | 340 delegate_->OnRequestFailed(completion_status.exists_in_cache, |
| 280 completion_status.error_code); | 341 completion_status.error_code); |
| 281 } | 342 } |
| 282 } | 343 } |
| 283 | 344 |
| 284 } // namespace content | 345 } // namespace content |
| OLD | NEW |