| 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 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOCOMPLETE_SYNC_BRIDGE_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOCOMPLETE_SYNC_BRIDGE_H_ |
| 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOCOMPLETE_SYNC_BRIDGE_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOCOMPLETE_SYNC_BRIDGE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/scoped_observer.h" | 11 #include "base/scoped_observer.h" |
| 12 #include "base/supports_user_data.h" | 12 #include "base/supports_user_data.h" |
| 13 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
| 14 #include "components/autofill/core/browser/webdata/autofill_change.h" | 14 #include "components/autofill/core/browser/webdata/autofill_change.h" |
| 15 #include "components/autofill/core/browser/webdata/autofill_webdata_service_obse
rver.h" | 15 #include "components/autofill/core/browser/webdata/autofill_webdata_service_obse
rver.h" |
| 16 #include "components/sync/model/metadata_change_list.h" | 16 #include "components/sync/model/metadata_change_list.h" |
| 17 #include "components/sync/model/model_error.h" |
| 17 #include "components/sync/model/model_type_sync_bridge.h" | 18 #include "components/sync/model/model_type_sync_bridge.h" |
| 18 | 19 |
| 19 namespace syncer { | |
| 20 class SyncError; | |
| 21 } | |
| 22 | |
| 23 namespace autofill { | 20 namespace autofill { |
| 24 | 21 |
| 25 class AutofillTable; | 22 class AutofillTable; |
| 26 class AutofillWebDataBackend; | 23 class AutofillWebDataBackend; |
| 27 class AutofillWebDataService; | 24 class AutofillWebDataService; |
| 28 | 25 |
| 29 class AutocompleteSyncBridge : public base::SupportsUserData::Data, | 26 class AutocompleteSyncBridge : public base::SupportsUserData::Data, |
| 30 public syncer::ModelTypeSyncBridge, | 27 public syncer::ModelTypeSyncBridge, |
| 31 public AutofillWebDataServiceObserverOnDBThread { | 28 public AutofillWebDataServiceObserverOnDBThread { |
| 32 public: | 29 public: |
| 33 AutocompleteSyncBridge(); | 30 AutocompleteSyncBridge(); |
| 34 AutocompleteSyncBridge( | 31 AutocompleteSyncBridge( |
| 35 AutofillWebDataBackend* backend, | 32 AutofillWebDataBackend* backend, |
| 36 const ChangeProcessorFactory& change_processor_factory); | 33 const ChangeProcessorFactory& change_processor_factory); |
| 37 ~AutocompleteSyncBridge() override; | 34 ~AutocompleteSyncBridge() override; |
| 38 | 35 |
| 39 static void CreateForWebDataServiceAndBackend( | 36 static void CreateForWebDataServiceAndBackend( |
| 40 AutofillWebDataService* web_data_service, | 37 AutofillWebDataService* web_data_service, |
| 41 AutofillWebDataBackend* web_data_backend); | 38 AutofillWebDataBackend* web_data_backend); |
| 42 | 39 |
| 43 static AutocompleteSyncBridge* FromWebDataService( | 40 static AutocompleteSyncBridge* FromWebDataService( |
| 44 AutofillWebDataService* web_data_service); | 41 AutofillWebDataService* web_data_service); |
| 45 | 42 |
| 46 // syncer::ModelTypeService implementation. | 43 // syncer::ModelTypeService implementation. |
| 47 std::unique_ptr<syncer::MetadataChangeList> CreateMetadataChangeList() | 44 std::unique_ptr<syncer::MetadataChangeList> CreateMetadataChangeList() |
| 48 override; | 45 override; |
| 49 syncer::SyncError MergeSyncData( | 46 syncer::ModelError MergeSyncData( |
| 50 std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, | 47 std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, |
| 51 syncer::EntityDataMap entity_data_map) override; | 48 syncer::EntityDataMap entity_data_map) override; |
| 52 syncer::SyncError ApplySyncChanges( | 49 syncer::ModelError ApplySyncChanges( |
| 53 std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, | 50 std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, |
| 54 syncer::EntityChangeList entity_changes) override; | 51 syncer::EntityChangeList entity_changes) override; |
| 55 void GetData(StorageKeyList storage_keys, DataCallback callback) override; | 52 void GetData(StorageKeyList storage_keys, DataCallback callback) override; |
| 56 void GetAllData(DataCallback callback) override; | 53 void GetAllData(DataCallback callback) override; |
| 57 // Generate a tag that uniquely identifies |entity_data| across all data | 54 // Generate a tag that uniquely identifies |entity_data| across all data |
| 58 // types. This is used to identify the entity on the server. The format, which | 55 // types. This is used to identify the entity on the server. The format, which |
| 59 // must remain the same for server compatibility, is: | 56 // must remain the same for server compatibility, is: |
| 60 // "autofill_entry|$name|$value" where $name and $value are escaped. | 57 // "autofill_entry|$name|$value" where $name and $value are escaped. |
| 61 std::string GetClientTag(const syncer::EntityData& entity_data) override; | 58 std::string GetClientTag(const syncer::EntityData& entity_data) override; |
| 62 // Generate a string key uniquely identifying |entity_data| in the context of | 59 // Generate a string key uniquely identifying |entity_data| in the context of |
| (...skipping 23 matching lines...) Expand all Loading... |
| 86 // SupportsUserData, so it's guaranteed to outlive |this|. | 83 // SupportsUserData, so it's guaranteed to outlive |this|. |
| 87 AutofillWebDataBackend* const web_data_backend_; | 84 AutofillWebDataBackend* const web_data_backend_; |
| 88 | 85 |
| 89 ScopedObserver<AutofillWebDataBackend, AutocompleteSyncBridge> | 86 ScopedObserver<AutofillWebDataBackend, AutocompleteSyncBridge> |
| 90 scoped_observer_; | 87 scoped_observer_; |
| 91 }; | 88 }; |
| 92 | 89 |
| 93 } // namespace autofill | 90 } // namespace autofill |
| 94 | 91 |
| 95 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOCOMPLETE_SYNC_BRIDGE_H_ | 92 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOCOMPLETE_SYNC_BRIDGE_H_ |
| OLD | NEW |