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

Side by Side Diff: chrome/browser/chromeos/contacts/contact_database.cc

Issue 10827406: contacts: Rename provider_id to contact_id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 4 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 #include "chrome/browser/chromeos/contacts/contact_database.h" 5 #include "chrome/browser/chromeos/contacts/contact_database.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 207
208 // TODO(derat): Serializing all of the contacts and so we can write them in a 208 // TODO(derat): Serializing all of the contacts and so we can write them in a
209 // single batch may be expensive, memory-wise. Consider writing them in 209 // single batch may be expensive, memory-wise. Consider writing them in
210 // several batches instead. (To avoid using partial writes in the event of a 210 // several batches instead. (To avoid using partial writes in the event of a
211 // crash, maybe add a dummy "write completed" contact that's removed in the 211 // crash, maybe add a dummy "write completed" contact that's removed in the
212 // first batch and added in the last.) 212 // first batch and added in the last.)
213 leveldb::WriteBatch updates; 213 leveldb::WriteBatch updates;
214 for (ContactPointers::const_iterator it = contacts->begin(); 214 for (ContactPointers::const_iterator it = contacts->begin();
215 it != contacts->end(); ++it) { 215 it != contacts->end(); ++it) {
216 const contacts::Contact& contact = **it; 216 const contacts::Contact& contact = **it;
217 if (contact.provider_id() == kUpdateMetadataKey) { 217 if (contact.contact_id() == kUpdateMetadataKey) {
218 LOG(WARNING) << "Skipping contact with reserved ID " 218 LOG(WARNING) << "Skipping contact with reserved ID "
219 << contact.provider_id(); 219 << contact.contact_id();
220 continue; 220 continue;
221 } 221 }
222 updates.Put(leveldb::Slice(contact.provider_id()), 222 updates.Put(leveldb::Slice(contact.contact_id()),
223 leveldb::Slice(contact.SerializeAsString())); 223 leveldb::Slice(contact.SerializeAsString()));
224 if (is_full_update) 224 if (is_full_update)
225 keys_to_delete.erase(contact.provider_id()); 225 keys_to_delete.erase(contact.contact_id());
226 } 226 }
227 227
228 for (std::set<std::string>::const_iterator it = keys_to_delete.begin(); 228 for (std::set<std::string>::const_iterator it = keys_to_delete.begin();
229 it != keys_to_delete.end(); ++it) { 229 it != keys_to_delete.end(); ++it) {
230 updates.Delete(leveldb::Slice(*it)); 230 updates.Delete(leveldb::Slice(*it));
231 } 231 }
232 232
233 updates.Put(leveldb::Slice(kUpdateMetadataKey), 233 updates.Put(leveldb::Slice(kUpdateMetadataKey),
234 leveldb::Slice(metadata->SerializeAsString())); 234 leveldb::Slice(metadata->SerializeAsString()));
235 235
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 275 }
276 contacts->push_back(contact.release()); 276 contacts->push_back(contact.release());
277 } 277 }
278 db_iterator->Next(); 278 db_iterator->Next();
279 } 279 }
280 280
281 *success = true; 281 *success = true;
282 } 282 }
283 283
284 } // namespace contacts 284 } // namespace contacts
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/contacts/contact.proto ('k') | chrome/browser/chromeos/contacts/contact_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698