Chromium Code Reviews| Index: chrome/browser/chromeos/contacts/contact_map.h |
| diff --git a/chrome/browser/chromeos/contacts/contact_map.h b/chrome/browser/chromeos/contacts/contact_map.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..01720087543fbfbdd3246c0573c9d04d1547206a |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/contacts/contact_map.h |
| @@ -0,0 +1,64 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MAP_H_ |
| +#define CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MAP_H_ |
| + |
| +#include <map> |
| +#include <string> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/scoped_vector.h" |
| +#include "base/stl_util.h" |
| +#include "base/time.h" |
| + |
| +namespace contacts { |
| + |
| +class Contact; |
| + |
| +// Stores Contact objects indexed by their IDs. |
| +class ContactMap { |
| + public: |
| + typedef std::map<std::string, Contact*> Map; |
| + typedef Map::const_iterator const_iterator; |
| + |
| + ContactMap(); |
| + ~ContactMap(); |
| + |
| + bool empty() const { return contacts_.empty(); } |
| + size_t size() const { return contacts_.size(); } |
| + const_iterator begin() const { return contacts_.begin(); } |
| + const_iterator end() const { return contacts_.end(); } |
| + |
| + // Returns the contact with ID |contact_id|. NULL is returned if the contact |
| + // isn't present. |
| + const Contact* Find(const std::string& contact_id) const; |
| + |
| + // Deletes all contacts. |
| + void Clear(); |
| + |
| + // Merges |updated_contacts| into |contacts_|. If |drop_deleted| is true, |
| + // updated contacts whose |deleted| field is true won't be merged and the |
| + // corresponding existing contacts, if any, will be deleted. Otherwise, |
| + // deleted contacts will be merged into |contacts_|. |
| + void Merge(scoped_ptr<ScopedVector<Contact> > updated_contacts, |
| + 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.
|
| + |
| + // Returns the maximum |update_time| value stored within a contact in |
| + // |contacts_|. |
| + base::Time GetMaxUpdateTime() const; |
| + |
| + private: |
| + Map contacts_; |
| + |
| + // Deletes values in |contacts_|. |
| + STLValueDeleter<Map> contacts_deleter_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ContactMap); |
| +}; |
| + |
| +} // namespace contacts |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MAP_H_ |