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

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

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.cc
diff --git a/chrome/browser/chromeos/contacts/contact_manager.cc b/chrome/browser/chromeos/contacts/contact_manager.cc
index ee9db7518ab7a81c9d4cb5afb6fa7db5bb320ae2..fe10537179d4bbc891f25fe7dff853353f83c8a1 100644
--- a/chrome/browser/chromeos/contacts/contact_manager.cc
+++ b/chrome/browser/chromeos/contacts/contact_manager.cc
@@ -37,7 +37,8 @@ ContactManager* ContactManager::GetInstance() {
ContactManager::ContactManager()
: profile_observers_deleter_(&profile_observers_),
contact_store_factory_(new GoogleContactStoreFactory),
- contact_stores_deleter_(&contact_stores_) {
+ contact_stores_deleter_(&contact_stores_),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!g_instance);
g_instance = this;
@@ -46,6 +47,7 @@ ContactManager::ContactManager()
ContactManager::~ContactManager() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_EQ(g_instance, this);
+ weak_ptr_factory_.InvalidateWeakPtrs();
g_instance = NULL;
for (ContactStoreMap::const_iterator it = contact_stores_.begin();
it != contact_stores_.end(); ++it) {
@@ -77,6 +79,11 @@ void ContactManager::Init() {
HandleProfileCreated(profiles[i]);
}
+base::WeakPtr<ContactManagerInterface> ContactManager::GetWeakPtr() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ return weak_ptr_factory_.GetWeakPtr();
+}
+
void ContactManager::AddObserver(ContactManagerObserver* observer,
Profile* profile) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
« no previous file with comments | « chrome/browser/chromeos/contacts/contact_manager.h ('k') | chrome/browser/chromeos/contacts/contact_manager_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698