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" | |
15 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
16 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
17 #include "components/autofill/core/browser/proto/autofill_sync.pb.h" | 16 #include "components/autofill/core/browser/proto/autofill_sync.pb.h" |
18 #include "components/autofill/core/browser/webdata/autofill_metadata_change_list .h" | 17 #include "components/autofill/core/browser/webdata/autofill_metadata_change_list .h" |
19 #include "components/autofill/core/browser/webdata/autofill_table.h" | 18 #include "components/autofill/core/browser/webdata/autofill_table.h" |
20 #include "components/autofill/core/browser/webdata/autofill_webdata_backend.h" | 19 #include "components/autofill/core/browser/webdata/autofill_webdata_backend.h" |
21 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 20 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
21 #include "components/sync/base/report_unrecoverable_error.h" | |
22 #include "components/sync/model/entity_data.h" | 22 #include "components/sync/model/entity_data.h" |
23 #include "components/sync/model/model_type_change_processor.h" | 23 #include "components/sync/model/model_type_change_processor.h" |
24 #include "components/sync/model/mutable_data_batch.h" | 24 #include "components/sync/model/mutable_data_batch.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; | |
30 using sync_pb::AutofillSpecifics; | 29 using sync_pb::AutofillSpecifics; |
31 using syncer::EntityChange; | 30 using syncer::EntityChange; |
32 using syncer::EntityChangeList; | 31 using syncer::EntityChangeList; |
33 using syncer::EntityData; | 32 using syncer::EntityData; |
34 using syncer::EntityDataMap; | 33 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::MutableDataBatch; | 37 using syncer::MutableDataBatch; |
38 using syncer::ReportUnrecoverableError; | |
39 | 39 |
40 namespace autofill { | 40 namespace autofill { |
41 | 41 |
42 namespace { | 42 namespace { |
43 | 43 |
44 const char kAutocompleteEntryNamespaceTag[] = "autofill_entry|"; | 44 const char kAutocompleteEntryNamespaceTag[] = "autofill_entry|"; |
45 const char kAutocompleteTagDelimiter[] = "|"; | 45 const char kAutocompleteTagDelimiter[] = "|"; |
46 | 46 |
47 // Simplify checking for optional errors and returning only when present. | 47 // Simplify checking for optional errors and returning only when present. |
48 #define RETURN_IF_ERROR(x) \ | 48 #define RETURN_IF_ERROR(x) \ |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 std::vector<AutofillEntry> save_to_sync_; | 265 std::vector<AutofillEntry> save_to_sync_; |
266 | 266 |
267 DISALLOW_COPY_AND_ASSIGN(SyncDifferenceTracker); | 267 DISALLOW_COPY_AND_ASSIGN(SyncDifferenceTracker); |
268 }; | 268 }; |
269 | 269 |
270 } // namespace | 270 } // namespace |
271 | 271 |
272 // static | 272 // static |
273 void AutocompleteSyncBridge::CreateForWebDataServiceAndBackend( | 273 void AutocompleteSyncBridge::CreateForWebDataServiceAndBackend( |
274 AutofillWebDataService* web_data_service, | 274 AutofillWebDataService* web_data_service, |
275 AutofillWebDataBackend* web_data_backend) { | 275 AutofillWebDataBackend* web_data_backend, |
276 version_info::Channel channel) { | |
276 web_data_service->GetDBUserData()->SetUserData( | 277 web_data_service->GetDBUserData()->SetUserData( |
277 UserDataKey(), | 278 UserDataKey(), |
278 new AutocompleteSyncBridge( | 279 new AutocompleteSyncBridge( |
279 web_data_backend, | 280 web_data_backend, |
280 base::BindRepeating( | 281 base::BindRepeating( |
281 &ModelTypeChangeProcessor::Create, | 282 &ModelTypeChangeProcessor::Create, |
282 base::BindRepeating(base::IgnoreResult(&DumpWithoutCrashing))))); | 283 base::BindRepeating(&ReportUnrecoverableError, channel)))); |
skym
2017/01/24 20:49:43
Can you create two functions in components/sync/ba
| |
283 } | 284 } |
284 | 285 |
285 // static | 286 // static |
286 AutocompleteSyncBridge* AutocompleteSyncBridge::FromWebDataService( | 287 AutocompleteSyncBridge* AutocompleteSyncBridge::FromWebDataService( |
287 AutofillWebDataService* web_data_service) { | 288 AutofillWebDataService* web_data_service) { |
288 return static_cast<AutocompleteSyncBridge*>( | 289 return static_cast<AutocompleteSyncBridge*>( |
289 web_data_service->GetDBUserData()->GetUserData(UserDataKey())); | 290 web_data_service->GetDBUserData()->GetUserData(UserDataKey())); |
290 } | 291 } |
291 | 292 |
292 AutocompleteSyncBridge::AutocompleteSyncBridge( | 293 AutocompleteSyncBridge::AutocompleteSyncBridge( |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
468 const AutofillChangeList& changes) { | 469 const AutofillChangeList& changes) { |
469 DCHECK(thread_checker_.CalledOnValidThread()); | 470 DCHECK(thread_checker_.CalledOnValidThread()); |
470 ActOnLocalChanges(changes); | 471 ActOnLocalChanges(changes); |
471 } | 472 } |
472 | 473 |
473 AutofillTable* AutocompleteSyncBridge::GetAutofillTable() const { | 474 AutofillTable* AutocompleteSyncBridge::GetAutofillTable() const { |
474 return AutofillTable::FromWebDatabase(web_data_backend_->GetDatabase()); | 475 return AutofillTable::FromWebDatabase(web_data_backend_->GetDatabase()); |
475 } | 476 } |
476 | 477 |
477 } // namespace autofill | 478 } // namespace autofill |
OLD | NEW |