OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/url_request/url_request_job.h" | 5 #include "net/url_request/url_request_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 request_->NotifyBeforeNetworkStart(defer); | 371 request_->NotifyBeforeNetworkStart(defer); |
372 } | 372 } |
373 | 373 |
374 void URLRequestJob::NotifyHeadersComplete() { | 374 void URLRequestJob::NotifyHeadersComplete() { |
375 if (!request_ || !request_->has_delegate()) | 375 if (!request_ || !request_->has_delegate()) |
376 return; // The request was destroyed, so there is no more work to do. | 376 return; // The request was destroyed, so there is no more work to do. |
377 | 377 |
378 if (has_handled_response_) | 378 if (has_handled_response_) |
379 return; | 379 return; |
380 | 380 |
381 // This should not be called on error, and the job type should have cleared | 381 DCHECK(!request_->status().is_io_pending()); |
382 // IO_PENDING state before calling this method. | |
383 DCHECK(request_->status().is_success()); | |
384 | 382 |
385 // Initialize to the current time, and let the subclass optionally override | 383 // Initialize to the current time, and let the subclass optionally override |
386 // the time stamps if it has that information. The default request_time is | 384 // the time stamps if it has that information. The default request_time is |
387 // set by URLRequest before it calls our Start method. | 385 // set by URLRequest before it calls our Start method. |
388 request_->response_info_.response_time = base::Time::Now(); | 386 request_->response_info_.response_time = base::Time::Now(); |
389 GetResponseInfo(&request_->response_info_); | 387 GetResponseInfo(&request_->response_info_); |
390 | 388 |
391 // When notifying the delegate, the delegate can release the request | 389 // When notifying the delegate, the delegate can release the request |
392 // (and thus release 'this'). After calling to the delgate, we must | 390 // (and thus release 'this'). After calling to the delgate, we must |
393 // check the request pointer to see if it still exists, and return | 391 // check the request pointer to see if it still exists, and return |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 | 754 |
757 const URLRequestStatus URLRequestJob::GetStatus() { | 755 const URLRequestStatus URLRequestJob::GetStatus() { |
758 if (request_) | 756 if (request_) |
759 return request_->status(); | 757 return request_->status(); |
760 // If the request is gone, we must be cancelled. | 758 // If the request is gone, we must be cancelled. |
761 return URLRequestStatus(URLRequestStatus::CANCELED, | 759 return URLRequestStatus(URLRequestStatus::CANCELED, |
762 ERR_ABORTED); | 760 ERR_ABORTED); |
763 } | 761 } |
764 | 762 |
765 void URLRequestJob::SetStatus(const URLRequestStatus &status) { | 763 void URLRequestJob::SetStatus(const URLRequestStatus &status) { |
766 if (request_) { | 764 if (request_) |
767 // A URLRequestJob should not replace a failed or cancelled status. | |
768 DCHECK(request_->status().is_success() || | |
769 request_->status().is_io_pending()); | |
770 request_->set_status(status); | 765 request_->set_status(status); |
771 } | |
772 } | 766 } |
773 | 767 |
774 void URLRequestJob::SetProxyServer(const HostPortPair& proxy_server) { | 768 void URLRequestJob::SetProxyServer(const HostPortPair& proxy_server) { |
775 request_->proxy_server_ = proxy_server; | 769 request_->proxy_server_ = proxy_server; |
776 } | 770 } |
777 | 771 |
778 bool URLRequestJob::ReadRawDataForFilter(int* bytes_read) { | 772 bool URLRequestJob::ReadRawDataForFilter(int* bytes_read) { |
779 bool rv = false; | 773 bool rv = false; |
780 | 774 |
781 DCHECK(bytes_read); | 775 DCHECK(bytes_read); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 // Alter the referrer if redirecting cross-origin (especially HTTP->HTTPS). | 899 // Alter the referrer if redirecting cross-origin (especially HTTP->HTTPS). |
906 redirect_info.new_referrer = | 900 redirect_info.new_referrer = |
907 ComputeReferrerForRedirect(request_->referrer_policy(), | 901 ComputeReferrerForRedirect(request_->referrer_policy(), |
908 request_->referrer(), | 902 request_->referrer(), |
909 redirect_info.new_url).spec(); | 903 redirect_info.new_url).spec(); |
910 | 904 |
911 return redirect_info; | 905 return redirect_info; |
912 } | 906 } |
913 | 907 |
914 } // namespace net | 908 } // namespace net |
OLD | NEW |