Chromium Code Reviews| Index: chrome/browser/chromeos/contacts/contact_manager.h |
| diff --git a/chrome/browser/chromeos/contacts/contact_manager.h b/chrome/browser/chromeos/contacts/contact_manager.h |
| index 8f3d162c9b1b5d4f42359d708b26a2815c73394b..0e508ff41bca8f4052c113bbb23f905ebd900c4e 100644 |
| --- a/chrome/browser/chromeos/contacts/contact_manager.h |
| +++ b/chrome/browser/chromeos/contacts/contact_manager.h |
| @@ -11,6 +11,7 @@ |
| #include "base/basictypes.h" |
| #include "base/compiler_specific.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| #include "base/observer_list.h" |
| #include "base/stl_util.h" |
| #include "chrome/browser/chromeos/contacts/contact_store_observer.h" |
| @@ -34,6 +35,9 @@ class ContactManagerInterface { |
| ContactManagerInterface() {} |
| virtual ~ContactManagerInterface() {} |
| + // Returns a weak pointer tied to the lifetime of this object. |
| + virtual base::WeakPtr<ContactManagerInterface> GetWeakPtr() = 0; |
|
satorux1
2012/08/30 16:43:29
This looks worrisome. I'm not sure if WeakPtr work
Daniel Erat
2012/08/30 16:56:16
Thanks for pointing out that thread!
The original
|
| + |
| // Adds or removes an observer for changes to |profile|'s contacts. |
| virtual void AddObserver(ContactManagerObserver* observer, |
| Profile* profile) = 0; |
| @@ -71,6 +75,7 @@ class ContactManager : public ContactManagerInterface, |
| void Init(); |
| // ContactManagerInterface overrides: |
| + virtual base::WeakPtr<ContactManagerInterface> GetWeakPtr() OVERRIDE; |
| virtual void AddObserver(ContactManagerObserver* observer, |
| Profile* profile) OVERRIDE; |
| virtual void RemoveObserver(ContactManagerObserver* observer, |
| @@ -118,6 +123,10 @@ class ContactManager : public ContactManagerInterface, |
| // Deletes values in |contact_stores_|. |
| STLValueDeleter<ContactStoreMap> contact_stores_deleter_; |
| + // Note: This should remain the last member so it'll be destroyed and |
| + // invalidate its weak pointers before any other members are destroyed. |
| + base::WeakPtrFactory<ContactManagerInterface> weak_ptr_factory_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(ContactManager); |
| }; |