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

Side by Side Diff: chrome/browser/chromeos/contacts/google_contact_store.h

Issue 10905033: contacts: Add ContactMap class. (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
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 #ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_GOOGLE_CONTACT_STORE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_GOOGLE_CONTACT_STORE_H_
6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_GOOGLE_CONTACT_STORE_H_ 6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_GOOGLE_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>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/scoped_vector.h" 17 #include "base/memory/scoped_vector.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "base/observer_list.h" 19 #include "base/observer_list.h"
20 #include "base/stl_util.h"
21 #include "base/time.h" 20 #include "base/time.h"
22 #include "base/timer.h" 21 #include "base/timer.h"
22 #include "chrome/browser/chromeos/contacts/contact_map.h"
23 #include "net/base/network_change_notifier.h" 23 #include "net/base/network_change_notifier.h"
24 24
25 class Profile; 25 class Profile;
26 26
27 namespace gdata { 27 namespace gdata {
28 class GDataContactsServiceInterface; 28 class GDataContactsServiceInterface;
29 } 29 }
30 30
31 namespace contacts { 31 namespace contacts {
32 32
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 virtual void AppendContacts(ContactPointers* contacts_out) OVERRIDE; 77 virtual void AppendContacts(ContactPointers* contacts_out) OVERRIDE;
78 virtual const Contact* GetContactById(const std::string& contact_id) OVERRIDE; 78 virtual const Contact* GetContactById(const std::string& contact_id) OVERRIDE;
79 virtual void AddObserver(ContactStoreObserver* observer) OVERRIDE; 79 virtual void AddObserver(ContactStoreObserver* observer) OVERRIDE;
80 virtual void RemoveObserver(ContactStoreObserver* observer) OVERRIDE; 80 virtual void RemoveObserver(ContactStoreObserver* observer) OVERRIDE;
81 81
82 // net::NetworkChangeNotifier::ConnectionTypeObserver implementation: 82 // net::NetworkChangeNotifier::ConnectionTypeObserver implementation:
83 virtual void OnConnectionTypeChanged( 83 virtual void OnConnectionTypeChanged(
84 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; 84 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
85 85
86 private: 86 private:
87 // Map from a contact's Google-assigned ID to the contact itself.
88 typedef std::map<std::string, Contact*> ContactMap;
89
90 // Returns the current time. Uses |current_time_for_testing_| instead if it's 87 // Returns the current time. Uses |current_time_for_testing_| instead if it's
91 // set. 88 // set.
92 base::Time GetCurrentTime() const; 89 base::Time GetCurrentTime() const;
93 90
94 // Destroys |db_| if non-NULL and resets the pointer. 91 // Destroys |db_| if non-NULL and resets the pointer.
95 // The underlying data is preserved on-disk. 92 // The underlying data is preserved on-disk.
96 void DestroyDatabase(); 93 void DestroyDatabase();
97 94
98 // Asynchronously downloads updated contacts and merges them into |contacts_|. 95 // Asynchronously downloads updated contacts and merges them into |contacts_|.
99 void UpdateContacts(); 96 void UpdateContacts();
(...skipping 30 matching lines...) Expand all
130 // being accessed by the database, we schedule an update. 127 // being accessed by the database, we schedule an update.
131 void OnDatabaseContactsSaved(bool success); 128 void OnDatabaseContactsSaved(bool success);
132 129
133 Profile* profile_; // not owned 130 Profile* profile_; // not owned
134 131
135 ObserverList<ContactStoreObserver> observers_; 132 ObserverList<ContactStoreObserver> observers_;
136 133
137 // Owns the pointed-to Contact values. 134 // Owns the pointed-to Contact values.
138 ContactMap contacts_; 135 ContactMap contacts_;
139 136
140 // Deletes values in |contacts_|.
141 STLValueDeleter<ContactMap> contacts_deleter_;
142
143 // Most-recent time that an entry in |contacts_| has been updated (as reported 137 // Most-recent time that an entry in |contacts_| has been updated (as reported
144 // by Google). 138 // by Google).
145 base::Time last_contact_update_time_; 139 base::Time last_contact_update_time_;
146 140
147 // Used to download contacts. 141 // Used to download contacts.
148 scoped_ptr<gdata::GDataContactsServiceInterface> gdata_service_; 142 scoped_ptr<gdata::GDataContactsServiceInterface> gdata_service_;
149 143
150 // Used to save contacts to disk and load them at startup. Owns the object. 144 // Used to save contacts to disk and load them at startup. Owns the object.
151 ContactDatabaseInterface* db_; 145 ContactDatabaseInterface* db_;
152 146
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 virtual bool CanCreateContactStoreForProfile(Profile* profile) OVERRIDE; 183 virtual bool CanCreateContactStoreForProfile(Profile* profile) OVERRIDE;
190 virtual ContactStore* CreateContactStore(Profile* profile) OVERRIDE; 184 virtual ContactStore* CreateContactStore(Profile* profile) OVERRIDE;
191 185
192 private: 186 private:
193 DISALLOW_COPY_AND_ASSIGN(GoogleContactStoreFactory); 187 DISALLOW_COPY_AND_ASSIGN(GoogleContactStoreFactory);
194 }; 188 };
195 189
196 } // namespace contacts 190 } // namespace contacts
197 191
198 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_GOOGLE_CONTACT_STORE_H_ 192 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_GOOGLE_CONTACT_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698