diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-17 21:41:08 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-17 21:41:08 +0000 |
commit | 0c03b435f8457e8601c80f44a69a56d9f96a274a (patch) | |
tree | e681f3661ec27777c0d8c5d499c36ff1c43d1508 /chrome/browser/strict_transport_security_persister.cc | |
parent | 03addd9009847497437ebe5466c164f50b93e990 (diff) | |
download | chromium_src-0c03b435f8457e8601c80f44a69a56d9f96a274a.zip chromium_src-0c03b435f8457e8601c80f44a69a56d9f96a274a.tar.gz chromium_src-0c03b435f8457e8601c80f44a69a56d9f96a274a.tar.bz2 |
Fix race conditions where an object's constructor uses PostTask on itself. This isn't safe since the posted task can execute before the constructor returns, leading to destruction of the object.
BUG=27944
Review URL: http://codereview.chromium.org/399016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32213 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/strict_transport_security_persister.cc')
-rw-r--r-- | chrome/browser/strict_transport_security_persister.cc | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/chrome/browser/strict_transport_security_persister.cc b/chrome/browser/strict_transport_security_persister.cc index 52fc611..ce6078a 100644 --- a/chrome/browser/strict_transport_security_persister.cc +++ b/chrome/browser/strict_transport_security_persister.cc @@ -12,13 +12,19 @@ #include "chrome/common/chrome_paths.h" #include "net/base/strict_transport_security_state.h" -StrictTransportSecurityPersister::StrictTransportSecurityPersister( - net::StrictTransportSecurityState* state, - const FilePath& profile_path) - : state_is_dirty_(false), - strict_transport_security_state_(state), - state_file_(profile_path.Append( - FILE_PATH_LITERAL("StrictTransportSecurity"))) { +StrictTransportSecurityPersister::StrictTransportSecurityPersister() + : state_is_dirty_(false) { +} + +StrictTransportSecurityPersister::~StrictTransportSecurityPersister() { + strict_transport_security_state_->SetDelegate(NULL); +} + +void StrictTransportSecurityPersister::Initialize( + net::StrictTransportSecurityState* state, const FilePath& profile_path) { + strict_transport_security_state_ = state; + state_file_ = + profile_path.Append(FILE_PATH_LITERAL("StrictTransportSecurity")); state->SetDelegate(this); Task* task = NewRunnableMethod(this, @@ -26,10 +32,6 @@ StrictTransportSecurityPersister::StrictTransportSecurityPersister( ChromeThread::PostDelayedTask(ChromeThread::FILE, FROM_HERE, task, 1000); } -StrictTransportSecurityPersister::~StrictTransportSecurityPersister() { - strict_transport_security_state_->SetDelegate(NULL); -} - void StrictTransportSecurityPersister::LoadState() { AutoLock locked_(lock_); DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); |