Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: net/url_request/url_request.cc

Issue 1563633002: Make URLRequestJob::SetStatus private. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // Don't allow errors to be sent from within Start(). 661 // Start() always completes asynchronously.
662 // TODO(brettw) this may cause NotifyDone to be sent synchronously, 662 //
663 // we probably don't want this: they should be sent asynchronously so 663 // Status is generally set by URLRequestJob itself, but Start() calls
664 // the caller does not get reentered. 664 // directly into the URLRequestJob subclass, so URLRequestJob can't set it
665 // here.
666 // TODO(mmenke): Make the URLRequest manage its own status.
667 status_ = URLRequestStatus::FromError(ERR_IO_PENDING);
665 job_->Start(); 668 job_->Start();
666 } 669 }
667 670
668 void URLRequest::Restart() { 671 void URLRequest::Restart() {
669 // Should only be called if the original job didn't make any progress. 672 // Should only be called if the original job didn't make any progress.
670 DCHECK(job_.get() && !job_->has_response_started()); 673 DCHECK(job_.get() && !job_->has_response_started());
671 RestartWithJob( 674 RestartWithJob(
672 URLRequestJobManager::GetInstance()->CreateJob(this, network_delegate_)); 675 URLRequestJobManager::GetInstance()->CreateJob(this, network_delegate_));
673 } 676 }
674 677
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 NotifyRequestCompleted(); 851 NotifyRequestCompleted();
849 852
850 OnCallToDelegate(); 853 OnCallToDelegate();
851 delegate_->OnResponseStarted(this); 854 delegate_->OnResponseStarted(this);
852 // Nothing may appear below this line as OnResponseStarted may delete 855 // Nothing may appear below this line as OnResponseStarted may delete
853 // |this|. 856 // |this|.
854 } 857 }
855 } 858 }
856 859
857 void URLRequest::FollowDeferredRedirect() { 860 void URLRequest::FollowDeferredRedirect() {
858 CHECK(job_.get()); 861 DCHECK(job_.get());
859 CHECK(status_.is_success()); 862 DCHECK(status_.is_success());
860 863
864 status_ = URLRequestStatus::FromError(ERR_IO_PENDING);
861 job_->FollowDeferredRedirect(); 865 job_->FollowDeferredRedirect();
862 } 866 }
863 867
864 void URLRequest::SetAuth(const AuthCredentials& credentials) { 868 void URLRequest::SetAuth(const AuthCredentials& credentials) {
865 DCHECK(job_.get()); 869 DCHECK(job_.get());
866 DCHECK(job_->NeedsAuth()); 870 DCHECK(job_->NeedsAuth());
867 871
872 status_ = URLRequestStatus::FromError(ERR_IO_PENDING);
868 job_->SetAuth(credentials); 873 job_->SetAuth(credentials);
869 } 874 }
870 875
871 void URLRequest::CancelAuth() { 876 void URLRequest::CancelAuth() {
872 DCHECK(job_.get()); 877 DCHECK(job_.get());
873 DCHECK(job_->NeedsAuth()); 878 DCHECK(job_->NeedsAuth());
874 879
880 status_ = URLRequestStatus::FromError(ERR_IO_PENDING);
875 job_->CancelAuth(); 881 job_->CancelAuth();
876 } 882 }
877 883
878 void URLRequest::ContinueWithCertificate(X509Certificate* client_cert, 884 void URLRequest::ContinueWithCertificate(X509Certificate* client_cert,
879 SSLPrivateKey* client_private_key) { 885 SSLPrivateKey* client_private_key) {
880 DCHECK(job_.get()); 886 DCHECK(job_.get());
881 887
888 status_ = URLRequestStatus::FromError(ERR_IO_PENDING);
882 job_->ContinueWithCertificate(client_cert, client_private_key); 889 job_->ContinueWithCertificate(client_cert, client_private_key);
883 } 890 }
884 891
885 void URLRequest::ContinueDespiteLastError() { 892 void URLRequest::ContinueDespiteLastError() {
886 DCHECK(job_.get()); 893 DCHECK(job_.get());
887 894
895 status_ = URLRequestStatus::FromError(ERR_IO_PENDING);
888 job_->ContinueDespiteLastError(); 896 job_->ContinueDespiteLastError();
889 } 897 }
890 898
891 void URLRequest::PrepareToRestart() { 899 void URLRequest::PrepareToRestart() {
892 DCHECK(job_.get()); 900 DCHECK(job_.get());
893 901
894 // Close the current URL_REQUEST_START_JOB, since we will be starting a new 902 // Close the current URL_REQUEST_START_JOB, since we will be starting a new
895 // one. 903 // one.
896 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_START_JOB); 904 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_START_JOB);
897 905
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 break; 1112 break;
1105 1113
1106 case NetworkDelegate::AUTH_REQUIRED_RESPONSE_IO_PENDING: 1114 case NetworkDelegate::AUTH_REQUIRED_RESPONSE_IO_PENDING:
1107 NOTREACHED(); 1115 NOTREACHED();
1108 break; 1116 break;
1109 } 1117 }
1110 } 1118 }
1111 1119
1112 void URLRequest::NotifyCertificateRequested( 1120 void URLRequest::NotifyCertificateRequested(
1113 SSLCertRequestInfo* cert_request_info) { 1121 SSLCertRequestInfo* cert_request_info) {
1122 status_ = URLRequestStatus();
1114 delegate_->OnCertificateRequested(this, cert_request_info); 1123 delegate_->OnCertificateRequested(this, cert_request_info);
1115 } 1124 }
1116 1125
1117 void URLRequest::NotifySSLCertificateError(const SSLInfo& ssl_info, 1126 void URLRequest::NotifySSLCertificateError(const SSLInfo& ssl_info,
1118 bool fatal) { 1127 bool fatal) {
1128 status_ = URLRequestStatus();
1119 delegate_->OnSSLCertificateError(this, ssl_info, fatal); 1129 delegate_->OnSSLCertificateError(this, ssl_info, fatal);
1120 } 1130 }
1121 1131
1122 bool URLRequest::CanGetCookies(const CookieList& cookie_list) const { 1132 bool URLRequest::CanGetCookies(const CookieList& cookie_list) const {
1123 DCHECK(!(load_flags_ & LOAD_DO_NOT_SEND_COOKIES)); 1133 DCHECK(!(load_flags_ & LOAD_DO_NOT_SEND_COOKIES));
1124 if (network_delegate_) { 1134 if (network_delegate_) {
1125 return network_delegate_->CanGetCookies(*this, cookie_list); 1135 return network_delegate_->CanGetCookies(*this, cookie_list);
1126 } 1136 }
1127 return g_default_can_use_cookies; 1137 return g_default_can_use_cookies;
1128 } 1138 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 } 1231 }
1222 1232
1223 void URLRequest::GetConnectionAttempts(ConnectionAttempts* out) const { 1233 void URLRequest::GetConnectionAttempts(ConnectionAttempts* out) const {
1224 if (job_) 1234 if (job_)
1225 job_->GetConnectionAttempts(out); 1235 job_->GetConnectionAttempts(out);
1226 else 1236 else
1227 out->clear(); 1237 out->clear();
1228 } 1238 }
1229 1239
1230 } // namespace net 1240 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698