diff options
author | pavely <pavely@chromium.org> | 2015-12-04 12:45:17 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-04 20:45:58 +0000 |
commit | d83166cef0b31328dead989eeee268e407f14b0f (patch) | |
tree | 9716027fa1d5eee82c013f95bcd25a96bc979c9b /sync/api | |
parent | 67b148846af4f57eb9e68a103bee001d809db60a (diff) | |
download | chromium_src-d83166cef0b31328dead989eeee268e407f14b0f.zip chromium_src-d83166cef0b31328dead989eeee268e407f14b0f.tar.gz chromium_src-d83166cef0b31328dead989eeee268e407f14b0f.tar.bz2 |
[Sync] Implement support for on-disk ModelTypeStore
The change is to pass nullptr environment to ModelTypeStoreImpl. This
causes leveldb to use default file backed environment. Service code that
creates store needs to pass task runner. Comment explains where to get
one. In the future store will be shared between model types, at that
point initialization pattern will change.
BUG=517663
R=stanisc@chromium.org, skym@chromium.org
Review URL: https://codereview.chromium.org/1494333002
Cr-Commit-Position: refs/heads/master@{#363286}
Diffstat (limited to 'sync/api')
-rw-r--r-- | sync/api/model_type_store.cc | 8 | ||||
-rw-r--r-- | sync/api/model_type_store.h | 19 |
2 files changed, 27 insertions, 0 deletions
diff --git a/sync/api/model_type_store.cc b/sync/api/model_type_store.cc index 72af046..17afffc 100644 --- a/sync/api/model_type_store.cc +++ b/sync/api/model_type_store.cc @@ -13,6 +13,14 @@ void ModelTypeStore::CreateInMemoryStoreForTest(const InitCallback& callback) { ModelTypeStoreImpl::CreateInMemoryStoreForTest(callback); } +// static +void ModelTypeStore::CreateStore( + const std::string& path, + scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, + const InitCallback& callback) { + ModelTypeStoreImpl::CreateStore(path, blocking_task_runner, callback); +} + ModelTypeStore::~ModelTypeStore() {} ModelTypeStore::WriteBatch::WriteBatch() {} diff --git a/sync/api/model_type_store.h b/sync/api/model_type_store.h index c37eddd..51ddca6 100644 --- a/sync/api/model_type_store.h +++ b/sync/api/model_type_store.h @@ -12,6 +12,10 @@ #include "base/macros.h" #include "sync/base/sync_export.h" +namespace base { +class SequencedTaskRunner; +} // namespace base + namespace syncer_v2 { // ModelTypeStore is leveldb backed store for model type's data, metadata and @@ -85,6 +89,21 @@ class SYNC_EXPORT ModelTypeStore { const std::string& global_metadata)> ReadMetadataCallback; + // CreateStore takes |path| and |blocking_task_runner|. Here is how to get + // task runner in production code: + // + // base::SequencedWorkerPool* worker_pool = + // content::BrowserThread::GetBlockingPool(); + // scoped_refptr<base::SequencedTaskRunner> blocking_task_runner( + // worker_pool->GetSequencedTaskRunnerWithShutdownBehavior( + // worker_pool->GetSequenceToken(), + // base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); + // + // In test get task runner from MessageLoop::task_runner(). + static void CreateStore( + const std::string& path, + scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, + const InitCallback& callback); // Creates store object backed by in-memory leveldb database. It is used in // tests. static void CreateInMemoryStoreForTest(const InitCallback& callback); |