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

Side by Side Diff: components/sync/core/model_type_store_impl.h

Issue 2388673002: Revert of [Sync] Move //components/sync to the syncer namespace. (patchset #5 id:40001 of https://co (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
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_CORE_MODEL_TYPE_STORE_IMPL_H_ 5 #ifndef COMPONENTS_SYNC_CORE_MODEL_TYPE_STORE_IMPL_H_
6 #define COMPONENTS_SYNC_CORE_MODEL_TYPE_STORE_IMPL_H_ 6 #define COMPONENTS_SYNC_CORE_MODEL_TYPE_STORE_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/threading/non_thread_safe.h" 13 #include "base/threading/non_thread_safe.h"
14 #include "components/sync/api/model_type_store.h" 14 #include "components/sync/api/model_type_store.h"
15 #include "components/sync/base/model_type.h" 15 #include "components/sync/base/model_type.h"
16 16
17 namespace leveldb { 17 namespace leveldb {
18 class WriteBatch; 18 class WriteBatch;
19 } // namespace leveldb 19 } // namespace leveldb
20 20
21 namespace syncer { 21 namespace syncer_v2 {
22 22
23 class ModelTypeStoreBackend; 23 class ModelTypeStoreBackend;
24 24
25 // ModelTypeStoreImpl handles details of store initialization, threading and 25 // ModelTypeStoreImpl handles details of store initialization, threading and
26 // leveldb key formatting. Actual leveldb IO calls are performed by 26 // leveldb key formatting. Actual leveldb IO calls are performed by
27 // ModelTypeStoreBackend. 27 // ModelTypeStoreBackend.
28 class ModelTypeStoreImpl : public ModelTypeStore, public base::NonThreadSafe { 28 class ModelTypeStoreImpl : public ModelTypeStore, public base::NonThreadSafe {
29 public: 29 public:
30 ~ModelTypeStoreImpl() override; 30 ~ModelTypeStoreImpl() override;
31 31
32 static void CreateStore( 32 static void CreateStore(
33 const ModelType type, 33 const syncer::ModelType type,
34 const std::string& path, 34 const std::string& path,
35 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, 35 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner,
36 const InitCallback& callback); 36 const InitCallback& callback);
37 static void CreateInMemoryStoreForTest(const InitCallback& callback); 37 static void CreateInMemoryStoreForTest(const InitCallback& callback);
38 38
39 // ModelTypeStore implementation. 39 // ModelTypeStore implementation.
40 void ReadData(const IdList& id_list, 40 void ReadData(const IdList& id_list,
41 const ReadDataCallback& callback) override; 41 const ReadDataCallback& callback) override;
42 void ReadAllData(const ReadAllDataCallback& callback) override; 42 void ReadAllData(const ReadAllDataCallback& callback) override;
43 void ReadAllMetadata(const ReadMetadataCallback& callback) override; 43 void ReadAllMetadata(const ReadMetadataCallback& callback) override;
(...skipping 14 matching lines...) Expand all
58 58
59 private: 59 private:
60 class WriteBatchImpl : public WriteBatch { 60 class WriteBatchImpl : public WriteBatch {
61 public: 61 public:
62 WriteBatchImpl(); 62 WriteBatchImpl();
63 ~WriteBatchImpl() override; 63 ~WriteBatchImpl() override;
64 std::unique_ptr<leveldb::WriteBatch> leveldb_write_batch_; 64 std::unique_ptr<leveldb::WriteBatch> leveldb_write_batch_;
65 }; 65 };
66 66
67 static void BackendInitDone( 67 static void BackendInitDone(
68 const ModelType type, 68 const syncer::ModelType type,
69 std::unique_ptr<Result> result, 69 std::unique_ptr<Result> result,
70 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, 70 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner,
71 const InitCallback& callback, 71 const InitCallback& callback,
72 scoped_refptr<ModelTypeStoreBackend> backend); 72 scoped_refptr<ModelTypeStoreBackend> backend);
73 73
74 // Format prefix key for data/metadata records with |type|. 74 // Format prefix key for data/metadata records with |type|.
75 static std::string FormatDataPrefix(const ModelType type); 75 static std::string FormatDataPrefix(const syncer::ModelType type);
76 static std::string FormatMetaPrefix(const ModelType type); 76 static std::string FormatMetaPrefix(const syncer::ModelType type);
77 77
78 static leveldb::WriteBatch* GetLeveldbWriteBatch(WriteBatch* write_batch); 78 static leveldb::WriteBatch* GetLeveldbWriteBatch(WriteBatch* write_batch);
79 79
80 // Format key for data/metadata records with given id. 80 // Format key for data/metadata records with given id.
81 std::string FormatDataKey(const std::string& id); 81 std::string FormatDataKey(const std::string& id);
82 std::string FormatMetadataKey(const std::string& id); 82 std::string FormatMetadataKey(const std::string& id);
83 83
84 ModelTypeStoreImpl( 84 ModelTypeStoreImpl(
85 const ModelType type, 85 const syncer::ModelType type,
86 scoped_refptr<ModelTypeStoreBackend> backend, 86 scoped_refptr<ModelTypeStoreBackend> backend,
87 scoped_refptr<base::SequencedTaskRunner> backend_task_runner); 87 scoped_refptr<base::SequencedTaskRunner> backend_task_runner);
88 88
89 // Callbacks for different calls to ModelTypeStoreBackend. 89 // Callbacks for different calls to ModelTypeStoreBackend.
90 void ReadDataDone(const ReadDataCallback& callback, 90 void ReadDataDone(const ReadDataCallback& callback,
91 std::unique_ptr<RecordList> record_list, 91 std::unique_ptr<RecordList> record_list,
92 std::unique_ptr<IdList> missing_id_list, 92 std::unique_ptr<IdList> missing_id_list,
93 Result result); 93 Result result);
94 void ReadAllDataDone(const ReadAllDataCallback& callback, 94 void ReadAllDataDone(const ReadAllDataCallback& callback,
95 std::unique_ptr<RecordList> record_list, 95 std::unique_ptr<RecordList> record_list,
(...skipping 15 matching lines...) Expand all
111 scoped_refptr<ModelTypeStoreBackend> backend_; 111 scoped_refptr<ModelTypeStoreBackend> backend_;
112 scoped_refptr<base::SequencedTaskRunner> backend_task_runner_; 112 scoped_refptr<base::SequencedTaskRunner> backend_task_runner_;
113 113
114 // Key prefix for data/metadata records of this model type. 114 // Key prefix for data/metadata records of this model type.
115 const std::string data_prefix_; 115 const std::string data_prefix_;
116 const std::string metadata_prefix_; 116 const std::string metadata_prefix_;
117 117
118 base::WeakPtrFactory<ModelTypeStoreImpl> weak_ptr_factory_; 118 base::WeakPtrFactory<ModelTypeStoreImpl> weak_ptr_factory_;
119 }; 119 };
120 120
121 } // namespace syncer 121 } // namespace syncer_v2
122 122
123 #endif // COMPONENTS_SYNC_CORE_MODEL_TYPE_STORE_IMPL_H_ 123 #endif // COMPONENTS_SYNC_CORE_MODEL_TYPE_STORE_IMPL_H_
OLDNEW
« 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