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

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
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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 void URLRequest::SetExtraRequestHeaders( 310 void URLRequest::SetExtraRequestHeaders(
311 const HttpRequestHeaders& headers) { 311 const HttpRequestHeaders& headers) {
312 DCHECK(!is_pending_); 312 DCHECK(!is_pending_);
313 extra_request_headers_ = headers; 313 extra_request_headers_ = headers;
314 314
315 // NOTE: This method will likely become non-trivial once the other setters 315 // NOTE: This method will likely become non-trivial once the other setters
316 // for request headers are implemented. 316 // for request headers are implemented.
317 } 317 }
318 318
319 LoadStateWithParam URLRequest::GetLoadState() const { 319 LoadStateWithParam URLRequest::GetLoadState() const {
320 if (blocked_on_delegate_) { 320 // Only return LOAD_STATE_WAITING_FOR_DELEGATE if there's a load state param.
321 if (blocked_on_delegate_ && !load_state_param_.empty()) {
mmenke 2012/11/07 17:25:25 This is need because the text we display on the lo
eroman 2012/11/13 20:50:11 Do you know what circumstances this happens, and w
321 return LoadStateWithParam(LOAD_STATE_WAITING_FOR_DELEGATE, 322 return LoadStateWithParam(LOAD_STATE_WAITING_FOR_DELEGATE,
322 load_state_param_); 323 load_state_param_);
323 } 324 }
324 return LoadStateWithParam(job_ ? job_->GetLoadState() : LOAD_STATE_IDLE, 325 return LoadStateWithParam(job_ ? job_->GetLoadState() : LOAD_STATE_IDLE,
325 string16()); 326 string16());
326 } 327 }
327 328
328 UploadProgress URLRequest::GetUploadProgress() const { 329 UploadProgress URLRequest::GetUploadProgress() const {
329 if (!job_) { 330 if (!job_) {
330 // We haven't started or the request was cancelled 331 // We haven't started or the request was cancelled
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 632
632 void URLRequest::NotifyReceivedRedirect(const GURL& location, 633 void URLRequest::NotifyReceivedRedirect(const GURL& location,
633 bool* defer_redirect) { 634 bool* defer_redirect) {
634 URLRequestJob* job = 635 URLRequestJob* job =
635 URLRequestJobManager::GetInstance()->MaybeInterceptRedirect( 636 URLRequestJobManager::GetInstance()->MaybeInterceptRedirect(
636 this, network_delegate_, location); 637 this, network_delegate_, location);
637 if (job) { 638 if (job) {
638 RestartWithJob(job); 639 RestartWithJob(job);
639 } else if (delegate_) { 640 } else if (delegate_) {
640 delegate_->OnReceivedRedirect(this, location, defer_redirect); 641 delegate_->OnReceivedRedirect(this, location, defer_redirect);
642 // |this| may be have been destroyed here.
641 } 643 }
642 } 644 }
643 645
644 void URLRequest::NotifyResponseStarted() { 646 void URLRequest::NotifyResponseStarted() {
645 int net_error = OK; 647 int net_error = OK;
646 if (!status_.is_success()) 648 if (!status_.is_success())
647 net_error = status_.error(); 649 net_error = status_.error();
648 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_URL_REQUEST_START_JOB, 650 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_URL_REQUEST_START_JOB,
649 net_error); 651 net_error);
650 652
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 return; 945 return;
944 946
945 is_pending_ = false; 947 is_pending_ = false;
946 has_notified_completion_ = true; 948 has_notified_completion_ = true;
947 if (network_delegate_) 949 if (network_delegate_)
948 network_delegate_->NotifyCompleted(this, job_ != NULL); 950 network_delegate_->NotifyCompleted(this, job_ != NULL);
949 } 951 }
950 952
951 void URLRequest::SetBlockedOnDelegate() { 953 void URLRequest::SetBlockedOnDelegate() {
952 blocked_on_delegate_ = true; 954 blocked_on_delegate_ = true;
953 net_log_.BeginEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE); 955 if (!load_state_param_.empty()) {
956 net_log_.BeginEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE,
957 NetLog::StringCallback("delegate", &load_state_param_));
958 } else {
959 net_log_.BeginEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE);
960 }
954 } 961 }
955 962
956 void URLRequest::SetUnblockedOnDelegate() { 963 void URLRequest::SetUnblockedOnDelegate() {
957 if (!blocked_on_delegate_) 964 if (!blocked_on_delegate_)
958 return; 965 return;
959 blocked_on_delegate_ = false; 966 blocked_on_delegate_ = false;
960 load_state_param_.clear(); 967 load_state_param_.clear();
961 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE); 968 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE);
962 } 969 }
963 970
964 void URLRequest::set_stack_trace(const base::debug::StackTrace& stack_trace) { 971 void URLRequest::set_stack_trace(const base::debug::StackTrace& stack_trace) {
965 base::debug::StackTrace* stack_trace_copy = 972 base::debug::StackTrace* stack_trace_copy =
966 new base::debug::StackTrace(NULL, 0); 973 new base::debug::StackTrace(NULL, 0);
967 *stack_trace_copy = stack_trace; 974 *stack_trace_copy = stack_trace;
968 stack_trace_.reset(stack_trace_copy); 975 stack_trace_.reset(stack_trace_copy);
969 } 976 }
970 977
971 const base::debug::StackTrace* URLRequest::stack_trace() const { 978 const base::debug::StackTrace* URLRequest::stack_trace() const {
972 return stack_trace_.get(); 979 return stack_trace_.get();
973 } 980 }
974 981
975 } // namespace net 982 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698