OLD | NEW |
---|---|
(Empty) | |
1 // 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.
| |
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 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.
| |
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 |model_type| and fill |metadata_batch| | |
30 // with it. | |
31 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
| |
32 syncer::MetadataBatch* metadata_batch); | |
33 | |
34 // Update the metadata row for |model_type|, keyed by |storage_key|, to | |
35 // contain the contents of |metadata|. | |
36 bool UpdateSyncMetadata(syncer::ModelType model_type, | |
37 const std::string& storage_key, | |
38 const sync_pb::EntityMetadata& metadata); | |
39 | |
40 // Remove the metadata row of type |model_type| keyed by |storage_key|. | |
41 bool ClearSyncMetadata(syncer::ModelType model_type, | |
42 const std::string& storage_key); | |
43 | |
44 // Update the stored sync state for the |model_type|. | |
45 bool UpdateModelTypeState(syncer::ModelType model_type, | |
46 const sync_pb::ModelTypeState& model_type_state); | |
47 | |
48 // Clear the stored sync state for |model_type|. | |
49 bool ClearModelTypeState(syncer::ModelType model_type); | |
50 | |
51 protected: | |
52 // Returns the database for the functions in this interface. | |
53 virtual sql::Connection& GetDB() = 0; | |
54 | |
55 // Called by the derived classes on initialization to make sure the tables | |
56 // and indices are properly set up. Must be called before anything else. | |
57 bool InitSyncTable(); | |
58 | |
59 private: | |
60 // Ensures typed_url_sync_metadata table exists. | |
61 bool InitTypedURLSyncMetadataTable(); | |
62 | |
63 // Ensures typed_url_model_type_state table exists. | |
64 bool InitModelTypeStateTable(); | |
65 | |
66 // Read all sync_pb::EntityMetadata for |model_type| and fill | |
67 // |metadata_records| with it. | |
68 bool GetAllSyncEntityMetadata(syncer::ModelType model_type, | |
69 syncer::EntityMetadataMap* metadata_records); | |
70 | |
71 // Read sync_pb::ModelTypeState for |model_type| and fill |state| with it. | |
72 bool GetModelTypeState(syncer::ModelType model_type, | |
73 sync_pb::ModelTypeState* state); | |
74 | |
75 DISALLOW_COPY_AND_ASSIGN(TypedURLSyncMetadataDatabase); | |
76 }; | |
77 | |
78 } // namespace history | |
79 | |
80 #endif // COMPONENTS_HISTORY_CORE_BROWSER_TYPED_URL_SYNC_METADATA_DATABASE_H_ | |
OLD | NEW |