Revert 168224 - Update V8 to version 3.15.4.
[chromium-blink-merge.git] / chrome / browser / chromeos / contacts / contact_map.h
blob22de98e7823ecd025466ba709d27c97ea31e3014
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.
5 #ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MAP_H_
6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MAP_H_
8 #include <map>
9 #include <string>
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"
17 namespace contacts {
19 class Contact;
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;
27 // What should Merge() do when passed a deleted contact?
28 enum DeletedContactPolicy {
29 // The deleted contact will be inserted into the map.
30 KEEP_DELETED_CONTACTS,
32 // The deleted contact will not be deleted from the map, and if there is a
33 // previous version of the now-deleted contact already in the map, it will
34 // also be removed.
35 DROP_DELETED_CONTACTS,
38 ContactMap();
39 ~ContactMap();
41 bool empty() const { return contacts_.empty(); }
42 size_t size() const { return contacts_.size(); }
43 const_iterator begin() const { return contacts_.begin(); }
44 const_iterator end() const { return contacts_.end(); }
46 // Returns the contact with ID |contact_id|. NULL is returned if the contact
47 // isn't present.
48 const Contact* Find(const std::string& contact_id) const;
50 // Deletes the contact with ID |contact_id|.
51 void Erase(const std::string& contact_id);
53 // Deletes all contacts.
54 void Clear();
56 // Merges |updated_contacts| into |contacts_|.
57 void Merge(scoped_ptr<ScopedVector<Contact> > updated_contacts,
58 DeletedContactPolicy policy);
60 private:
61 Map contacts_;
63 // Deletes values in |contacts_|.
64 STLValueDeleter<Map> contacts_deleter_;
66 DISALLOW_COPY_AND_ASSIGN(ContactMap);
69 } // namespace contacts
71 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MAP_H_