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

Unified Diff: net/base/cookie_monster.h

Issue 2756003: Make CookieMonster NonThreadSafe. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Address eroman's and cindylau's comments. Created 10 years, 6 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 | « chrome/browser/net/cookie_policy_browsertest.cc ('k') | net/base/cookie_monster.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/cookie_monster.h
diff --git a/net/base/cookie_monster.h b/net/base/cookie_monster.h
index ec9ca160855a62568dfecf5e7cf5d107bae4e331..8a7e2631970f72381209f5fe147b9515a48d9222 100644
--- a/net/base/cookie_monster.h
+++ b/net/base/cookie_monster.h
@@ -14,6 +14,8 @@
#include "base/basictypes.h"
#include "base/lock.h"
+#include "base/logging.h"
+#include "base/non_thread_safe.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "base/time.h"
@@ -33,7 +35,7 @@ namespace net {
//
// TODO(deanm) Implement CookieMonster, the cookie database.
// - Verify that our domain enforcement and non-dotted handling is correct
-class CookieMonster : public CookieStore {
+class CookieMonster : public CookieStore, NonThreadSafe {
public:
class CanonicalCookie;
class Delegate;
@@ -88,7 +90,10 @@ class CookieMonster : public CookieStore {
virtual std::string GetCookiesWithOptions(const GURL& url,
const CookieOptions& options);
virtual void DeleteCookie(const GURL& url, const std::string& cookie_name);
- virtual CookieMonster* GetCookieMonster() { return this; }
+ virtual CookieMonster* GetCookieMonster() {
+ DCHECK(CalledOnValidThread());
+ return this;
+ }
// Sets a cookie given explicit user-provided cookie attributes. The cookie
// name, value, domain, etc. are each provided as separate strings. This
@@ -112,6 +117,7 @@ class CookieMonster : public CookieStore {
bool SetCookieWithCreationTime(const GURL& url,
const std::string& cookie_line,
const base::Time& creation_time) {
+ DCHECK(CalledOnValidThread());
return SetCookieWithCreationTimeAndOptions(url, cookie_line, creation_time,
CookieOptions());
}
@@ -281,6 +287,8 @@ class CookieMonster : public CookieStore {
scoped_refptr<Delegate> delegate_;
+ // TODO(willchan): Remove this lock after making sure CookieMonster is
+ // completely single threaded.
// Lock for thread-safety
Lock lock_;
« no previous file with comments | « chrome/browser/net/cookie_policy_browsertest.cc ('k') | net/base/cookie_monster.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698