diff options
author | mmenke <mmenke@chromium.org> | 2016-02-05 15:50:17 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-05 23:52:18 +0000 |
commit | 24379d50fb80256588a925bfdd34679a71013f05 (patch) | |
tree | 4075484e2af6bc95d73d89697fea5c1b99bd45b6 /ios/net | |
parent | 038375b76689cd86ca9c1e8dc4e87cba19abc1ad (diff) | |
download | chromium_src-24379d50fb80256588a925bfdd34679a71013f05.zip chromium_src-24379d50fb80256588a925bfdd34679a71013f05.tar.gz chromium_src-24379d50fb80256588a925bfdd34679a71013f05.tar.bz2 |
Promote CookieMonster::DeleteCanonicalCookieAsync to CookieStore.
This is part of an effort to get rid of GetCookieMonster, and make
classes that care abotu cookies only depend on CookieStore.
TBR=sky@chromium.org
BUG=579653
Review URL: https://codereview.chromium.org/1666513002
Cr-Commit-Position: refs/heads/master@{#373952}
Diffstat (limited to 'ios/net')
-rw-r--r-- | ios/net/cookies/cookie_store_ios.h | 3 | ||||
-rw-r--r-- | ios/net/cookies/cookie_store_ios.mm | 23 | ||||
-rw-r--r-- | ios/net/cookies/cookie_store_ios_unittest.mm | 7 |
3 files changed, 33 insertions, 0 deletions
diff --git a/ios/net/cookies/cookie_store_ios.h b/ios/net/cookies/cookie_store_ios.h index 36f92e3..5eebe1d 100644 --- a/ios/net/cookies/cookie_store_ios.h +++ b/ios/net/cookies/cookie_store_ios.h @@ -142,6 +142,9 @@ class CookieStoreIOS : public net::CookieStore, void DeleteCookieAsync(const GURL& url, const std::string& cookie_name, const base::Closure& callback) override; + void DeleteCanonicalCookieAsync( + const CanonicalCookie& cookie, + const DeleteCallback& callback) override; net::CookieMonster* GetCookieMonster() override; void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin, const base::Time& delete_end, diff --git a/ios/net/cookies/cookie_store_ios.mm b/ios/net/cookies/cookie_store_ios.mm index 519c129..f50f0f8 100644 --- a/ios/net/cookies/cookie_store_ios.mm +++ b/ios/net/cookies/cookie_store_ios.mm @@ -620,6 +620,29 @@ void CookieStoreIOS::DeleteCookieAsync(const GURL& url, } } +void CookieStoreIOS::DeleteCanonicalCookieAsync( + const CanonicalCookie& cookie, + const DeleteCallback& callback) { + DCHECK(thread_checker_.CalledOnValidThread()); + + switch (synchronization_state_) { + case NOT_SYNCHRONIZED: + cookie_monster_->DeleteCanonicalCookieAsync(cookie, + WrapDeleteCallback(callback)); + break; + case SYNCHRONIZING: + tasks_pending_synchronization_.push_back( + base::Bind(&CookieStoreIOS::DeleteCanonicalCookieAsync, this, cookie, + WrapDeleteCallback(callback))); + break; + case SYNCHRONIZED: + // This relies on the fact cookies are given unique creation dates. + CookieFilterFunction filter = base::Bind( + IsCookieCreatedBetween, cookie.CreationDate(), cookie.CreationDate()); + DeleteCookiesWithFilter(filter, callback); + } +} + // CookieStoreIOS is an implementation of CookieStore which is not a // CookieMonster. As CookieStore is the main cookie API, a caller of // GetCookieMonster must handle the case where this returns null. diff --git a/ios/net/cookies/cookie_store_ios_unittest.mm b/ios/net/cookies/cookie_store_ios_unittest.mm index 41319a8..ac38dc7 100644 --- a/ios/net/cookies/cookie_store_ios_unittest.mm +++ b/ios/net/cookies/cookie_store_ios_unittest.mm @@ -134,6 +134,13 @@ class RoundTripTestCookieStore : public net::CookieStore { store_->DeleteCookieAsync(url, cookie_name, callback); } + void DeleteCanonicalCookieAsync( + const CanonicalCookie& cookie, + const DeleteCallback& callback) override { + RoundTrip(); + store_->DeleteCanonicalCookieAsync(cookie, callback); + } + net::CookieMonster* GetCookieMonster() override { return nullptr; } void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin, |