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

Side by Side Diff: chrome/browser/webdata/autocomplete_syncable_service.cc

Issue 10766016: [Sync] Add location parameter to SyncChange in Sync API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: F Created 8 years, 5 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/webdata/autocomplete_syncable_service.h" 5 #include "chrome/browser/webdata/autocomplete_syncable_service.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 FROM_HERE, 150 FROM_HERE,
151 "Failed to update webdata."); 151 "Failed to update webdata.");
152 } 152 }
153 153
154 WebDataService::NotifyOfMultipleAutofillChanges(web_data_service_); 154 WebDataService::NotifyOfMultipleAutofillChanges(web_data_service_);
155 155
156 syncer::SyncChangeList new_changes; 156 syncer::SyncChangeList new_changes;
157 for (AutocompleteEntryMap::iterator i = new_db_entries.begin(); 157 for (AutocompleteEntryMap::iterator i = new_db_entries.begin();
158 i != new_db_entries.end(); ++i) { 158 i != new_db_entries.end(); ++i) {
159 new_changes.push_back( 159 new_changes.push_back(
160 syncer::SyncChange( 160 syncer::SyncChange(FROM_HERE,
161 i->second.first, CreateSyncData(*(i->second.second)))); 161 i->second.first,
162 CreateSyncData(*(i->second.second))));
162 } 163 }
163 164
164 if (ShouldCullSyncedData()) { 165 if (ShouldCullSyncedData()) {
165 // This will schedule a deletion operation on the DB thread, which will 166 // This will schedule a deletion operation on the DB thread, which will
166 // trigger a notification to propagate the deletion to Sync. 167 // trigger a notification to propagate the deletion to Sync.
167 web_data_service_->RemoveExpiredFormElements(); 168 web_data_service_->RemoveExpiredFormElements();
168 } 169 }
169 170
170 syncer::SyncError error = 171 syncer::SyncError error =
171 sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes); 172 sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 change->key().value(), 409 change->key().value(),
409 &timestamps)) { 410 &timestamps)) {
410 NOTREACHED(); 411 NOTREACHED();
411 return; 412 return;
412 } 413 }
413 AutofillEntry entry(change->key(), timestamps); 414 AutofillEntry entry(change->key(), timestamps);
414 syncer::SyncChange::SyncChangeType change_type = 415 syncer::SyncChange::SyncChangeType change_type =
415 (change->type() == AutofillChange::ADD) ? 416 (change->type() == AutofillChange::ADD) ?
416 syncer::SyncChange::ACTION_ADD : 417 syncer::SyncChange::ACTION_ADD :
417 syncer::SyncChange::ACTION_UPDATE; 418 syncer::SyncChange::ACTION_UPDATE;
418 new_changes.push_back(syncer::SyncChange(change_type, 419 new_changes.push_back(syncer::SyncChange(FROM_HERE,
419 CreateSyncData(entry))); 420 change_type,
421 CreateSyncData(entry)));
420 break; 422 break;
421 } 423 }
422 case AutofillChange::REMOVE: { 424 case AutofillChange::REMOVE: {
423 std::vector<base::Time> timestamps; 425 std::vector<base::Time> timestamps;
424 AutofillEntry entry(change->key(), timestamps); 426 AutofillEntry entry(change->key(), timestamps);
425 new_changes.push_back( 427 new_changes.push_back(
426 syncer::SyncChange(syncer::SyncChange::ACTION_DELETE, 428 syncer::SyncChange(FROM_HERE,
427 CreateSyncData(entry))); 429 syncer::SyncChange::ACTION_DELETE,
430 CreateSyncData(entry)));
428 break; 431 break;
429 } 432 }
430 default: 433 default:
431 NOTREACHED(); 434 NOTREACHED();
432 break; 435 break;
433 } 436 }
434 } 437 }
435 syncer::SyncError error = 438 syncer::SyncError error =
436 sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes); 439 sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes);
437 if (error.IsSet()) { 440 if (error.IsSet()) {
(...skipping 11 matching lines...) Expand all
449 UTF16ToUTF8(entry.key().value()))); 452 UTF16ToUTF8(entry.key().value())));
450 return syncer::SyncData::CreateLocalData(tag, tag, autofill_specifics); 453 return syncer::SyncData::CreateLocalData(tag, tag, autofill_specifics);
451 } 454 }
452 455
453 // static 456 // static
454 std::string AutocompleteSyncableService::KeyToTag(const std::string& name, 457 std::string AutocompleteSyncableService::KeyToTag(const std::string& name,
455 const std::string& value) { 458 const std::string& value) {
456 std::string ns(kAutofillEntryNamespaceTag); 459 std::string ns(kAutofillEntryNamespaceTag);
457 return ns + net::EscapePath(name) + "|" + net::EscapePath(value); 460 return ns + net::EscapePath(name) + "|" + net::EscapePath(value);
458 } 461 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698