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

Side by Side Diff: sync/api/mock_model_type_store.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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
« no previous file with comments | « sync/api/mock_model_type_store.h ('k') | sync/api/model_type_change_processor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "sync/api/mock_model_type_store.h"
6
7 #include <utility>
8
9 #include "base/bind.h"
10 #include "base/location.h"
11 #include "base/logging.h"
12 #include "base/memory/ptr_util.h"
13 #include "base/single_thread_task_runner.h"
14 #include "base/threading/thread_task_runner_handle.h"
15
16 namespace syncer_v2 {
17
18 MockModelTypeStore::MockModelTypeStore() {}
19
20 MockModelTypeStore::~MockModelTypeStore() {}
21
22 void MockModelTypeStore::ReadData(const IdList& id_list,
23 const ReadDataCallback& callback) {
24 if (!read_data_handler_.is_null()) {
25 read_data_handler_.Run(id_list, callback);
26 } else {
27 base::ThreadTaskRunnerHandle::Get()->PostTask(
28 FROM_HERE, base::Bind(callback, Result::SUCCESS,
29 base::Passed(std::unique_ptr<RecordList>()),
30 base::Passed(std::unique_ptr<IdList>())));
31 }
32 }
33
34 void MockModelTypeStore::ReadAllData(const ReadAllDataCallback& callback) {
35 if (!read_all_data_handler_.is_null()) {
36 read_all_data_handler_.Run(callback);
37 } else {
38 base::ThreadTaskRunnerHandle::Get()->PostTask(
39 FROM_HERE, base::Bind(callback, Result::SUCCESS,
40 base::Passed(std::unique_ptr<RecordList>())));
41 }
42 }
43
44 void MockModelTypeStore::ReadAllMetadata(const ReadMetadataCallback& callback) {
45 if (!read_all_metadata_handler_.is_null()) {
46 read_all_metadata_handler_.Run(callback);
47 } else {
48 base::ThreadTaskRunnerHandle::Get()->PostTask(
49 FROM_HERE,
50 base::Bind(callback, Result::SUCCESS,
51 base::Passed(std::unique_ptr<RecordList>()), std::string()));
52 }
53 }
54
55 std::unique_ptr<MockModelTypeStore::WriteBatch>
56 MockModelTypeStore::CreateWriteBatch() {
57 return base::WrapUnique(new MockModelTypeStore::WriteBatch());
58 }
59
60 void MockModelTypeStore::CommitWriteBatch(
61 std::unique_ptr<WriteBatch> write_batch,
62 const CallbackWithResult& callback) {
63 if (!commit_write_batch_handler_.is_null()) {
64 commit_write_batch_handler_.Run(std::move(write_batch), callback);
65 } else {
66 base::ThreadTaskRunnerHandle::Get()->PostTask(
67 FROM_HERE, base::Bind(callback, Result::SUCCESS));
68 }
69 }
70
71 void MockModelTypeStore::WriteData(WriteBatch* write_batch,
72 const std::string& id,
73 const std::string& value) {
74 if (!write_data_handler_.is_null()) {
75 write_data_handler_.Run(write_batch, id, value);
76 }
77 }
78
79 void MockModelTypeStore::WriteMetadata(WriteBatch* write_batch,
80 const std::string& id,
81 const std::string& value) {
82 if (!write_metadata_handler_.is_null()) {
83 write_metadata_handler_.Run(write_batch, id, value);
84 }
85 }
86
87 void MockModelTypeStore::WriteGlobalMetadata(WriteBatch* write_batch,
88 const std::string& value) {
89 if (!write_global_metadata_handler_.is_null()) {
90 write_global_metadata_handler_.Run(write_batch, value);
91 }
92 }
93
94 void MockModelTypeStore::DeleteData(WriteBatch* write_batch,
95 const std::string& id) {
96 if (!delete_data_handler_.is_null()) {
97 delete_data_handler_.Run(write_batch, id);
98 }
99 }
100
101 void MockModelTypeStore::DeleteMetadata(WriteBatch* write_batch,
102 const std::string& id) {
103 if (!delete_metadata_handler_.is_null()) {
104 delete_metadata_handler_.Run(write_batch, id);
105 }
106 }
107
108 void MockModelTypeStore::DeleteGlobalMetadata(WriteBatch* write_batch) {
109 if (!delete_global_metadata_handler_.is_null()) {
110 delete_global_metadata_handler_.Run(write_batch);
111 }
112 }
113
114 void MockModelTypeStore::RegisterReadDataHandler(
115 const ReadDataSignature& handler) {
116 read_data_handler_ = handler;
117 }
118
119 void MockModelTypeStore::RegisterReadAllDataHandler(
120 const ReadAllDataSignature& handler) {
121 read_all_data_handler_ = handler;
122 }
123
124 void MockModelTypeStore::RegisterReadAllMetadataHandler(
125 const ReadAllMetadataSignature& handler) {
126 read_all_metadata_handler_ = handler;
127 }
128
129 void MockModelTypeStore::RegisterCommitWriteBatchHandler(
130 const CommitWriteBatchSignature& handler) {
131 commit_write_batch_handler_ = handler;
132 }
133
134 void MockModelTypeStore::RegisterWriteDataHandler(
135 const WriteRecordSignature& handler) {
136 write_data_handler_ = handler;
137 }
138
139 void MockModelTypeStore::RegisterWriteMetadataHandler(
140 const WriteRecordSignature& handler) {
141 write_metadata_handler_ = handler;
142 }
143
144 void MockModelTypeStore::RegisterWriteGlobalMetadataHandler(
145 const WriteGlobalMetadataSignature& handler) {
146 write_global_metadata_handler_ = handler;
147 }
148
149 void MockModelTypeStore::RegisterDeleteDataHandler(
150 const DeleteRecordSignature& handler) {
151 delete_data_handler_ = handler;
152 }
153
154 void MockModelTypeStore::RegisterDeleteMetadataHandler(
155 const DeleteRecordSignature& handler) {
156 delete_metadata_handler_ = handler;
157 }
158
159 void MockModelTypeStore::RegisterDeleteGlobalMetadataHandler(
160 const DeleteGlobalMetadataSignature& handler) {
161 delete_global_metadata_handler_ = handler;
162 }
163
164 } // namespace syncer_v2
OLDNEW
« no previous file with comments | « sync/api/mock_model_type_store.h ('k') | sync/api/model_type_change_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698