Index: content/common/net/url_fetcher_impl.cc |
diff --git a/content/common/net/url_fetcher_impl.cc b/content/common/net/url_fetcher_impl.cc |
index 24a6a3bc95ff4c2241e86afc7edb2404fc7ff5d7..921da23c79d8b6152f59f06cea2faadea83e5a64 100644 |
--- a/content/common/net/url_fetcher_impl.cc |
+++ b/content/common/net/url_fetcher_impl.cc |
@@ -20,6 +20,7 @@ |
#include "base/string_util.h" |
#include "base/threading/thread.h" |
#include "base/timer.h" |
+#include "content/public/common/content_url_request_user_data.h" |
#include "content/public/common/url_fetcher_delegate.h" |
#include "content/public/common/url_fetcher_factory.h" |
#include "googleurl/src/gurl.h" |
@@ -247,6 +248,7 @@ class URLFetcherImpl::Core |
// Read buffer |
scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
// Cookie/cache info for the request |
+ scoped_ptr<content::ContentURLRequestUserData> content_url_request_user_data_; |
net::ResponseCookies cookies_; // Response cookies |
net::HttpRequestHeaders extra_request_headers_; |
scoped_refptr<net::HttpResponseHeaders> response_headers_; |
@@ -568,6 +570,8 @@ URLFetcherImpl::Core::~Core() { |
void URLFetcherImpl::Core::Start() { |
DCHECK(delegate_loop_proxy_); |
DCHECK(request_context_getter_) << "We need an URLRequestContext!"; |
+ DCHECK(content_url_request_user_data_.get()) |
+ << "We need a ContentURLRequestUserData!"; |
if (io_message_loop_proxy_) { |
DCHECK_EQ(io_message_loop_proxy_, |
request_context_getter_->GetIOMessageLoopProxy()); |
@@ -763,6 +767,7 @@ void URLFetcherImpl::Core::RetryOrCompleteUrlFetch() { |
backoff_delay = base::TimeDelta(); |
} |
request_context_getter_ = NULL; |
+ content_url_request_user_data_.reset(NULL); |
bool posted = delegate_loop_proxy_->PostTask( |
FROM_HERE, base::Bind(&Core::OnCompletedURLRequest, this, backoff_delay)); |
@@ -796,6 +801,7 @@ void URLFetcherImpl::Core::StartURLRequest() { |
} |
DCHECK(request_context_getter_); |
+ DCHECK(content_url_request_user_data_.get()); |
DCHECK(!request_.get()); |
g_registry.Get().AddURLFetcherCore(this); |
@@ -810,6 +816,11 @@ void URLFetcherImpl::Core::StartURLRequest() { |
request_->set_load_flags(flags); |
request_->set_context(request_context_getter_->GetURLRequestContext()); |
request_->set_referrer(referrer_); |
+ request_->SetUserData( |
+ content::ContentURLRequestUserData::kUserDataKey, |
+ new content::ContentURLRequestUserData( |
+ content_url_request_user_data_->process_id(), |
+ content_url_request_user_data_->routing_id())); |
switch (request_type_) { |
case GET: |
@@ -890,6 +901,7 @@ void URLFetcherImpl::Core::CancelURLRequest() { |
// delete the object, but we cannot delay the destruction of the request |
// context. |
request_context_getter_ = NULL; |
+ content_url_request_user_data_.reset(NULL); |
was_cancelled_ = true; |
temp_file_writer_.reset(); |
} |
@@ -1023,6 +1035,12 @@ void URLFetcherImpl::SetRequestContext( |
core_->request_context_getter_ = request_context_getter; |
} |
+void URLFetcherImpl::SetContentURLRequestUserData( |
+ content::ContentURLRequestUserData* user_data) { |
+ DCHECK(!core_->content_url_request_user_data_.get()); |
+ core_->content_url_request_user_data_.reset(user_data); |
+} |
+ |
void URLFetcherImpl::SetAutomaticallyRetryOn5xx(bool retry) { |
core_->automatically_retry_on_5xx_ = retry; |
} |
@@ -1074,9 +1092,11 @@ void URLFetcherImpl::Start() { |
core_->Start(); |
} |
-void URLFetcherImpl::StartWithRequestContextGetter( |
- net::URLRequestContextGetter* request_context_getter) { |
+void URLFetcherImpl::StartWithRequestContextGetterAndUserData( |
+ net::URLRequestContextGetter* request_context_getter, |
+ content::ContentURLRequestUserData* user_data) { |
SetRequestContext(request_context_getter); |
+ SetContentURLRequestUserData(user_data); |
core_->Start(); |
} |