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

Side by Side Diff: chrome/browser/chromeos/contacts/fake_contact_store.cc

Issue 10827406: contacts: Rename provider_id to contact_id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge 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 unified diff | Download patch | Annotate | Revision Log
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/fake_contact_store.h" 5 #include "chrome/browser/chromeos/contacts/fake_contact_store.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "chrome/browser/chromeos/contacts/contact.pb.h" 9 #include "chrome/browser/chromeos/contacts/contact.pb.h"
10 #include "chrome/browser/chromeos/contacts/contact_store_observer.h" 10 #include "chrome/browser/chromeos/contacts/contact_store_observer.h"
(...skipping 11 matching lines...) Expand all
22 22
23 FakeContactStore::~FakeContactStore() { 23 FakeContactStore::~FakeContactStore() {
24 factory_->RemoveStore(this); 24 factory_->RemoveStore(this);
25 } 25 }
26 26
27 void FakeContactStore::SetContacts(const ContactPointers& contacts) { 27 void FakeContactStore::SetContacts(const ContactPointers& contacts) {
28 STLDeleteValues(&contacts_); 28 STLDeleteValues(&contacts_);
29 contacts_.clear(); 29 contacts_.clear();
30 for (ContactPointers::const_iterator it = contacts.begin(); 30 for (ContactPointers::const_iterator it = contacts.begin();
31 it != contacts.end(); ++it) { 31 it != contacts.end(); ++it) {
32 contacts_[(*it)->provider_id()] = new Contact(**it); 32 contacts_[(*it)->contact_id()] = new Contact(**it);
33 } 33 }
34 } 34 }
35 35
36 void FakeContactStore::NotifyObserversAboutContactsUpdate() { 36 void FakeContactStore::NotifyObserversAboutContactsUpdate() {
37 FOR_EACH_OBSERVER(ContactStoreObserver, 37 FOR_EACH_OBSERVER(ContactStoreObserver,
38 observers_, 38 observers_,
39 OnContactsUpdated(this)); 39 OnContactsUpdated(this));
40 } 40 }
41 41
42 void FakeContactStore::Init() { 42 void FakeContactStore::Init() {
43 } 43 }
44 44
45 void FakeContactStore::AppendContacts(ContactPointers* contacts_out) { 45 void FakeContactStore::AppendContacts(ContactPointers* contacts_out) {
46 CHECK(contacts_out); 46 CHECK(contacts_out);
47 for (ContactMap::const_iterator it = contacts_.begin(); 47 for (ContactMap::const_iterator it = contacts_.begin();
48 it != contacts_.end(); ++it) { 48 it != contacts_.end(); ++it) {
49 if (!it->second->deleted()) 49 if (!it->second->deleted())
50 contacts_out->push_back(it->second); 50 contacts_out->push_back(it->second);
51 } 51 }
52 } 52 }
53 53
54 const Contact* FakeContactStore::GetContactByProviderId( 54 const Contact* FakeContactStore::GetContactById(const std::string& contact_id) {
55 const std::string& provider_id) { 55 ContactMap::const_iterator it = contacts_.find(contact_id);
56 ContactMap::const_iterator it = contacts_.find(provider_id);
57 return (it != contacts_.end() && !it->second->deleted()) ? it->second : NULL; 56 return (it != contacts_.end() && !it->second->deleted()) ? it->second : NULL;
58 } 57 }
59 58
60 void FakeContactStore::AddObserver(ContactStoreObserver* observer) { 59 void FakeContactStore::AddObserver(ContactStoreObserver* observer) {
61 CHECK(observer); 60 CHECK(observer);
62 observers_.AddObserver(observer); 61 observers_.AddObserver(observer);
63 } 62 }
64 63
65 void FakeContactStore::RemoveObserver(ContactStoreObserver* observer) { 64 void FakeContactStore::RemoveObserver(ContactStoreObserver* observer) {
66 CHECK(observer); 65 CHECK(observer);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 CHECK(profile); 103 CHECK(profile);
105 CHECK(CanCreateContactStoreForProfile(profile)); 104 CHECK(CanCreateContactStoreForProfile(profile));
106 FakeContactStore* store = new FakeContactStore(this); 105 FakeContactStore* store = new FakeContactStore(this);
107 CHECK(stores_.insert(std::make_pair(profile, store)).second) 106 CHECK(stores_.insert(std::make_pair(profile, store)).second)
108 << "Got request to create second FakeContactStore for profile " 107 << "Got request to create second FakeContactStore for profile "
109 << profile << " (" << profile->GetProfileName() << ")"; 108 << profile << " (" << profile->GetProfileName() << ")";
110 return store; 109 return store;
111 } 110 }
112 111
113 } // namespace contacts 112 } // namespace contacts
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/contacts/fake_contact_store.h ('k') | chrome/browser/chromeos/contacts/google_contact_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698