Chromium Code Reviews| 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..100ebd0b6974be49c6935ef2a5177a748fec3b4f 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_), |
| + weak_ptr_factory_(this) { |
|
satorux1
2012/08/30 17:19:26
ALLOW_THIS_IN_INITIALIZER_LIST ?
Daniel Erat
2012/08/30 20:59:45
Done.
|
| 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)); |