diff options
author | tburkard@chromium.org <tburkard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-24 21:38:14 +0000 |
---|---|---|
committer | tburkard@chromium.org <tburkard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-24 21:38:14 +0000 |
commit | dc8313ade80a2e5b983e3994cf0e415662cdb222 (patch) | |
tree | 311c06cdcab63df97f9d906c0bd2579a1b49aaa7 /net | |
parent | 545de6c7fbb40e93c5f8cae397b8d9dffaaadd1d (diff) | |
download | chromium_src-dc8313ade80a2e5b983e3994cf0e415662cdb222.zip chromium_src-dc8313ade80a2e5b983e3994cf0e415662cdb222.tar.gz chromium_src-dc8313ade80a2e5b983e3994cf0e415662cdb222.tar.bz2 |
Refactor CookieStore/CookieMonster
Make GetAllCookiesForURLAsync part of CookieStore, so that the most common
use cases do not need to know about CookieMonster any more.
R=erikwright@chromium.org, jam@chromium.org, mmenke@chromium.org
Review URL: https://codereview.chromium.org/198913002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259018 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/cookies/cookie_monster.h | 11 | ||||
-rw-r--r-- | net/cookies/cookie_store.h | 11 | ||||
-rw-r--r-- | net/cookies/cookie_store_test_helpers.cc | 6 | ||||
-rw-r--r-- | net/cookies/cookie_store_test_helpers.h | 4 | ||||
-rw-r--r-- | net/url_request/url_request_http_job.cc | 15 | ||||
-rw-r--r-- | net/websockets/websocket_job_test.cc | 6 |
6 files changed, 36 insertions, 17 deletions
diff --git a/net/cookies/cookie_monster.h b/net/cookies/cookie_monster.h index 455484e..5a06922 100644 --- a/net/cookies/cookie_monster.h +++ b/net/cookies/cookie_monster.h @@ -187,11 +187,6 @@ class NET_EXPORT CookieMonster : public CookieStore { const CookieOptions& options, const GetCookieListCallback& callback); - // Invokes GetAllCookiesForURLWithOptions with options set to include HTTP - // only cookies. - void GetAllCookiesForURLAsync(const GURL& url, - const GetCookieListCallback& callback); - // Deletes all of the cookies. void DeleteAllAsync(const DeleteCallback& callback); @@ -257,6 +252,12 @@ class NET_EXPORT CookieMonster : public CookieStore { const CookieOptions& options, const GetCookiesCallback& callback) OVERRIDE; + // Invokes GetAllCookiesForURLWithOptions with options set to include HTTP + // only cookies. + virtual void GetAllCookiesForURLAsync( + const GURL& url, + const GetCookieListCallback& callback) OVERRIDE; + // Deletes all cookies with that might apply to |url| that has |cookie_name|. virtual void DeleteCookieAsync( const GURL& url, const std::string& cookie_name, diff --git a/net/cookies/cookie_store.h b/net/cookies/cookie_store.h index 730f710..b2552a6 100644 --- a/net/cookies/cookie_store.h +++ b/net/cookies/cookie_store.h @@ -15,6 +15,7 @@ #include "base/memory/ref_counted.h" #include "base/time/time.h" #include "net/base/net_export.h" +#include "net/cookies/canonical_cookie.h" #include "net/cookies/cookie_options.h" class GURL; @@ -28,8 +29,8 @@ class CookieMonster; class NET_EXPORT CookieStore : public base::RefCountedThreadSafe<CookieStore> { public: // Callback definitions. - typedef base::Callback<void(const std::string& cookie)> - GetCookiesCallback; + typedef base::Callback<void(const CookieList& cookies)> GetCookieListCallback; + typedef base::Callback<void(const std::string& cookie)> GetCookiesCallback; typedef base::Callback<void(bool success)> SetCookiesCallback; typedef base::Callback<void(int num_deleted)> DeleteCallback; @@ -55,6 +56,12 @@ class NET_EXPORT CookieStore : public base::RefCountedThreadSafe<CookieStore> { const CookieOptions& options, const GetCookiesCallback& callback) = 0; + // Returns all matching cookies without marking them as accessed, + // including HTTP only cookies. + virtual void GetAllCookiesForURLAsync( + const GURL& url, + const GetCookieListCallback& callback) = 0; + // Deletes the passed in cookie for the specified URL. virtual void DeleteCookieAsync(const GURL& url, const std::string& cookie_name, diff --git a/net/cookies/cookie_store_test_helpers.cc b/net/cookies/cookie_store_test_helpers.cc index 68086e1c4..fdf2c1f 100644 --- a/net/cookies/cookie_store_test_helpers.cc +++ b/net/cookies/cookie_store_test_helpers.cc @@ -68,6 +68,12 @@ void DelayedCookieMonster::GetCookiesWithOptionsAsync( base::TimeDelta::FromMilliseconds(kDelayedTime)); } +void DelayedCookieMonster::GetAllCookiesForURLAsync( + const GURL& url, + const GetCookieListCallback& callback) { + cookie_monster_->GetAllCookiesForURLAsync(url, callback); +} + void DelayedCookieMonster::InvokeSetCookiesCallback( const CookieMonster::SetCookiesCallback& callback) { if (!callback.is_null()) diff --git a/net/cookies/cookie_store_test_helpers.h b/net/cookies/cookie_store_test_helpers.h index 3119e03..84b83bc 100644 --- a/net/cookies/cookie_store_test_helpers.h +++ b/net/cookies/cookie_store_test_helpers.h @@ -34,6 +34,10 @@ class DelayedCookieMonster : public CookieStore { const CookieOptions& options, const CookieMonster::GetCookiesCallback& callback) OVERRIDE; + virtual void GetAllCookiesForURLAsync( + const GURL& url, + const GetCookieListCallback& callback) OVERRIDE; + virtual bool SetCookieWithOptions(const GURL& url, const std::string& cookie_line, const CookieOptions& options); diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc index 56fed93..8d93eea 100644 --- a/net/url_request/url_request_http_job.cc +++ b/net/url_request/url_request_http_job.cc @@ -24,7 +24,7 @@ #include "net/base/network_delegate.h" #include "net/base/sdch_manager.h" #include "net/cert/cert_status_flags.h" -#include "net/cookies/cookie_monster.h" +#include "net/cookies/cookie_store.h" #include "net/http/http_content_disposition.h" #include "net/http/http_network_session.h" #include "net/http/http_request_headers.h" @@ -550,15 +550,10 @@ void URLRequestHttpJob::AddCookieHeaderAndStart() { CookieStore* cookie_store = GetCookieStore(); 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_factory_.GetWeakPtr())); - } else { - CheckCookiePolicyAndLoad(CookieList()); - } + cookie_store->GetAllCookiesForURLAsync( + request_->url(), + base::Bind(&URLRequestHttpJob::CheckCookiePolicyAndLoad, + weak_factory_.GetWeakPtr())); } else { DoStartTransaction(); } diff --git a/net/websockets/websocket_job_test.cc b/net/websockets/websocket_job_test.cc index 3d7d424..e12ddae 100644 --- a/net/websockets/websocket_job_test.cc +++ b/net/websockets/websocket_job_test.cc @@ -204,6 +204,12 @@ class MockCookieStore : public CookieStore { callback.Run(GetCookiesWithOptions(url, options)); } + virtual void GetAllCookiesForURLAsync( + const GURL& url, + const GetCookieListCallback& callback) OVERRIDE { + ADD_FAILURE(); + } + virtual void DeleteCookieAsync(const GURL& url, const std::string& cookie_name, const base::Closure& callback) OVERRIDE { |