summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authormmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-14 05:04:30 +0000
committermmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-14 05:04:30 +0000
commit0a12e45004c11896b358ee01f41cee547313d301 (patch)
tree66406b1d881385ba04a09247b75b3b6684e9759b /net
parent89e4bfb3300a99095aa1d3dfb02c37d1edb8e64c (diff)
downloadchromium_src-0a12e45004c11896b358ee01f41cee547313d301.zip
chromium_src-0a12e45004c11896b358ee01f41cee547313d301.tar.gz
chromium_src-0a12e45004c11896b358ee01f41cee547313d301.tar.bz2
Set blocked_on_delegate_ when a URLRequest is blocked by
its NetworkDelegate during a redirect. R=eroman@chromium.org BUG=159197 Review URL: https://chromiumcodereview.appspot.com/11364057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167600 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/net_log_event_type_list.h9
-rw-r--r--net/url_request/url_request.cc11
-rw-r--r--net/url_request/url_request_http_job.cc5
-rw-r--r--net/url_request/url_request_job.cc3
-rw-r--r--net/url_request/url_request_job.h4
5 files changed, 23 insertions, 9 deletions
diff --git a/net/base/net_log_event_type_list.h b/net/base/net_log_event_type_list.h
index 2bdbae3..bbbbcdc 100644
--- a/net/base/net_log_event_type_list.h
+++ b/net/base/net_log_event_type_list.h
@@ -717,8 +717,13 @@ EVENT_TYPE(URL_REQUEST_START_JOB)
// }
EVENT_TYPE(URL_REQUEST_REDIRECTED)
-// Measures the time a net::URLRequest is blocked waiting for a delegate
-// (usually an extension) to respond to the onBeforeRequest extension event.
+// Measures the time a net::URLRequest is blocked waiting for either the
+// NetworkDelegate or a URLRequest::Delegate to respond.
+//
+// The parameters attached to the event are:
+// {
+// "delegate": <What's blocking the request, if known>,
+// }
EVENT_TYPE(URL_REQUEST_BLOCKED_ON_DELEGATE)
// The specified number of bytes were read from the net::URLRequest.
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc
index 2c35725..7bfa772 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -326,7 +326,8 @@ void URLRequest::SetExtraRequestHeaders(
}
LoadStateWithParam URLRequest::GetLoadState() const {
- if (blocked_on_delegate_) {
+ // Only return LOAD_STATE_WAITING_FOR_DELEGATE if there's a load state param.
+ if (blocked_on_delegate_ && !load_state_param_.empty()) {
return LoadStateWithParam(LOAD_STATE_WAITING_FOR_DELEGATE,
load_state_param_);
}
@@ -651,6 +652,7 @@ void URLRequest::NotifyReceivedRedirect(const GURL& location,
RestartWithJob(job);
} else if (delegate_) {
delegate_->OnReceivedRedirect(this, location, defer_redirect);
+ // |this| may be have been destroyed here.
}
}
@@ -964,7 +966,12 @@ void URLRequest::NotifyRequestCompleted() {
void URLRequest::SetBlockedOnDelegate() {
blocked_on_delegate_ = true;
- net_log_.BeginEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE);
+ if (!load_state_param_.empty()) {
+ net_log_.BeginEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE,
+ NetLog::StringCallback("delegate", &load_state_param_));
+ } else {
+ net_log_.BeginEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE);
+ }
}
void URLRequest::SetUnblockedOnDelegate() {
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index c011b436..241d2b8 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -813,8 +813,7 @@ void URLRequestHttpJob::OnStartCompleted(int result) {
if (error != net::OK) {
if (error == net::ERR_IO_PENDING) {
awaiting_callback_ = true;
- request_->net_log().BeginEvent(
- NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE);
+ SetBlockedOnDelegate();
} else {
std::string source("delegate");
request_->net_log().AddEvent(NetLog::TYPE_CANCELLED,
@@ -849,7 +848,7 @@ void URLRequestHttpJob::OnStartCompleted(int result) {
}
void URLRequestHttpJob::OnHeadersReceivedCallback(int result) {
- request_->net_log().EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE);
+ SetUnblockedOnDelegate();
awaiting_callback_ = false;
// Check that there are no callbacks to already canceled requests.
diff --git a/net/url_request/url_request_job.cc b/net/url_request/url_request_job.cc
index 66fc9f3..ba003838 100644
--- a/net/url_request/url_request_job.cc
+++ b/net/url_request/url_request_job.cc
@@ -191,6 +191,8 @@ void URLRequestJob::FollowDeferredRedirect() {
// It is also possible that FollowRedirect will drop the last reference to
// this job, so we need to reset our members before calling it.
+ SetUnblockedOnDelegate();
+
GURL redirect_url = deferred_redirect_url_;
int redirect_status_code = deferred_redirect_status_code_;
@@ -307,6 +309,7 @@ void URLRequestJob::NotifyHeadersComplete() {
if (defer_redirect) {
deferred_redirect_url_ = new_location;
deferred_redirect_status_code_ = http_status_code;
+ SetBlockedOnDelegate();
} else {
FollowRedirect(new_location, http_status_code);
}
diff --git a/net/url_request/url_request_job.h b/net/url_request/url_request_job.h
index 0af7fa1..0b462bc 100644
--- a/net/url_request/url_request_job.h
+++ b/net/url_request/url_request_job.h
@@ -241,8 +241,8 @@ class NET_EXPORT URLRequestJob : public base::RefCounted<URLRequestJob>,
// Should only be called if the job has not started a resposne.
void NotifyRestartRequired();
- // Called when the delegate blocks or unblocks this request when intercepting
- // certain requests.
+ // Called when the network delegate blocks or unblocks this request when
+ // intercepting certain requests.
void SetBlockedOnDelegate();
void SetUnblockedOnDelegate();