| 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 "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" | 
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 99   return initial_sync_ended_types_; | 99   return initial_sync_ended_types_; | 
| 100 } | 100 } | 
| 101 | 101 | 
| 102 ModelTypeSet FakeSyncManager::GetTypesWithEmptyProgressMarkerToken( | 102 ModelTypeSet FakeSyncManager::GetTypesWithEmptyProgressMarkerToken( | 
| 103     ModelTypeSet types) { | 103     ModelTypeSet types) { | 
| 104   ModelTypeSet empty_types = types; | 104   ModelTypeSet empty_types = types; | 
| 105   empty_types.RemoveAll(progress_marker_types_); | 105   empty_types.RemoveAll(progress_marker_types_); | 
| 106   return empty_types; | 106   return empty_types; | 
| 107 } | 107 } | 
| 108 | 108 | 
| 109 bool FakeSyncManager::PurgePartiallySyncedTypes() { | 109 void FakeSyncManager::PurgePartiallySyncedTypes() { | 
| 110   ModelTypeSet partial_types; | 110   ModelTypeSet partial_types; | 
| 111   for (ModelTypeSet::Iterator i = progress_marker_types_.First(); i.Good(); | 111   for (ModelTypeSet::Iterator i = progress_marker_types_.First(); i.Good(); | 
| 112        i.Inc()) { | 112        i.Inc()) { | 
| 113     if (!initial_sync_ended_types_.Has(i.Get())) | 113     if (!initial_sync_ended_types_.Has(i.Get())) | 
| 114       partial_types.Put(i.Get()); | 114       partial_types.Put(i.Get()); | 
| 115   } | 115   } | 
| 116   progress_marker_types_.RemoveAll(partial_types); | 116   progress_marker_types_.RemoveAll(partial_types); | 
| 117   cleaned_types_.PutAll(partial_types); | 117   cleaned_types_.PutAll(partial_types); | 
| 118   return true; | 118 } | 
|  | 119 | 
|  | 120 void FakeSyncManager::PurgeDisabledTypes(ModelTypeSet to_purge, | 
|  | 121                                          ModelTypeSet to_journal, | 
|  | 122                                          ModelTypeSet to_unapply) { | 
|  | 123   // Simulate cleaning up disabled types. | 
|  | 124   // TODO(sync): consider only cleaning those types that were recently disabled, | 
|  | 125   // if this isn't the first cleanup, which more accurately reflects the | 
|  | 126   // behavior of the real cleanup logic. | 
|  | 127   GetUserShare()->directory->PurgeEntriesWithTypeIn(to_purge, to_journal, | 
|  | 128                                                     to_unapply); | 
|  | 129   initial_sync_ended_types_.RemoveAll(to_purge); | 
|  | 130   progress_marker_types_.RemoveAll(to_purge); | 
|  | 131   cleaned_types_.PutAll(to_purge); | 
| 119 } | 132 } | 
| 120 | 133 | 
| 121 void FakeSyncManager::UpdateCredentials(const SyncCredentials& credentials) { | 134 void FakeSyncManager::UpdateCredentials(const SyncCredentials& credentials) { | 
| 122   NOTIMPLEMENTED(); | 135   NOTIMPLEMENTED(); | 
| 123 } | 136 } | 
| 124 | 137 | 
| 125 void FakeSyncManager::StartSyncingNormally( | 138 void FakeSyncManager::StartSyncingNormally( | 
| 126     const ModelSafeRoutingInfo& routing_info, | 139     const ModelSafeRoutingInfo& routing_info, | 
| 127     base::Time last_poll_time) { | 140     base::Time last_poll_time) { | 
| 128   // Do nothing. | 141   // Do nothing. | 
| 129 } | 142 } | 
| 130 | 143 | 
| 131 void FakeSyncManager::ConfigureSyncer( | 144 void FakeSyncManager::ConfigureSyncer( | 
| 132     ConfigureReason reason, | 145     ConfigureReason reason, | 
| 133     ModelTypeSet to_download, | 146     ModelTypeSet to_download, | 
| 134     ModelTypeSet to_purge, |  | 
| 135     ModelTypeSet to_journal, |  | 
| 136     ModelTypeSet to_unapply, |  | 
| 137     const ModelSafeRoutingInfo& new_routing_info, | 147     const ModelSafeRoutingInfo& new_routing_info, | 
| 138     const base::Closure& ready_task, | 148     const base::Closure& ready_task, | 
| 139     const base::Closure& retry_task) { | 149     const base::Closure& retry_task) { | 
| 140   last_configure_reason_ = reason; | 150   last_configure_reason_ = reason; | 
| 141   enabled_types_ = GetRoutingInfoTypes(new_routing_info); | 151   enabled_types_ = GetRoutingInfoTypes(new_routing_info); | 
| 142   ModelTypeSet success_types = to_download; | 152   ModelTypeSet success_types = to_download; | 
| 143   success_types.RemoveAll(configure_fail_types_); | 153   success_types.RemoveAll(configure_fail_types_); | 
| 144 | 154 | 
| 145   DVLOG(1) << "Faking configuration. Downloading: " | 155   DVLOG(1) << "Faking configuration. Downloading: " | 
| 146            << ModelTypeSetToString(success_types) | 156            << ModelTypeSetToString(success_types); | 
| 147            << ". Cleaning: " << ModelTypeSetToString(to_purge); |  | 
| 148 | 157 | 
| 149   // Update our fake directory by clearing and fake-downloading as necessary. | 158   // Update our fake directory by clearing and fake-downloading as necessary. | 
| 150   UserShare* share = GetUserShare(); | 159   UserShare* share = GetUserShare(); | 
| 151   share->directory->PurgeEntriesWithTypeIn(to_purge, to_journal, to_unapply); |  | 
| 152   for (ModelTypeSet::Iterator it = success_types.First(); it.Good(); it.Inc()) { | 160   for (ModelTypeSet::Iterator it = success_types.First(); it.Good(); it.Inc()) { | 
| 153     // We must be careful to not create the same root node twice. | 161     // We must be careful to not create the same root node twice. | 
| 154     if (!initial_sync_ended_types_.Has(it.Get())) { | 162     if (!initial_sync_ended_types_.Has(it.Get())) { | 
| 155       TestUserShare::CreateRoot(it.Get(), share); | 163       TestUserShare::CreateRoot(it.Get(), share); | 
| 156     } | 164     } | 
| 157   } | 165   } | 
| 158 | 166 | 
| 159   // Simulate cleaning up disabled types. |  | 
| 160   // TODO(sync): consider only cleaning those types that were recently disabled, |  | 
| 161   // if this isn't the first cleanup, which more accurately reflects the |  | 
| 162   // behavior of the real cleanup logic. |  | 
| 163   initial_sync_ended_types_.RemoveAll(to_purge); |  | 
| 164   progress_marker_types_.RemoveAll(to_purge); |  | 
| 165   cleaned_types_.PutAll(to_purge); |  | 
| 166 |  | 
| 167   // Now simulate the actual configuration for those types that successfully | 167   // Now simulate the actual configuration for those types that successfully | 
| 168   // download + apply. | 168   // download + apply. | 
| 169   progress_marker_types_.PutAll(success_types); | 169   progress_marker_types_.PutAll(success_types); | 
| 170   initial_sync_ended_types_.PutAll(success_types); | 170   initial_sync_ended_types_.PutAll(success_types); | 
| 171   downloaded_types_.PutAll(success_types); | 171   downloaded_types_.PutAll(success_types); | 
| 172 | 172 | 
| 173   ready_task.Run(); | 173   ready_task.Run(); | 
| 174 } | 174 } | 
| 175 | 175 | 
| 176 void FakeSyncManager::AddObserver(Observer* observer) { | 176 void FakeSyncManager::AddObserver(Observer* observer) { | 
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 262 } | 262 } | 
| 263 | 263 | 
| 264 void FakeSyncManager::OnCookieJarChanged(bool account_mismatch, | 264 void FakeSyncManager::OnCookieJarChanged(bool account_mismatch, | 
| 265                                          bool empty_jar) {} | 265                                          bool empty_jar) {} | 
| 266 | 266 | 
| 267 void FakeSyncManager::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) { | 267 void FakeSyncManager::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) { | 
| 268   NOTIMPLEMENTED(); | 268   NOTIMPLEMENTED(); | 
| 269 } | 269 } | 
| 270 | 270 | 
| 271 }  // namespace syncer | 271 }  // namespace syncer | 
| OLD | NEW | 
|---|