| Index: chrome/browser/prefs/pref_member.h
|
| diff --git a/chrome/browser/prefs/pref_member.h b/chrome/browser/prefs/pref_member.h
|
| index 88a00711f4e91286a64d7f6130191160c873d0e8..28b6508af1a0c30d9d76f9d35f6ac0ef8877a432 100644
|
| --- a/chrome/browser/prefs/pref_member.h
|
| +++ b/chrome/browser/prefs/pref_member.h
|
| @@ -33,8 +33,10 @@
|
| #include "base/values.h"
|
| #include "content/browser/browser_thread.h"
|
| #include "content/common/notification_observer.h"
|
| +#include "content/common/notification_registrar.h"
|
|
|
| class PrefService;
|
| +class Profile;
|
|
|
| namespace subtle {
|
|
|
| @@ -86,6 +88,8 @@ class PrefMemberBase : public NotificationObserver {
|
|
|
| virtual void CreateInternal() const = 0;
|
|
|
| + void ObserveProfileDestruction(Profile* profile);
|
| +
|
| // See PrefMember<> for description.
|
| void Destroy();
|
|
|
| @@ -120,6 +124,7 @@ class PrefMemberBase : public NotificationObserver {
|
| // Ordered the members to compact the class instance.
|
| private:
|
| std::string pref_name_;
|
| + NotificationRegistrar registrar_;
|
| NotificationObserver* observer_;
|
| PrefService* prefs_;
|
|
|
| @@ -145,6 +150,12 @@ class PrefMember : public subtle::PrefMemberBase {
|
| subtle::PrefMemberBase::Init(pref_name, prefs, observer);
|
| }
|
|
|
| + // Starts observing PROFILE_DESTROYED notifications for the given |profile|,
|
| + // to automatically unsubscribe from the PrefService.
|
| + void ObserveProfileDestruction(Profile* profile) {
|
| + subtle::PrefMemberBase::ObserveProfileDestruction(profile);
|
| + }
|
| +
|
| // Unsubscribes the PrefMember from the PrefService. After calling this
|
| // function, the PrefMember may not be used any more.
|
| // This method should only be called on the UI thread.
|
|
|