Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: components/sync/engine/fake_sync_manager.cc

Issue 2644373003: Revert of [Sync] Make directory types registration explicit in ModelTypeRegistry (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/sequenced_task_runner.h" 15 #include "base/sequenced_task_runner.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "components/sync/base/weak_handle.h" 18 #include "components/sync/base/weak_handle.h"
19 #include "components/sync/engine/engine_components_factory.h" 19 #include "components/sync/engine/engine_components_factory.h"
20 #include "components/sync/engine/fake_model_type_connector.h"
20 #include "components/sync/engine/net/http_post_provider_factory.h" 21 #include "components/sync/engine/net/http_post_provider_factory.h"
21 #include "components/sync/syncable/directory.h" 22 #include "components/sync/syncable/directory.h"
23 #include "components/sync/test/fake_sync_encryption_handler.h"
22 24
23 class GURL; 25 class GURL;
24 26
25 namespace syncer { 27 namespace syncer {
26 28
27 FakeSyncManager::FakeSyncManager(ModelTypeSet initial_sync_ended_types, 29 FakeSyncManager::FakeSyncManager(ModelTypeSet initial_sync_ended_types,
28 ModelTypeSet progress_marker_types, 30 ModelTypeSet progress_marker_types,
29 ModelTypeSet configure_fail_types) 31 ModelTypeSet configure_fail_types)
30 : initial_sync_ended_types_(initial_sync_ended_types), 32 : initial_sync_ended_types_(initial_sync_ended_types),
31 progress_marker_types_(progress_marker_types), 33 progress_marker_types_(progress_marker_types),
32 configure_fail_types_(configure_fail_types), 34 configure_fail_types_(configure_fail_types),
33 last_configure_reason_(CONFIGURE_REASON_UNKNOWN), 35 last_configure_reason_(CONFIGURE_REASON_UNKNOWN),
34 num_invalidations_received_(0) {} 36 num_invalidations_received_(0) {
37 fake_encryption_handler_ = base::MakeUnique<FakeSyncEncryptionHandler>();
38 }
35 39
36 FakeSyncManager::~FakeSyncManager() {} 40 FakeSyncManager::~FakeSyncManager() {}
37 41
38 ModelTypeSet FakeSyncManager::GetAndResetPurgedTypes() { 42 ModelTypeSet FakeSyncManager::GetAndResetPurgedTypes() {
39 ModelTypeSet purged_types = purged_types_; 43 ModelTypeSet purged_types = purged_types_;
40 purged_types_.Clear(); 44 purged_types_.Clear();
41 return purged_types; 45 return purged_types;
42 } 46 }
43 47
44 ModelTypeSet FakeSyncManager::GetAndResetUnappliedTypes() { 48 ModelTypeSet FakeSyncManager::GetAndResetUnappliedTypes() {
45 ModelTypeSet unapplied_types = unapplied_types_; 49 ModelTypeSet unapplied_types = unapplied_types_;
46 unapplied_types_.Clear(); 50 unapplied_types_.Clear();
47 return unapplied_types; 51 return unapplied_types;
48 } 52 }
49 53
50 ModelTypeSet FakeSyncManager::GetAndResetDownloadedTypes() { 54 ModelTypeSet FakeSyncManager::GetAndResetDownloadedTypes() {
51 ModelTypeSet downloaded_types = downloaded_types_; 55 ModelTypeSet downloaded_types = downloaded_types_;
52 downloaded_types_.Clear(); 56 downloaded_types_.Clear();
53 return downloaded_types; 57 return downloaded_types;
54 } 58 }
55 59
60 ModelTypeSet FakeSyncManager::GetAndResetEnabledTypes() {
61 ModelTypeSet enabled_types = enabled_types_;
62 enabled_types_.Clear();
63 return enabled_types;
64 }
65
56 ConfigureReason FakeSyncManager::GetAndResetConfigureReason() { 66 ConfigureReason FakeSyncManager::GetAndResetConfigureReason() {
57 ConfigureReason reason = last_configure_reason_; 67 ConfigureReason reason = last_configure_reason_;
58 last_configure_reason_ = CONFIGURE_REASON_UNKNOWN; 68 last_configure_reason_ = CONFIGURE_REASON_UNKNOWN;
59 return reason; 69 return reason;
60 } 70 }
61 71
62 int FakeSyncManager::GetInvalidationCount() const { 72 int FakeSyncManager::GetInvalidationCount() const {
63 return num_invalidations_received_; 73 return num_invalidations_received_;
64 } 74 }
65 75
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // Types from |to_unapply| should retain their server data and progress 137 // Types from |to_unapply| should retain their server data and progress
128 // markers. 138 // markers.
129 initial_sync_ended_types_.RemoveAll(Difference(to_purge, to_unapply)); 139 initial_sync_ended_types_.RemoveAll(Difference(to_purge, to_unapply));
130 progress_marker_types_.RemoveAll(Difference(to_purge, to_unapply)); 140 progress_marker_types_.RemoveAll(Difference(to_purge, to_unapply));
131 } 141 }
132 142
133 void FakeSyncManager::UpdateCredentials(const SyncCredentials& credentials) { 143 void FakeSyncManager::UpdateCredentials(const SyncCredentials& credentials) {
134 NOTIMPLEMENTED(); 144 NOTIMPLEMENTED();
135 } 145 }
136 146
137 void FakeSyncManager::StartSyncingNormally(base::Time last_poll_time) { 147 void FakeSyncManager::StartSyncingNormally(
138 // Do nothing. 148 const ModelSafeRoutingInfo& routing_info,
139 } 149 base::Time last_poll_time) {
140
141 void FakeSyncManager::StartConfiguration() {
142 // Do nothing. 150 // Do nothing.
143 } 151 }
144 152
145 void FakeSyncManager::ConfigureSyncer( 153 void FakeSyncManager::ConfigureSyncer(
146 ConfigureReason reason, 154 ConfigureReason reason,
147 ModelTypeSet to_download, 155 ModelTypeSet to_download,
156 const ModelSafeRoutingInfo& new_routing_info,
148 const base::Closure& ready_task, 157 const base::Closure& ready_task,
149 const base::Closure& retry_task) { 158 const base::Closure& retry_task) {
150 last_configure_reason_ = reason; 159 last_configure_reason_ = reason;
160 enabled_types_ = GetRoutingInfoTypes(new_routing_info);
151 ModelTypeSet success_types = to_download; 161 ModelTypeSet success_types = to_download;
152 success_types.RemoveAll(configure_fail_types_); 162 success_types.RemoveAll(configure_fail_types_);
153 163
154 DVLOG(1) << "Faking configuration. Downloading: " 164 DVLOG(1) << "Faking configuration. Downloading: "
155 << ModelTypeSetToString(success_types); 165 << ModelTypeSetToString(success_types);
156 166
157 // Update our fake directory by clearing and fake-downloading as necessary. 167 // Update our fake directory by clearing and fake-downloading as necessary.
158 UserShare* share = GetUserShare(); 168 UserShare* share = GetUserShare();
159 for (ModelTypeSet::Iterator it = success_types.First(); it.Good(); it.Inc()) { 169 for (ModelTypeSet::Iterator it = success_types.First(); it.Good(); it.Inc()) {
160 // We must be careful to not create the same root node twice. 170 // We must be careful to not create the same root node twice.
(...skipping 30 matching lines...) Expand all
191 201
192 void FakeSyncManager::ShutdownOnSyncThread(ShutdownReason reason) { 202 void FakeSyncManager::ShutdownOnSyncThread(ShutdownReason reason) {
193 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); 203 DCHECK(sync_task_runner_->RunsTasksOnCurrentThread());
194 test_user_share_.TearDown(); 204 test_user_share_.TearDown();
195 } 205 }
196 206
197 UserShare* FakeSyncManager::GetUserShare() { 207 UserShare* FakeSyncManager::GetUserShare() {
198 return test_user_share_.user_share(); 208 return test_user_share_.user_share();
199 } 209 }
200 210
201 ModelTypeConnector* FakeSyncManager::GetModelTypeConnector() {
202 return &fake_model_type_connector_;
203 }
204
205 std::unique_ptr<ModelTypeConnector> 211 std::unique_ptr<ModelTypeConnector>
206 FakeSyncManager::GetModelTypeConnectorProxy() { 212 FakeSyncManager::GetModelTypeConnectorProxy() {
207 return base::MakeUnique<FakeModelTypeConnector>(); 213 return base::MakeUnique<FakeModelTypeConnector>();
208 } 214 }
209 215
210 const std::string FakeSyncManager::cache_guid() { 216 const std::string FakeSyncManager::cache_guid() {
211 return test_user_share_.user_share()->directory->cache_guid(); 217 return test_user_share_.user_share()->directory->cache_guid();
212 } 218 }
213 219
214 bool FakeSyncManager::ReceivedExperiment(Experiments* experiments) { 220 bool FakeSyncManager::ReceivedExperiment(Experiments* experiments) {
215 return false; 221 return false;
216 } 222 }
217 223
218 bool FakeSyncManager::HasUnsyncedItems() { 224 bool FakeSyncManager::HasUnsyncedItems() {
219 NOTIMPLEMENTED(); 225 NOTIMPLEMENTED();
220 return false; 226 return false;
221 } 227 }
222 228
223 SyncEncryptionHandler* FakeSyncManager::GetEncryptionHandler() { 229 SyncEncryptionHandler* FakeSyncManager::GetEncryptionHandler() {
224 return &fake_encryption_handler_; 230 return fake_encryption_handler_.get();
225 } 231 }
226 232
227 std::vector<std::unique_ptr<ProtocolEvent>> 233 std::vector<std::unique_ptr<ProtocolEvent>>
228 FakeSyncManager::GetBufferedProtocolEvents() { 234 FakeSyncManager::GetBufferedProtocolEvents() {
229 return std::vector<std::unique_ptr<ProtocolEvent>>(); 235 return std::vector<std::unique_ptr<ProtocolEvent>>();
230 } 236 }
231 237
232 void FakeSyncManager::RefreshTypes(ModelTypeSet types) { 238 void FakeSyncManager::RefreshTypes(ModelTypeSet types) {
233 last_refresh_request_types_ = types; 239 last_refresh_request_types_ = types;
234 } 240 }
(...skipping 30 matching lines...) Expand all
265 } 271 }
266 272
267 void FakeSyncManager::OnCookieJarChanged(bool account_mismatch, 273 void FakeSyncManager::OnCookieJarChanged(bool account_mismatch,
268 bool empty_jar) {} 274 bool empty_jar) {}
269 275
270 void FakeSyncManager::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) { 276 void FakeSyncManager::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) {
271 NOTIMPLEMENTED(); 277 NOTIMPLEMENTED();
272 } 278 }
273 279
274 } // namespace syncer 280 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/engine/fake_sync_manager.h ('k') | components/sync/engine/model_type_configurer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698