| 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_state_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 #include "sync/test/fake_sync_encryption_handler.h" |
| 23 | 23 |
| 24 namespace syncer { | 24 namespace syncer { |
| 25 | 25 |
| 26 FakeSyncManager::FakeSyncManager(ModelTypeSet initial_sync_ended_types, | 26 FakeSyncManager::FakeSyncManager(ModelTypeSet initial_sync_ended_types, |
| 27 ModelTypeSet progress_marker_types, | 27 ModelTypeSet progress_marker_types, |
| 28 ModelTypeSet configure_fail_types) : | 28 ModelTypeSet configure_fail_types) : |
| 29 initial_sync_ended_types_(initial_sync_ended_types), | 29 initial_sync_ended_types_(initial_sync_ended_types), |
| 30 progress_marker_types_(progress_marker_types), | 30 progress_marker_types_(progress_marker_types), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 45 downloaded_types_.Clear(); | 45 downloaded_types_.Clear(); |
| 46 return downloaded_types; | 46 return downloaded_types; |
| 47 } | 47 } |
| 48 | 48 |
| 49 ModelTypeSet FakeSyncManager::GetAndResetEnabledTypes() { | 49 ModelTypeSet FakeSyncManager::GetAndResetEnabledTypes() { |
| 50 ModelTypeSet enabled_types = enabled_types_; | 50 ModelTypeSet enabled_types = enabled_types_; |
| 51 enabled_types_.Clear(); | 51 enabled_types_.Clear(); |
| 52 return enabled_types; | 52 return enabled_types; |
| 53 } | 53 } |
| 54 | 54 |
| 55 void FakeSyncManager::Invalidate(const ObjectIdPayloadMap& id_payloads, | 55 void FakeSyncManager::Invalidate(const ObjectIdStateMap& id_state_map, |
| 56 IncomingNotificationSource source) { | 56 IncomingNotificationSource source) { |
| 57 if (!sync_task_runner_->PostTask( | 57 if (!sync_task_runner_->PostTask( |
| 58 FROM_HERE, | 58 FROM_HERE, |
| 59 base::Bind(&FakeSyncManager::InvalidateOnSyncThread, | 59 base::Bind(&FakeSyncManager::InvalidateOnSyncThread, |
| 60 base::Unretained(this), id_payloads, source))) { | 60 base::Unretained(this), id_state_map, source))) { |
| 61 NOTREACHED(); | 61 NOTREACHED(); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 void FakeSyncManager::EnableNotifications() { | 65 void FakeSyncManager::EnableNotifications() { |
| 66 if (!sync_task_runner_->PostTask( | 66 if (!sync_task_runner_->PostTask( |
| 67 FROM_HERE, | 67 FROM_HERE, |
| 68 base::Bind(&FakeSyncManager::EnableNotificationsOnSyncThread, | 68 base::Bind(&FakeSyncManager::EnableNotificationsOnSyncThread, |
| 69 base::Unretained(this)))) { | 69 base::Unretained(this)))) { |
| 70 NOTREACHED(); | 70 NOTREACHED(); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 bool FakeSyncManager::HasUnsyncedItems() { | 258 bool FakeSyncManager::HasUnsyncedItems() { |
| 259 NOTIMPLEMENTED(); | 259 NOTIMPLEMENTED(); |
| 260 return false; | 260 return false; |
| 261 } | 261 } |
| 262 | 262 |
| 263 SyncEncryptionHandler* FakeSyncManager::GetEncryptionHandler() { | 263 SyncEncryptionHandler* FakeSyncManager::GetEncryptionHandler() { |
| 264 return fake_encryption_handler_.get(); | 264 return fake_encryption_handler_.get(); |
| 265 } | 265 } |
| 266 | 266 |
| 267 void FakeSyncManager::InvalidateOnSyncThread( | 267 void FakeSyncManager::InvalidateOnSyncThread( |
| 268 const ObjectIdPayloadMap& id_payloads, | 268 const ObjectIdStateMap& id_state_map, |
| 269 IncomingNotificationSource source) { | 269 IncomingNotificationSource source) { |
| 270 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); | 270 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
| 271 registrar_.DispatchInvalidationsToHandlers(id_payloads, source); | 271 registrar_.DispatchInvalidationsToHandlers(id_state_map, source); |
| 272 } | 272 } |
| 273 | 273 |
| 274 void FakeSyncManager::EnableNotificationsOnSyncThread() { | 274 void FakeSyncManager::EnableNotificationsOnSyncThread() { |
| 275 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); | 275 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
| 276 registrar_.EmitOnNotificationsEnabled(); | 276 registrar_.EmitOnNotificationsEnabled(); |
| 277 } | 277 } |
| 278 | 278 |
| 279 void FakeSyncManager::DisableNotificationsOnSyncThread( | 279 void FakeSyncManager::DisableNotificationsOnSyncThread( |
| 280 NotificationsDisabledReason reason) { | 280 NotificationsDisabledReason reason) { |
| 281 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); | 281 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
| 282 registrar_.EmitOnNotificationsDisabled(reason); | 282 registrar_.EmitOnNotificationsDisabled(reason); |
| 283 } | 283 } |
| 284 | 284 |
| 285 } // namespace syncer | 285 } // namespace syncer |
| OLD | NEW |