| OLD | NEW |
| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/debug/dump_without_crashing.h" |
| 14 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 16 #include "components/autofill/core/browser/proto/autofill_sync.pb.h" | 17 #include "components/autofill/core/browser/proto/autofill_sync.pb.h" |
| 17 #include "components/autofill/core/browser/webdata/autofill_metadata_change_list
.h" | 18 #include "components/autofill/core/browser/webdata/autofill_metadata_change_list
.h" |
| 18 #include "components/autofill/core/browser/webdata/autofill_table.h" | 19 #include "components/autofill/core/browser/webdata/autofill_table.h" |
| 19 #include "components/autofill/core/browser/webdata/autofill_webdata_backend.h" | 20 #include "components/autofill/core/browser/webdata/autofill_webdata_backend.h" |
| 20 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 21 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
| 21 #include "components/sync/model/entity_data.h" | 22 #include "components/sync/model/entity_data.h" |
| 22 #include "components/sync/model/model_type_change_processor.h" | 23 #include "components/sync/model/model_type_change_processor.h" |
| 23 #include "components/sync/model/mutable_data_batch.h" | 24 #include "components/sync/model/mutable_data_batch.h" |
| 24 #include "net/base/escape.h" | 25 #include "net/base/escape.h" |
| 25 | 26 |
| 26 using base::Optional; | 27 using base::Optional; |
| 27 using base::Time; | 28 using base::Time; |
| 29 using base::debug::DumpWithoutCrashing; |
| 28 using sync_pb::AutofillSpecifics; | 30 using sync_pb::AutofillSpecifics; |
| 29 using syncer::EntityChange; | 31 using syncer::EntityChange; |
| 30 using syncer::EntityChangeList; | 32 using syncer::EntityChangeList; |
| 31 using syncer::EntityData; | 33 using syncer::EntityData; |
| 32 using syncer::EntityDataMap; | 34 using syncer::EntityDataMap; |
| 33 using syncer::MetadataChangeList; | 35 using syncer::MetadataChangeList; |
| 34 using syncer::ModelError; | 36 using syncer::ModelError; |
| 35 using syncer::ModelTypeChangeProcessor; | 37 using syncer::ModelTypeChangeProcessor; |
| 36 using syncer::MutableDataBatch; | 38 using syncer::MutableDataBatch; |
| 37 | 39 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 269 |
| 268 } // namespace | 270 } // namespace |
| 269 | 271 |
| 270 // static | 272 // static |
| 271 void AutocompleteSyncBridge::CreateForWebDataServiceAndBackend( | 273 void AutocompleteSyncBridge::CreateForWebDataServiceAndBackend( |
| 272 AutofillWebDataService* web_data_service, | 274 AutofillWebDataService* web_data_service, |
| 273 AutofillWebDataBackend* web_data_backend) { | 275 AutofillWebDataBackend* web_data_backend) { |
| 274 web_data_service->GetDBUserData()->SetUserData( | 276 web_data_service->GetDBUserData()->SetUserData( |
| 275 UserDataKey(), | 277 UserDataKey(), |
| 276 new AutocompleteSyncBridge( | 278 new AutocompleteSyncBridge( |
| 277 web_data_backend, base::Bind(&ModelTypeChangeProcessor::Create))); | 279 web_data_backend, |
| 280 base::BindRepeating( |
| 281 &ModelTypeChangeProcessor::Create, |
| 282 base::BindRepeating(base::IgnoreResult(&DumpWithoutCrashing))))); |
| 278 } | 283 } |
| 279 | 284 |
| 280 // static | 285 // static |
| 281 AutocompleteSyncBridge* AutocompleteSyncBridge::FromWebDataService( | 286 AutocompleteSyncBridge* AutocompleteSyncBridge::FromWebDataService( |
| 282 AutofillWebDataService* web_data_service) { | 287 AutofillWebDataService* web_data_service) { |
| 283 return static_cast<AutocompleteSyncBridge*>( | 288 return static_cast<AutocompleteSyncBridge*>( |
| 284 web_data_service->GetDBUserData()->GetUserData(UserDataKey())); | 289 web_data_service->GetDBUserData()->GetUserData(UserDataKey())); |
| 285 } | 290 } |
| 286 | 291 |
| 287 AutocompleteSyncBridge::AutocompleteSyncBridge( | 292 AutocompleteSyncBridge::AutocompleteSyncBridge( |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 const AutofillChangeList& changes) { | 468 const AutofillChangeList& changes) { |
| 464 DCHECK(thread_checker_.CalledOnValidThread()); | 469 DCHECK(thread_checker_.CalledOnValidThread()); |
| 465 ActOnLocalChanges(changes); | 470 ActOnLocalChanges(changes); |
| 466 } | 471 } |
| 467 | 472 |
| 468 AutofillTable* AutocompleteSyncBridge::GetAutofillTable() const { | 473 AutofillTable* AutocompleteSyncBridge::GetAutofillTable() const { |
| 469 return AutofillTable::FromWebDatabase(web_data_backend_->GetDatabase()); | 474 return AutofillTable::FromWebDatabase(web_data_backend_->GetDatabase()); |
| 470 } | 475 } |
| 471 | 476 |
| 472 } // namespace autofill | 477 } // namespace autofill |
| OLD | NEW |