OLD | NEW |
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 #ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_STORE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_STORE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_STORE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_STORE_H_ |
7 | 7 |
8 #include "chrome/browser/chromeos/contacts/contact_store.h" | 8 #include "chrome/browser/chromeos/contacts/contact_store.h" |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 13 matching lines...) Expand all Loading... |
24 class FakeContactStoreFactory; | 24 class FakeContactStoreFactory; |
25 typedef std::vector<const Contact*> ContactPointers; | 25 typedef std::vector<const Contact*> ContactPointers; |
26 | 26 |
27 // A "fake" in-memory implementation of ContactStore used for testing. | 27 // A "fake" in-memory implementation of ContactStore used for testing. |
28 class FakeContactStore : public ContactStore { | 28 class FakeContactStore : public ContactStore { |
29 public: | 29 public: |
30 explicit FakeContactStore(FakeContactStoreFactory* factory); | 30 explicit FakeContactStore(FakeContactStoreFactory* factory); |
31 virtual ~FakeContactStore(); | 31 virtual ~FakeContactStore(); |
32 | 32 |
33 // Makes an internal copy of |contacts| so they can be returned by | 33 // Makes an internal copy of |contacts| so they can be returned by |
34 // AppendContacts() and GetContactByProviderId(). | 34 // AppendContacts() and GetContactById(). |
35 void SetContacts(const ContactPointers& contacts); | 35 void SetContacts(const ContactPointers& contacts); |
36 | 36 |
37 // Invokes observers' OnContactsUpdated() methods. | 37 // Invokes observers' OnContactsUpdated() methods. |
38 void NotifyObserversAboutContactsUpdate(); | 38 void NotifyObserversAboutContactsUpdate(); |
39 | 39 |
40 // ContactStore implementation: | 40 // ContactStore implementation: |
41 virtual void Init() OVERRIDE; | 41 virtual void Init() OVERRIDE; |
42 virtual void AppendContacts(ContactPointers* contacts_out) OVERRIDE; | 42 virtual void AppendContacts(ContactPointers* contacts_out) OVERRIDE; |
43 virtual const Contact* GetContactByProviderId( | 43 virtual const Contact* GetContactById(const std::string& contact_id) OVERRIDE; |
44 const std::string& provider_id) OVERRIDE; | |
45 virtual void AddObserver(ContactStoreObserver* observer) OVERRIDE; | 44 virtual void AddObserver(ContactStoreObserver* observer) OVERRIDE; |
46 virtual void RemoveObserver(ContactStoreObserver* observer) OVERRIDE; | 45 virtual void RemoveObserver(ContactStoreObserver* observer) OVERRIDE; |
47 | 46 |
48 private: | 47 private: |
49 // Map from a contact's provider ID to the contact itself. | 48 // Map from a contact's ID to the contact itself. |
50 typedef std::map<std::string, Contact*> ContactMap; | 49 typedef std::map<std::string, Contact*> ContactMap; |
51 | 50 |
52 // Factory that created this store. Not owned. | 51 // Factory that created this store. Not owned. |
53 FakeContactStoreFactory* factory_; | 52 FakeContactStoreFactory* factory_; |
54 | 53 |
55 ObserverList<ContactStoreObserver> observers_; | 54 ObserverList<ContactStoreObserver> observers_; |
56 | 55 |
57 // Owns the pointed-to Contact values. | 56 // Owns the pointed-to Contact values. |
58 ContactMap contacts_; | 57 ContactMap contacts_; |
59 | 58 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 94 |
96 // Should CanCreateContactStoreForProfile() return true? | 95 // Should CanCreateContactStoreForProfile() return true? |
97 bool permit_store_creation_; | 96 bool permit_store_creation_; |
98 | 97 |
99 DISALLOW_COPY_AND_ASSIGN(FakeContactStoreFactory); | 98 DISALLOW_COPY_AND_ASSIGN(FakeContactStoreFactory); |
100 }; | 99 }; |
101 | 100 |
102 } // namespace contacts | 101 } // namespace contacts |
103 | 102 |
104 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_STORE_H_ | 103 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_STORE_H_ |
OLD | NEW |