summaryrefslogtreecommitdiffstats
path: root/net/url_request
diff options
context:
space:
mode:
authorpeter@chromium.org <peter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-12 18:23:05 +0000
committerpeter@chromium.org <peter@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-12 18:23:05 +0000
commita8030a22c88436615550267e26b539382dd5fe8b (patch)
treed25b01d04058e18309329edef8cfb1d059690429 /net/url_request
parent26ca33d393dbd3d3b8763d1659f906f52d2e0289 (diff)
downloadchromium_src-a8030a22c88436615550267e26b539382dd5fe8b.zip
chromium_src-a8030a22c88436615550267e26b539382dd5fe8b.tar.gz
chromium_src-a8030a22c88436615550267e26b539382dd5fe8b.tar.bz2
Revert 256579 "Allow the content browser client to specify a spe..."
This broke the Android builders. The try-bots on the CL did point out the compile errors, but it was committed manually anyway. Logs: http://build.chromium.org/p/chromium.linux/builders/Android%20Clang%20Builder%20%28dbg%29/builds/30977/steps/compile/logs/stdio > Allow the content browser client to specify a special cookie store to be > used for a given render process id. This special cookie store will then > be used for renderer messages pertaining to cookies, url fetches in net, > and websockets. If the special cookie store is NULL, a default cookie store > will be used. > > R=erikwright@chromium.org, jam@chromium.org, lambroslambrou@chromium.org, mmenke@chromium.org, tyoshino@chromium.org > > Review URL: https://codereview.chromium.org/188693003 TBR=tburkard@chromium.org Review URL: https://codereview.chromium.org/197463003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256583 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request')
-rw-r--r--net/url_request/url_fetcher_core.cc2
-rw-r--r--net/url_request/url_request.cc82
-rw-r--r--net/url_request/url_request.h24
-rw-r--r--net/url_request/url_request_context.cc6
-rw-r--r--net/url_request/url_request_context.h6
-rw-r--r--net/url_request/url_request_http_job.cc9
-rw-r--r--net/url_request/url_request_job.cc6
-rw-r--r--net/url_request/url_request_job.h4
8 files changed, 40 insertions, 99 deletions
diff --git a/net/url_request/url_fetcher_core.cc b/net/url_request/url_fetcher_core.cc
index eb45ecf..eea2e81 100644
--- a/net/url_request/url_fetcher_core.cc
+++ b/net/url_request/url_fetcher_core.cc
@@ -507,7 +507,7 @@ void URLFetcherCore::StartURLRequest() {
g_registry.Get().AddURLFetcherCore(this);
current_response_bytes_ = 0;
request_ = request_context_getter_->GetURLRequestContext()->CreateRequest(
- original_url_, DEFAULT_PRIORITY, this, NULL);
+ original_url_, DEFAULT_PRIORITY, this);
request_->set_stack_trace(stack_trace_);
int flags = request_->load_flags() | load_flags_;
if (!g_interception_enabled)
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc
index e2be4c2..531e8e8 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -209,17 +209,38 @@ URLRequest::URLRequest(const GURL& url,
RequestPriority priority,
Delegate* delegate,
const URLRequestContext* context)
- : identifier_(GenerateURLRequestIdentifier()) {
- Init(url, priority, delegate, context, NULL);
-}
+ : context_(context),
+ network_delegate_(context->network_delegate()),
+ net_log_(BoundNetLog::Make(context->net_log(),
+ NetLog::SOURCE_URL_REQUEST)),
+ url_chain_(1, url),
+ method_("GET"),
+ referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE),
+ load_flags_(LOAD_NORMAL),
+ delegate_(delegate),
+ is_pending_(false),
+ is_redirecting_(false),
+ redirect_limit_(kMaxRedirects),
+ priority_(priority),
+ identifier_(GenerateURLRequestIdentifier()),
+ calling_delegate_(false),
+ use_blocked_by_as_load_param_(false),
+ before_request_callback_(base::Bind(&URLRequest::BeforeRequestComplete,
+ base::Unretained(this))),
+ has_notified_completion_(false),
+ received_response_content_length_(0),
+ creation_time_(base::TimeTicks::Now()),
+ notified_before_network_start_(false) {
+ SIMPLE_STATS_COUNTER("URLRequestCount");
-URLRequest::URLRequest(const GURL& url,
- RequestPriority priority,
- Delegate* delegate,
- const URLRequestContext* context,
- CookieStore* cookie_store)
- : identifier_(GenerateURLRequestIdentifier()) {
- Init(url, priority, delegate, context, cookie_store);
+ // Sanity check out environment.
+ DCHECK(base::MessageLoop::current())
+ << "The current base::MessageLoop must exist";
+
+ CHECK(context);
+ context->url_requests()->insert(this);
+
+ net_log_.BeginEvent(NetLog::TYPE_REQUEST_ALIVE);
}
URLRequest::~URLRequest() {
@@ -263,47 +284,6 @@ void URLRequest::UnregisterRequestInterceptor(Interceptor* interceptor) {
interceptor);
}
-void URLRequest::Init(const GURL& url,
- RequestPriority priority,
- Delegate* delegate,
- const URLRequestContext* context,
- CookieStore* cookie_store) {
- context_ = context;
- network_delegate_ = context->network_delegate();
- net_log_ = BoundNetLog::Make(context->net_log(), NetLog::SOURCE_URL_REQUEST);
- url_chain_.push_back(url);
- method_ = "GET";
- referrer_policy_ = CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE;
- load_flags_ = LOAD_NORMAL;
- delegate_ = delegate;
- is_pending_ = false;
- is_redirecting_ = false;
- redirect_limit_ = kMaxRedirects;
- priority_ = priority;
- calling_delegate_ = false;
- use_blocked_by_as_load_param_ =false;
- before_request_callback_ = base::Bind(&URLRequest::BeforeRequestComplete,
- base::Unretained(this));
- has_notified_completion_ = false;
- received_response_content_length_ = 0;
- creation_time_ = base::TimeTicks::Now();
- notified_before_network_start_ = false;
-
- SIMPLE_STATS_COUNTER("URLRequestCount");
-
- // Sanity check out environment.
- DCHECK(base::MessageLoop::current())
- << "The current base::MessageLoop must exist";
-
- CHECK(context);
- context->url_requests()->insert(this);
- cookie_store_ = cookie_store;
- if (cookie_store_ == NULL)
- cookie_store_ = context->cookie_store();
-
- net_log_.BeginEvent(NetLog::TYPE_REQUEST_ALIVE);
-}
-
void URLRequest::EnableChunkedUpload() {
DCHECK(!upload_data_stream_ || upload_data_stream_->is_chunked());
if (!upload_data_stream_) {
diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h
index f4e8c40..7c8e1a9 100644
--- a/net/url_request/url_request.h
+++ b/net/url_request/url_request.h
@@ -25,7 +25,6 @@
#include "net/base/request_priority.h"
#include "net/base/upload_progress.h"
#include "net/cookies/canonical_cookie.h"
-#include "net/cookies/cookie_store.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_response_info.h"
#include "net/url_request/url_request_status.h"
@@ -292,20 +291,11 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe),
virtual ~Delegate() {}
};
- // TODO(tburkard): we should get rid of this constructor, and have each
- // creator of a URLRequest specifically list the cookie store to be used.
- // For now, this constructor will use the cookie store in |context|.
URLRequest(const GURL& url,
RequestPriority priority,
Delegate* delegate,
const URLRequestContext* context);
- URLRequest(const GURL& url,
- RequestPriority priority,
- Delegate* delegate,
- const URLRequestContext* context,
- CookieStore* cookie_store);
-
// If destroyed after Start() has been called but while IO is pending,
// then the request will be effectively canceled and the delegate
// will not have any more of its methods called.
@@ -701,8 +691,6 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe),
// Allow the URLRequestJob class to set our status too
void set_status(const URLRequestStatus& value) { status_ = value; }
- CookieStore* cookie_store() const { return cookie_store_; }
-
// Allow the URLRequestJob to redirect this request. Returns OK if
// successful, otherwise an error code is returned.
int Redirect(const GURL& location, int http_status_code);
@@ -742,15 +730,6 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe),
static void RegisterRequestInterceptor(Interceptor* interceptor);
static void UnregisterRequestInterceptor(Interceptor* interceptor);
- // Initializes the URLRequest. Code shared between the two constructors.
- // TODO(tburkard): This can ultimately be folded into a single constructor
- // again.
- void Init(const GURL& url,
- RequestPriority priotity,
- Delegate* delegate,
- const URLRequestContext* context,
- CookieStore* cookie_store);
-
// Resumes or blocks a request paused by the NetworkDelegate::OnBeforeRequest
// handler. If |blocked| is true, the request is blocked and an error page is
// returned indicating so. This should only be called after Start is called
@@ -916,9 +895,6 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe),
// Keeps track of whether or not OnBeforeNetworkStart has been called yet.
bool notified_before_network_start_;
- // The cookie store to be used for this request.
- scoped_refptr<CookieStore> cookie_store_;
-
DISALLOW_COPY_AND_ASSIGN(URLRequest);
};
diff --git a/net/url_request/url_request_context.cc b/net/url_request/url_request_context.cc
index d6a4d2f..3542b16 100644
--- a/net/url_request/url_request_context.cc
+++ b/net/url_request/url_request_context.cc
@@ -73,10 +73,8 @@ const HttpNetworkSession::Params* URLRequestContext::GetNetworkSessionParams(
scoped_ptr<URLRequest> URLRequestContext::CreateRequest(
const GURL& url,
RequestPriority priority,
- URLRequest::Delegate* delegate,
- CookieStore* cookie_store) const {
- return scoped_ptr<URLRequest>(
- new URLRequest(url, priority, delegate, this, cookie_store));
+ URLRequest::Delegate* delegate) const {
+ return scoped_ptr<URLRequest>(new URLRequest(url, priority, delegate, this));
}
void URLRequestContext::set_cookie_store(CookieStore* cookie_store) {
diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h
index a05c9ae..5bb5b51 100644
--- a/net/url_request/url_request_context.h
+++ b/net/url_request/url_request_context.h
@@ -58,13 +58,9 @@ class NET_EXPORT URLRequestContext
// May return NULL if this context doesn't have an associated network session.
const HttpNetworkSession::Params* GetNetworkSessionParams() const;
- // Creates a URLRequest. |cookie_store| optionally specifies a cookie store
- // to be used rather than the one represented by the context, or NULL
- // otherwise.
scoped_ptr<URLRequest> CreateRequest(const GURL& url,
RequestPriority priority,
- URLRequest::Delegate* delegate,
- CookieStore* cookie_store) const;
+ URLRequest::Delegate* delegate) const;
NetLog* net_log() const {
return net_log_;
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index 044e5f0..82ef633 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -539,7 +539,7 @@ void URLRequestHttpJob::AddCookieHeaderAndStart() {
if (!request_)
return;
- CookieStore* cookie_store = GetCookieStore();
+ CookieStore* cookie_store = request_->context()->cookie_store();
if (cookie_store && !(request_info_.load_flags & LOAD_DO_NOT_SEND_COOKIES)) {
net::CookieMonster* cookie_monster = cookie_store->GetCookieMonster();
if (cookie_monster) {
@@ -558,7 +558,7 @@ void URLRequestHttpJob::AddCookieHeaderAndStart() {
void URLRequestHttpJob::DoLoadCookies() {
CookieOptions options;
options.set_include_httponly();
- GetCookieStore()->GetCookiesWithOptionsAsync(
+ request_->context()->cookie_store()->GetCookiesWithOptionsAsync(
request_->url(), options,
base::Bind(&URLRequestHttpJob::OnCookiesLoaded,
weak_factory_.GetWeakPtr()));
@@ -638,7 +638,8 @@ void URLRequestHttpJob::SaveNextCookie() {
new SharedBoolean(true);
if (!(request_info_.load_flags & LOAD_DO_NOT_SAVE_COOKIES) &&
- GetCookieStore() && response_cookies_.size() > 0) {
+ request_->context()->cookie_store() &&
+ response_cookies_.size() > 0) {
CookieOptions options;
options.set_include_httponly();
options.set_server_time(response_date_);
@@ -656,7 +657,7 @@ void URLRequestHttpJob::SaveNextCookie() {
if (CanSetCookie(
response_cookies_[response_cookies_save_index_], &options)) {
callback_pending->data = true;
- GetCookieStore()->SetCookieWithOptionsAsync(
+ request_->context()->cookie_store()->SetCookieWithOptionsAsync(
request_->url(), response_cookies_[response_cookies_save_index_],
options, callback);
}
diff --git a/net/url_request/url_request_job.cc b/net/url_request/url_request_job.cc
index c4b34c2..78f704a 100644
--- a/net/url_request/url_request_job.cc
+++ b/net/url_request/url_request_job.cc
@@ -286,12 +286,6 @@ bool URLRequestJob::CanEnablePrivacyMode() const {
return request_->CanEnablePrivacyMode();
}
-CookieStore* URLRequestJob::GetCookieStore() const {
- DCHECK(request_);
-
- return request_->cookie_store();
-}
-
void URLRequestJob::NotifyBeforeNetworkStart(bool* defer) {
if (!request_)
return;
diff --git a/net/url_request/url_request_job.h b/net/url_request/url_request_job.h
index 9bb763e..3194ef6 100644
--- a/net/url_request/url_request_job.h
+++ b/net/url_request/url_request_job.h
@@ -26,7 +26,6 @@ namespace net {
class AuthChallengeInfo;
class AuthCredentials;
class CookieOptions;
-class CookieStore;
class Filter;
class HttpRequestHeaders;
class HttpResponseInfo;
@@ -239,9 +238,6 @@ class NET_EXPORT URLRequestJob
// Delegates to URLRequest::Delegate.
bool CanEnablePrivacyMode() const;
- // Returns the cookie store to be used for the request.
- CookieStore* GetCookieStore() const;
-
// Notifies the job that the network is about to be used.
void NotifyBeforeNetworkStart(bool* defer);