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

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: update a comment 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..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));

Powered by Google App Engine
This is Rietveld 408576698