From 512d03f78c442cf31bae077d93ecc4882a46b286 Mon Sep 17 00:00:00 2001 From: "rsleevi@chromium.org" Date: Tue, 26 Jun 2012 01:06:06 +0000 Subject: RefCounted types should not have public destructors, delegate cleanup For Delegate/Observer-type classes that specify an interface but do not have any particular lifetime requirements, make their destructors protected. This is to allow their interfaces to be implemented safely by RefCounted types. With public destructors, it's possible to do "scoped_ptr foo", and then assign a RefCountedDelegateImpl, which would lead to a double free. As none of these Delegates actually need public destructors (ownership of the Delegate* is not transferred during a function call / class constructor), mark the destructors protected so that it becomes a compile warning to try to delete them via the Delegate*. BUG=123295 TEST=it compiles Review URL: https://chromiumcodereview.appspot.com/10383262 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144086 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/common/pref_store.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'chrome/common/pref_store.h') diff --git a/chrome/common/pref_store.h b/chrome/common/pref_store.h index 67fa4c9..1b63eb2 100644 --- a/chrome/common/pref_store.h +++ b/chrome/common/pref_store.h @@ -27,12 +27,13 @@ class PrefStore : public base::RefCounted { // Observer interface for monitoring PrefStore. class Observer { public: - virtual ~Observer() {} - // Called when the value for the given |key| in the store changes. virtual void OnPrefValueChanged(const std::string& key) = 0; // Notification about the PrefStore being fully initialized. virtual void OnInitializationCompleted(bool succeeded) = 0; + + protected: + virtual ~Observer() {} }; // Return values for GetValue(). -- cgit v1.1