OLD | NEW |
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 "sync/internal_api/public/test/fake_sync_manager.h" | 5 #include "sync/internal_api/public/test/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/location.h" | 10 #include "base/location.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
15 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
16 #include "sync/internal_api/public/http_post_provider_factory.h" | 16 #include "sync/internal_api/public/http_post_provider_factory.h" |
17 #include "sync/internal_api/public/internal_components_factory.h" | 17 #include "sync/internal_api/public/internal_components_factory.h" |
18 #include "sync/internal_api/public/util/weak_handle.h" | 18 #include "sync/internal_api/public/util/weak_handle.h" |
19 #include "sync/notifier/notifications_disabled_reason.h" | 19 #include "sync/notifier/notifications_disabled_reason.h" |
20 #include "sync/notifier/object_id_payload_map.h" | 20 #include "sync/notifier/object_id_payload_map.h" |
21 #include "sync/notifier/sync_notifier.h" | 21 #include "sync/notifier/sync_notifier.h" |
| 22 #include "sync/test/fake_sync_encryption_handler.h" |
22 | 23 |
23 namespace syncer { | 24 namespace syncer { |
24 | 25 |
25 FakeSyncManager::FakeSyncManager(ModelTypeSet initial_sync_ended_types, | 26 FakeSyncManager::FakeSyncManager(ModelTypeSet initial_sync_ended_types, |
26 ModelTypeSet progress_marker_types, | 27 ModelTypeSet progress_marker_types, |
27 ModelTypeSet configure_fail_types) : | 28 ModelTypeSet configure_fail_types) : |
28 initial_sync_ended_types_(initial_sync_ended_types), | 29 initial_sync_ended_types_(initial_sync_ended_types), |
29 progress_marker_types_(progress_marker_types), | 30 progress_marker_types_(progress_marker_types), |
30 configure_fail_types_(configure_fail_types) {} | 31 configure_fail_types_(configure_fail_types) { |
| 32 fake_encryption_handler_.reset(new FakeSyncEncryptionHandler()); |
| 33 } |
31 | 34 |
32 FakeSyncManager::~FakeSyncManager() {} | 35 FakeSyncManager::~FakeSyncManager() {} |
33 | 36 |
34 ModelTypeSet FakeSyncManager::GetAndResetCleanedTypes() { | 37 ModelTypeSet FakeSyncManager::GetAndResetCleanedTypes() { |
35 ModelTypeSet cleaned_types = cleaned_types_; | 38 ModelTypeSet cleaned_types = cleaned_types_; |
36 cleaned_types_.Clear(); | 39 cleaned_types_.Clear(); |
37 return cleaned_types; | 40 return cleaned_types; |
38 } | 41 } |
39 | 42 |
40 ModelTypeSet FakeSyncManager::GetAndResetDownloadedTypes() { | 43 ModelTypeSet FakeSyncManager::GetAndResetDownloadedTypes() { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 void FakeSyncManager::UnregisterInvalidationHandler( | 176 void FakeSyncManager::UnregisterInvalidationHandler( |
174 SyncNotifierObserver* handler) { | 177 SyncNotifierObserver* handler) { |
175 registrar_.UnregisterHandler(handler); | 178 registrar_.UnregisterHandler(handler); |
176 } | 179 } |
177 | 180 |
178 void FakeSyncManager::StartSyncingNormally( | 181 void FakeSyncManager::StartSyncingNormally( |
179 const ModelSafeRoutingInfo& routing_info) { | 182 const ModelSafeRoutingInfo& routing_info) { |
180 // Do nothing. | 183 // Do nothing. |
181 } | 184 } |
182 | 185 |
183 void FakeSyncManager::SetEncryptionPassphrase(const std::string& passphrase, | |
184 bool is_explicit) { | |
185 NOTIMPLEMENTED(); | |
186 } | |
187 | |
188 void FakeSyncManager::SetDecryptionPassphrase(const std::string& passphrase) { | |
189 NOTIMPLEMENTED(); | |
190 } | |
191 | |
192 void FakeSyncManager::ConfigureSyncer( | 186 void FakeSyncManager::ConfigureSyncer( |
193 ConfigureReason reason, | 187 ConfigureReason reason, |
194 const ModelTypeSet& types_to_config, | 188 const ModelTypeSet& types_to_config, |
195 const ModelSafeRoutingInfo& new_routing_info, | 189 const ModelSafeRoutingInfo& new_routing_info, |
196 const base::Closure& ready_task, | 190 const base::Closure& ready_task, |
197 const base::Closure& retry_task) { | 191 const base::Closure& retry_task) { |
198 ModelTypeSet enabled_types = GetRoutingInfoTypes(new_routing_info); | 192 ModelTypeSet enabled_types = GetRoutingInfoTypes(new_routing_info); |
199 ModelTypeSet disabled_types = Difference( | 193 ModelTypeSet disabled_types = Difference( |
200 ModelTypeSet::All(), enabled_types); | 194 ModelTypeSet::All(), enabled_types); |
201 ModelTypeSet success_types = types_to_config; | 195 ModelTypeSet success_types = types_to_config; |
(...skipping 26 matching lines...) Expand all Loading... |
228 | 222 |
229 void FakeSyncManager::RemoveObserver(Observer* observer) { | 223 void FakeSyncManager::RemoveObserver(Observer* observer) { |
230 observers_.RemoveObserver(observer); | 224 observers_.RemoveObserver(observer); |
231 } | 225 } |
232 | 226 |
233 SyncStatus FakeSyncManager::GetDetailedStatus() const { | 227 SyncStatus FakeSyncManager::GetDetailedStatus() const { |
234 NOTIMPLEMENTED(); | 228 NOTIMPLEMENTED(); |
235 return SyncStatus(); | 229 return SyncStatus(); |
236 } | 230 } |
237 | 231 |
238 bool FakeSyncManager::IsUsingExplicitPassphrase() { | |
239 NOTIMPLEMENTED(); | |
240 return false; | |
241 } | |
242 | |
243 bool FakeSyncManager::GetKeystoreKeyBootstrapToken(std::string* token) { | 232 bool FakeSyncManager::GetKeystoreKeyBootstrapToken(std::string* token) { |
244 return false; | 233 return false; |
245 } | 234 } |
246 | 235 |
247 void FakeSyncManager::SaveChanges() { | 236 void FakeSyncManager::SaveChanges() { |
248 // Do nothing. | 237 // Do nothing. |
249 } | 238 } |
250 | 239 |
251 void FakeSyncManager::StopSyncingForShutdown(const base::Closure& callback) { | 240 void FakeSyncManager::StopSyncingForShutdown(const base::Closure& callback) { |
252 if (!sync_task_runner_->PostTask(FROM_HERE, callback)) { | 241 if (!sync_task_runner_->PostTask(FROM_HERE, callback)) { |
253 NOTREACHED(); | 242 NOTREACHED(); |
254 } | 243 } |
255 } | 244 } |
256 | 245 |
257 void FakeSyncManager::ShutdownOnSyncThread() { | 246 void FakeSyncManager::ShutdownOnSyncThread() { |
258 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); | 247 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
259 } | 248 } |
260 | 249 |
261 UserShare* FakeSyncManager::GetUserShare() { | 250 UserShare* FakeSyncManager::GetUserShare() { |
262 NOTIMPLEMENTED(); | |
263 return NULL; | 251 return NULL; |
264 } | 252 } |
265 | 253 |
266 void FakeSyncManager::RefreshNigori(const std::string& chrome_version, | |
267 const base::Closure& done_callback) { | |
268 done_callback.Run(); | |
269 } | |
270 | |
271 void FakeSyncManager::EnableEncryptEverything() { | |
272 NOTIMPLEMENTED(); | |
273 } | |
274 | |
275 bool FakeSyncManager::ReceivedExperiment(Experiments* experiments) { | 254 bool FakeSyncManager::ReceivedExperiment(Experiments* experiments) { |
276 return false; | 255 return false; |
277 } | 256 } |
278 | 257 |
279 bool FakeSyncManager::HasUnsyncedItems() { | 258 bool FakeSyncManager::HasUnsyncedItems() { |
280 NOTIMPLEMENTED(); | 259 NOTIMPLEMENTED(); |
281 return false; | 260 return false; |
282 } | 261 } |
283 | 262 |
| 263 SyncEncryptionHandler* FakeSyncManager::GetEncryptionHandler() { |
| 264 return fake_encryption_handler_.get(); |
| 265 } |
| 266 |
284 void FakeSyncManager::InvalidateOnSyncThread( | 267 void FakeSyncManager::InvalidateOnSyncThread( |
285 const ObjectIdPayloadMap& id_payloads, | 268 const ObjectIdPayloadMap& id_payloads, |
286 IncomingNotificationSource source) { | 269 IncomingNotificationSource source) { |
287 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); | 270 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
288 registrar_.DispatchInvalidationsToHandlers(id_payloads, source); | 271 registrar_.DispatchInvalidationsToHandlers(id_payloads, source); |
289 } | 272 } |
290 | 273 |
291 void FakeSyncManager::EnableNotificationsOnSyncThread() { | 274 void FakeSyncManager::EnableNotificationsOnSyncThread() { |
292 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); | 275 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
293 registrar_.EmitOnNotificationsEnabled(); | 276 registrar_.EmitOnNotificationsEnabled(); |
294 } | 277 } |
295 | 278 |
296 void FakeSyncManager::DisableNotificationsOnSyncThread( | 279 void FakeSyncManager::DisableNotificationsOnSyncThread( |
297 NotificationsDisabledReason reason) { | 280 NotificationsDisabledReason reason) { |
298 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); | 281 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
299 registrar_.EmitOnNotificationsDisabled(reason); | 282 registrar_.EmitOnNotificationsDisabled(reason); |
300 } | 283 } |
301 | 284 |
302 } // namespace syncer | 285 } // namespace syncer |
OLD | NEW |