Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1458)

Unified Diff: net/cookies/cookie_monster.cc

Issue 14365006: Add a way to query a cookie store whether any cookies exist for a given (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cookies/cookie_monster.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/cookie_monster.cc
===================================================================
--- net/cookies/cookie_monster.cc (revision 194665)
+++ net/cookies/cookie_monster.cc (working copy)
@@ -765,6 +765,41 @@
}
}
+// Task class for HasCookiesForETLDP1Task call.
+class CookieMonster::HasCookiesForETLDP1Task
+ : public CookieMonster::CookieMonsterTask {
+ public:
+ HasCookiesForETLDP1Task(
+ CookieMonster* cookie_monster,
+ const std::string& etldp1,
+ const CookieMonster::HasCookiesForETLDP1Callback& callback)
+ : CookieMonsterTask(cookie_monster),
+ etldp1_(etldp1),
+ callback_(callback) {
+ }
+
+ // CookieMonster::CookieMonsterTask:
+ virtual void Run() OVERRIDE;
+
+ protected:
+ virtual ~HasCookiesForETLDP1Task() {}
+
+ private:
+ std::string etldp1_;
+ CookieMonster::HasCookiesForETLDP1Callback callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(HasCookiesForETLDP1Task);
+};
+
+void CookieMonster::HasCookiesForETLDP1Task::Run() {
+ bool result = this->cookie_monster()->HasCookiesForETLDP1(etldp1_);
+ if (!callback_.is_null()) {
+ this->InvokeCallback(
+ base::Bind(&CookieMonster::HasCookiesForETLDP1Callback::Run,
+ base::Unretained(&callback_), result));
+ }
+}
+
// Asynchronous CookieMonster API
void CookieMonster::SetCookieWithDetailsAsync(
@@ -813,6 +848,15 @@
DoCookieTaskForURL(task, url);
}
+void CookieMonster::HasCookiesForETLDP1Async(
+ const std::string& etldp1,
+ const HasCookiesForETLDP1Callback& callback) {
+ scoped_refptr<HasCookiesForETLDP1Task> task =
+ new HasCookiesForETLDP1Task(this, etldp1, callback);
+
+ DoCookieTaskForURL(task, GURL("http://" + etldp1));
+}
+
void CookieMonster::DeleteAllAsync(const DeleteCallback& callback) {
scoped_refptr<DeleteAllTask> task =
new DeleteAllTask(this, callback);
@@ -1232,6 +1276,15 @@
return num_deleted;
}
+bool CookieMonster::HasCookiesForETLDP1(const std::string& etldp1) {
+ base::AutoLock autolock(lock_);
+
+ const std::string key(GetKey(etldp1));
+
+ CookieMapItPair its = cookies_.equal_range(key);
+ return its.first != its.second;
+}
+
CookieMonster* CookieMonster::GetCookieMonster() {
return this;
}
« no previous file with comments | « net/cookies/cookie_monster.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698