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

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

Issue 11364057: Set blocked_on_delegate_ when a URLRequest is blocked during redirects (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix comment Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « net/base/net_log_event_type_list.h ('k') | net/url_request/url_request_http_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 void URLRequest::SetExtraRequestHeaders( 319 void URLRequest::SetExtraRequestHeaders(
320 const HttpRequestHeaders& headers) { 320 const HttpRequestHeaders& headers) {
321 DCHECK(!is_pending_); 321 DCHECK(!is_pending_);
322 extra_request_headers_ = headers; 322 extra_request_headers_ = headers;
323 323
324 // NOTE: This method will likely become non-trivial once the other setters 324 // NOTE: This method will likely become non-trivial once the other setters
325 // for request headers are implemented. 325 // for request headers are implemented.
326 } 326 }
327 327
328 LoadStateWithParam URLRequest::GetLoadState() const { 328 LoadStateWithParam URLRequest::GetLoadState() const {
329 if (blocked_on_delegate_) { 329 // Only return LOAD_STATE_WAITING_FOR_DELEGATE if there's a load state param.
330 if (blocked_on_delegate_ && !load_state_param_.empty()) {
330 return LoadStateWithParam(LOAD_STATE_WAITING_FOR_DELEGATE, 331 return LoadStateWithParam(LOAD_STATE_WAITING_FOR_DELEGATE,
331 load_state_param_); 332 load_state_param_);
332 } 333 }
333 return LoadStateWithParam(job_ ? job_->GetLoadState() : LOAD_STATE_IDLE, 334 return LoadStateWithParam(job_ ? job_->GetLoadState() : LOAD_STATE_IDLE,
334 string16()); 335 string16());
335 } 336 }
336 337
337 UploadProgress URLRequest::GetUploadProgress() const { 338 UploadProgress URLRequest::GetUploadProgress() const {
338 if (!job_) { 339 if (!job_) {
339 // We haven't started or the request was cancelled 340 // We haven't started or the request was cancelled
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 bool* defer_redirect) { 645 bool* defer_redirect) {
645 is_redirecting_ = true; 646 is_redirecting_ = true;
646 647
647 URLRequestJob* job = 648 URLRequestJob* job =
648 URLRequestJobManager::GetInstance()->MaybeInterceptRedirect( 649 URLRequestJobManager::GetInstance()->MaybeInterceptRedirect(
649 this, network_delegate_, location); 650 this, network_delegate_, location);
650 if (job) { 651 if (job) {
651 RestartWithJob(job); 652 RestartWithJob(job);
652 } else if (delegate_) { 653 } else if (delegate_) {
653 delegate_->OnReceivedRedirect(this, location, defer_redirect); 654 delegate_->OnReceivedRedirect(this, location, defer_redirect);
655 // |this| may be have been destroyed here.
654 } 656 }
655 } 657 }
656 658
657 void URLRequest::NotifyResponseStarted() { 659 void URLRequest::NotifyResponseStarted() {
658 int net_error = OK; 660 int net_error = OK;
659 if (!status_.is_success()) 661 if (!status_.is_success())
660 net_error = status_.error(); 662 net_error = status_.error();
661 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_URL_REQUEST_START_JOB, 663 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_URL_REQUEST_START_JOB,
662 net_error); 664 net_error);
663 665
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 959
958 is_pending_ = false; 960 is_pending_ = false;
959 is_redirecting_ = false; 961 is_redirecting_ = false;
960 has_notified_completion_ = true; 962 has_notified_completion_ = true;
961 if (network_delegate_) 963 if (network_delegate_)
962 network_delegate_->NotifyCompleted(this, job_ != NULL); 964 network_delegate_->NotifyCompleted(this, job_ != NULL);
963 } 965 }
964 966
965 void URLRequest::SetBlockedOnDelegate() { 967 void URLRequest::SetBlockedOnDelegate() {
966 blocked_on_delegate_ = true; 968 blocked_on_delegate_ = true;
967 net_log_.BeginEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE); 969 if (!load_state_param_.empty()) {
970 net_log_.BeginEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE,
971 NetLog::StringCallback("delegate", &load_state_param_));
972 } else {
973 net_log_.BeginEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE);
974 }
968 } 975 }
969 976
970 void URLRequest::SetUnblockedOnDelegate() { 977 void URLRequest::SetUnblockedOnDelegate() {
971 if (!blocked_on_delegate_) 978 if (!blocked_on_delegate_)
972 return; 979 return;
973 blocked_on_delegate_ = false; 980 blocked_on_delegate_ = false;
974 load_state_param_.clear(); 981 load_state_param_.clear();
975 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE); 982 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE);
976 } 983 }
977 984
978 void URLRequest::set_stack_trace(const base::debug::StackTrace& stack_trace) { 985 void URLRequest::set_stack_trace(const base::debug::StackTrace& stack_trace) {
979 base::debug::StackTrace* stack_trace_copy = 986 base::debug::StackTrace* stack_trace_copy =
980 new base::debug::StackTrace(NULL, 0); 987 new base::debug::StackTrace(NULL, 0);
981 *stack_trace_copy = stack_trace; 988 *stack_trace_copy = stack_trace;
982 stack_trace_.reset(stack_trace_copy); 989 stack_trace_.reset(stack_trace_copy);
983 } 990 }
984 991
985 const base::debug::StackTrace* URLRequest::stack_trace() const { 992 const base::debug::StackTrace* URLRequest::stack_trace() const {
986 return stack_trace_.get(); 993 return stack_trace_.get();
987 } 994 }
988 995
989 } // namespace net 996 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_log_event_type_list.h ('k') | net/url_request/url_request_http_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698