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.h" | 5 #include "net/url_request/url_request.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
651 referrer_.clear(); | 651 referrer_.clear(); |
652 std::string source("delegate"); | 652 std::string source("delegate"); |
653 net_log_.AddEvent(NetLog::TYPE_CANCELLED, | 653 net_log_.AddEvent(NetLog::TYPE_CANCELLED, |
654 NetLog::StringCallback("source", &source)); | 654 NetLog::StringCallback("source", &source)); |
655 RestartWithJob(new URLRequestErrorJob( | 655 RestartWithJob(new URLRequestErrorJob( |
656 this, network_delegate_, ERR_BLOCKED_BY_CLIENT)); | 656 this, network_delegate_, ERR_BLOCKED_BY_CLIENT)); |
657 return; | 657 return; |
658 } | 658 } |
659 } | 659 } |
660 | 660 |
661 // Mark the request as pending, as Start() always completes asynchronously. | |
662 // Status is generally set by URLRequestJob itself, but Start() calls | |
663 // directly into the URLRequestJob subclass, so URLRequestJob can't set it | |
664 // here. | |
665 // TODO(mmenke): Make the URLRequest manage its own status. | |
666 status_ = URLRequestStatus::FromError(ERR_IO_PENDING); | |
667 | |
661 // Don't allow errors to be sent from within Start(). | 668 // Don't allow errors to be sent from within Start(). |
Randy Smith (Not in Mondays)
2016/01/11 02:27:48
Do you understand this comment? It confuses me--I
mmenke
2016/01/11 06:17:11
I merged it with the above comment - yea, I think
| |
662 // TODO(brettw) this may cause NotifyDone to be sent synchronously, | |
663 // we probably don't want this: they should be sent asynchronously so | |
664 // the caller does not get reentered. | |
mmenke
2016/01/07 15:54:55
This comment is rather outdated - NotifyDone alway
Randy Smith (Not in Mondays)
2016/01/11 02:27:48
Acknowledged.
| |
665 job_->Start(); | 669 job_->Start(); |
666 } | 670 } |
667 | 671 |
668 void URLRequest::Restart() { | 672 void URLRequest::Restart() { |
669 // Should only be called if the original job didn't make any progress. | 673 // Should only be called if the original job didn't make any progress. |
670 DCHECK(job_.get() && !job_->has_response_started()); | 674 DCHECK(job_.get() && !job_->has_response_started()); |
671 RestartWithJob( | 675 RestartWithJob( |
672 URLRequestJobManager::GetInstance()->CreateJob(this, network_delegate_)); | 676 URLRequestJobManager::GetInstance()->CreateJob(this, network_delegate_)); |
673 } | 677 } |
674 | 678 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
848 NotifyRequestCompleted(); | 852 NotifyRequestCompleted(); |
849 | 853 |
850 OnCallToDelegate(); | 854 OnCallToDelegate(); |
851 delegate_->OnResponseStarted(this); | 855 delegate_->OnResponseStarted(this); |
852 // Nothing may appear below this line as OnResponseStarted may delete | 856 // Nothing may appear below this line as OnResponseStarted may delete |
853 // |this|. | 857 // |this|. |
854 } | 858 } |
855 } | 859 } |
856 | 860 |
857 void URLRequest::FollowDeferredRedirect() { | 861 void URLRequest::FollowDeferredRedirect() { |
858 CHECK(job_.get()); | 862 DCHECK(job_.get()); |
859 CHECK(status_.is_success()); | 863 DCHECK(status_.is_success()); |
860 | 864 |
865 status_ = URLRequestStatus::FromError(ERR_IO_PENDING); | |
Randy Smith (Not in Mondays)
2016/01/11 02:27:48
I'm struggling with my conscience as to whether th
mmenke
2016/01/11 06:17:11
So, we don't really distinguish well between what
| |
861 job_->FollowDeferredRedirect(); | 866 job_->FollowDeferredRedirect(); |
862 } | 867 } |
863 | 868 |
864 void URLRequest::SetAuth(const AuthCredentials& credentials) { | 869 void URLRequest::SetAuth(const AuthCredentials& credentials) { |
865 DCHECK(job_.get()); | 870 DCHECK(job_.get()); |
866 DCHECK(job_->NeedsAuth()); | 871 DCHECK(job_->NeedsAuth()); |
867 | 872 |
873 status_ = URLRequestStatus::FromError(ERR_IO_PENDING); | |
868 job_->SetAuth(credentials); | 874 job_->SetAuth(credentials); |
869 } | 875 } |
870 | 876 |
871 void URLRequest::CancelAuth() { | 877 void URLRequest::CancelAuth() { |
872 DCHECK(job_.get()); | 878 DCHECK(job_.get()); |
873 DCHECK(job_->NeedsAuth()); | 879 DCHECK(job_->NeedsAuth()); |
874 | 880 |
881 status_ = URLRequestStatus::FromError(ERR_IO_PENDING); | |
875 job_->CancelAuth(); | 882 job_->CancelAuth(); |
876 } | 883 } |
877 | 884 |
878 void URLRequest::ContinueWithCertificate(X509Certificate* client_cert, | 885 void URLRequest::ContinueWithCertificate(X509Certificate* client_cert, |
879 SSLPrivateKey* client_private_key) { | 886 SSLPrivateKey* client_private_key) { |
880 DCHECK(job_.get()); | 887 DCHECK(job_.get()); |
881 | 888 |
889 status_ = URLRequestStatus::FromError(ERR_IO_PENDING); | |
882 job_->ContinueWithCertificate(client_cert, client_private_key); | 890 job_->ContinueWithCertificate(client_cert, client_private_key); |
883 } | 891 } |
884 | 892 |
885 void URLRequest::ContinueDespiteLastError() { | 893 void URLRequest::ContinueDespiteLastError() { |
886 DCHECK(job_.get()); | 894 DCHECK(job_.get()); |
887 | 895 |
896 status_ = URLRequestStatus::FromError(ERR_IO_PENDING); | |
888 job_->ContinueDespiteLastError(); | 897 job_->ContinueDespiteLastError(); |
889 } | 898 } |
890 | 899 |
891 void URLRequest::PrepareToRestart() { | 900 void URLRequest::PrepareToRestart() { |
892 DCHECK(job_.get()); | 901 DCHECK(job_.get()); |
893 | 902 |
894 // Close the current URL_REQUEST_START_JOB, since we will be starting a new | 903 // Close the current URL_REQUEST_START_JOB, since we will be starting a new |
895 // one. | 904 // one. |
896 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_START_JOB); | 905 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_START_JOB); |
897 | 906 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1104 break; | 1113 break; |
1105 | 1114 |
1106 case NetworkDelegate::AUTH_REQUIRED_RESPONSE_IO_PENDING: | 1115 case NetworkDelegate::AUTH_REQUIRED_RESPONSE_IO_PENDING: |
1107 NOTREACHED(); | 1116 NOTREACHED(); |
1108 break; | 1117 break; |
1109 } | 1118 } |
1110 } | 1119 } |
1111 | 1120 |
1112 void URLRequest::NotifyCertificateRequested( | 1121 void URLRequest::NotifyCertificateRequested( |
1113 SSLCertRequestInfo* cert_request_info) { | 1122 SSLCertRequestInfo* cert_request_info) { |
1123 status_ = URLRequestStatus(); | |
1114 delegate_->OnCertificateRequested(this, cert_request_info); | 1124 delegate_->OnCertificateRequested(this, cert_request_info); |
1115 } | 1125 } |
1116 | 1126 |
1117 void URLRequest::NotifySSLCertificateError(const SSLInfo& ssl_info, | 1127 void URLRequest::NotifySSLCertificateError(const SSLInfo& ssl_info, |
1118 bool fatal) { | 1128 bool fatal) { |
1129 status_ = URLRequestStatus(); | |
1119 delegate_->OnSSLCertificateError(this, ssl_info, fatal); | 1130 delegate_->OnSSLCertificateError(this, ssl_info, fatal); |
1120 } | 1131 } |
1121 | 1132 |
1122 bool URLRequest::CanGetCookies(const CookieList& cookie_list) const { | 1133 bool URLRequest::CanGetCookies(const CookieList& cookie_list) const { |
1123 DCHECK(!(load_flags_ & LOAD_DO_NOT_SEND_COOKIES)); | 1134 DCHECK(!(load_flags_ & LOAD_DO_NOT_SEND_COOKIES)); |
1124 if (network_delegate_) { | 1135 if (network_delegate_) { |
1125 return network_delegate_->CanGetCookies(*this, cookie_list); | 1136 return network_delegate_->CanGetCookies(*this, cookie_list); |
1126 } | 1137 } |
1127 return g_default_can_use_cookies; | 1138 return g_default_can_use_cookies; |
1128 } | 1139 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1221 } | 1232 } |
1222 | 1233 |
1223 void URLRequest::GetConnectionAttempts(ConnectionAttempts* out) const { | 1234 void URLRequest::GetConnectionAttempts(ConnectionAttempts* out) const { |
1224 if (job_) | 1235 if (job_) |
1225 job_->GetConnectionAttempts(out); | 1236 job_->GetConnectionAttempts(out); |
1226 else | 1237 else |
1227 out->clear(); | 1238 out->clear(); |
1228 } | 1239 } |
1229 | 1240 |
1230 } // namespace net | 1241 } // namespace net |
OLD | NEW |