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