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

Side by Side Diff: chrome/browser/chromeos/contacts/google_contact_store.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, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/contacts/contact_manager_stub.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/contacts/google_contact_store.h" 5 #include "chrome/browser/chromeos/contacts/google_contact_store.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 scoped_ptr<ContactPointers> contacts_to_save_to_db(new ContactPointers); 298 scoped_ptr<ContactPointers> contacts_to_save_to_db(new ContactPointers);
299 if (db_) { 299 if (db_) {
300 for (size_t i = 0; i < updated_contacts->size(); ++i) 300 for (size_t i = 0; i < updated_contacts->size(); ++i)
301 contacts_to_save_to_db->push_back((*updated_contacts)[i]); 301 contacts_to_save_to_db->push_back((*updated_contacts)[i]);
302 } 302 }
303 bool got_updates = !updated_contacts->empty(); 303 bool got_updates = !updated_contacts->empty();
304 304
305 MergeContacts(is_full_update, updated_contacts.Pass()); 305 MergeContacts(is_full_update, updated_contacts.Pass());
306 last_successful_update_start_time_ = update_start_time; 306 last_successful_update_start_time_ = update_start_time;
307 307
308 if (is_full_update || got_updates > 0) { 308 if (is_full_update || got_updates) {
309 FOR_EACH_OBSERVER(ContactStoreObserver, 309 FOR_EACH_OBSERVER(ContactStoreObserver,
310 observers_, 310 observers_,
311 OnContactsUpdated(this)); 311 OnContactsUpdated(this));
312 } 312 }
313 313
314 if (db_) { 314 if (db_) {
315 // Even if this was an incremental update and we didn't get any updated
316 // contacts, we still want to write updated metadata containing
317 // |update_start_time|.
315 VLOG(1) << "Saving " << contacts_to_save_to_db->size() << " contact(s) to " 318 VLOG(1) << "Saving " << contacts_to_save_to_db->size() << " contact(s) to "
316 << "database as " << (is_full_update ? "full" : "partial") 319 << "database as " << (is_full_update ? "full" : "incremental")
317 << " update"; 320 << " update";
318 scoped_ptr<UpdateMetadata> metadata(new UpdateMetadata); 321 scoped_ptr<UpdateMetadata> metadata(new UpdateMetadata);
319 metadata->set_last_update_start_time(update_start_time.ToInternalValue()); 322 metadata->set_last_update_start_time(update_start_time.ToInternalValue());
320 db_->SaveContacts( 323 db_->SaveContacts(
321 contacts_to_save_to_db.Pass(), 324 contacts_to_save_to_db.Pass(),
322 metadata.Pass(), 325 metadata.Pass(),
323 is_full_update, 326 is_full_update,
324 base::Bind(&GoogleContactStore::OnDatabaseContactsSaved, 327 base::Bind(&GoogleContactStore::OnDatabaseContactsSaved,
325 weak_ptr_factory_.GetWeakPtr())); 328 weak_ptr_factory_.GetWeakPtr()));
326 329
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 return gdata::util::IsGDataAvailable(profile); 403 return gdata::util::IsGDataAvailable(profile);
401 } 404 }
402 405
403 ContactStore* GoogleContactStoreFactory::CreateContactStore(Profile* profile) { 406 ContactStore* GoogleContactStoreFactory::CreateContactStore(Profile* profile) {
404 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 407 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
405 DCHECK(CanCreateContactStoreForProfile(profile)); 408 DCHECK(CanCreateContactStoreForProfile(profile));
406 return new GoogleContactStore(profile); 409 return new GoogleContactStore(profile);
407 } 410 }
408 411
409 } // namespace contacts 412 } // namespace contacts
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/contacts/contact_manager_stub.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698