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

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

Issue 10905033: contacts: Add ContactMap class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: explicitly include string 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MAP_H_
6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MAP_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/scoped_vector.h"
14 #include "base/stl_util.h"
15 #include "base/time.h"
16
17 namespace contacts {
18
19 class Contact;
20
21 // Stores Contact objects indexed by their IDs.
22 class ContactMap {
23 public:
24 typedef std::map<std::string, Contact*> Map;
25 typedef Map::const_iterator const_iterator;
26
27 ContactMap();
28 ~ContactMap();
29
30 bool empty() const { return contacts_.empty(); }
31 size_t size() const { return contacts_.size(); }
32 const_iterator begin() const { return contacts_.begin(); }
33 const_iterator end() const { return contacts_.end(); }
34
35 // Returns the contact with ID |contact_id|. NULL is returned if the contact
36 // isn't present.
37 const Contact* Find(const std::string& contact_id) const;
38
39 // Deletes all contacts.
40 void Clear();
41
42 // Merges |updated_contacts| into |contacts_|. If |drop_deleted| is true,
43 // updated contacts whose |deleted| field is true won't be merged and the
44 // corresponding existing contacts, if any, will be deleted. Otherwise,
45 // deleted contacts will be merged into |contacts_|.
46 void Merge(scoped_ptr<ScopedVector<Contact> > updated_contacts,
47 bool drop_deleted);
satorux1 2012/09/06 17:16:48 boolean parameter like this can make callers crypt
Daniel Erat 2012/09/09 14:51:30 Good suggestion; done.
48
49 // Returns the maximum |update_time| value stored within a contact in
50 // |contacts_|.
51 base::Time GetMaxUpdateTime() const;
52
53 private:
54 Map contacts_;
55
56 // Deletes values in |contacts_|.
57 STLValueDeleter<Map> contacts_deleter_;
58
59 DISALLOW_COPY_AND_ASSIGN(ContactMap);
60 };
61
62 } // namespace contacts
63
64 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MAP_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/contacts/contact_map.cc » ('j') | chrome/browser/chromeos/contacts/contact_map.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698