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