| 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 #include "chrome/browser/chromeos/contacts/contact_map.h" | 5 #include "chrome/browser/chromeos/contacts/contact_map.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/contacts/contact.pb.h" | 7 #include "chrome/browser/chromeos/contacts/contact.pb.h" |
| 8 | 8 |
| 9 namespace contacts { | 9 namespace contacts { |
| 10 | 10 |
| 11 ContactMap::ContactMap() : contacts_deleter_(&contacts_) {} | 11 ContactMap::ContactMap() : contacts_deleter_(&contacts_) {} |
| 12 | 12 |
| 13 ContactMap::~ContactMap() {} | 13 ContactMap::~ContactMap() {} |
| 14 | 14 |
| 15 const Contact* ContactMap::Find(const std::string& contact_id) const { | 15 const Contact* ContactMap::Find(const std::string& contact_id) const { |
| 16 Map::const_iterator it = contacts_.find(contact_id); | 16 Map::const_iterator it = contacts_.find(contact_id); |
| 17 return (it != contacts_.end()) ? it->second : NULL; | 17 return (it != contacts_.end()) ? it->second : NULL; |
| 18 } | 18 } |
| 19 | 19 |
| 20 void ContactMap::Clear() { | 20 void ContactMap::Clear() { |
| 21 STLDeleteValues(&contacts_); | 21 STLDeleteValues(&contacts_); |
| 22 contacts_.clear(); | |
| 23 } | 22 } |
| 24 | 23 |
| 25 void ContactMap::Merge(scoped_ptr<ScopedVector<Contact> > updated_contacts, | 24 void ContactMap::Merge(scoped_ptr<ScopedVector<Contact> > updated_contacts, |
| 26 DeletedContactPolicy policy) { | 25 DeletedContactPolicy policy) { |
| 27 for (ScopedVector<Contact>::iterator it = updated_contacts->begin(); | 26 for (ScopedVector<Contact>::iterator it = updated_contacts->begin(); |
| 28 it != updated_contacts->end(); ++it) { | 27 it != updated_contacts->end(); ++it) { |
| 29 Contact* contact = *it; | 28 Contact* contact = *it; |
| 30 Map::iterator map_it = contacts_.find(contact->contact_id()); | 29 Map::iterator map_it = contacts_.find(contact->contact_id()); |
| 31 | 30 |
| 32 if (contact->deleted() && policy == DROP_DELETED_CONTACTS) { | 31 if (contact->deleted() && policy == DROP_DELETED_CONTACTS) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 59 base::Time::FromInternalValue(contact->update_time()); | 58 base::Time::FromInternalValue(contact->update_time()); |
| 60 if (!update_time.is_null() && | 59 if (!update_time.is_null() && |
| 61 (max_update_time.is_null() || max_update_time < update_time)) { | 60 (max_update_time.is_null() || max_update_time < update_time)) { |
| 62 max_update_time = update_time; | 61 max_update_time = update_time; |
| 63 } | 62 } |
| 64 } | 63 } |
| 65 return max_update_time; | 64 return max_update_time; |
| 66 } | 65 } |
| 67 | 66 |
| 68 } // namespace contacts | 67 } // namespace contacts |
| OLD | NEW |