| OLD | NEW |
| 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 #ifndef COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_TEST_UTIL_H_ | 5 #ifndef COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_TEST_UTIL_H_ |
| 6 #define COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_TEST_UTIL_H_ | 6 #define COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 autofill::PersonalDataManager* personal_data_manager); | 84 autofill::PersonalDataManager* personal_data_manager); |
| 85 | 85 |
| 86 // The client will call this callback to produce the SyncableService | 86 // The client will call this callback to produce the SyncableService |
| 87 // specific to |type|. | 87 // specific to |type|. |
| 88 void SetSyncableServiceCallback( | 88 void SetSyncableServiceCallback( |
| 89 const base::Callback<base::WeakPtr<syncer::SyncableService>( | 89 const base::Callback<base::WeakPtr<syncer::SyncableService>( |
| 90 syncer::ModelType type)>& get_syncable_service_callback); | 90 syncer::ModelType type)>& get_syncable_service_callback); |
| 91 | 91 |
| 92 // The client will call this callback to produce the SyncService for the | 92 // The client will call this callback to produce the SyncService for the |
| 93 // current Profile. | 93 // current Profile. |
| 94 void SetSyncServiceCallback( | 94 void SetSyncServiceCallback(const base::Callback<sync_driver::SyncService*( |
| 95 const base::Callback<syncer::SyncService*(void)>& | 95 void)>& get_sync_service_callback); |
| 96 get_sync_service_callback); | |
| 97 | 96 |
| 98 void SetHistoryService(history::HistoryService* history_service); | 97 void SetHistoryService(history::HistoryService* history_service); |
| 99 | 98 |
| 100 void SetBookmarkModelCallback( | 99 void SetBookmarkModelCallback( |
| 101 const base::Callback<bookmarks::BookmarkModel*(void)>& | 100 const base::Callback<bookmarks::BookmarkModel*(void)>& |
| 102 get_bookmark_model_callback); | 101 get_bookmark_model_callback); |
| 103 | 102 |
| 104 void set_activate_model_creation() { activate_model_creation_ = true; } | 103 void set_activate_model_creation() { activate_model_creation_ = true; } |
| 105 | 104 |
| 106 std::unique_ptr<syncer::FakeSyncClient> Build(); | 105 std::unique_ptr<sync_driver::FakeSyncClient> Build(); |
| 107 | 106 |
| 108 private: | 107 private: |
| 109 // Associated bundle to source objects from. | 108 // Associated bundle to source objects from. |
| 110 ProfileSyncServiceBundle* const bundle_; | 109 ProfileSyncServiceBundle* const bundle_; |
| 111 | 110 |
| 112 autofill::PersonalDataManager* personal_data_manager_; | 111 autofill::PersonalDataManager* personal_data_manager_; |
| 113 base::Callback<base::WeakPtr<syncer::SyncableService>( | 112 base::Callback<base::WeakPtr<syncer::SyncableService>( |
| 114 syncer::ModelType type)> | 113 syncer::ModelType type)> |
| 115 get_syncable_service_callback_; | 114 get_syncable_service_callback_; |
| 116 base::Callback<syncer::SyncService*(void)> get_sync_service_callback_; | 115 base::Callback<sync_driver::SyncService*(void)> get_sync_service_callback_; |
| 117 history::HistoryService* history_service_ = nullptr; | 116 history::HistoryService* history_service_ = nullptr; |
| 118 base::Callback<bookmarks::BookmarkModel*(void)> | 117 base::Callback<bookmarks::BookmarkModel*(void)> |
| 119 get_bookmark_model_callback_; | 118 get_bookmark_model_callback_; |
| 120 // If set, the built client will be able to build some ModelSafeWorker | 119 // If set, the built client will be able to build some ModelSafeWorker |
| 121 // instances. | 120 // instances. |
| 122 bool activate_model_creation_ = false; | 121 bool activate_model_creation_ = false; |
| 123 | 122 |
| 124 DISALLOW_COPY_AND_ASSIGN(SyncClientBuilder); | 123 DISALLOW_COPY_AND_ASSIGN(SyncClientBuilder); |
| 125 }; | 124 }; |
| 126 | 125 |
| 127 // Creates an InitParams instance with the specified |start_behavior| and | 126 // Creates an InitParams instance with the specified |start_behavior| and |
| 128 // |sync_client|, and fills the rest with dummy values and objects owned by | 127 // |sync_client|, and fills the rest with dummy values and objects owned by |
| 129 // the bundle. | 128 // the bundle. |
| 130 ProfileSyncService::InitParams CreateBasicInitParams( | 129 ProfileSyncService::InitParams CreateBasicInitParams( |
| 131 ProfileSyncService::StartBehavior start_behavior, | 130 ProfileSyncService::StartBehavior start_behavior, |
| 132 std::unique_ptr<syncer::SyncClient> sync_client); | 131 std::unique_ptr<sync_driver::SyncClient> sync_client); |
| 133 | 132 |
| 134 // Accessors | 133 // Accessors |
| 135 | 134 |
| 136 net::URLRequestContextGetter* url_request_context() { | 135 net::URLRequestContextGetter* url_request_context() { |
| 137 return url_request_context_.get(); | 136 return url_request_context_.get(); |
| 138 } | 137 } |
| 139 | 138 |
| 140 syncable_prefs::TestingPrefServiceSyncable* pref_service() { | 139 syncable_prefs::TestingPrefServiceSyncable* pref_service() { |
| 141 return &pref_service_; | 140 return &pref_service_; |
| 142 } | 141 } |
| 143 | 142 |
| 144 FakeProfileOAuth2TokenService* auth_service() { return &auth_service_; } | 143 FakeProfileOAuth2TokenService* auth_service() { return &auth_service_; } |
| 145 | 144 |
| 146 FakeSigninManagerType* signin_manager() { return &signin_manager_; } | 145 FakeSigninManagerType* signin_manager() { return &signin_manager_; } |
| 147 | 146 |
| 148 AccountTrackerService* account_tracker() { return &account_tracker_; } | 147 AccountTrackerService* account_tracker() { return &account_tracker_; } |
| 149 | 148 |
| 150 syncer::SyncApiComponentFactoryMock* component_factory() { | 149 SyncApiComponentFactoryMock* component_factory() { |
| 151 return &component_factory_; | 150 return &component_factory_; |
| 152 } | 151 } |
| 153 | 152 |
| 154 sync_sessions::FakeSyncSessionsClient* sync_sessions_client() { | 153 sync_sessions::FakeSyncSessionsClient* sync_sessions_client() { |
| 155 return &sync_sessions_client_; | 154 return &sync_sessions_client_; |
| 156 } | 155 } |
| 157 | 156 |
| 158 invalidation::FakeInvalidationService* fake_invalidation_service() { | 157 invalidation::FakeInvalidationService* fake_invalidation_service() { |
| 159 return &fake_invalidation_service_; | 158 return &fake_invalidation_service_; |
| 160 } | 159 } |
| 161 | 160 |
| 162 base::SingleThreadTaskRunner* db_thread() { return db_thread_.get(); } | 161 base::SingleThreadTaskRunner* db_thread() { return db_thread_.get(); } |
| 163 | 162 |
| 164 void set_db_thread( | 163 void set_db_thread( |
| 165 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread) { | 164 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread) { |
| 166 db_thread_ = db_thread; | 165 db_thread_ = db_thread; |
| 167 } | 166 } |
| 168 | 167 |
| 169 private: | 168 private: |
| 170 scoped_refptr<base::SingleThreadTaskRunner> db_thread_; | 169 scoped_refptr<base::SingleThreadTaskRunner> db_thread_; |
| 171 base::SequencedWorkerPoolOwner worker_pool_owner_; | 170 base::SequencedWorkerPoolOwner worker_pool_owner_; |
| 172 syncable_prefs::TestingPrefServiceSyncable pref_service_; | 171 syncable_prefs::TestingPrefServiceSyncable pref_service_; |
| 173 TestSigninClient signin_client_; | 172 TestSigninClient signin_client_; |
| 174 AccountTrackerService account_tracker_; | 173 AccountTrackerService account_tracker_; |
| 175 FakeSigninManagerType signin_manager_; | 174 FakeSigninManagerType signin_manager_; |
| 176 FakeProfileOAuth2TokenService auth_service_; | 175 FakeProfileOAuth2TokenService auth_service_; |
| 177 syncer::SyncApiComponentFactoryMock component_factory_; | 176 SyncApiComponentFactoryMock component_factory_; |
| 178 sync_sessions::FakeSyncSessionsClient sync_sessions_client_; | 177 sync_sessions::FakeSyncSessionsClient sync_sessions_client_; |
| 179 invalidation::FakeInvalidationService fake_invalidation_service_; | 178 invalidation::FakeInvalidationService fake_invalidation_service_; |
| 180 scoped_refptr<net::URLRequestContextGetter> url_request_context_; | 179 scoped_refptr<net::URLRequestContextGetter> url_request_context_; |
| 181 | 180 |
| 182 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceBundle); | 181 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceBundle); |
| 183 }; | 182 }; |
| 184 | 183 |
| 185 } // namespace browser_sync | 184 } // namespace browser_sync |
| 186 | 185 |
| 187 #endif // COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_TEST_UTIL_H_ | 186 #endif // COMPONENTS_BROWSER_SYNC_PROFILE_SYNC_TEST_UTIL_H_ |
| OLD | NEW |