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

Side by Side Diff: sync/internal_api/test/fake_sync_manager.cc

Issue 10701085: Revert "Revert 142517 - [Sync] Refactor sync configuration logic." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix deps Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "sync/internal_api/public/test/fake_sync_manager.h"
6
7 #include "sync/internal_api/public/http_post_provider_factory.h"
8 #include "sync/internal_api/public/util/weak_handle.h"
9 #include "sync/notifier/sync_notifier.h"
10
11 namespace syncer {
12
13 FakeSyncManager::FakeSyncManager(std::string name)
14 : SyncManager(name) {}
15 FakeSyncManager::~FakeSyncManager() {
16 }
17
18 void FakeSyncManager::set_initial_sync_ended_types(
19 syncer::ModelTypeSet types) {
20 initial_sync_ended_types_ = types;
21 }
22
23 void FakeSyncManager::set_progress_marker_types(
24 syncer::ModelTypeSet types) {
25 progress_marker_types_ = types;
26 }
27
28 void FakeSyncManager::set_configure_fail_types(syncer::ModelTypeSet types) {
29 configure_fail_types_ = types;
30 }
31
32 syncer::ModelTypeSet FakeSyncManager::GetAndResetCleanedTypes() {
33 syncer::ModelTypeSet cleaned_types = cleaned_types_;
34 cleaned_types_.Clear();
35 return cleaned_types;
36 }
37
38 syncer::ModelTypeSet FakeSyncManager::GetAndResetDownloadedTypes() {
39 syncer::ModelTypeSet downloaded_types = downloaded_types_;
40 downloaded_types_.Clear();
41 return downloaded_types;
42 }
43
44 bool FakeSyncManager::Init(
45 const FilePath& database_location,
46 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
47 const std::string& sync_server_and_path,
48 int sync_server_port,
49 bool use_ssl,
50 const scoped_refptr<base::TaskRunner>& blocking_task_runner,
51 scoped_ptr<HttpPostProviderFactory> post_factory,
52 const syncer::ModelSafeRoutingInfo& model_safe_routing_info,
53 const std::vector<syncer::ModelSafeWorker*>& workers,
54 syncer::ExtensionsActivityMonitor* extensions_activity_monitor,
55 ChangeDelegate* change_delegate,
56 const SyncCredentials& credentials,
57 scoped_ptr<syncer::SyncNotifier> sync_notifier,
58 const std::string& restored_key_for_bootstrapping,
59 TestingMode testing_mode,
60 syncer::Encryptor* encryptor,
61 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler,
62 syncer::ReportUnrecoverableErrorFunction
63 report_unrecoverable_error_function) {
64 FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
65 OnInitializationComplete(
66 syncer::WeakHandle<syncer::JsBackend>(),
67 true));
68 return true;
69 }
70
71 syncer::ModelTypeSet FakeSyncManager::InitialSyncEndedTypes() {
72 return initial_sync_ended_types_;
73 }
74
75 syncer::ModelTypeSet FakeSyncManager::GetTypesWithEmptyProgressMarkerToken(
76 syncer::ModelTypeSet types) {
77 syncer::ModelTypeSet empty_types = types;
78 empty_types.RemoveAll(progress_marker_types_);
79 return empty_types;
80 }
81
82 void FakeSyncManager::UpdateEnabledTypes(const syncer::ModelTypeSet& types) {
83 }
84
85 void FakeSyncManager::ConfigureSyncer(
86 ConfigureReason reason,
87 const syncer::ModelTypeSet& types_to_config,
88 const syncer::ModelSafeRoutingInfo& new_routing_info,
89 const base::Closure& ready_task,
90 const base::Closure& retry_task) {
91 syncer::ModelTypeSet enabled_types = GetRoutingInfoTypes(new_routing_info);
92 syncer::ModelTypeSet disabled_types = Difference(
93 syncer::ModelTypeSet::All(), enabled_types);
94 syncer::ModelTypeSet success_types = types_to_config;
95 success_types.RemoveAll(configure_fail_types_);
96
97 DVLOG(1) << "Faking configuration. Downloading: "
98 << syncer::ModelTypeSetToString(success_types) << ". Cleaning: "
99 << syncer::ModelTypeSetToString(disabled_types);
100
101 // Simulate cleaning up disabled types.
102 // TODO(sync): consider only cleaning those types that were recently disabled,
103 // if this isn't the first cleanup, which more accurately reflects the
104 // behavior of the real cleanup logic.
105 initial_sync_ended_types_.RemoveAll(disabled_types);
106 progress_marker_types_.RemoveAll(disabled_types);
107 cleaned_types_.PutAll(disabled_types);
108
109 // Now simulate the actual configuration for those types that successfully
110 // download + apply.
111 progress_marker_types_.PutAll(success_types);
112 initial_sync_ended_types_.PutAll(success_types);
113 downloaded_types_.PutAll(success_types);
114
115 ready_task.Run();
116 }
117
118 void FakeSyncManager::AddObserver(Observer* observer) {
119 observers_.AddObserver(observer);
120 }
121
122 void FakeSyncManager::RemoveObserver(Observer* observer) {
123 observers_.RemoveObserver(observer);
124 }
125
126 void FakeSyncManager::ShutdownOnSyncThread() {
127 }
128
129 void FakeSyncManager::RefreshNigori(const std::string& chrome_version,
130 const base::Closure& done_callback) {
131 done_callback.Run();
132 }
133
134 bool FakeSyncManager::ReceivedExperiment(
135 syncer::Experiments* experiments) const {
136 return false;
137 }
138
139 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698