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

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

Issue 2799653006: Revert of [Sync] Stop accessing BrowserContextKeyedServiceFactory on non-UI thread. (Closed)
Patch Set: Created 3 years, 8 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 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/profile_sync_test_util.h" 5 #include "components/browser_sync/profile_sync_test_util.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "components/bookmarks/browser/bookmark_model.h" 11 #include "components/bookmarks/browser/bookmark_model.h"
12 #include "components/history/core/browser/history_model_worker.h" 12 #include "components/history/core/browser/history_model_worker.h"
13 #include "components/history/core/browser/history_service.h" 13 #include "components/history/core/browser/history_service.h"
14 #include "components/pref_registry/pref_registry_syncable.h" 14 #include "components/pref_registry/pref_registry_syncable.h"
15 #include "components/signin/core/browser/signin_manager_base.h" 15 #include "components/signin/core/browser/signin_manager_base.h"
16 #include "components/sync/base/sync_prefs.h" 16 #include "components/sync/base/sync_prefs.h"
17 #include "components/sync/driver/signin_manager_wrapper.h" 17 #include "components/sync/driver/signin_manager_wrapper.h"
18 #include "components/sync/engine/browser_thread_model_worker.h" 18 #include "components/sync/engine/browser_thread_model_worker.h"
19 #include "components/sync/engine/passive_model_worker.h" 19 #include "components/sync/engine/passive_model_worker.h"
20 #include "components/sync/engine/ui_model_worker.h" 20 #include "components/sync/engine/ui_model_worker.h"
21 #include "net/url_request/url_request_test_util.h" 21 #include "net/url_request/url_request_test_util.h"
22 22
23 using ServiceProvider = syncer::SyncClient::ServiceProvider;
24
25 namespace browser_sync { 23 namespace browser_sync {
26 24
27 namespace { 25 namespace {
28 26
29 class BundleSyncClient : public syncer::FakeSyncClient { 27 class BundleSyncClient : public syncer::FakeSyncClient {
30 public: 28 public:
31 BundleSyncClient(syncer::SyncApiComponentFactory* factory, 29 BundleSyncClient(syncer::SyncApiComponentFactory* factory,
32 PrefService* pref_service, 30 PrefService* pref_service,
33 sync_sessions::SyncSessionsClient* sync_sessions_client, 31 sync_sessions::SyncSessionsClient* sync_sessions_client,
34 autofill::PersonalDataManager* personal_data_manager, 32 autofill::PersonalDataManager* personal_data_manager,
35 const base::Callback<base::WeakPtr<syncer::SyncableService>( 33 const base::Callback<base::WeakPtr<syncer::SyncableService>(
36 syncer::ModelType type)>& get_syncable_service_callback, 34 syncer::ModelType type)>& get_syncable_service_callback,
37 const base::Callback<syncer::SyncService*(void)>& 35 const base::Callback<syncer::SyncService*(void)>&
38 get_sync_service_callback, 36 get_sync_service_callback,
39 const base::Callback<bookmarks::BookmarkModel*(void)>& 37 const base::Callback<bookmarks::BookmarkModel*(void)>&
40 get_bookmark_model_callback, 38 get_bookmark_model_callback,
41 scoped_refptr<base::SingleThreadTaskRunner> db_thread, 39 scoped_refptr<base::SingleThreadTaskRunner> db_thread,
42 scoped_refptr<base::SingleThreadTaskRunner> file_thread, 40 scoped_refptr<base::SingleThreadTaskRunner> file_thread,
43 history::HistoryService* history_service); 41 history::HistoryService* history_service);
44 42
45 ~BundleSyncClient() override; 43 ~BundleSyncClient() override;
46 44
47 PrefService* GetPrefService() override; 45 PrefService* GetPrefService() override;
48 sync_sessions::SyncSessionsClient* GetSyncSessionsClient() override; 46 sync_sessions::SyncSessionsClient* GetSyncSessionsClient() override;
49 autofill::PersonalDataManager* GetPersonalDataManager() override; 47 autofill::PersonalDataManager* GetPersonalDataManager() override;
50 ServiceProvider GetSyncableServiceForType(syncer::ModelType type) override; 48 base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType(
49 syncer::ModelType type) override;
51 syncer::SyncService* GetSyncService() override; 50 syncer::SyncService* GetSyncService() override;
52 scoped_refptr<syncer::ModelSafeWorker> CreateModelWorkerForGroup( 51 scoped_refptr<syncer::ModelSafeWorker> CreateModelWorkerForGroup(
53 syncer::ModelSafeGroup group) override; 52 syncer::ModelSafeGroup group) override;
54 history::HistoryService* GetHistoryService() override; 53 history::HistoryService* GetHistoryService() override;
55 bookmarks::BookmarkModel* GetBookmarkModel() override; 54 bookmarks::BookmarkModel* GetBookmarkModel() override;
56 55
57 private: 56 private:
58 PrefService* const pref_service_; 57 PrefService* const pref_service_;
59 sync_sessions::SyncSessionsClient* const sync_sessions_client_; 58 sync_sessions::SyncSessionsClient* const sync_sessions_client_;
60 autofill::PersonalDataManager* const personal_data_manager_; 59 autofill::PersonalDataManager* const personal_data_manager_;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 102 }
104 103
105 sync_sessions::SyncSessionsClient* BundleSyncClient::GetSyncSessionsClient() { 104 sync_sessions::SyncSessionsClient* BundleSyncClient::GetSyncSessionsClient() {
106 return sync_sessions_client_; 105 return sync_sessions_client_;
107 } 106 }
108 107
109 autofill::PersonalDataManager* BundleSyncClient::GetPersonalDataManager() { 108 autofill::PersonalDataManager* BundleSyncClient::GetPersonalDataManager() {
110 return personal_data_manager_; 109 return personal_data_manager_;
111 } 110 }
112 111
113 ServiceProvider BundleSyncClient::GetSyncableServiceForType( 112 base::WeakPtr<syncer::SyncableService>
114 syncer::ModelType type) { 113 BundleSyncClient::GetSyncableServiceForType(syncer::ModelType type) {
115 if (get_syncable_service_callback_.is_null()) 114 if (get_syncable_service_callback_.is_null())
116 return syncer::FakeSyncClient::GetSyncableServiceForType(type); 115 return syncer::FakeSyncClient::GetSyncableServiceForType(type);
117 return base::Bind(get_syncable_service_callback_, type); 116 return get_syncable_service_callback_.Run(type);
118 } 117 }
119 118
120 syncer::SyncService* BundleSyncClient::GetSyncService() { 119 syncer::SyncService* BundleSyncClient::GetSyncService() {
121 if (get_sync_service_callback_.is_null()) 120 if (get_sync_service_callback_.is_null())
122 return syncer::FakeSyncClient::GetSyncService(); 121 return syncer::FakeSyncClient::GetSyncService();
123 return get_sync_service_callback_.Run(); 122 return get_sync_service_callback_.Run();
124 } 123 }
125 124
126 scoped_refptr<syncer::ModelSafeWorker> 125 scoped_refptr<syncer::ModelSafeWorker>
127 BundleSyncClient::CreateModelWorkerForGroup(syncer::ModelSafeGroup group) { 126 BundleSyncClient::CreateModelWorkerForGroup(syncer::ModelSafeGroup group) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 base::Bind(&EmptyNetworkTimeUpdate); 259 base::Bind(&EmptyNetworkTimeUpdate);
261 init_params.base_directory = base::FilePath(FILE_PATH_LITERAL("dummyPath")); 260 init_params.base_directory = base::FilePath(FILE_PATH_LITERAL("dummyPath"));
262 init_params.url_request_context = url_request_context(); 261 init_params.url_request_context = url_request_context();
263 init_params.debug_identifier = "dummyDebugName"; 262 init_params.debug_identifier = "dummyDebugName";
264 init_params.channel = version_info::Channel::UNKNOWN; 263 init_params.channel = version_info::Channel::UNKNOWN;
265 264
266 return init_params; 265 return init_params;
267 } 266 }
268 267
269 } // namespace browser_sync 268 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698