Fix race condition in CefCookieManagerImpl constructor (issue #542).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@556 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2012-03-29 16:51:31 +00:00
parent 4f1dd4f96c
commit 3b23cc1815
2 changed files with 13 additions and 19 deletions

View File

@ -66,18 +66,14 @@ class VisitCookiesCallback : public base::RefCounted<VisitCookiesCallback> {
} // namespace } // namespace
CefCookieManagerImpl::CefCookieManagerImpl() CefCookieManagerImpl::CefCookieManagerImpl(bool is_global)
: is_global_(true) { : is_global_(is_global) {
cookie_monster_ = if (is_global) {
static_cast<net::CookieMonster*>( cookie_monster_ =
_Context->request_context()->cookie_store()); static_cast<net::CookieMonster*>(
DCHECK(cookie_monster_); _Context->request_context()->cookie_store());
} DCHECK(cookie_monster_);
}
// Creates a new cookie monster with storage at the specified |path|.
CefCookieManagerImpl::CefCookieManagerImpl(const CefString& path)
:is_global_(false) {
SetStoragePath(path);
} }
CefCookieManagerImpl::~CefCookieManagerImpl() { CefCookieManagerImpl::~CefCookieManagerImpl() {
@ -239,7 +235,7 @@ CefRefPtr<CefCookieManager> CefCookieManager::GetGlobalManager() {
return NULL; return NULL;
} }
return new CefCookieManagerImpl(); return new CefCookieManagerImpl(true);
} }
// static // static
@ -251,5 +247,7 @@ CefRefPtr<CefCookieManager> CefCookieManager::CreateManager(
return NULL; return NULL;
} }
return new CefCookieManagerImpl(path); CefRefPtr<CefCookieManager> manager(new CefCookieManagerImpl(false));
manager->SetStoragePath(path);
return manager;
} }

View File

@ -12,11 +12,7 @@
// Implementation of the CefCookieManager interface. // Implementation of the CefCookieManager interface.
class CefCookieManagerImpl : public CefCookieManager { class CefCookieManagerImpl : public CefCookieManager {
public: public:
// Creates a new reference to the existing global cookie monster. CefCookieManagerImpl(bool is_global);
CefCookieManagerImpl();
// Creates a new cookie monster with storage at the specified |path|.
explicit CefCookieManagerImpl(const CefString& path);
~CefCookieManagerImpl(); ~CefCookieManagerImpl();