1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_FACTORY_H__ 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_FACTORY_H__ 7 #pragma once 8 9 #include <string> 10 #include <utility> 11 12 #include "base/task.h" 13 #include "chrome/browser/sync/glue/change_processor.h" 14 #include "chrome/browser/sync/glue/data_type_controller.h" 15 #include "chrome/browser/sync/glue/model_associator.h" 16 #include "chrome/browser/sync/unrecoverable_error_handler.h" 17 18 class PersonalDataManager; 19 class PasswordStore; 20 class ProfileSyncService; 21 class WebDatabase; 22 23 namespace browser_sync { 24 class DataTypeManager; 25 class SyncBackendHost; 26 class UnrecoverableErrorHandler; 27 } 28 29 namespace history { 30 class HistoryBackend; 31 }; 32 33 // Factory class for all profile sync related classes. 34 class ProfileSyncFactory { 35 public: 36 // The various factory methods for the data type model associators 37 // and change processors all return this struct. This is needed 38 // because the change processors typically require a type-specific 39 // model associator at construction time. 40 struct SyncComponents { 41 browser_sync::AssociatorInterface* model_associator; 42 browser_sync::ChangeProcessor* change_processor; SyncComponentsSyncComponents43 SyncComponents(browser_sync::AssociatorInterface* ma, 44 browser_sync::ChangeProcessor* cp) 45 : model_associator(ma), change_processor(cp) {} 46 }; 47 ~ProfileSyncFactory()48 virtual ~ProfileSyncFactory() {} 49 50 // Instantiates and initializes a new ProfileSyncService. Enabled 51 // data types are registered with the service. The return pointer 52 // is owned by the caller. 53 virtual ProfileSyncService* CreateProfileSyncService( 54 const std::string& cros_user) = 0; 55 56 // Instantiates a new DataTypeManager with a SyncBackendHost and a 57 // list of data type controllers. The return pointer is owned by 58 // the caller. 59 virtual browser_sync::DataTypeManager* CreateDataTypeManager( 60 browser_sync::SyncBackendHost* backend, 61 const browser_sync::DataTypeController::TypeMap& controllers) = 0; 62 63 // Instantiates both a model associator and change processor for the 64 // app data type. The pointers in the return struct are 65 // owned by the caller. 66 virtual SyncComponents CreateAppSyncComponents( 67 ProfileSyncService* profile_sync_service, 68 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; 69 70 // Instantiates both a model associator and change processor for the 71 // autofill data type. The pointers in the return struct are owned 72 // by the caller. 73 virtual SyncComponents CreateAutofillSyncComponents( 74 ProfileSyncService* profile_sync_service, 75 WebDatabase* web_database, 76 PersonalDataManager* personal_data, 77 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; 78 79 // Instantiates both a model associator and change processor for the 80 // autofill data type. The pointers in the return struct are owned 81 // by the caller. 82 virtual SyncComponents CreateAutofillProfileSyncComponents( 83 ProfileSyncService* profile_sync_service, 84 WebDatabase* web_database, 85 PersonalDataManager* personal_data, 86 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; 87 88 // Instantiates both a model associator and change processor for the 89 // bookmark data type. The pointers in the return struct are owned 90 // by the caller. 91 virtual SyncComponents CreateBookmarkSyncComponents( 92 ProfileSyncService* profile_sync_service, 93 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; 94 95 // Instantiates both a model associator and change processor for the 96 // extension data type. The pointers in the return struct are 97 // owned by the caller. 98 virtual SyncComponents CreateExtensionSyncComponents( 99 ProfileSyncService* profile_sync_service, 100 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; 101 102 // Instantiates both a model associator and change processor for the 103 // password data type. The pointers in the return struct are 104 // owned by the caller. 105 virtual SyncComponents CreatePasswordSyncComponents( 106 ProfileSyncService* profile_sync_service, 107 PasswordStore* password_store, 108 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; 109 110 // Instantiates both a model associator and change processor for the 111 // preference data type. The pointers in the return struct are 112 // owned by the caller. 113 virtual SyncComponents CreatePreferenceSyncComponents( 114 ProfileSyncService* profile_sync_service, 115 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; 116 117 // Instantiates both a model associator and change processor for the 118 // theme data type. The pointers in the return struct are 119 // owned by the caller. 120 virtual SyncComponents CreateThemeSyncComponents( 121 ProfileSyncService* profile_sync_service, 122 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; 123 124 // Instantiates both a model associator and change processor for the 125 // typed_url data type. The pointers in the return struct are owned 126 // by the caller. 127 virtual SyncComponents CreateTypedUrlSyncComponents( 128 ProfileSyncService* profile_sync_service, 129 history::HistoryBackend* history_backend, 130 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; 131 132 // Instantiates both a model associator and change processor for the 133 // session data type. The pointers in the return struct are 134 // owned by the caller. 135 virtual SyncComponents CreateSessionSyncComponents( 136 ProfileSyncService* profile_sync_service, 137 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; 138 }; 139 140 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_FACTORY_H__ 141