Index: components/history/core/browser/typed_url_sync_metadata_database.h |
diff --git a/components/history/core/browser/typed_url_sync_metadata_database.h b/components/history/core/browser/typed_url_sync_metadata_database.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6113833e1bd56bc51b2d7e7b61bcddaff9b93ff4 |
--- /dev/null |
+++ b/components/history/core/browser/typed_url_sync_metadata_database.h |
@@ -0,0 +1,80 @@ |
+// Copyright (c) 2017 The Chromium Authors. All rights reserved. |
sky
2017/03/01 04:15:24
no (c)
Gang Wu
2017/03/02 05:41:12
Done.
|
+// 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_METADATA_DATABASE_H_ |
+#define COMPONENTS_HISTORY_CORE_BROWSER_TYPED_URL_SYNC_METADATA_DATABASE_H_ |
+ |
+#include "base/macros.h" |
+#include "components/sync/base/model_type.h" |
+#include "components/sync/model/metadata_batch.h" |
+ |
+namespace sql { |
+class Connection; |
+} |
+ |
+namespace history { |
+ |
+// A sync metadata database needs to maintain two tables: entity metadata table |
+// and datatype state table. Entity metadata table contains metadata(sync |
+// states) for each urls. Datatype state table contains the state of typed url |
sky
2017/03/01 04:15:24
urls->url
Gang Wu
2017/03/02 05:41:12
Done.
|
+// datatype. |
+class TypedURLSyncMetadataDatabase { |
+ public: |
+ // Must call InitVisitTable() before using to make sure the database is |
+ // initialized. |
+ TypedURLSyncMetadataDatabase(); |
+ virtual ~TypedURLSyncMetadataDatabase(); |
+ |
+ // Read all the stored metadata for |model_type| and fill |metadata_batch| |
+ // with it. |
+ bool GetAllSyncMetadata(syncer::ModelType model_type, |
sky
2017/03/01 04:15:24
Why does this need to take a model_type? Same comm
Gang Wu
2017/03/02 05:41:12
I was thinking about merge with AutofillTable's Ge
|
+ syncer::MetadataBatch* metadata_batch); |
+ |
+ // Update the metadata row for |model_type|, keyed by |storage_key|, to |
+ // contain the contents of |metadata|. |
+ bool UpdateSyncMetadata(syncer::ModelType model_type, |
+ const std::string& storage_key, |
+ const sync_pb::EntityMetadata& metadata); |
+ |
+ // Remove the metadata row of type |model_type| keyed by |storage_key|. |
+ bool ClearSyncMetadata(syncer::ModelType model_type, |
+ const std::string& storage_key); |
+ |
+ // Update the stored sync state for the |model_type|. |
+ bool UpdateModelTypeState(syncer::ModelType model_type, |
+ const sync_pb::ModelTypeState& model_type_state); |
+ |
+ // Clear the stored sync state for |model_type|. |
+ bool ClearModelTypeState(syncer::ModelType model_type); |
+ |
+ protected: |
+ // Returns the database for the functions in this interface. |
+ virtual sql::Connection& GetDB() = 0; |
+ |
+ // Called by the derived classes on initialization to make sure the tables |
+ // and indices are properly set up. Must be called before anything else. |
+ bool InitSyncTable(); |
+ |
+ private: |
+ // Ensures typed_url_sync_metadata table exists. |
+ bool InitTypedURLSyncMetadataTable(); |
+ |
+ // Ensures typed_url_model_type_state table exists. |
+ bool InitModelTypeStateTable(); |
+ |
+ // Read all sync_pb::EntityMetadata for |model_type| and fill |
+ // |metadata_records| with it. |
+ bool GetAllSyncEntityMetadata(syncer::ModelType model_type, |
+ syncer::EntityMetadataMap* metadata_records); |
+ |
+ // Read sync_pb::ModelTypeState for |model_type| and fill |state| with it. |
+ bool GetModelTypeState(syncer::ModelType model_type, |
+ sync_pb::ModelTypeState* state); |
+ |
+ DISALLOW_COPY_AND_ASSIGN(TypedURLSyncMetadataDatabase); |
+}; |
+ |
+} // namespace history |
+ |
+#endif // COMPONENTS_HISTORY_CORE_BROWSER_TYPED_URL_SYNC_METADATA_DATABASE_H_ |