| OLD | NEW |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/appcache/appcache_url_loader_job.h" | 5 #include "content/browser/appcache/appcache_url_loader_job.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "content/browser/appcache/appcache_histograms.h" | 8 #include "content/browser/appcache/appcache_histograms.h" |
| 9 #include "content/browser/appcache/appcache_subresource_url_factory.h" | 9 #include "content/browser/appcache/appcache_subresource_url_factory.h" |
| 10 #include "content/browser/appcache/appcache_url_loader_request.h" | 10 #include "content/browser/appcache/appcache_url_loader_request.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 subresource_load_info_ = std::move(subresource_load_info); | 216 subresource_load_info_ = std::move(subresource_load_info); |
| 217 | 217 |
| 218 binding_.Bind(std::move(subresource_load_info_->url_loader_request)); | 218 binding_.Bind(std::move(subresource_load_info_->url_loader_request)); |
| 219 binding_.set_connection_error_handler(base::Bind( | 219 binding_.set_connection_error_handler(base::Bind( |
| 220 &AppCacheURLLoaderJob::OnConnectionError, StaticAsWeakPtr(this))); | 220 &AppCacheURLLoaderJob::OnConnectionError, StaticAsWeakPtr(this))); |
| 221 | 221 |
| 222 client_ = std::move(subresource_load_info_->client); | 222 client_ = std::move(subresource_load_info_->client); |
| 223 default_url_loader_factory_getter_ = default_url_loader; | 223 default_url_loader_factory_getter_ = default_url_loader; |
| 224 } | 224 } |
| 225 | 225 |
| 226 void AppCacheURLLoaderJob::BindRequest(mojom::URLLoaderClientPtr client, |
| 227 mojom::URLLoaderRequest request) { |
| 228 DCHECK(!binding_.is_bound()); |
| 229 binding_.Bind(std::move(request)); |
| 230 |
| 231 client_ = std::move(client); |
| 232 |
| 233 binding_.set_connection_error_handler(base::Bind( |
| 234 &AppCacheURLLoaderJob::OnConnectionError, StaticAsWeakPtr(this))); |
| 235 } |
| 236 |
| 226 void AppCacheURLLoaderJob::Start(mojom::URLLoaderRequest request, | 237 void AppCacheURLLoaderJob::Start(mojom::URLLoaderRequest request, |
| 227 mojom::URLLoaderClientPtr client) { | 238 mojom::URLLoaderClientPtr client) { |
| 228 DCHECK(!binding_.is_bound()); | 239 BindRequest(std::move(client), std::move(request)); |
| 229 binding_.Bind(std::move(request)); | |
| 230 | |
| 231 binding_.set_connection_error_handler(base::Bind( | |
| 232 &AppCacheURLLoaderJob::OnConnectionError, StaticAsWeakPtr(this))); | |
| 233 | |
| 234 client_ = std::move(client); | |
| 235 | |
| 236 // Send the cached AppCacheResponse if any. | 240 // Send the cached AppCacheResponse if any. |
| 237 if (info_.get()) | 241 if (info_.get()) |
| 238 SendResponseInfo(); | 242 SendResponseInfo(); |
| 239 } | 243 } |
| 240 | 244 |
| 241 AppCacheURLLoaderJob::AppCacheURLLoaderJob( | 245 AppCacheURLLoaderJob::AppCacheURLLoaderJob( |
| 242 const ResourceRequest& request, | 246 const ResourceRequest& request, |
| 243 AppCacheURLLoaderRequest* appcache_request, | 247 AppCacheURLLoaderRequest* appcache_request, |
| 244 AppCacheStorage* storage) | 248 AppCacheStorage* storage) |
| 245 : request_(request), | 249 : request_(request), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 264 } | 268 } |
| 265 | 269 |
| 266 if (response_info) { | 270 if (response_info) { |
| 267 info_ = response_info; | 271 info_ = response_info; |
| 268 reader_.reset( | 272 reader_.reset( |
| 269 storage_->CreateResponseReader(manifest_url_, entry_.response_id())); | 273 storage_->CreateResponseReader(manifest_url_, entry_.response_id())); |
| 270 | 274 |
| 271 if (is_range_request()) | 275 if (is_range_request()) |
| 272 SetupRangeResponse(); | 276 SetupRangeResponse(); |
| 273 | 277 |
| 274 if (IsResourceTypeFrame(request_.resource_type)) { | 278 if (IsResourceTypeFrame(request_.resource_type) && |
| 275 DCHECK(!main_resource_loader_callback_.is_null()); | 279 main_resource_loader_callback_) { |
| 276 std::move(main_resource_loader_callback_) | 280 std::move(main_resource_loader_callback_) |
| 277 .Run(base::Bind(&AppCacheURLLoaderJob::Start, StaticAsWeakPtr(this))); | 281 .Run(base::Bind(&AppCacheURLLoaderJob::Start, StaticAsWeakPtr(this))); |
| 278 } | 282 } |
| 279 | 283 |
| 280 response_body_stream_ = std::move(data_pipe_.producer_handle); | 284 response_body_stream_ = std::move(data_pipe_.producer_handle); |
| 281 | 285 |
| 282 // TODO(ananta) | 286 // TODO(ananta) |
| 283 // Move the asynchronous reading and mojo pipe handling code to a helper | 287 // Move the asynchronous reading and mojo pipe handling code to a helper |
| 284 // class. That would also need a change to BlobURLLoader. | 288 // class. That would also need a change to BlobURLLoader. |
| 285 | 289 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 } | 455 } |
| 452 | 456 |
| 453 void AppCacheURLLoaderJob::DisconnectFromNetworkLoader() { | 457 void AppCacheURLLoaderJob::DisconnectFromNetworkLoader() { |
| 454 // Close the pipe to the network loader as we are delivering a fallback | 458 // Close the pipe to the network loader as we are delivering a fallback |
| 455 // response to the client. | 459 // response to the client. |
| 456 network_loader_client_binding_.Close(); | 460 network_loader_client_binding_.Close(); |
| 457 network_loader_ = nullptr; | 461 network_loader_ = nullptr; |
| 458 } | 462 } |
| 459 | 463 |
| 460 } // namespace content | 464 } // namespace content |
| OLD | NEW |