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/invalidator.h" | 19 #include "sync/notifier/invalidator.h" |
20 #include "sync/notifier/invalidator_state.h" | 20 #include "sync/notifier/invalidator_state.h" |
21 #include "sync/notifier/object_id_state_map.h" | 21 #include "sync/notifier/object_id_invalidation_map.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), |
31 configure_fail_types_(configure_fail_types) { | 31 configure_fail_types_(configure_fail_types) { |
(...skipping 13 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 ObjectIdStateMap& id_state_map, | 55 void FakeSyncManager::Invalidate( |
56 IncomingInvalidationSource source) { | 56 const ObjectIdInvalidationMap& invalidation_map, |
| 57 IncomingInvalidationSource source) { |
57 if (!sync_task_runner_->PostTask( | 58 if (!sync_task_runner_->PostTask( |
58 FROM_HERE, | 59 FROM_HERE, |
59 base::Bind(&FakeSyncManager::InvalidateOnSyncThread, | 60 base::Bind(&FakeSyncManager::InvalidateOnSyncThread, |
60 base::Unretained(this), id_state_map, source))) { | 61 base::Unretained(this), invalidation_map, source))) { |
61 NOTREACHED(); | 62 NOTREACHED(); |
62 } | 63 } |
63 } | 64 } |
64 | 65 |
65 void FakeSyncManager::UpdateInvalidatorState(InvalidatorState state) { | 66 void FakeSyncManager::UpdateInvalidatorState(InvalidatorState state) { |
66 if (!sync_task_runner_->PostTask( | 67 if (!sync_task_runner_->PostTask( |
67 FROM_HERE, | 68 FROM_HERE, |
68 base::Bind(&FakeSyncManager::UpdateInvalidatorStateOnSyncThread, | 69 base::Bind(&FakeSyncManager::UpdateInvalidatorStateOnSyncThread, |
69 base::Unretained(this), state))) { | 70 base::Unretained(this), state))) { |
70 NOTREACHED(); | 71 NOTREACHED(); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 bool FakeSyncManager::HasUnsyncedItems() { | 245 bool FakeSyncManager::HasUnsyncedItems() { |
245 NOTIMPLEMENTED(); | 246 NOTIMPLEMENTED(); |
246 return false; | 247 return false; |
247 } | 248 } |
248 | 249 |
249 SyncEncryptionHandler* FakeSyncManager::GetEncryptionHandler() { | 250 SyncEncryptionHandler* FakeSyncManager::GetEncryptionHandler() { |
250 return fake_encryption_handler_.get(); | 251 return fake_encryption_handler_.get(); |
251 } | 252 } |
252 | 253 |
253 void FakeSyncManager::InvalidateOnSyncThread( | 254 void FakeSyncManager::InvalidateOnSyncThread( |
254 const ObjectIdStateMap& id_state_map, | 255 const ObjectIdInvalidationMap& invalidation_map, |
255 IncomingInvalidationSource source) { | 256 IncomingInvalidationSource source) { |
256 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); | 257 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
257 registrar_.DispatchInvalidationsToHandlers(id_state_map, source); | 258 registrar_.DispatchInvalidationsToHandlers(invalidation_map, source); |
258 } | 259 } |
259 | 260 |
260 void FakeSyncManager::UpdateInvalidatorStateOnSyncThread( | 261 void FakeSyncManager::UpdateInvalidatorStateOnSyncThread( |
261 InvalidatorState state) { | 262 InvalidatorState state) { |
262 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); | 263 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
263 registrar_.UpdateInvalidatorState(state); | 264 registrar_.UpdateInvalidatorState(state); |
264 } | 265 } |
265 | 266 |
266 } // namespace syncer | 267 } // namespace syncer |
OLD | NEW |