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

Side by Side Diff: components/browser_sync/browser/profile_sync_test_util.cc

Issue 1705813002: Remove //chrome and //content deps from ProfileSyncServiceBookmarkTest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@586642_pre-clean-up
Patch Set: Just rebased Created 4 years, 10 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
« no previous file with comments | « components/browser_sync/browser/profile_sync_test_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/browser_sync/browser/profile_sync_test_util.h" 5 #include "components/browser_sync/browser/profile_sync_test_util.h"
6 6
7 #include "components/bookmarks/browser/bookmark_model.h"
7 #include "components/history/core/browser/history_model_worker.h" 8 #include "components/history/core/browser/history_model_worker.h"
8 #include "components/pref_registry/pref_registry_syncable.h" 9 #include "components/pref_registry/pref_registry_syncable.h"
9 #include "components/signin/core/browser/signin_manager_base.h" 10 #include "components/signin/core/browser/signin_manager_base.h"
10 #include "components/sync_driver/glue/browser_thread_model_worker.h" 11 #include "components/sync_driver/glue/browser_thread_model_worker.h"
11 #include "components/sync_driver/glue/ui_model_worker.h" 12 #include "components/sync_driver/glue/ui_model_worker.h"
12 #include "components/sync_driver/signin_manager_wrapper.h" 13 #include "components/sync_driver/signin_manager_wrapper.h"
13 #include "components/sync_driver/sync_prefs.h" 14 #include "components/sync_driver/sync_prefs.h"
14 #include "net/url_request/url_request_test_util.h" 15 #include "net/url_request/url_request_test_util.h"
15 #include "sync/internal_api/public/engine/passive_model_worker.h" 16 #include "sync/internal_api/public/engine/passive_model_worker.h"
16 17
17 using sync_driver::ClearBrowsingDataCallback; 18 using sync_driver::ClearBrowsingDataCallback;
18 19
19 namespace browser_sync { 20 namespace browser_sync {
20 21
21 namespace { 22 namespace {
22 23
23 class BundleSyncClient : public sync_driver::FakeSyncClient { 24 class BundleSyncClient : public sync_driver::FakeSyncClient {
24 public: 25 public:
25 BundleSyncClient( 26 BundleSyncClient(
26 sync_driver::SyncApiComponentFactory* factory, 27 sync_driver::SyncApiComponentFactory* factory,
27 PrefService* pref_service, 28 PrefService* pref_service,
28 const ClearBrowsingDataCallback& clear_browsing_data_callback, 29 const ClearBrowsingDataCallback& clear_browsing_data_callback,
29 sync_sessions::SyncSessionsClient* sync_sessions_client, 30 sync_sessions::SyncSessionsClient* sync_sessions_client,
30 autofill::PersonalDataManager* personal_data_manager, 31 autofill::PersonalDataManager* personal_data_manager,
31 const base::Callback<base::WeakPtr<syncer::SyncableService>( 32 const base::Callback<base::WeakPtr<syncer::SyncableService>(
32 syncer::ModelType type)>& get_syncable_service_callback, 33 syncer::ModelType type)>& get_syncable_service_callback,
33 const base::Callback<sync_driver::SyncService*(void)>& 34 const base::Callback<sync_driver::SyncService*(void)>&
34 get_sync_service_callback, 35 get_sync_service_callback,
36 const base::Callback<bookmarks::BookmarkModel*(void)>&
37 get_bookmark_model_callback,
35 scoped_refptr<base::SingleThreadTaskRunner> db_thread, 38 scoped_refptr<base::SingleThreadTaskRunner> db_thread,
36 scoped_refptr<base::SingleThreadTaskRunner> file_thread, 39 scoped_refptr<base::SingleThreadTaskRunner> file_thread,
37 history::HistoryService* history_service); 40 history::HistoryService* history_service);
38 41
39 ~BundleSyncClient() override; 42 ~BundleSyncClient() override;
40 43
41 PrefService* GetPrefService() override; 44 PrefService* GetPrefService() override;
42 ClearBrowsingDataCallback GetClearBrowsingDataCallback() override; 45 ClearBrowsingDataCallback GetClearBrowsingDataCallback() override;
43 sync_sessions::SyncSessionsClient* GetSyncSessionsClient() override; 46 sync_sessions::SyncSessionsClient* GetSyncSessionsClient() override;
44 autofill::PersonalDataManager* GetPersonalDataManager() override; 47 autofill::PersonalDataManager* GetPersonalDataManager() override;
45 base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType( 48 base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType(
46 syncer::ModelType type) override; 49 syncer::ModelType type) override;
47 sync_driver::SyncService* GetSyncService() override; 50 sync_driver::SyncService* GetSyncService() override;
48 scoped_refptr<syncer::ModelSafeWorker> CreateModelWorkerForGroup( 51 scoped_refptr<syncer::ModelSafeWorker> CreateModelWorkerForGroup(
49 syncer::ModelSafeGroup group, 52 syncer::ModelSafeGroup group,
50 syncer::WorkerLoopDestructionObserver* observer) override; 53 syncer::WorkerLoopDestructionObserver* observer) override;
51 history::HistoryService* GetHistoryService() override; 54 history::HistoryService* GetHistoryService() override;
55 bookmarks::BookmarkModel* GetBookmarkModel() override;
52 56
53 private: 57 private:
54 PrefService* const pref_service_; 58 PrefService* const pref_service_;
55 const ClearBrowsingDataCallback clear_browsing_data_callback_; 59 const ClearBrowsingDataCallback clear_browsing_data_callback_;
56 sync_sessions::SyncSessionsClient* const sync_sessions_client_; 60 sync_sessions::SyncSessionsClient* const sync_sessions_client_;
57 autofill::PersonalDataManager* const personal_data_manager_; 61 autofill::PersonalDataManager* const personal_data_manager_;
58 const base::Callback<base::WeakPtr<syncer::SyncableService>( 62 const base::Callback<base::WeakPtr<syncer::SyncableService>(
59 syncer::ModelType type)> 63 syncer::ModelType type)>
60 get_syncable_service_callback_; 64 get_syncable_service_callback_;
61 const base::Callback<sync_driver::SyncService*(void)> 65 const base::Callback<sync_driver::SyncService*(void)>
62 get_sync_service_callback_; 66 get_sync_service_callback_;
67 const base::Callback<bookmarks::BookmarkModel*(void)>
68 get_bookmark_model_callback_;
63 // These task runners, if not null, are used in CreateModelWorkerForGroup. 69 // These task runners, if not null, are used in CreateModelWorkerForGroup.
64 const scoped_refptr<base::SingleThreadTaskRunner> db_thread_; 70 const scoped_refptr<base::SingleThreadTaskRunner> db_thread_;
65 const scoped_refptr<base::SingleThreadTaskRunner> file_thread_; 71 const scoped_refptr<base::SingleThreadTaskRunner> file_thread_;
66 history::HistoryService* history_service_; 72 history::HistoryService* history_service_;
67 }; 73 };
68 74
69 BundleSyncClient::BundleSyncClient( 75 BundleSyncClient::BundleSyncClient(
70 sync_driver::SyncApiComponentFactory* factory, 76 sync_driver::SyncApiComponentFactory* factory,
71 PrefService* pref_service, 77 PrefService* pref_service,
72 const ClearBrowsingDataCallback& clear_browsing_data_callback, 78 const ClearBrowsingDataCallback& clear_browsing_data_callback,
73 sync_sessions::SyncSessionsClient* sync_sessions_client, 79 sync_sessions::SyncSessionsClient* sync_sessions_client,
74 autofill::PersonalDataManager* personal_data_manager, 80 autofill::PersonalDataManager* personal_data_manager,
75 const base::Callback<base::WeakPtr<syncer::SyncableService>( 81 const base::Callback<base::WeakPtr<syncer::SyncableService>(
76 syncer::ModelType type)>& get_syncable_service_callback, 82 syncer::ModelType type)>& get_syncable_service_callback,
77 const base::Callback<sync_driver::SyncService*(void)>& 83 const base::Callback<sync_driver::SyncService*(void)>&
78 get_sync_service_callback, 84 get_sync_service_callback,
85 const base::Callback<bookmarks::BookmarkModel*(void)>&
86 get_bookmark_model_callback,
79 scoped_refptr<base::SingleThreadTaskRunner> db_thread, 87 scoped_refptr<base::SingleThreadTaskRunner> db_thread,
80 scoped_refptr<base::SingleThreadTaskRunner> file_thread, 88 scoped_refptr<base::SingleThreadTaskRunner> file_thread,
81 history::HistoryService* history_service) 89 history::HistoryService* history_service)
82 : sync_driver::FakeSyncClient(factory), 90 : sync_driver::FakeSyncClient(factory),
83 pref_service_(pref_service), 91 pref_service_(pref_service),
84 clear_browsing_data_callback_(clear_browsing_data_callback), 92 clear_browsing_data_callback_(clear_browsing_data_callback),
85 sync_sessions_client_(sync_sessions_client), 93 sync_sessions_client_(sync_sessions_client),
86 personal_data_manager_(personal_data_manager), 94 personal_data_manager_(personal_data_manager),
87 get_syncable_service_callback_(get_syncable_service_callback), 95 get_syncable_service_callback_(get_syncable_service_callback),
88 get_sync_service_callback_(get_sync_service_callback), 96 get_sync_service_callback_(get_sync_service_callback),
97 get_bookmark_model_callback_(get_bookmark_model_callback),
89 db_thread_(db_thread), 98 db_thread_(db_thread),
90 file_thread_(file_thread), 99 file_thread_(file_thread),
91 history_service_(history_service) { 100 history_service_(history_service) {
92 DCHECK_EQ(!!db_thread_, !!file_thread_); 101 DCHECK_EQ(!!db_thread_, !!file_thread_);
93 } 102 }
94 103
95 BundleSyncClient::~BundleSyncClient() = default; 104 BundleSyncClient::~BundleSyncClient() = default;
96 105
97 PrefService* BundleSyncClient::GetPrefService() { 106 PrefService* BundleSyncClient::GetPrefService() {
98 return pref_service_; 107 return pref_service_;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 return nullptr; 162 return nullptr;
154 } 163 }
155 } 164 }
156 165
157 history::HistoryService* BundleSyncClient::GetHistoryService() { 166 history::HistoryService* BundleSyncClient::GetHistoryService() {
158 if (history_service_) 167 if (history_service_)
159 return history_service_; 168 return history_service_;
160 return FakeSyncClient::GetHistoryService(); 169 return FakeSyncClient::GetHistoryService();
161 } 170 }
162 171
172 bookmarks::BookmarkModel* BundleSyncClient::GetBookmarkModel() {
173 if (get_bookmark_model_callback_.is_null())
174 return FakeSyncClient::GetBookmarkModel();
175 return get_bookmark_model_callback_.Run();
176 }
177
163 } // namespace 178 } // namespace
164 179
165 void EmptyNetworkTimeUpdate(const base::Time&, 180 void EmptyNetworkTimeUpdate(const base::Time&,
166 const base::TimeDelta&, 181 const base::TimeDelta&,
167 const base::TimeDelta&) {} 182 const base::TimeDelta&) {}
168 183
169 void RegisterPrefsForProfileSyncService( 184 void RegisterPrefsForProfileSyncService(
170 user_prefs::PrefRegistrySyncable* registry) { 185 user_prefs::PrefRegistrySyncable* registry) {
171 sync_driver::SyncPrefs::RegisterProfilePrefs(registry); 186 sync_driver::SyncPrefs::RegisterProfilePrefs(registry);
172 AccountTrackerService::RegisterPrefs(registry); 187 AccountTrackerService::RegisterPrefs(registry);
(...skipping 29 matching lines...) Expand all
202 const base::Callback<sync_driver::SyncService*(void)>& 217 const base::Callback<sync_driver::SyncService*(void)>&
203 get_sync_service_callback) { 218 get_sync_service_callback) {
204 get_sync_service_callback_ = get_sync_service_callback; 219 get_sync_service_callback_ = get_sync_service_callback;
205 } 220 }
206 221
207 void ProfileSyncServiceBundle::SyncClientBuilder::SetHistoryService( 222 void ProfileSyncServiceBundle::SyncClientBuilder::SetHistoryService(
208 history::HistoryService* history_service) { 223 history::HistoryService* history_service) {
209 history_service_ = history_service; 224 history_service_ = history_service;
210 } 225 }
211 226
227 void ProfileSyncServiceBundle::SyncClientBuilder::SetBookmarkModelCallback(
228 const base::Callback<bookmarks::BookmarkModel*(void)>&
229 get_bookmark_model_callback) {
230 get_bookmark_model_callback_ = get_bookmark_model_callback;
231 }
232
212 scoped_ptr<sync_driver::FakeSyncClient> 233 scoped_ptr<sync_driver::FakeSyncClient>
213 ProfileSyncServiceBundle::SyncClientBuilder::Build() { 234 ProfileSyncServiceBundle::SyncClientBuilder::Build() {
214 return make_scoped_ptr(new BundleSyncClient( 235 return make_scoped_ptr(new BundleSyncClient(
215 bundle_->component_factory(), bundle_->pref_service(), 236 bundle_->component_factory(), bundle_->pref_service(),
216 clear_browsing_data_callback_, bundle_->sync_sessions_client(), 237 clear_browsing_data_callback_, bundle_->sync_sessions_client(),
217 personal_data_manager_, get_syncable_service_callback_, 238 personal_data_manager_, get_syncable_service_callback_,
218 get_sync_service_callback_, 239 get_sync_service_callback_, get_bookmark_model_callback_,
219 activate_model_creation_ ? bundle_->db_thread() : nullptr, 240 activate_model_creation_ ? bundle_->db_thread() : nullptr,
220 activate_model_creation_ ? base::ThreadTaskRunnerHandle::Get() : nullptr, 241 activate_model_creation_ ? base::ThreadTaskRunnerHandle::Get() : nullptr,
221 history_service_)); 242 history_service_));
222 } 243 }
223 244
224 ProfileSyncServiceBundle::ProfileSyncServiceBundle() 245 ProfileSyncServiceBundle::ProfileSyncServiceBundle()
225 : db_thread_(base::ThreadTaskRunnerHandle::Get()), 246 : db_thread_(base::ThreadTaskRunnerHandle::Get()),
226 worker_pool_owner_(2, "sync test worker pool"), 247 worker_pool_owner_(2, "sync test worker pool"),
227 signin_client_(&pref_service_), 248 signin_client_(&pref_service_),
228 #if defined(OS_CHROMEOS) 249 #if defined(OS_CHROMEOS)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 init_params.debug_identifier = "dummyDebugName"; 281 init_params.debug_identifier = "dummyDebugName";
261 init_params.channel = version_info::Channel::UNKNOWN; 282 init_params.channel = version_info::Channel::UNKNOWN;
262 init_params.db_thread = db_thread_; 283 init_params.db_thread = db_thread_;
263 init_params.file_thread = base::ThreadTaskRunnerHandle::Get(); 284 init_params.file_thread = base::ThreadTaskRunnerHandle::Get();
264 init_params.blocking_pool = worker_pool_owner_.pool().get(); 285 init_params.blocking_pool = worker_pool_owner_.pool().get();
265 286
266 return init_params; 287 return init_params;
267 } 288 }
268 289
269 } // namespace browser_sync 290 } // namespace browser_sync
OLDNEW
« no previous file with comments | « components/browser_sync/browser/profile_sync_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698