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

Side by Side Diff: components/autofill/core/browser/webdata/autocomplete_sync_bridge.cc

Issue 2923363004: [Sync] Migrate bridge implementations to change list based MergeSyncData (Closed)
Patch Set: Created 3 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/autofill/core/browser/webdata/autocomplete_sync_bridge.h" 5 #include "components/autofill/core/browser/webdata/autocomplete_sync_bridge.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <unordered_set> 9 #include <unordered_set>
10 #include <utility> 10 #include <utility>
(...skipping 13 matching lines...) Expand all
24 #include "components/sync/model_impl/sync_metadata_store_change_list.h" 24 #include "components/sync/model_impl/sync_metadata_store_change_list.h"
25 #include "net/base/escape.h" 25 #include "net/base/escape.h"
26 26
27 using base::Optional; 27 using base::Optional;
28 using base::Time; 28 using base::Time;
29 using base::debug::DumpWithoutCrashing; 29 using base::debug::DumpWithoutCrashing;
30 using sync_pb::AutofillSpecifics; 30 using sync_pb::AutofillSpecifics;
31 using syncer::EntityChange; 31 using syncer::EntityChange;
32 using syncer::EntityChangeList; 32 using syncer::EntityChangeList;
33 using syncer::EntityData; 33 using syncer::EntityData;
34 using syncer::EntityDataMap;
35 using syncer::MetadataChangeList; 34 using syncer::MetadataChangeList;
36 using syncer::ModelError; 35 using syncer::ModelError;
37 using syncer::ModelTypeChangeProcessor; 36 using syncer::ModelTypeChangeProcessor;
38 using syncer::ModelTypeSyncBridge; 37 using syncer::ModelTypeSyncBridge;
39 using syncer::MutableDataBatch; 38 using syncer::MutableDataBatch;
40 39
41 namespace autofill { 40 namespace autofill {
42 41
43 namespace { 42 namespace {
44 43
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 318
320 std::unique_ptr<MetadataChangeList> 319 std::unique_ptr<MetadataChangeList>
321 AutocompleteSyncBridge::CreateMetadataChangeList() { 320 AutocompleteSyncBridge::CreateMetadataChangeList() {
322 DCHECK(thread_checker_.CalledOnValidThread()); 321 DCHECK(thread_checker_.CalledOnValidThread());
323 return base::MakeUnique<syncer::SyncMetadataStoreChangeList>( 322 return base::MakeUnique<syncer::SyncMetadataStoreChangeList>(
324 GetAutofillTable(), syncer::AUTOFILL); 323 GetAutofillTable(), syncer::AUTOFILL);
325 } 324 }
326 325
327 Optional<syncer::ModelError> AutocompleteSyncBridge::MergeSyncData( 326 Optional<syncer::ModelError> AutocompleteSyncBridge::MergeSyncData(
328 std::unique_ptr<MetadataChangeList> metadata_change_list, 327 std::unique_ptr<MetadataChangeList> metadata_change_list,
329 EntityDataMap entity_data_map) { 328 EntityChangeList entity_data) {
330 DCHECK(thread_checker_.CalledOnValidThread()); 329 DCHECK(thread_checker_.CalledOnValidThread());
331 330
332 SyncDifferenceTracker tracker(GetAutofillTable()); 331 SyncDifferenceTracker tracker(GetAutofillTable());
333 for (auto kv : entity_data_map) { 332 for (const auto& change : entity_data) {
334 DCHECK(kv.second->specifics.has_autofill()); 333 DCHECK(change.data().specifics.has_autofill());
335 RETURN_IF_ERROR(tracker.IncorporateRemoteSpecifics( 334 RETURN_IF_ERROR(tracker.IncorporateRemoteSpecifics(
336 kv.first, kv.second->specifics.autofill())); 335 change.storage_key(), change.data().specifics.autofill()));
337 } 336 }
338 337
339 RETURN_IF_ERROR(tracker.FlushToLocal(web_data_backend_)); 338 RETURN_IF_ERROR(tracker.FlushToLocal(web_data_backend_));
340 RETURN_IF_ERROR(tracker.FlushToSync(true, std::move(metadata_change_list), 339 RETURN_IF_ERROR(tracker.FlushToSync(true, std::move(metadata_change_list),
341 change_processor())); 340 change_processor()));
342 web_data_backend_->RemoveExpiredFormElements(); 341 web_data_backend_->RemoveExpiredFormElements();
343 web_data_backend_->NotifyThatSyncHasStarted(syncer::AUTOFILL); 342 web_data_backend_->NotifyThatSyncHasStarted(syncer::AUTOFILL);
344 return {}; 343 return {};
345 } 344 }
346 345
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 const AutofillChangeList& changes) { 488 const AutofillChangeList& changes) {
490 DCHECK(thread_checker_.CalledOnValidThread()); 489 DCHECK(thread_checker_.CalledOnValidThread());
491 ActOnLocalChanges(changes); 490 ActOnLocalChanges(changes);
492 } 491 }
493 492
494 AutofillTable* AutocompleteSyncBridge::GetAutofillTable() const { 493 AutofillTable* AutocompleteSyncBridge::GetAutofillTable() const {
495 return AutofillTable::FromWebDatabase(web_data_backend_->GetDatabase()); 494 return AutofillTable::FromWebDatabase(web_data_backend_->GetDatabase());
496 } 495 }
497 496
498 } // namespace autofill 497 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698