Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Unified Diff: chrome/browser/chromeos/contacts/contact_manager.h

Issue 10896031: contacts: Add ContactManagerInterface::GetWeakPtr(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: apply review feedback Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
+
// 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);
};
« no previous file with comments | « chrome/browser/chromeos/contacts/contact_database_unittest.cc ('k') | chrome/browser/chromeos/contacts/contact_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698