| 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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 DCHECK(false); | 421 DCHECK(false); |
| 422 NotifyCompleted(net::ERR_FAILED); | 422 NotifyCompleted(net::ERR_FAILED); |
| 423 } | 423 } |
| 424 ReadMore(); | 424 ReadMore(); |
| 425 } | 425 } |
| 426 | 426 |
| 427 void AppCacheURLLoaderJob::NotifyCompleted(int error_code) { | 427 void AppCacheURLLoaderJob::NotifyCompleted(int error_code) { |
| 428 if (storage_.get()) | 428 if (storage_.get()) |
| 429 storage_->CancelDelegateCallbacks(this); | 429 storage_->CancelDelegateCallbacks(this); |
| 430 | 430 |
| 431 const net::HttpResponseInfo* http_info = is_range_request() | 431 const net::HttpResponseInfo* http_info = |
| 432 ? range_response_info_.get() | 432 is_range_request() ? range_response_info_.get() |
| 433 : info_->http_response_info(); | 433 : (info_ ? info_->http_response_info() : nullptr); |
| 434 | 434 |
| 435 ResourceRequestCompletionStatus request_complete_data; | 435 ResourceRequestCompletionStatus request_complete_data; |
| 436 request_complete_data.error_code = error_code; | 436 request_complete_data.error_code = error_code; |
| 437 | 437 |
| 438 // TODO(ananta) | 438 // TODO(ananta) |
| 439 // Fill other details in the ResourceRequestCompletionStatus structure in | 439 // Fill other details in the ResourceRequestCompletionStatus structure in |
| 440 // case of an error. | 440 // case of an error. |
| 441 if (!request_complete_data.error_code) { | 441 if (!request_complete_data.error_code) { |
| 442 request_complete_data.exists_in_cache = http_info->was_cached; | 442 request_complete_data.exists_in_cache = http_info->was_cached; |
| 443 request_complete_data.completion_time = base::TimeTicks::Now(); | 443 request_complete_data.completion_time = base::TimeTicks::Now(); |
| 444 request_complete_data.encoded_body_length = | 444 request_complete_data.encoded_body_length = |
| 445 is_range_request() ? range_response_info_->headers->GetContentLength() | 445 is_range_request() ? range_response_info_->headers->GetContentLength() |
| 446 : info_->response_data_size(); | 446 : (info_ ? info_->response_data_size() : 0); |
| 447 request_complete_data.decoded_body_length = | 447 request_complete_data.decoded_body_length = |
| 448 request_complete_data.encoded_body_length; | 448 request_complete_data.encoded_body_length; |
| 449 } | 449 } |
| 450 client_->OnComplete(request_complete_data); | 450 client_->OnComplete(request_complete_data); |
| 451 } | 451 } |
| 452 | 452 |
| 453 void AppCacheURLLoaderJob::DisconnectFromNetworkLoader() { | 453 void AppCacheURLLoaderJob::DisconnectFromNetworkLoader() { |
| 454 // Close the pipe to the network loader as we are delivering a fallback | 454 // Close the pipe to the network loader as we are delivering a fallback |
| 455 // response to the client. | 455 // response to the client. |
| 456 network_loader_client_binding_.Close(); | 456 network_loader_client_binding_.Close(); |
| 457 network_loader_ = nullptr; | 457 network_loader_ = nullptr; |
| 458 } | 458 } |
| 459 | 459 |
| 460 } // namespace content | 460 } // namespace content |
| OLD | NEW |