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

Unified Diff: components/sync/core/model_type_store_impl.h

Issue 2416823003: [Sync] Move some things from core/ to model(_impl)/. (Closed)
Patch Set: Rebase. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: components/sync/core/model_type_store_impl.h
diff --git a/components/sync/core/model_type_store_impl.h b/components/sync/core/model_type_store_impl.h
deleted file mode 100644
index c1b089d41f7273c31652043a6cd0feb99c4b927b..0000000000000000000000000000000000000000
--- a/components/sync/core/model_type_store_impl.h
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef COMPONENTS_SYNC_CORE_MODEL_TYPE_STORE_IMPL_H_
-#define COMPONENTS_SYNC_CORE_MODEL_TYPE_STORE_IMPL_H_
-
-#include <memory>
-#include <string>
-
-#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
-#include "base/threading/non_thread_safe.h"
-#include "components/sync/base/model_type.h"
-#include "components/sync/model/model_type_store.h"
-
-namespace leveldb {
-class WriteBatch;
-} // namespace leveldb
-
-namespace syncer {
-
-class ModelTypeStoreBackend;
-
-// ModelTypeStoreImpl handles details of store initialization, threading and
-// leveldb key formatting. Actual leveldb IO calls are performed by
-// ModelTypeStoreBackend.
-class ModelTypeStoreImpl : public ModelTypeStore, public base::NonThreadSafe {
- public:
- ~ModelTypeStoreImpl() override;
-
- static void CreateStore(
- const ModelType type,
- const std::string& path,
- scoped_refptr<base::SequencedTaskRunner> blocking_task_runner,
- const InitCallback& callback);
- static void CreateInMemoryStoreForTest(const InitCallback& callback);
-
- // ModelTypeStore implementation.
- void ReadData(const IdList& id_list,
- const ReadDataCallback& callback) override;
- void ReadAllData(const ReadAllDataCallback& callback) override;
- void ReadAllMetadata(const ReadMetadataCallback& callback) override;
- std::unique_ptr<WriteBatch> CreateWriteBatch() override;
- void CommitWriteBatch(std::unique_ptr<WriteBatch> write_batch,
- const CallbackWithResult& callback) override;
- void WriteData(WriteBatch* write_batch,
- const std::string& id,
- const std::string& value) override;
- void WriteMetadata(WriteBatch* write_batch,
- const std::string& id,
- const std::string& value) override;
- void WriteGlobalMetadata(WriteBatch* write_batch,
- const std::string& value) override;
- void DeleteData(WriteBatch* write_batch, const std::string& id) override;
- void DeleteMetadata(WriteBatch* write_batch, const std::string& id) override;
- void DeleteGlobalMetadata(WriteBatch* write_batch) override;
-
- private:
- class WriteBatchImpl : public WriteBatch {
- public:
- WriteBatchImpl();
- ~WriteBatchImpl() override;
- std::unique_ptr<leveldb::WriteBatch> leveldb_write_batch_;
- };
-
- static void BackendInitDone(
- const ModelType type,
- std::unique_ptr<Result> result,
- scoped_refptr<base::SequencedTaskRunner> blocking_task_runner,
- const InitCallback& callback,
- scoped_refptr<ModelTypeStoreBackend> backend);
-
- // Format prefix key for data/metadata records with |type|.
- static std::string FormatDataPrefix(const ModelType type);
- static std::string FormatMetaPrefix(const ModelType type);
-
- static leveldb::WriteBatch* GetLeveldbWriteBatch(WriteBatch* write_batch);
-
- // Format key for data/metadata records with given id.
- std::string FormatDataKey(const std::string& id);
- std::string FormatMetadataKey(const std::string& id);
-
- ModelTypeStoreImpl(
- const ModelType type,
- scoped_refptr<ModelTypeStoreBackend> backend,
- scoped_refptr<base::SequencedTaskRunner> backend_task_runner);
-
- // Callbacks for different calls to ModelTypeStoreBackend.
- void ReadDataDone(const ReadDataCallback& callback,
- std::unique_ptr<RecordList> record_list,
- std::unique_ptr<IdList> missing_id_list,
- Result result);
- void ReadAllDataDone(const ReadAllDataCallback& callback,
- std::unique_ptr<RecordList> record_list,
- Result result);
- void ReadMetadataRecordsDone(const ReadMetadataCallback& callback,
- std::unique_ptr<RecordList> metadata_records,
- Result result);
- void ReadAllMetadataDone(const ReadMetadataCallback& callback,
- std::unique_ptr<RecordList> metadata_records,
- std::unique_ptr<RecordList> global_metadata_records,
- std::unique_ptr<IdList> missing_id_list,
- Result result);
- void WriteModificationsDone(const CallbackWithResult& callback,
- Result result);
-
- // Backend should be deleted on backend thread.
- // To accomplish this store's dtor posts task to backend thread passing
- // backend ownership to task parameter.
- scoped_refptr<ModelTypeStoreBackend> backend_;
- scoped_refptr<base::SequencedTaskRunner> backend_task_runner_;
-
- // Key prefix for data/metadata records of this model type.
- const std::string data_prefix_;
- const std::string metadata_prefix_;
-
- base::WeakPtrFactory<ModelTypeStoreImpl> weak_ptr_factory_;
-};
-
-} // namespace syncer
-
-#endif // COMPONENTS_SYNC_CORE_MODEL_TYPE_STORE_IMPL_H_
« no previous file with comments | « components/sync/core/model_type_store_backend_unittest.cc ('k') | components/sync/core/model_type_store_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698