diff options
author | danno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-10 12:30:59 +0000 |
---|---|---|
committer | danno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-10 12:30:59 +0000 |
commit | e7fce50d090e0b5bb7fd47382839367d172432e8 (patch) | |
tree | f7439beaa36d258f959cd40e737d01ce3dd5b7a6 /chrome/browser/policy | |
parent | a61c5b5dcfeaced75dd5e2d43187219053357a7c (diff) | |
download | chromium_src-e7fce50d090e0b5bb7fd47382839367d172432e8.zip chromium_src-e7fce50d090e0b5bb7fd47382839367d172432e8.tar.gz chromium_src-e7fce50d090e0b5bb7fd47382839367d172432e8.tar.bz2 |
Fix memory leaks in AsynchronousPolicyProvider.
BUG=66102, 66054
TEST=valgrind on linux and mac
Review URL: http://codereview.chromium.org/5748002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68844 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/policy')
-rw-r--r-- | chrome/browser/policy/asynchronous_policy_loader.cc | 5 | ||||
-rw-r--r-- | chrome/browser/policy/asynchronous_policy_loader.h | 15 |
2 files changed, 11 insertions, 9 deletions
diff --git a/chrome/browser/policy/asynchronous_policy_loader.cc b/chrome/browser/policy/asynchronous_policy_loader.cc index ea27bb7..f244eda 100644 --- a/chrome/browser/policy/asynchronous_policy_loader.cc +++ b/chrome/browser/policy/asynchronous_policy_loader.cc @@ -61,9 +61,10 @@ void AsynchronousPolicyLoader::PostUpdatePolicyTask( } void AsynchronousPolicyLoader::UpdatePolicy(DictionaryValue* new_policy_raw) { + scoped_ptr<DictionaryValue> new_policy(new_policy_raw); DCHECK(policy_.get()); - if (!policy_->Equals(new_policy_raw)) { - policy_.reset(new_policy_raw); + if (!policy_->Equals(new_policy.get())) { + policy_.reset(new_policy.release()); // TODO(danno): Change the notification between the provider and the // PrefStore into a notification mechanism, removing the need for the // WeakPtr for the provider. diff --git a/chrome/browser/policy/asynchronous_policy_loader.h b/chrome/browser/policy/asynchronous_policy_loader.h index 2600847..30878f5 100644 --- a/chrome/browser/policy/asynchronous_policy_loader.h +++ b/chrome/browser/policy/asynchronous_policy_loader.h @@ -47,15 +47,10 @@ class AsynchronousPolicyLoader friend class base::RefCountedThreadSafe<AsynchronousPolicyLoader>; virtual ~AsynchronousPolicyLoader() {} - // Schedules a call to UpdatePolicy on |origin_loop_|. + // Schedules a call to UpdatePolicy on |origin_loop_|. Takes ownership of + // |new_policy|. void PostUpdatePolicyTask(DictionaryValue* new_policy); - // Replaces the existing policy to value map with a new one, sending - // notification to the provider if there is a policy change. Must be called on - // |origin_loop_| so that it's safe to call back into the provider, which is - // not thread-safe. - void UpdatePolicy(DictionaryValue* new_policy); - AsynchronousPolicyProvider::Delegate* delegate() { return delegate_.get(); } @@ -67,6 +62,12 @@ class AsynchronousPolicyLoader private: friend class AsynchronousPolicyLoaderTest; + // Replaces the existing policy to value map with a new one, sending + // notification to the provider if there is a policy change. Must be called on + // |origin_loop_| so that it's safe to call back into the provider, which is + // not thread-safe. Takes ownership of |new_policy|. + void UpdatePolicy(DictionaryValue* new_policy); + // Provides the low-level mechanics for loading policy. scoped_ptr<AsynchronousPolicyProvider::Delegate> delegate_; |