OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_SYNC_API_MODEL_TYPE_STORE_H_ | 5 #ifndef COMPONENTS_SYNC_API_MODEL_TYPE_STORE_H_ |
6 #define COMPONENTS_SYNC_API_MODEL_TYPE_STORE_H_ | 6 #define COMPONENTS_SYNC_API_MODEL_TYPE_STORE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "components/sync/base/model_type.h" | 14 #include "components/sync/base/model_type.h" |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 class SequencedTaskRunner; | 17 class SequencedTaskRunner; |
18 } // namespace base | 18 } // namespace base |
19 | 19 |
20 namespace syncer_v2 { | 20 namespace syncer { |
21 | 21 |
22 // ModelTypeStore is leveldb backed store for model type's data, metadata and | 22 // ModelTypeStore is leveldb backed store for model type's data, metadata and |
23 // global metadata. | 23 // global metadata. |
24 // | 24 // |
25 // Store keeps records for entries identified by ids. For each entry store keeps | 25 // Store keeps records for entries identified by ids. For each entry store keeps |
26 // data and metadata. Also store keeps one record for global metadata. | 26 // data and metadata. Also store keeps one record for global metadata. |
27 // | 27 // |
28 // To create store call one of Create*Store static factory functions. Model type | 28 // To create store call one of Create*Store static factory functions. Model type |
29 // controls store's lifetime with returned unique_ptr. Call to Create*Store | 29 // controls store's lifetime with returned unique_ptr. Call to Create*Store |
30 // function triggers asynchronous store backend initialization, callback will be | 30 // function triggers asynchronous store backend initialization, callback will be |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // | 96 // |
97 // base::SequencedWorkerPool* worker_pool = | 97 // base::SequencedWorkerPool* worker_pool = |
98 // content::BrowserThread::GetBlockingPool(); | 98 // content::BrowserThread::GetBlockingPool(); |
99 // scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( | 99 // scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( |
100 // worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( | 100 // worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( |
101 // worker_pool->GetSequenceToken(), | 101 // worker_pool->GetSequenceToken(), |
102 // base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 102 // base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
103 // | 103 // |
104 // In test get task runner from MessageLoop::task_runner(). | 104 // In test get task runner from MessageLoop::task_runner(). |
105 static void CreateStore( | 105 static void CreateStore( |
106 const syncer::ModelType type, | 106 const ModelType type, |
107 const std::string& path, | 107 const std::string& path, |
108 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, | 108 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, |
109 const InitCallback& callback); | 109 const InitCallback& callback); |
110 // Creates store object backed by in-memory leveldb database. It is used in | 110 // Creates store object backed by in-memory leveldb database. It is used in |
111 // tests. | 111 // tests. |
112 static void CreateInMemoryStoreForTest(const InitCallback& callback); | 112 static void CreateInMemoryStoreForTest(const InitCallback& callback); |
113 | 113 |
114 virtual ~ModelTypeStore(); | 114 virtual ~ModelTypeStore(); |
115 | 115 |
116 // Read operations return records either for all entries or only for ones | 116 // Read operations return records either for all entries or only for ones |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 virtual void DeleteData(WriteBatch* write_batch, const std::string& id) = 0; | 149 virtual void DeleteData(WriteBatch* write_batch, const std::string& id) = 0; |
150 virtual void DeleteMetadata(WriteBatch* write_batch, | 150 virtual void DeleteMetadata(WriteBatch* write_batch, |
151 const std::string& id) = 0; | 151 const std::string& id) = 0; |
152 virtual void DeleteGlobalMetadata(WriteBatch* write_batch) = 0; | 152 virtual void DeleteGlobalMetadata(WriteBatch* write_batch) = 0; |
153 // TODO(pavely): Consider implementing DeleteAllMetadata with following | 153 // TODO(pavely): Consider implementing DeleteAllMetadata with following |
154 // signature: | 154 // signature: |
155 // virtual void DeleteAllMetadata(const CallbackWithResult& callback) = 0. | 155 // virtual void DeleteAllMetadata(const CallbackWithResult& callback) = 0. |
156 // It will delete all metadata records and global metadata record. | 156 // It will delete all metadata records and global metadata record. |
157 }; | 157 }; |
158 | 158 |
159 } // namespace syncer_v2 | 159 } // namespace syncer |
160 | 160 |
161 #endif // COMPONENTS_SYNC_API_MODEL_TYPE_STORE_H_ | 161 #endif // COMPONENTS_SYNC_API_MODEL_TYPE_STORE_H_ |
OLD | NEW |