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

Side by Side Diff: components/sync/engine/fake_sync_manager.cc

Issue 2641523004: [Sync] Make directory types registration explicit in ModelTypeRegistry (Closed)
Patch Set: Address comments Created 3 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "components/sync/engine/fake_sync_manager.h" 5 #include "components/sync/engine/fake_sync_manager.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/sequenced_task_runner.h" 15 #include "base/sequenced_task_runner.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "components/sync/base/weak_handle.h" 18 #include "components/sync/base/weak_handle.h"
19 #include "components/sync/engine/engine_components_factory.h" 19 #include "components/sync/engine/engine_components_factory.h"
20 #include "components/sync/engine/fake_model_type_connector.h"
21 #include "components/sync/engine/net/http_post_provider_factory.h" 20 #include "components/sync/engine/net/http_post_provider_factory.h"
22 #include "components/sync/syncable/directory.h" 21 #include "components/sync/syncable/directory.h"
23 #include "components/sync/test/fake_sync_encryption_handler.h"
24 22
25 class GURL; 23 class GURL;
26 24
27 namespace syncer { 25 namespace syncer {
28 26
29 FakeSyncManager::FakeSyncManager(ModelTypeSet initial_sync_ended_types, 27 FakeSyncManager::FakeSyncManager(ModelTypeSet initial_sync_ended_types,
30 ModelTypeSet progress_marker_types, 28 ModelTypeSet progress_marker_types,
31 ModelTypeSet configure_fail_types) 29 ModelTypeSet configure_fail_types)
32 : initial_sync_ended_types_(initial_sync_ended_types), 30 : initial_sync_ended_types_(initial_sync_ended_types),
33 progress_marker_types_(progress_marker_types), 31 progress_marker_types_(progress_marker_types),
34 configure_fail_types_(configure_fail_types), 32 configure_fail_types_(configure_fail_types),
35 last_configure_reason_(CONFIGURE_REASON_UNKNOWN), 33 last_configure_reason_(CONFIGURE_REASON_UNKNOWN),
36 num_invalidations_received_(0) { 34 num_invalidations_received_(0) {}
37 fake_encryption_handler_ = base::MakeUnique<FakeSyncEncryptionHandler>();
38 }
39 35
40 FakeSyncManager::~FakeSyncManager() {} 36 FakeSyncManager::~FakeSyncManager() {}
41 37
42 ModelTypeSet FakeSyncManager::GetAndResetPurgedTypes() { 38 ModelTypeSet FakeSyncManager::GetAndResetPurgedTypes() {
43 ModelTypeSet purged_types = purged_types_; 39 ModelTypeSet purged_types = purged_types_;
44 purged_types_.Clear(); 40 purged_types_.Clear();
45 return purged_types; 41 return purged_types;
46 } 42 }
47 43
48 ModelTypeSet FakeSyncManager::GetAndResetUnappliedTypes() { 44 ModelTypeSet FakeSyncManager::GetAndResetUnappliedTypes() {
49 ModelTypeSet unapplied_types = unapplied_types_; 45 ModelTypeSet unapplied_types = unapplied_types_;
50 unapplied_types_.Clear(); 46 unapplied_types_.Clear();
51 return unapplied_types; 47 return unapplied_types;
52 } 48 }
53 49
54 ModelTypeSet FakeSyncManager::GetAndResetDownloadedTypes() { 50 ModelTypeSet FakeSyncManager::GetAndResetDownloadedTypes() {
55 ModelTypeSet downloaded_types = downloaded_types_; 51 ModelTypeSet downloaded_types = downloaded_types_;
56 downloaded_types_.Clear(); 52 downloaded_types_.Clear();
57 return downloaded_types; 53 return downloaded_types;
58 } 54 }
59 55
60 ModelTypeSet FakeSyncManager::GetAndResetEnabledTypes() {
61 ModelTypeSet enabled_types = enabled_types_;
62 enabled_types_.Clear();
63 return enabled_types;
64 }
65
66 ConfigureReason FakeSyncManager::GetAndResetConfigureReason() { 56 ConfigureReason FakeSyncManager::GetAndResetConfigureReason() {
67 ConfigureReason reason = last_configure_reason_; 57 ConfigureReason reason = last_configure_reason_;
68 last_configure_reason_ = CONFIGURE_REASON_UNKNOWN; 58 last_configure_reason_ = CONFIGURE_REASON_UNKNOWN;
69 return reason; 59 return reason;
70 } 60 }
71 61
72 int FakeSyncManager::GetInvalidationCount() const { 62 int FakeSyncManager::GetInvalidationCount() const {
73 return num_invalidations_received_; 63 return num_invalidations_received_;
74 } 64 }
75 65
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // Types from |to_unapply| should retain their server data and progress 127 // Types from |to_unapply| should retain their server data and progress
138 // markers. 128 // markers.
139 initial_sync_ended_types_.RemoveAll(Difference(to_purge, to_unapply)); 129 initial_sync_ended_types_.RemoveAll(Difference(to_purge, to_unapply));
140 progress_marker_types_.RemoveAll(Difference(to_purge, to_unapply)); 130 progress_marker_types_.RemoveAll(Difference(to_purge, to_unapply));
141 } 131 }
142 132
143 void FakeSyncManager::UpdateCredentials(const SyncCredentials& credentials) { 133 void FakeSyncManager::UpdateCredentials(const SyncCredentials& credentials) {
144 NOTIMPLEMENTED(); 134 NOTIMPLEMENTED();
145 } 135 }
146 136
147 void FakeSyncManager::StartSyncingNormally( 137 void FakeSyncManager::StartSyncingNormally(base::Time last_poll_time) {
148 const ModelSafeRoutingInfo& routing_info, 138 // Do nothing.
149 base::Time last_poll_time) { 139 }
140
141 void FakeSyncManager::StartConfiguration() {
150 // Do nothing. 142 // Do nothing.
151 } 143 }
152 144
153 void FakeSyncManager::ConfigureSyncer( 145 void FakeSyncManager::ConfigureSyncer(
154 ConfigureReason reason, 146 ConfigureReason reason,
155 ModelTypeSet to_download, 147 ModelTypeSet to_download,
156 const ModelSafeRoutingInfo& new_routing_info,
157 const base::Closure& ready_task, 148 const base::Closure& ready_task,
158 const base::Closure& retry_task) { 149 const base::Closure& retry_task) {
159 last_configure_reason_ = reason; 150 last_configure_reason_ = reason;
160 enabled_types_ = GetRoutingInfoTypes(new_routing_info);
161 ModelTypeSet success_types = to_download; 151 ModelTypeSet success_types = to_download;
162 success_types.RemoveAll(configure_fail_types_); 152 success_types.RemoveAll(configure_fail_types_);
163 153
164 DVLOG(1) << "Faking configuration. Downloading: " 154 DVLOG(1) << "Faking configuration. Downloading: "
165 << ModelTypeSetToString(success_types); 155 << ModelTypeSetToString(success_types);
166 156
167 // Update our fake directory by clearing and fake-downloading as necessary. 157 // Update our fake directory by clearing and fake-downloading as necessary.
168 UserShare* share = GetUserShare(); 158 UserShare* share = GetUserShare();
169 for (ModelTypeSet::Iterator it = success_types.First(); it.Good(); it.Inc()) { 159 for (ModelTypeSet::Iterator it = success_types.First(); it.Good(); it.Inc()) {
170 // We must be careful to not create the same root node twice. 160 // We must be careful to not create the same root node twice.
(...skipping 30 matching lines...) Expand all
201 191
202 void FakeSyncManager::ShutdownOnSyncThread(ShutdownReason reason) { 192 void FakeSyncManager::ShutdownOnSyncThread(ShutdownReason reason) {
203 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); 193 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
204 test_user_share_.TearDown(); 194 test_user_share_.TearDown();
205 } 195 }
206 196
207 UserShare* FakeSyncManager::GetUserShare() { 197 UserShare* FakeSyncManager::GetUserShare() {
208 return test_user_share_.user_share(); 198 return test_user_share_.user_share();
209 } 199 }
210 200
201 ModelTypeConnector* FakeSyncManager::GetModelTypeConnector() {
202 return &fake_model_type_connector_;
203 }
204
211 std::unique_ptr<ModelTypeConnector> 205 std::unique_ptr<ModelTypeConnector>
212 FakeSyncManager::GetModelTypeConnectorProxy() { 206 FakeSyncManager::GetModelTypeConnectorProxy() {
213 return base::MakeUnique<FakeModelTypeConnector>(); 207 return base::MakeUnique<FakeModelTypeConnector>();
214 } 208 }
215 209
216 const std::string FakeSyncManager::cache_guid() { 210 const std::string FakeSyncManager::cache_guid() {
217 return test_user_share_.user_share()->directory->cache_guid(); 211 return test_user_share_.user_share()->directory->cache_guid();
218 } 212 }
219 213
220 bool FakeSyncManager::ReceivedExperiment(Experiments* experiments) { 214 bool FakeSyncManager::ReceivedExperiment(Experiments* experiments) {
221 return false; 215 return false;
222 } 216 }
223 217
224 bool FakeSyncManager::HasUnsyncedItems() { 218 bool FakeSyncManager::HasUnsyncedItems() {
225 NOTIMPLEMENTED(); 219 NOTIMPLEMENTED();
226 return false; 220 return false;
227 } 221 }
228 222
229 SyncEncryptionHandler* FakeSyncManager::GetEncryptionHandler() { 223 SyncEncryptionHandler* FakeSyncManager::GetEncryptionHandler() {
230 return fake_encryption_handler_.get(); 224 return &fake_encryption_handler_;
231 } 225 }
232 226
233 std::vector<std::unique_ptr<ProtocolEvent>> 227 std::vector<std::unique_ptr<ProtocolEvent>>
234 FakeSyncManager::GetBufferedProtocolEvents() { 228 FakeSyncManager::GetBufferedProtocolEvents() {
235 return std::vector<std::unique_ptr<ProtocolEvent>>(); 229 return std::vector<std::unique_ptr<ProtocolEvent>>();
236 } 230 }
237 231
238 void FakeSyncManager::RefreshTypes(ModelTypeSet types) { 232 void FakeSyncManager::RefreshTypes(ModelTypeSet types) {
239 last_refresh_request_types_ = types; 233 last_refresh_request_types_ = types;
240 } 234 }
(...skipping 30 matching lines...) Expand all
271 } 265 }
272 266
273 void FakeSyncManager::OnCookieJarChanged(bool account_mismatch, 267 void FakeSyncManager::OnCookieJarChanged(bool account_mismatch,
274 bool empty_jar) {} 268 bool empty_jar) {}
275 269
276 void FakeSyncManager::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) { 270 void FakeSyncManager::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) {
277 NOTIMPLEMENTED(); 271 NOTIMPLEMENTED();
278 } 272 }
279 273
280 } // namespace syncer 274 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/engine/fake_sync_manager.h ('k') | components/sync/engine/model_type_configurer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698