diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-18 23:26:17 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-18 23:26:17 +0000 |
commit | e2d4bf08e8e7eedcf4fc9899a70d6bea5ebc4e15 (patch) | |
tree | d49246fedbc4221e0f9bb82c0cafd13ac3f09740 /net | |
parent | b205d20619df6f2bbf4433fe0e1686b06b797b16 (diff) | |
download | chromium_src-e2d4bf08e8e7eedcf4fc9899a70d6bea5ebc4e15.zip chromium_src-e2d4bf08e8e7eedcf4fc9899a70d6bea5ebc4e15.tar.gz chromium_src-e2d4bf08e8e7eedcf4fc9899a70d6bea5ebc4e15.tar.bz2 |
Make CookieMonster NonThreadSafe.
Made ExtensionFunction RefCountedThreadSafe so it can be posted to different threads.
Used WaitableEvent in AutomationProvider.
BUG=44083
Review URL: http://codereview.chromium.org/2756003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50296 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rwxr-xr-x | net/base/cookie_monster.cc | 13 | ||||
-rw-r--r-- | net/base/cookie_monster.h | 12 |
2 files changed, 23 insertions, 2 deletions
diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc index fbc0877..a4f0953 100755 --- a/net/base/cookie_monster.cc +++ b/net/base/cookie_monster.cc @@ -549,6 +549,7 @@ bool CookieMonster::HasCookieableScheme(const GURL& url) { void CookieMonster::SetCookieableSchemes( const char* schemes[], size_t num_schemes) { + DCHECK(CalledOnValidThread()); AutoLock autolock(lock_); // Cookieable Schemes must be set before first use of function. @@ -564,6 +565,7 @@ bool CookieMonster::SetCookieWithCreationTimeAndOptions( const std::string& cookie_line, const Time& creation_time_or_null, const CookieOptions& options) { + DCHECK(CalledOnValidThread()); AutoLock autolock(lock_); if (!HasCookieableScheme(url)) { @@ -619,6 +621,7 @@ bool CookieMonster::SetCookieWithDetails( const GURL& url, const std::string& name, const std::string& value, const std::string& domain, const std::string& path, const base::Time& expiration_time, bool secure, bool http_only) { + DCHECK(CalledOnValidThread()); // Expect a valid domain attribute with no illegal characters. std::string parsed_domain = ParsedCookie::ParseValueString(domain); @@ -836,6 +839,7 @@ int CookieMonster::GarbageCollectExpired( } int CookieMonster::DeleteAll(bool sync_to_store) { + DCHECK(CalledOnValidThread()); AutoLock autolock(lock_); InitIfNecessary(); @@ -853,6 +857,7 @@ int CookieMonster::DeleteAll(bool sync_to_store) { int CookieMonster::DeleteAllCreatedBetween(const Time& delete_begin, const Time& delete_end, bool sync_to_store) { + DCHECK(CalledOnValidThread()); AutoLock autolock(lock_); InitIfNecessary(); @@ -874,11 +879,13 @@ int CookieMonster::DeleteAllCreatedBetween(const Time& delete_begin, int CookieMonster::DeleteAllCreatedAfter(const Time& delete_begin, bool sync_to_store) { + DCHECK(CalledOnValidThread()); return DeleteAllCreatedBetween(delete_begin, Time(), sync_to_store); } int CookieMonster::DeleteAllForURL(const GURL& url, bool sync_to_store) { + DCHECK(CalledOnValidThread()); AutoLock autolock(lock_); InitIfNecessary(); @@ -895,6 +902,7 @@ int CookieMonster::DeleteAllForURL(const GURL& url, bool CookieMonster::DeleteCookie(const std::string& domain, const CanonicalCookie& cookie, bool sync_to_store) { + DCHECK(CalledOnValidThread()); AutoLock autolock(lock_); InitIfNecessary(); @@ -922,6 +930,7 @@ static bool CookieSorter(CookieMonster::CanonicalCookie* cc1, bool CookieMonster::SetCookieWithOptions(const GURL& url, const std::string& cookie_line, const CookieOptions& options) { + DCHECK(CalledOnValidThread()); return SetCookieWithCreationTimeAndOptions(url, cookie_line, Time(), options); } @@ -939,6 +948,7 @@ bool CookieMonster::SetCookieWithOptions(const GURL& url, // should be fast and simple enough for now. std::string CookieMonster::GetCookiesWithOptions(const GURL& url, const CookieOptions& options) { + DCHECK(CalledOnValidThread()); AutoLock autolock(lock_); InitIfNecessary(); @@ -971,6 +981,7 @@ std::string CookieMonster::GetCookiesWithOptions(const GURL& url, void CookieMonster::DeleteCookie(const GURL& url, const std::string& cookie_name) { + DCHECK(CalledOnValidThread()); AutoLock autolock(lock_); InitIfNecessary(); @@ -1002,6 +1013,7 @@ void CookieMonster::DeleteCookie(const GURL& url, } CookieMonster::CookieList CookieMonster::GetAllCookies() { + DCHECK(CalledOnValidThread()); AutoLock autolock(lock_); InitIfNecessary(); @@ -1025,6 +1037,7 @@ CookieMonster::CookieList CookieMonster::GetAllCookies() { } CookieMonster::CookieList CookieMonster::GetAllCookiesForURL(const GURL& url) { + DCHECK(CalledOnValidThread()); AutoLock autolock(lock_); InitIfNecessary(); diff --git a/net/base/cookie_monster.h b/net/base/cookie_monster.h index ee869e9..109fe94 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()); } @@ -283,6 +289,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_; |