Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: components/history/core/browser/typed_url_sync_metadata_database.h

Issue 2721713002: [sync] Add typed url sync metadata to the history db (Closed)
Patch Set: brettw review Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_TYPED_URL_SYNC_METADATA_DATABASE_H_
6 #define COMPONENTS_HISTORY_CORE_BROWSER_TYPED_URL_SYNC_METADATA_DATABASE_H_
7
8 #include "base/macros.h"
9 #include "components/sync/base/model_type.h"
10 #include "components/sync/model/metadata_batch.h"
11
12 namespace sql {
13 class Connection;
14 }
15
16 namespace history {
17
18 // A sync metadata database needs to maintain two tables: entity metadata table
19 // and datatype state table. Entity metadata table contains metadata(sync
20 // states) for each url. Datatype state table contains the state of typed url
21 // datatype.
22 class TypedURLSyncMetadataDatabase {
23 public:
24 // Must call InitVisitTable() before using to make sure the database is
25 // initialized.
26 TypedURLSyncMetadataDatabase();
27 virtual ~TypedURLSyncMetadataDatabase();
28
29 // Read all the stored metadata for typed URL and fill |metadata_batch|
30 // with it.
31 bool GetAllSyncMetadata(syncer::MetadataBatch* metadata_batch);
32
33 // Update the metadata row for typed URL, keyed by |storage_key|, to
34 // contain the contents of |metadata|.
35 bool UpdateSyncMetadata(const std::string& storage_key,
36 const sync_pb::EntityMetadata& metadata);
37
38 // Remove the metadata row of typed URL keyed by |storage_key|.
39 bool ClearSyncMetadata(const std::string& storage_key);
40
41 // Update the stored sync state for the typed URL.
42 bool UpdateModelTypeState(const sync_pb::ModelTypeState& model_type_state);
43
44 // Clear the stored sync state for typed URL.
45 bool ClearModelTypeState();
46
47 protected:
48 // Returns the database for the functions in this interface.
49 virtual sql::Connection& GetDB() = 0;
50
51 // Called by the derived classes on initialization to make sure the tables
52 // and indices are properly set up. Must be called before anything else.
53 bool InitSyncTable();
54
55 private:
56 // Ensures typed_url_sync_metadata table exists.
57 bool InitTypedURLSyncMetadataTable();
58
59 // Ensures typed_url_model_type_state table exists.
60 bool InitModelTypeStateTable();
61
62 // Read all sync_pb::EntityMetadata for typed URL and fill
63 // |metadata_records| with it.
64 bool GetAllSyncEntityMetadata(syncer::EntityMetadataMap* metadata_records);
65
66 // Read sync_pb::ModelTypeState for typed URL and fill |state| with it.
67 bool GetModelTypeState(sync_pb::ModelTypeState* state);
68
69 DISALLOW_COPY_AND_ASSIGN(TypedURLSyncMetadataDatabase);
70 };
71
72 } // namespace history
73
74 #endif // COMPONENTS_HISTORY_CORE_BROWSER_TYPED_URL_SYNC_METADATA_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698