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

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

Powered by Google App Engine
This is Rietveld 408576698