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 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 | 794 |
795 void URLRequest::StopCaching() { | 795 void URLRequest::StopCaching() { |
796 DCHECK(job_.get()); | 796 DCHECK(job_.get()); |
797 job_->StopCaching(); | 797 job_->StopCaching(); |
798 } | 798 } |
799 | 799 |
800 void URLRequest::NotifyReceivedRedirect(const RedirectInfo& redirect_info, | 800 void URLRequest::NotifyReceivedRedirect(const RedirectInfo& redirect_info, |
801 bool* defer_redirect) { | 801 bool* defer_redirect) { |
802 is_redirecting_ = true; | 802 is_redirecting_ = true; |
803 | 803 |
804 // TODO(davidben): Pass the full RedirectInfo down to MaybeInterceptRedirect? | |
805 URLRequestJob* job = | 804 URLRequestJob* job = |
806 URLRequestJobManager::GetInstance()->MaybeInterceptRedirect( | 805 URLRequestJobManager::GetInstance()->MaybeInterceptRedirect( |
807 this, network_delegate_, redirect_info.new_url); | 806 this, network_delegate_, redirect_info.new_url); |
808 if (job) { | 807 if (job) { |
809 RestartWithJob(job); | 808 RestartWithJob(job); |
810 } else { | 809 } else { |
811 OnCallToDelegate(); | 810 OnCallToDelegate(); |
812 delegate_->OnReceivedRedirect(this, redirect_info, defer_redirect); | 811 delegate_->OnReceivedRedirect(this, redirect_info, defer_redirect); |
813 // |this| may be have been destroyed here. | 812 // |this| may be have been destroyed here. |
814 } | 813 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 int URLRequest::Redirect(const RedirectInfo& redirect_info) { | 917 int URLRequest::Redirect(const RedirectInfo& redirect_info) { |
919 // Matches call in NotifyReceivedRedirect. | 918 // Matches call in NotifyReceivedRedirect. |
920 OnCallToDelegateComplete(); | 919 OnCallToDelegateComplete(); |
921 if (net_log_.IsCapturing()) { | 920 if (net_log_.IsCapturing()) { |
922 net_log_.AddEvent( | 921 net_log_.AddEvent( |
923 NetLogEventType::URL_REQUEST_REDIRECTED, | 922 NetLogEventType::URL_REQUEST_REDIRECTED, |
924 NetLog::StringCallback("location", | 923 NetLog::StringCallback("location", |
925 &redirect_info.new_url.possibly_invalid_spec())); | 924 &redirect_info.new_url.possibly_invalid_spec())); |
926 } | 925 } |
927 | 926 |
928 // TODO(davidben): Pass the full RedirectInfo to the NetworkDelegate. | |
929 if (network_delegate_) | 927 if (network_delegate_) |
930 network_delegate_->NotifyBeforeRedirect(this, redirect_info.new_url); | 928 network_delegate_->NotifyBeforeRedirect(this, redirect_info.new_url); |
931 | 929 |
932 if (redirect_limit_ <= 0) { | 930 if (redirect_limit_ <= 0) { |
933 DVLOG(1) << "disallowing redirect: exceeds limit"; | 931 DVLOG(1) << "disallowing redirect: exceeds limit"; |
934 return ERR_TOO_MANY_REDIRECTS; | 932 return ERR_TOO_MANY_REDIRECTS; |
935 } | 933 } |
936 | 934 |
937 if (!redirect_info.new_url.is_valid()) | 935 if (!redirect_info.new_url.is_valid()) |
938 return ERR_INVALID_URL; | 936 return ERR_INVALID_URL; |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 out->clear(); | 1213 out->clear(); |
1216 } | 1214 } |
1217 | 1215 |
1218 void URLRequest::set_status(URLRequestStatus status) { | 1216 void URLRequest::set_status(URLRequestStatus status) { |
1219 DCHECK(status_.is_io_pending() || status_.is_success() || | 1217 DCHECK(status_.is_io_pending() || status_.is_success() || |
1220 (!status.is_success() && !status.is_io_pending())); | 1218 (!status.is_success() && !status.is_io_pending())); |
1221 status_ = status; | 1219 status_ = status; |
1222 } | 1220 } |
1223 | 1221 |
1224 } // namespace net | 1222 } // namespace net |
OLD | NEW |