summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/cookies/cookie_monster.h22
-rw-r--r--net/cookies/cookie_store.h12
-rw-r--r--net/cookies/cookie_store_test_helpers.cc8
-rw-r--r--net/cookies/cookie_store_test_helpers.h6
-rw-r--r--net/cookies/cookie_store_unittest.h35
-rw-r--r--net/websockets/websocket_job_test.cc8
6 files changed, 82 insertions, 9 deletions
diff --git a/net/cookies/cookie_monster.h b/net/cookies/cookie_monster.h
index de00319..3e2ed6d 100644
--- a/net/cookies/cookie_monster.h
+++ b/net/cookies/cookie_monster.h
@@ -201,14 +201,6 @@ class NET_EXPORT CookieMonster : public CookieStore {
void DeleteAllForHostAsync(const GURL& url,
const DeleteCallback& callback);
- // Same as DeleteAllForHostAsync, except it deletes cookies between
- // [|delete_begin|, |delete_end|).
- // Returns the number of cookies deleted.
- void DeleteAllCreatedBetweenForHostAsync(const base::Time delete_begin,
- const base::Time delete_end,
- const GURL& url,
- const DeleteCallback& callback);
-
// Deletes one specific cookie.
void DeleteCanonicalCookieAsync(const CanonicalCookie& cookie,
const DeleteCookieCallback& callback);
@@ -272,13 +264,25 @@ class NET_EXPORT CookieMonster : public CookieStore {
const base::Closure& callback) OVERRIDE;
// Deletes all of the cookies that have a creation_date greater than or equal
- // to |delete_begin| and less than |delete_end|
+ // to |delete_begin| and less than |delete_end|.
// Returns the number of cookies that have been deleted.
virtual void DeleteAllCreatedBetweenAsync(
const base::Time& delete_begin,
const base::Time& delete_end,
const DeleteCallback& callback) OVERRIDE;
+ // Deletes all of the cookies that match the host of the given URL
+ // regardless of path and that have a creation_date greater than or
+ // equal to |delete_begin| and less then |delete_end|. This includes
+ // all http_only and secure cookies, but does not include any domain
+ // cookies that may apply to this host.
+ // Returns the number of cookies deleted.
+ virtual void DeleteAllCreatedBetweenForHostAsync(
+ const base::Time delete_begin,
+ const base::Time delete_end,
+ const GURL& url,
+ const DeleteCallback& callback) OVERRIDE;
+
virtual void DeleteSessionCookiesAsync(const DeleteCallback&) OVERRIDE;
virtual CookieMonster* GetCookieMonster() OVERRIDE;
diff --git a/net/cookies/cookie_store.h b/net/cookies/cookie_store.h
index af99637..7dee857 100644
--- a/net/cookies/cookie_store.h
+++ b/net/cookies/cookie_store.h
@@ -68,6 +68,18 @@ class NET_EXPORT CookieStore : public base::RefCountedThreadSafe<CookieStore> {
const base::Time& delete_end,
const DeleteCallback& callback) = 0;
+ // Deletes all of the cookies that match the host of the given URL
+ // regardless of path and that have a creation_date greater than or
+ // equal to |delete_begin| and less then |delete_end|. This includes
+ // all http_only and secure cookies, but does not include any domain
+ // cookies that may apply to this host.
+ // Returns the number of cookies deleted.
+ virtual void DeleteAllCreatedBetweenForHostAsync(
+ const base::Time delete_begin,
+ const base::Time delete_end,
+ const GURL& url,
+ const DeleteCallback& callback) = 0;
+
virtual void DeleteSessionCookiesAsync(const DeleteCallback&) = 0;
// Returns the underlying CookieMonster.
diff --git a/net/cookies/cookie_store_test_helpers.cc b/net/cookies/cookie_store_test_helpers.cc
index 22992f6..68086e1c4 100644
--- a/net/cookies/cookie_store_test_helpers.cc
+++ b/net/cookies/cookie_store_test_helpers.cc
@@ -113,6 +113,14 @@ void DelayedCookieMonster::DeleteAllCreatedBetweenAsync(
ADD_FAILURE();
}
+void DelayedCookieMonster::DeleteAllCreatedBetweenForHostAsync(
+ const base::Time delete_begin,
+ const base::Time delete_end,
+ const GURL& url,
+ const DeleteCallback& callback) {
+ ADD_FAILURE();
+}
+
void DelayedCookieMonster::DeleteSessionCookiesAsync(const DeleteCallback&) {
ADD_FAILURE();
}
diff --git a/net/cookies/cookie_store_test_helpers.h b/net/cookies/cookie_store_test_helpers.h
index 86b572a..3119e03 100644
--- a/net/cookies/cookie_store_test_helpers.h
+++ b/net/cookies/cookie_store_test_helpers.h
@@ -53,6 +53,12 @@ class DelayedCookieMonster : public CookieStore {
const base::Time& delete_end,
const DeleteCallback& callback) OVERRIDE;
+ virtual void DeleteAllCreatedBetweenForHostAsync(
+ const base::Time delete_begin,
+ const base::Time delete_end,
+ const GURL& url,
+ const DeleteCallback& callback) OVERRIDE;
+
virtual void DeleteSessionCookiesAsync(const DeleteCallback&) OVERRIDE;
virtual CookieMonster* GetCookieMonster() OVERRIDE;
diff --git a/net/cookies/cookie_store_unittest.h b/net/cookies/cookie_store_unittest.h
index 90999ec..20854b3 100644
--- a/net/cookies/cookie_store_unittest.h
+++ b/net/cookies/cookie_store_unittest.h
@@ -173,6 +173,20 @@ class CookieStoreTest : public testing::Test {
return callback.result();
}
+ int DeleteAllCreatedBetweenForHost(CookieStore* cs,
+ const base::Time delete_begin,
+ const base::Time delete_end,
+ const GURL& url) {
+ DCHECK(cs);
+ IntResultCookieCallback callback;
+ cs->DeleteAllCreatedBetweenForHostAsync(
+ delete_begin, delete_end, url,
+ base::Bind(&IntResultCookieCallback::Run, base::Unretained(&callback)));
+ RunFor(kTimeout);
+ EXPECT_TRUE(callback.did_run());
+ return callback.result();
+ }
+
int DeleteSessionCookies(CookieStore* cs) {
DCHECK(cs);
IntResultCookieCallback callback;
@@ -795,6 +809,26 @@ TYPED_TEST_P(CookieStoreTest, TestDeleteAllCreatedBetween) {
this->GetCookies(cs.get(), this->url_google_));
}
+TYPED_TEST_P(CookieStoreTest, TestDeleteAllCreatedBetweenForHost) {
+ scoped_refptr<CookieStore> cs(this->GetCookieStore());
+ GURL url_not_google("http://www.notgoogle.com");
+ base::Time now = base::Time::Now();
+
+ // These 3 cookies match the time range and host.
+ EXPECT_TRUE(this->SetCookie(cs.get(), this->url_google_, "A=B"));
+ EXPECT_TRUE(this->SetCookie(cs.get(), this->url_google_, "C=D"));
+ EXPECT_TRUE(this->SetCookie(cs.get(), this->url_google_, "Y=Z"));
+
+ // This cookie does not match host.
+ EXPECT_TRUE(this->SetCookie(cs.get(), url_not_google, "E=F"));
+
+ // Delete cookies.
+ EXPECT_EQ(
+ 3, // Deletes A=B, C=D, Y=Z
+ this->DeleteAllCreatedBetweenForHost(
+ cs.get(), now, base::Time::Max(), this->url_google_));
+}
+
TYPED_TEST_P(CookieStoreTest, TestSecure) {
scoped_refptr<CookieStore> cs(this->GetCookieStore());
@@ -976,6 +1010,7 @@ REGISTER_TYPED_TEST_CASE_P(CookieStoreTest,
HttpOnlyTest,
TestCookieDeletion,
TestDeleteAllCreatedBetween,
+ TestDeleteAllCreatedBetweenForHost,
TestSecure,
NetUtilCookieTest,
OverwritePersistentCookie,
diff --git a/net/websockets/websocket_job_test.cc b/net/websockets/websocket_job_test.cc
index bdbae70..4b3b70e 100644
--- a/net/websockets/websocket_job_test.cc
+++ b/net/websockets/websocket_job_test.cc
@@ -216,6 +216,14 @@ class MockCookieStore : public CookieStore {
ADD_FAILURE();
}
+ virtual void DeleteAllCreatedBetweenForHostAsync(
+ const base::Time delete_begin,
+ const base::Time delete_end,
+ const GURL& url,
+ const DeleteCallback& callback) OVERRIDE {
+ ADD_FAILURE();
+ }
+
virtual void DeleteSessionCookiesAsync(const DeleteCallback&) OVERRIDE {
ADD_FAILURE();
}