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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 return; | 369 return; |
370 | 370 |
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; |
mmenke
2015/08/03 21:01:20
These three checks seem aimed at papering over bug
davidben
2015/08/05 18:56:39
Clearly we should unrefcount URLRequestJob. :-) Th
mmenke
2015/08/05 20:00:24
I agree with removing refcounting, but that wouldn
| |
380 | 380 |
381 DCHECK(!request_->status().is_io_pending()); | 381 // This should not be called on error, and the job type should have cleared |
382 // IO_PENDING state before calling this method. | |
383 DCHECK(request_->status().is_success()); | |
382 | 384 |
383 // Initialize to the current time, and let the subclass optionally override | 385 // Initialize to the current time, and let the subclass optionally override |
384 // the time stamps if it has that information. The default request_time is | 386 // the time stamps if it has that information. The default request_time is |
385 // set by URLRequest before it calls our Start method. | 387 // set by URLRequest before it calls our Start method. |
386 request_->response_info_.response_time = base::Time::Now(); | 388 request_->response_info_.response_time = base::Time::Now(); |
387 GetResponseInfo(&request_->response_info_); | 389 GetResponseInfo(&request_->response_info_); |
388 | 390 |
389 // When notifying the delegate, the delegate can release the request | 391 // When notifying the delegate, the delegate can release the request |
390 // (and thus release 'this'). After calling to the delgate, we must | 392 // (and thus release 'this'). After calling to the delgate, we must |
391 // check the request pointer to see if it still exists, and return | 393 // 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... | |
754 | 756 |
755 const URLRequestStatus URLRequestJob::GetStatus() { | 757 const URLRequestStatus URLRequestJob::GetStatus() { |
756 if (request_) | 758 if (request_) |
757 return request_->status(); | 759 return request_->status(); |
758 // If the request is gone, we must be cancelled. | 760 // If the request is gone, we must be cancelled. |
759 return URLRequestStatus(URLRequestStatus::CANCELED, | 761 return URLRequestStatus(URLRequestStatus::CANCELED, |
760 ERR_ABORTED); | 762 ERR_ABORTED); |
761 } | 763 } |
762 | 764 |
763 void URLRequestJob::SetStatus(const URLRequestStatus &status) { | 765 void URLRequestJob::SetStatus(const URLRequestStatus &status) { |
764 if (request_) | 766 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()); | |
mmenke
2015/08/03 21:01:20
Want to change the added DCHECKs to CHECKs (Partic
davidben
2015/08/05 18:56:39
SGTM.
| |
765 request_->set_status(status); | 770 request_->set_status(status); |
771 } | |
766 } | 772 } |
767 | 773 |
768 void URLRequestJob::SetProxyServer(const HostPortPair& proxy_server) { | 774 void URLRequestJob::SetProxyServer(const HostPortPair& proxy_server) { |
769 request_->proxy_server_ = proxy_server; | 775 request_->proxy_server_ = proxy_server; |
770 } | 776 } |
771 | 777 |
772 bool URLRequestJob::ReadRawDataForFilter(int* bytes_read) { | 778 bool URLRequestJob::ReadRawDataForFilter(int* bytes_read) { |
773 bool rv = false; | 779 bool rv = false; |
774 | 780 |
775 DCHECK(bytes_read); | 781 DCHECK(bytes_read); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
899 // Alter the referrer if redirecting cross-origin (especially HTTP->HTTPS). | 905 // Alter the referrer if redirecting cross-origin (especially HTTP->HTTPS). |
900 redirect_info.new_referrer = | 906 redirect_info.new_referrer = |
901 ComputeReferrerForRedirect(request_->referrer_policy(), | 907 ComputeReferrerForRedirect(request_->referrer_policy(), |
902 request_->referrer(), | 908 request_->referrer(), |
903 redirect_info.new_url).spec(); | 909 redirect_info.new_url).spec(); |
904 | 910 |
905 return redirect_info; | 911 return redirect_info; |
906 } | 912 } |
907 | 913 |
908 } // namespace net | 914 } // namespace net |
OLD | NEW |