Chromium Code Reviews| Index: components/history/core/browser/typed_url_sync_bridge.h |
| diff --git a/components/history/core/browser/typed_url_sync_bridge.h b/components/history/core/browser/typed_url_sync_bridge.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c3e362b082152bf85fc8a1b8ba82c316ac4759a1 |
| --- /dev/null |
| +++ b/components/history/core/browser/typed_url_sync_bridge.h |
| @@ -0,0 +1,68 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_HISTORY_CORE_BROWSER_TYPED_URL_SYNC_BRIDGE_H_ |
| +#define COMPONENTS_HISTORY_CORE_BROWSER_TYPED_URL_SYNC_BRIDGE_H_ |
| + |
| +#include "components/history/core/browser/history_backend_observer.h" |
| +#include "components/sync/model/metadata_change_list.h" |
| +#include "components/sync/model/model_type_sync_bridge.h" |
| +#include "components/sync/model/sync_error.h" |
| + |
| +namespace history { |
| + |
| +class TypedURLSyncBridge : public syncer::ModelTypeSyncBridge, |
| + public history::HistoryBackendObserver { |
| + public: |
| + TypedURLSyncBridge(HistoryBackend* history_backend, |
| + const ChangeProcessorFactory& change_processor_factory); |
| + ~TypedURLSyncBridge() override; |
| + |
| + // syncer::ModelTypeService implementation. |
| + std::unique_ptr<syncer::MetadataChangeList> CreateMetadataChangeList() |
| + override; |
| + base::Optional<syncer::ModelError> MergeSyncData( |
| + std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, |
| + syncer::EntityDataMap entity_data_map) override; |
| + base::Optional<syncer::ModelError> ApplySyncChanges( |
| + std::unique_ptr<syncer::MetadataChangeList> metadata_change_list, |
| + syncer::EntityChangeList entity_changes) override; |
| + void GetData(StorageKeyList storage_keys, DataCallback callback) override; |
| + void GetAllData(DataCallback callback) override; |
| + // Generate a tag that uniquely identifies |entity_data| across all data |
| + // types. This is used to identify the entity on the server. The format, which |
| + // must remain the same for server compatibility, is: |
| + // "autofill_entry|$name|$value" where $name and $value are escaped. |
|
skym
2017/03/03 17:41:09
This is an autocomplete comment, and is not applic
Gang Wu
2017/03/06 08:21:24
Done.
|
| + std::string GetClientTag(const syncer::EntityData& entity_data) override; |
| + // Generate a string key uniquely identifying |entity_data| in the context of |
| + // local storage. The format, which should stay the same, is $name|$value" |
| + // where $name and $value are escaped. |
|
skym
2017/03/03 17:41:09
Same
Gang Wu
2017/03/06 08:21:24
Done.
|
| + std::string GetStorageKey(const syncer::EntityData& entity_data) override; |
| + |
| + // history::HistoryBackendObserver: |
| + void OnURLVisited(history::HistoryBackend* history_backend, |
| + ui::PageTransition transition, |
| + const history::URLRow& row, |
| + const history::RedirectList& redirects, |
| + base::Time visit_time) override; |
| + void OnURLsModified(history::HistoryBackend* history_backend, |
| + const history::URLRows& changed_urls) override; |
| + void OnURLsDeleted(history::HistoryBackend* history_backend, |
| + bool all_history, |
| + bool expired, |
| + const history::URLRows& deleted_rows, |
| + const std::set<GURL>& favicon_urls) override; |
| + |
| + private: |
| + // The backend we're syncing local changes from and sync changes to. |
| + HistoryBackend* const history_backend_; |
| + |
| + base::SequenceChecker sequence_checker_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TypedURLSyncBridge); |
| +}; |
| + |
| +} // namespace history |
| + |
| +#endif // COMPONENTS_HISTORY_CORE_BROWSER_TYPED_URL_SYNC_BRIDGE_H_ |