| 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/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } | 186 } |
| 187 | 187 |
| 188 void FakeSyncManager::StartSyncingNormally( | 188 void FakeSyncManager::StartSyncingNormally( |
| 189 const ModelSafeRoutingInfo& routing_info) { | 189 const ModelSafeRoutingInfo& routing_info) { |
| 190 // Do nothing. | 190 // Do nothing. |
| 191 } | 191 } |
| 192 | 192 |
| 193 void FakeSyncManager::ConfigureSyncer( | 193 void FakeSyncManager::ConfigureSyncer( |
| 194 ConfigureReason reason, | 194 ConfigureReason reason, |
| 195 ModelTypeSet to_download, | 195 ModelTypeSet to_download, |
| 196 ModelTypeSet to_purge, |
| 196 ModelTypeSet to_journal, | 197 ModelTypeSet to_journal, |
| 197 ModelTypeSet to_unapply, | 198 ModelTypeSet to_unapply, |
| 198 ModelTypeSet to_ignore, | |
| 199 const ModelSafeRoutingInfo& new_routing_info, | 199 const ModelSafeRoutingInfo& new_routing_info, |
| 200 const base::Closure& ready_task, | 200 const base::Closure& ready_task, |
| 201 const base::Closure& retry_task) { | 201 const base::Closure& retry_task) { |
| 202 last_configure_reason_ = reason; | 202 last_configure_reason_ = reason; |
| 203 ModelTypeSet enabled_types = GetRoutingInfoTypes(new_routing_info); | 203 ModelTypeSet enabled_types = GetRoutingInfoTypes(new_routing_info); |
| 204 ModelTypeSet disabled_types = Difference( | |
| 205 ModelTypeSet::All(), enabled_types); | |
| 206 disabled_types.RemoveAll(to_ignore); | |
| 207 ModelTypeSet success_types = to_download; | 204 ModelTypeSet success_types = to_download; |
| 208 success_types.RemoveAll(configure_fail_types_); | 205 success_types.RemoveAll(configure_fail_types_); |
| 209 | 206 |
| 210 DVLOG(1) << "Faking configuration. Downloading: " | 207 DVLOG(1) << "Faking configuration. Downloading: " |
| 211 << ModelTypeSetToString(success_types) << ". Cleaning: " | 208 << ModelTypeSetToString(success_types) << ". Cleaning: " |
| 212 << ModelTypeSetToString(disabled_types); | 209 << ModelTypeSetToString(to_purge); |
| 213 | 210 |
| 214 // Update our fake directory by clearing and fake-downloading as necessary. | 211 // Update our fake directory by clearing and fake-downloading as necessary. |
| 215 UserShare* share = GetUserShare(); | 212 UserShare* share = GetUserShare(); |
| 216 share->directory->PurgeEntriesWithTypeIn(disabled_types, | 213 share->directory->PurgeEntriesWithTypeIn(to_purge, |
| 217 to_journal, | 214 to_journal, |
| 218 to_unapply); | 215 to_unapply); |
| 219 for (ModelTypeSet::Iterator it = success_types.First(); it.Good(); it.Inc()) { | 216 for (ModelTypeSet::Iterator it = success_types.First(); it.Good(); it.Inc()) { |
| 220 // We must be careful to not create the same root node twice. | 217 // We must be careful to not create the same root node twice. |
| 221 if (!initial_sync_ended_types_.Has(it.Get())) { | 218 if (!initial_sync_ended_types_.Has(it.Get())) { |
| 222 TestUserShare::CreateRoot(it.Get(), share); | 219 TestUserShare::CreateRoot(it.Get(), share); |
| 223 } | 220 } |
| 224 } | 221 } |
| 225 | 222 |
| 226 // Simulate cleaning up disabled types. | 223 // Simulate cleaning up disabled types. |
| 227 // TODO(sync): consider only cleaning those types that were recently disabled, | 224 // TODO(sync): consider only cleaning those types that were recently disabled, |
| 228 // if this isn't the first cleanup, which more accurately reflects the | 225 // if this isn't the first cleanup, which more accurately reflects the |
| 229 // behavior of the real cleanup logic. | 226 // behavior of the real cleanup logic. |
| 230 initial_sync_ended_types_.RemoveAll(disabled_types); | 227 initial_sync_ended_types_.RemoveAll(to_purge); |
| 231 progress_marker_types_.RemoveAll(disabled_types); | 228 progress_marker_types_.RemoveAll(to_purge); |
| 232 cleaned_types_.PutAll(disabled_types); | 229 cleaned_types_.PutAll(to_purge); |
| 233 | 230 |
| 234 // Now simulate the actual configuration for those types that successfully | 231 // Now simulate the actual configuration for those types that successfully |
| 235 // download + apply. | 232 // download + apply. |
| 236 progress_marker_types_.PutAll(success_types); | 233 progress_marker_types_.PutAll(success_types); |
| 237 initial_sync_ended_types_.PutAll(success_types); | 234 initial_sync_ended_types_.PutAll(success_types); |
| 238 downloaded_types_.PutAll(success_types); | 235 downloaded_types_.PutAll(success_types); |
| 239 | 236 |
| 240 ready_task.Run(); | 237 ready_task.Run(); |
| 241 } | 238 } |
| 242 | 239 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 InvalidatorState state) { | 300 InvalidatorState state) { |
| 304 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); | 301 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
| 305 registrar_.UpdateInvalidatorState(state); | 302 registrar_.UpdateInvalidatorState(state); |
| 306 } | 303 } |
| 307 | 304 |
| 308 ModelTypeSet FakeSyncManager::GetLastRefreshRequestTypes() { | 305 ModelTypeSet FakeSyncManager::GetLastRefreshRequestTypes() { |
| 309 return last_refresh_request_types_; | 306 return last_refresh_request_types_; |
| 310 } | 307 } |
| 311 | 308 |
| 312 } // namespace syncer | 309 } // namespace syncer |
| OLD | NEW |