summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordroger@google.com <droger@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-20 21:00:16 +0000
committerdroger@google.com <droger@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-20 21:00:16 +0000
commit1a6fff54665ded8a4be408f112938ad0328556dc (patch)
tree2fe727e144d021b5eacc8bfcbb5e2bce92a49a64
parent688f1693e30d0ee0ac12909182c471dbfc5a56c9 (diff)
downloadchromium_src-1a6fff54665ded8a4be408f112938ad0328556dc.zip
chromium_src-1a6fff54665ded8a4be408f112938ad0328556dc.tar.gz
chromium_src-1a6fff54665ded8a4be408f112938ad0328556dc.tar.bz2
Allow CookieStorage implementations other than CookieMonster.
BUG=NONE TEST=NONE Review URL: http://codereview.chromium.org/8344081 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106575 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc11
-rw-r--r--net/url_request/url_request_http_job.cc42
-rw-r--r--net/url_request/url_request_http_job.h1
3 files changed, 32 insertions, 22 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index 90a4c75..8f2807fe 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -322,8 +322,15 @@ void ChromeURLRequestContextGetter::OnDefaultCharsetChange(
void ChromeURLRequestContextGetter::OnClearSiteDataOnExitChange(
bool clear_site_data) {
- GetURLRequestContext()->cookie_store()->GetCookieMonster()->
- SetClearPersistentStoreOnExit(clear_site_data);
+ net::CookieMonster* cookie_monster =
+ GetURLRequestContext()->cookie_store()->GetCookieMonster();
+
+ // If there is no cookie monster, this function does nothing. If
+ // clear_site_data is true, this is most certainly not the expected behavior.
+ DCHECK(!clear_site_data || cookie_monster);
+
+ if (cookie_monster)
+ cookie_monster->SetClearPersistentStoreOnExit(clear_site_data);
}
void ChromeURLRequestContextGetter::GetCookieStoreAsyncHelper(
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index 6a59cd8..7e0d8da 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -472,34 +472,36 @@ void URLRequestHttpJob::AddCookieHeaderAndStart() {
CookieStore* cookie_store =
request_->context()->cookie_store();
- if (cookie_store) {
- cookie_store->GetCookieMonster()->GetAllCookiesForURLAsync(
- request_->url(),
- base::Bind(&URLRequestHttpJob::CheckCookiePolicyAndLoad,
- weak_ptr_factory_.GetWeakPtr()));
+ if (cookie_store && !(request_info_.load_flags & LOAD_DO_NOT_SEND_COOKIES)) {
+ net::CookieMonster* cookie_monster = cookie_store->GetCookieMonster();
+ if (cookie_monster) {
+ cookie_monster->GetAllCookiesForURLAsync(
+ request_->url(),
+ base::Bind(&URLRequestHttpJob::CheckCookiePolicyAndLoad,
+ weak_ptr_factory_.GetWeakPtr()));
+ } else {
+ DoLoadCookies();
+ }
} else {
DoStartTransaction();
}
}
+void URLRequestHttpJob::DoLoadCookies() {
+ CookieOptions options;
+ options.set_include_httponly();
+ request_->context()->cookie_store()->GetCookiesWithInfoAsync(
+ request_->url(), options,
+ base::Bind(&URLRequestHttpJob::OnCookiesLoaded,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
void URLRequestHttpJob::CheckCookiePolicyAndLoad(
const CookieList& cookie_list) {
- bool allow = true;
- if ((request_info_.load_flags & LOAD_DO_NOT_SEND_COOKIES) ||
- !CanGetCookies(cookie_list)) {
- allow = false;
- }
-
- if (allow) {
- CookieOptions options;
- options.set_include_httponly();
- request_->context()->cookie_store()->GetCookiesWithInfoAsync(
- request_->url(), options,
- base::Bind(&URLRequestHttpJob::OnCookiesLoaded,
- weak_ptr_factory_.GetWeakPtr()));
- } else {
+ if (CanGetCookies(cookie_list))
+ DoLoadCookies();
+ else
DoStartTransaction();
- }
}
void URLRequestHttpJob::OnCookiesLoaded(
diff --git a/net/url_request/url_request_http_job.h b/net/url_request/url_request_http_job.h
index d802186..d8e8e19 100644
--- a/net/url_request/url_request_http_job.h
+++ b/net/url_request/url_request_http_job.h
@@ -169,6 +169,7 @@ class URLRequestHttpJob : public URLRequestJob {
void DoneWithRequest(CompletionCause reason);
// Callback functions for Cookie Monster
+ void DoLoadCookies();
void CheckCookiePolicyAndLoad(const CookieList& cookie_list);
void OnCookiesLoaded(
const std::string& cookie_line,