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

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

Powered by Google App Engine
This is Rietveld 408576698