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

Side by Side Diff: chrome/browser/sync/profile_sync_factory_impl.cc

Issue 8065016: [Sync] Refactor non-frontend DTC to handle new API properly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Try harder trybot (rebase). Created 9 years, 2 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "chrome/browser/extensions/extension_service.h" 6 #include "chrome/browser/extensions/extension_service.h"
7 #include "chrome/browser/extensions/extension_settings_backend.h" 7 #include "chrome/browser/extensions/extension_settings_backend.h"
8 #include "chrome/browser/prefs/pref_model_associator.h"
8 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/search_engines/template_url_service.h" 10 #include "chrome/browser/search_engines/template_url_service.h"
10 #include "chrome/browser/search_engines/template_url_service_factory.h" 11 #include "chrome/browser/search_engines/template_url_service_factory.h"
11 #include "chrome/browser/sync/api/syncable_service.h" 12 #include "chrome/browser/sync/api/syncable_service.h"
12 #include "chrome/browser/sync/glue/app_data_type_controller.h" 13 #include "chrome/browser/sync/glue/app_data_type_controller.h"
13 #include "chrome/browser/sync/glue/autofill_change_processor.h" 14 #include "chrome/browser/sync/glue/autofill_change_processor.h"
14 #include "chrome/browser/sync/glue/autofill_data_type_controller.h" 15 #include "chrome/browser/sync/glue/autofill_data_type_controller.h"
15 #include "chrome/browser/sync/glue/autofill_model_associator.h" 16 #include "chrome/browser/sync/glue/autofill_model_associator.h"
16 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h" 17 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h"
17 #include "chrome/browser/sync/glue/bookmark_change_processor.h" 18 #include "chrome/browser/sync/glue/bookmark_change_processor.h"
18 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h" 19 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h"
19 #include "chrome/browser/sync/glue/bookmark_model_associator.h" 20 #include "chrome/browser/sync/glue/bookmark_model_associator.h"
20 #include "chrome/browser/sync/glue/data_type_manager_impl.h" 21 #include "chrome/browser/sync/glue/data_type_manager_impl.h"
21 #include "chrome/browser/sync/glue/extension_data_type_controller.h" 22 #include "chrome/browser/sync/glue/extension_data_type_controller.h"
22 #include "chrome/browser/sync/glue/extension_setting_data_type_controller.h" 23 #include "chrome/browser/sync/glue/extension_setting_data_type_controller.h"
23 #include "chrome/browser/sync/glue/generic_change_processor.h" 24 #include "chrome/browser/sync/glue/generic_change_processor.h"
24 #include "chrome/browser/sync/glue/password_change_processor.h" 25 #include "chrome/browser/sync/glue/password_change_processor.h"
25 #include "chrome/browser/sync/glue/password_data_type_controller.h" 26 #include "chrome/browser/sync/glue/password_data_type_controller.h"
26 #include "chrome/browser/sync/glue/password_model_associator.h" 27 #include "chrome/browser/sync/glue/password_model_associator.h"
27 #include "chrome/browser/sync/glue/preference_data_type_controller.h" 28 #include "chrome/browser/sync/glue/preference_data_type_controller.h"
28 #include "chrome/browser/sync/glue/search_engine_data_type_controller.h" 29 #include "chrome/browser/sync/glue/search_engine_data_type_controller.h"
29 #include "chrome/browser/sync/glue/session_change_processor.h" 30 #include "chrome/browser/sync/glue/session_change_processor.h"
30 #include "chrome/browser/sync/glue/session_data_type_controller.h" 31 #include "chrome/browser/sync/glue/session_data_type_controller.h"
31 #include "chrome/browser/sync/glue/session_model_associator.h" 32 #include "chrome/browser/sync/glue/session_model_associator.h"
33 #include "chrome/browser/sync/glue/shared_change_processor.h"
32 #include "chrome/browser/sync/glue/syncable_service_adapter.h" 34 #include "chrome/browser/sync/glue/syncable_service_adapter.h"
33 #include "chrome/browser/sync/glue/sync_backend_host.h" 35 #include "chrome/browser/sync/glue/sync_backend_host.h"
34 #include "chrome/browser/sync/glue/theme_change_processor.h" 36 #include "chrome/browser/sync/glue/theme_change_processor.h"
35 #include "chrome/browser/sync/glue/theme_data_type_controller.h" 37 #include "chrome/browser/sync/glue/theme_data_type_controller.h"
36 #include "chrome/browser/sync/glue/theme_model_associator.h" 38 #include "chrome/browser/sync/glue/theme_model_associator.h"
37 #include "chrome/browser/sync/glue/typed_url_change_processor.h" 39 #include "chrome/browser/sync/glue/typed_url_change_processor.h"
38 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h" 40 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h"
39 #include "chrome/browser/sync/glue/typed_url_model_associator.h" 41 #include "chrome/browser/sync/glue/typed_url_model_associator.h"
40 #include "chrome/browser/sync/profile_sync_service.h" 42 #include "chrome/browser/sync/profile_sync_service.h"
41 #include "chrome/browser/sync/profile_sync_factory_impl.h" 43 #include "chrome/browser/sync/profile_sync_factory_impl.h"
(...skipping 20 matching lines...) Expand all
62 using browser_sync::ExtensionSettingDataTypeController; 64 using browser_sync::ExtensionSettingDataTypeController;
63 using browser_sync::GenericChangeProcessor; 65 using browser_sync::GenericChangeProcessor;
64 using browser_sync::PasswordChangeProcessor; 66 using browser_sync::PasswordChangeProcessor;
65 using browser_sync::PasswordDataTypeController; 67 using browser_sync::PasswordDataTypeController;
66 using browser_sync::PasswordModelAssociator; 68 using browser_sync::PasswordModelAssociator;
67 using browser_sync::PreferenceDataTypeController; 69 using browser_sync::PreferenceDataTypeController;
68 using browser_sync::SearchEngineDataTypeController; 70 using browser_sync::SearchEngineDataTypeController;
69 using browser_sync::SessionChangeProcessor; 71 using browser_sync::SessionChangeProcessor;
70 using browser_sync::SessionDataTypeController; 72 using browser_sync::SessionDataTypeController;
71 using browser_sync::SessionModelAssociator; 73 using browser_sync::SessionModelAssociator;
74 using browser_sync::SharedChangeProcessor;
72 using browser_sync::SyncableServiceAdapter; 75 using browser_sync::SyncableServiceAdapter;
73 using browser_sync::SyncBackendHost; 76 using browser_sync::SyncBackendHost;
74 using browser_sync::ThemeChangeProcessor; 77 using browser_sync::ThemeChangeProcessor;
75 using browser_sync::ThemeDataTypeController; 78 using browser_sync::ThemeDataTypeController;
76 using browser_sync::ThemeModelAssociator; 79 using browser_sync::ThemeModelAssociator;
77 using browser_sync::TypedUrlChangeProcessor; 80 using browser_sync::TypedUrlChangeProcessor;
78 using browser_sync::TypedUrlDataTypeController; 81 using browser_sync::TypedUrlDataTypeController;
79 using browser_sync::TypedUrlModelAssociator; 82 using browser_sync::TypedUrlModelAssociator;
80 using browser_sync::UnrecoverableErrorHandler; 83 using browser_sync::UnrecoverableErrorHandler;
81 84
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 new SearchEngineDataTypeController(this, profile_, pss)); 179 new SearchEngineDataTypeController(this, profile_, pss));
177 } 180 }
178 } 181 }
179 182
180 DataTypeManager* ProfileSyncFactoryImpl::CreateDataTypeManager( 183 DataTypeManager* ProfileSyncFactoryImpl::CreateDataTypeManager(
181 SyncBackendHost* backend, 184 SyncBackendHost* backend,
182 const DataTypeController::TypeMap* controllers) { 185 const DataTypeController::TypeMap* controllers) {
183 return new DataTypeManagerImpl(backend, controllers); 186 return new DataTypeManagerImpl(backend, controllers);
184 } 187 }
185 188
189 browser_sync::GenericChangeProcessor*
190 ProfileSyncFactoryImpl::CreateGenericChangeProcessor(
191 ProfileSyncService* profile_sync_service,
192 browser_sync::UnrecoverableErrorHandler* error_handler,
193 const base::WeakPtr<SyncableService>& local_service) {
194 sync_api::UserShare* user_share = profile_sync_service->GetUserShare();
195 return new GenericChangeProcessor(error_handler,
196 local_service,
197 user_share);
198 }
199
200 browser_sync::SharedChangeProcessor* ProfileSyncFactoryImpl::
201 CreateSharedChangeProcessor() {
202 return new SharedChangeProcessor();
203 }
204
186 ProfileSyncFactory::SyncComponents 205 ProfileSyncFactory::SyncComponents
187 ProfileSyncFactoryImpl::CreateAppSyncComponents( 206 ProfileSyncFactoryImpl::CreateAppSyncComponents(
188 ProfileSyncService* profile_sync_service, 207 ProfileSyncService* profile_sync_service,
189 UnrecoverableErrorHandler* error_handler) { 208 UnrecoverableErrorHandler* error_handler) {
190 SyncableService* app_sync_service = 209 base::WeakPtr<SyncableService> app_sync_service =
191 profile_sync_service->profile()->GetExtensionService(); 210 profile_sync_service->profile()->GetExtensionService()->AsWeakPtr();
192 sync_api::UserShare* user_share = profile_sync_service->GetUserShare(); 211 sync_api::UserShare* user_share = profile_sync_service->GetUserShare();
193 GenericChangeProcessor* change_processor = 212 GenericChangeProcessor* change_processor =
194 new GenericChangeProcessor(app_sync_service, error_handler, user_share); 213 new GenericChangeProcessor(error_handler, app_sync_service, user_share);
195 browser_sync::SyncableServiceAdapter* sync_service_adapter = 214 browser_sync::SyncableServiceAdapter* sync_service_adapter =
196 new browser_sync::SyncableServiceAdapter(syncable::APPS, 215 new browser_sync::SyncableServiceAdapter(syncable::APPS,
197 app_sync_service, 216 app_sync_service,
198 change_processor); 217 change_processor);
199 return SyncComponents(sync_service_adapter, change_processor); 218 return SyncComponents(sync_service_adapter, change_processor);
200 } 219 }
201 220
202 ProfileSyncFactory::SyncComponents 221 ProfileSyncFactory::SyncComponents
203 ProfileSyncFactoryImpl::CreateAutofillSyncComponents( 222 ProfileSyncFactoryImpl::CreateAutofillSyncComponents(
204 ProfileSyncService* profile_sync_service, 223 ProfileSyncService* profile_sync_service,
205 WebDatabase* web_database, 224 WebDatabase* web_database,
206 browser_sync::UnrecoverableErrorHandler* error_handler) { 225 browser_sync::UnrecoverableErrorHandler* error_handler) {
207 226
208 AutofillModelAssociator* model_associator = 227 AutofillModelAssociator* model_associator =
209 new AutofillModelAssociator(profile_sync_service, 228 new AutofillModelAssociator(profile_sync_service,
210 web_database, 229 web_database,
211 profile_sync_service->profile()); 230 profile_sync_service->profile());
212 AutofillChangeProcessor* change_processor = 231 AutofillChangeProcessor* change_processor =
213 new AutofillChangeProcessor(model_associator, 232 new AutofillChangeProcessor(model_associator,
214 web_database, 233 web_database,
215 profile_sync_service->profile(), 234 profile_sync_service->profile(),
216 error_handler); 235 error_handler);
217 return SyncComponents(model_associator, change_processor); 236 return SyncComponents(model_associator, change_processor);
218 } 237 }
219 238
220 ProfileSyncFactory::SyncComponents 239 base::WeakPtr<SyncableService>
221 ProfileSyncFactoryImpl::CreateAutofillProfileSyncComponents( 240 ProfileSyncFactoryImpl::GetAutofillProfileSyncableService(
222 ProfileSyncService* profile_sync_service, 241 WebDataService* web_data_service) {
223 WebDataService* web_data_service, 242 // TODO(isherman): This currently leaks at sync shutdown since the sync
akalin 2011/10/12 19:54:21 rebase?
Nicolas Zea 2011/10/12 23:47:43 Done.
224 browser_sync::UnrecoverableErrorHandler* error_handler) { 243 // datatype controller doesn't own it. See crbug.com/96922.
225 AutofillProfileSyncableService* sync_service = 244 return (new AutofillProfileSyncableService(web_data_service))->AsWeakPtr();
226 new AutofillProfileSyncableService(web_data_service);
227 sync_api::UserShare* user_share = profile_sync_service->GetUserShare();
228 GenericChangeProcessor* change_processor =
229 new GenericChangeProcessor(sync_service, error_handler, user_share);
230 browser_sync::SyncableServiceAdapter* sync_service_adapter =
231 new browser_sync::SyncableServiceAdapter(syncable::AUTOFILL_PROFILE,
232 sync_service,
233 change_processor);
234 return SyncComponents(sync_service_adapter, change_processor);
235 } 245 }
236 246
237 ProfileSyncFactory::SyncComponents 247 ProfileSyncFactory::SyncComponents
238 ProfileSyncFactoryImpl::CreateBookmarkSyncComponents( 248 ProfileSyncFactoryImpl::CreateBookmarkSyncComponents(
239 ProfileSyncService* profile_sync_service, 249 ProfileSyncService* profile_sync_service,
240 UnrecoverableErrorHandler* error_handler) { 250 UnrecoverableErrorHandler* error_handler) {
241 BookmarkModel* bookmark_model = 251 BookmarkModel* bookmark_model =
242 profile_sync_service->profile()->GetBookmarkModel(); 252 profile_sync_service->profile()->GetBookmarkModel();
243 sync_api::UserShare* user_share = profile_sync_service->GetUserShare(); 253 sync_api::UserShare* user_share = profile_sync_service->GetUserShare();
244 BookmarkModelAssociator* model_associator = 254 BookmarkModelAssociator* model_associator =
245 new BookmarkModelAssociator(bookmark_model, 255 new BookmarkModelAssociator(bookmark_model,
246 user_share, 256 user_share,
247 error_handler); 257 error_handler);
248 BookmarkChangeProcessor* change_processor = 258 BookmarkChangeProcessor* change_processor =
249 new BookmarkChangeProcessor(model_associator, 259 new BookmarkChangeProcessor(model_associator,
250 error_handler); 260 error_handler);
251 return SyncComponents(model_associator, change_processor); 261 return SyncComponents(model_associator, change_processor);
252 } 262 }
253 263
254 ProfileSyncFactory::SyncComponents 264 ProfileSyncFactory::SyncComponents
255 ProfileSyncFactoryImpl::CreateExtensionSettingSyncComponents( 265 ProfileSyncFactoryImpl::CreateExtensionSettingSyncComponents(
256 ExtensionSettingsBackend* extension_settings_backend, 266 ExtensionSettingsBackend* extension_settings_backend,
257 ProfileSyncService* profile_sync_service, 267 ProfileSyncService* profile_sync_service,
258 UnrecoverableErrorHandler* error_handler) { 268 UnrecoverableErrorHandler* error_handler) {
259 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
260 sync_api::UserShare* user_share = profile_sync_service->GetUserShare(); 270 sync_api::UserShare* user_share = profile_sync_service->GetUserShare();
261 GenericChangeProcessor* change_processor = 271 GenericChangeProcessor* change_processor =
262 new GenericChangeProcessor( 272 new GenericChangeProcessor(error_handler,
263 extension_settings_backend, 273 extension_settings_backend->AsWeakPtr(),
264 error_handler, 274 user_share);
265 user_share);
266 browser_sync::SyncableServiceAdapter* sync_service_adapter = 275 browser_sync::SyncableServiceAdapter* sync_service_adapter =
267 new browser_sync::SyncableServiceAdapter(syncable::EXTENSION_SETTINGS, 276 new browser_sync::SyncableServiceAdapter(syncable::EXTENSION_SETTINGS,
268 extension_settings_backend, 277 extension_settings_backend,
269 change_processor); 278 change_processor);
270 return SyncComponents(sync_service_adapter, change_processor); 279 return SyncComponents(sync_service_adapter, change_processor);
271 } 280 }
272 281
273 ProfileSyncFactory::SyncComponents 282 ProfileSyncFactory::SyncComponents
274 ProfileSyncFactoryImpl::CreateExtensionSyncComponents( 283 ProfileSyncFactoryImpl::CreateExtensionSyncComponents(
275 ProfileSyncService* profile_sync_service, 284 ProfileSyncService* profile_sync_service,
276 UnrecoverableErrorHandler* error_handler) { 285 UnrecoverableErrorHandler* error_handler) {
277 SyncableService* extension_sync_service = 286 base::WeakPtr<SyncableService> extension_sync_service =
278 profile_sync_service->profile()->GetExtensionService(); 287 profile_sync_service->profile()->GetExtensionService()->AsWeakPtr();
279 sync_api::UserShare* user_share = profile_sync_service->GetUserShare(); 288 sync_api::UserShare* user_share = profile_sync_service->GetUserShare();
280 GenericChangeProcessor* change_processor = 289 GenericChangeProcessor* change_processor =
281 new GenericChangeProcessor(extension_sync_service, error_handler, 290 new GenericChangeProcessor(error_handler,
282 user_share); 291 extension_sync_service,
292 user_share);
283 browser_sync::SyncableServiceAdapter* sync_service_adapter = 293 browser_sync::SyncableServiceAdapter* sync_service_adapter =
284 new browser_sync::SyncableServiceAdapter(syncable::EXTENSIONS, 294 new browser_sync::SyncableServiceAdapter(syncable::EXTENSIONS,
285 extension_sync_service, 295 extension_sync_service,
286 change_processor); 296 change_processor);
287 return SyncComponents(sync_service_adapter, change_processor); 297 return SyncComponents(sync_service_adapter, change_processor);
288 } 298 }
289 299
290 ProfileSyncFactory::SyncComponents 300 ProfileSyncFactory::SyncComponents
291 ProfileSyncFactoryImpl::CreatePasswordSyncComponents( 301 ProfileSyncFactoryImpl::CreatePasswordSyncComponents(
292 ProfileSyncService* profile_sync_service, 302 ProfileSyncService* profile_sync_service,
293 PasswordStore* password_store, 303 PasswordStore* password_store,
294 UnrecoverableErrorHandler* error_handler) { 304 UnrecoverableErrorHandler* error_handler) {
295 PasswordModelAssociator* model_associator = 305 PasswordModelAssociator* model_associator =
296 new PasswordModelAssociator(profile_sync_service, 306 new PasswordModelAssociator(profile_sync_service,
297 password_store); 307 password_store);
298 PasswordChangeProcessor* change_processor = 308 PasswordChangeProcessor* change_processor =
299 new PasswordChangeProcessor(model_associator, 309 new PasswordChangeProcessor(model_associator,
300 password_store, 310 password_store,
301 error_handler); 311 error_handler);
302 return SyncComponents(model_associator, change_processor); 312 return SyncComponents(model_associator, change_processor);
303 } 313 }
304 314
305 ProfileSyncFactory::SyncComponents 315 ProfileSyncFactory::SyncComponents
306 ProfileSyncFactoryImpl::CreatePreferenceSyncComponents( 316 ProfileSyncFactoryImpl::CreatePreferenceSyncComponents(
307 ProfileSyncService* profile_sync_service, 317 ProfileSyncService* profile_sync_service,
308 UnrecoverableErrorHandler* error_handler) { 318 UnrecoverableErrorHandler* error_handler) {
309 SyncableService* pref_sync_service = 319 base::WeakPtr<SyncableService> pref_sync_service =
310 profile_->GetPrefs()->GetSyncableService(); 320 profile_->GetPrefs()->GetSyncableService()->AsWeakPtr();
311 sync_api::UserShare* user_share = profile_sync_service->GetUserShare(); 321 sync_api::UserShare* user_share = profile_sync_service->GetUserShare();
312 GenericChangeProcessor* change_processor = 322 GenericChangeProcessor* change_processor =
313 new GenericChangeProcessor(pref_sync_service, error_handler, user_share); 323 new GenericChangeProcessor(error_handler,
324 pref_sync_service,
325 user_share);
314 SyncableServiceAdapter* sync_service_adapter = 326 SyncableServiceAdapter* sync_service_adapter =
315 new SyncableServiceAdapter(syncable::PREFERENCES, 327 new SyncableServiceAdapter(syncable::PREFERENCES,
316 pref_sync_service, 328 pref_sync_service,
317 change_processor); 329 change_processor);
318 return SyncComponents(sync_service_adapter, change_processor); 330 return SyncComponents(sync_service_adapter, change_processor);
319 } 331 }
320 332
321 ProfileSyncFactory::SyncComponents 333 ProfileSyncFactory::SyncComponents
322 ProfileSyncFactoryImpl::CreateThemeSyncComponents( 334 ProfileSyncFactoryImpl::CreateThemeSyncComponents(
323 ProfileSyncService* profile_sync_service, 335 ProfileSyncService* profile_sync_service,
(...skipping 29 matching lines...) Expand all
353 new SessionModelAssociator(profile_sync_service); 365 new SessionModelAssociator(profile_sync_service);
354 SessionChangeProcessor* change_processor = 366 SessionChangeProcessor* change_processor =
355 new SessionChangeProcessor(error_handler, model_associator); 367 new SessionChangeProcessor(error_handler, model_associator);
356 return SyncComponents(model_associator, change_processor); 368 return SyncComponents(model_associator, change_processor);
357 } 369 }
358 370
359 ProfileSyncFactory::SyncComponents 371 ProfileSyncFactory::SyncComponents
360 ProfileSyncFactoryImpl::CreateSearchEngineSyncComponents( 372 ProfileSyncFactoryImpl::CreateSearchEngineSyncComponents(
361 ProfileSyncService* profile_sync_service, 373 ProfileSyncService* profile_sync_service,
362 UnrecoverableErrorHandler* error_handler) { 374 UnrecoverableErrorHandler* error_handler) {
363 SyncableService* se_sync_service = 375 base::WeakPtr<SyncableService> se_sync_service =
364 TemplateURLServiceFactory::GetForProfile(profile_); 376 TemplateURLServiceFactory::GetForProfile(profile_)->AsWeakPtr();
365 DCHECK(se_sync_service); 377 DCHECK(se_sync_service);
366 sync_api::UserShare* user_share = profile_sync_service->GetUserShare(); 378 sync_api::UserShare* user_share = profile_sync_service->GetUserShare();
367 GenericChangeProcessor* change_processor = 379 GenericChangeProcessor* change_processor =
368 new GenericChangeProcessor(se_sync_service, error_handler, user_share); 380 new GenericChangeProcessor(error_handler,
381 se_sync_service,
382 user_share);
369 SyncableServiceAdapter* sync_service_adapter = 383 SyncableServiceAdapter* sync_service_adapter =
370 new SyncableServiceAdapter(syncable::SEARCH_ENGINES, 384 new SyncableServiceAdapter(syncable::SEARCH_ENGINES,
371 se_sync_service, 385 se_sync_service,
372 change_processor); 386 change_processor);
373 return SyncComponents(sync_service_adapter, change_processor); 387 return SyncComponents(sync_service_adapter, change_processor);
374 } 388 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698