summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortburkard@chromium.org <tburkard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-24 21:38:14 +0000
committertburkard@chromium.org <tburkard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-24 21:38:14 +0000
commitdc8313ade80a2e5b983e3994cf0e415662cdb222 (patch)
tree311c06cdcab63df97f9d906c0bd2579a1b49aaa7
parent545de6c7fbb40e93c5f8cae397b8d9dffaaadd1d (diff)
downloadchromium_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
-rw-r--r--content/browser/renderer_host/render_message_filter.cc10
-rw-r--r--net/cookies/cookie_monster.h11
-rw-r--r--net/cookies/cookie_store.h11
-rw-r--r--net/cookies/cookie_store_test_helpers.cc6
-rw-r--r--net/cookies/cookie_store_test_helpers.h4
-rw-r--r--net/url_request/url_request_http_job.cc15
-rw-r--r--net/websockets/websocket_job_test.cc6
7 files changed, 40 insertions, 23 deletions
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index 958b491..a3ada4e 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -62,7 +62,7 @@
#include "net/base/mime_util.h"
#include "net/base/request_priority.h"
#include "net/cookies/canonical_cookie.h"
-#include "net/cookies/cookie_monster.h"
+#include "net/cookies/cookie_store.h"
#include "net/http/http_cache.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
@@ -594,7 +594,7 @@ void RenderMessageFilter::OnSetCookie(int render_frame_id,
net::CookieStore* cookie_store = GetCookieStoreForURL(url);
// Pass a null callback since we don't care about when the 'set' completes.
cookie_store->SetCookieWithOptionsAsync(
- url, cookie, options, net::CookieMonster::SetCookiesCallback());
+ url, cookie, options, net::CookieStore::SetCookiesCallback());
}
}
@@ -616,8 +616,7 @@ void RenderMessageFilter::OnGetCookies(int render_frame_id,
base::debug::Alias(url_buf);
net::CookieStore* cookie_store = GetCookieStoreForURL(url);
- net::CookieMonster* cookie_monster = cookie_store->GetCookieMonster();
- cookie_monster->GetAllCookiesForURLAsync(
+ cookie_store->GetAllCookiesForURLAsync(
url, base::Bind(&RenderMessageFilter::CheckPolicyForCookies, this,
render_frame_id, url, first_party_for_cookies,
reply_msg));
@@ -643,8 +642,7 @@ void RenderMessageFilter::OnGetRawCookies(
// be applied to outbound requests for the given URL. Since this cookie info
// is visible in the developer tools, it is helpful to make it match reality.
net::CookieStore* cookie_store = GetCookieStoreForURL(url);
- net::CookieMonster* cookie_monster = cookie_store->GetCookieMonster();
- cookie_monster->GetAllCookiesForURLAsync(
+ cookie_store->GetAllCookiesForURLAsync(
url, base::Bind(&RenderMessageFilter::SendGetRawCookiesResponse,
this, reply_msg));
}
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 {