| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_H__ | 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_H__ |
| 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_H__ | 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_H__ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "components/invalidation/invalidation_service.h" | 12 #include "components/invalidation/invalidation_service.h" |
| 13 #include "components/sync_driver/data_type_controller.h" | 13 #include "components/sync_driver/data_type_controller.h" |
| 14 #include "components/sync_driver/data_type_error_handler.h" | 14 #include "components/sync_driver/data_type_error_handler.h" |
| 15 #include "components/sync_driver/sync_api_component_factory.h" | 15 #include "components/sync_driver/sync_api_component_factory.h" |
| 16 #include "sync/api/sync_merge_result.h" | 16 #include "sync/api/sync_merge_result.h" |
| 17 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" | 17 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" |
| 18 #include "sync/internal_api/public/util/weak_handle.h" | 18 #include "sync/internal_api/public/util/weak_handle.h" |
| 19 | 19 |
| 20 class PasswordStore; | 20 class PasswordStore; |
| 21 class Profile; | 21 class Profile; |
| 22 class ProfileSyncService; | 22 class ProfileSyncService; |
| 23 | 23 |
| 24 namespace browser_sync { | 24 namespace browser_sync { |
| 25 class LocalDeviceInfoProvider; |
| 26 class SyncBackendHost; |
| 27 } // namespace browser_sync |
| 28 |
| 29 namespace sync_driver { |
| 25 class AssociatorInterface; | 30 class AssociatorInterface; |
| 26 class ChangeProcessor; | 31 class ChangeProcessor; |
| 27 class DataTypeEncryptionHandler; | 32 class DataTypeEncryptionHandler; |
| 33 class DataTypeErrorHandler; |
| 28 class DataTypeManager; | 34 class DataTypeManager; |
| 29 class DataTypeManagerObserver; | 35 class DataTypeManagerObserver; |
| 30 class FailedDataTypesHandler; | 36 class FailedDataTypesHandler; |
| 31 class GenericChangeProcessor; | 37 class GenericChangeProcessor; |
| 32 class LocalDeviceInfoProvider; | |
| 33 class SyncBackendHost; | |
| 34 class DataTypeErrorHandler; | |
| 35 } // namespace browser_sync | |
| 36 | |
| 37 namespace sync_driver { | |
| 38 class SyncPrefs; | 38 class SyncPrefs; |
| 39 } | 39 } // namespace sync_driver |
| 40 | 40 |
| 41 namespace syncer { | 41 namespace syncer { |
| 42 class DataTypeDebugInfoListener; | 42 class DataTypeDebugInfoListener; |
| 43 class SyncableService; | 43 class SyncableService; |
| 44 } | 44 } // namespace syncer |
| 45 | 45 |
| 46 namespace history { | 46 namespace history { |
| 47 class HistoryBackend; | 47 class HistoryBackend; |
| 48 } | 48 } // namespace history |
| 49 | 49 |
| 50 // Factory class for all profile sync related classes. | 50 // Factory class for all profile sync related classes. |
| 51 class ProfileSyncComponentsFactory | 51 class ProfileSyncComponentsFactory |
| 52 : public browser_sync::SyncApiComponentFactory { | 52 : public sync_driver::SyncApiComponentFactory { |
| 53 public: | 53 public: |
| 54 // The various factory methods for the data type model associators | 54 // The various factory methods for the data type model associators |
| 55 // and change processors all return this struct. This is needed | 55 // and change processors all return this struct. This is needed |
| 56 // because the change processors typically require a type-specific | 56 // because the change processors typically require a type-specific |
| 57 // model associator at construction time. | 57 // model associator at construction time. |
| 58 // | 58 // |
| 59 // Note: This interface is deprecated in favor of the SyncableService API. | 59 // Note: This interface is deprecated in favor of the SyncableService API. |
| 60 // New datatypes that do not live on the UI thread should directly return a | 60 // New datatypes that do not live on the UI thread should directly return a |
| 61 // weak pointer to a syncer::SyncableService. All others continue to return | 61 // weak pointer to a syncer::SyncableService. All others continue to return |
| 62 // SyncComponents. It is safe to assume that the factory methods below are | 62 // SyncComponents. It is safe to assume that the factory methods below are |
| 63 // called on the same thread in which the datatype resides. | 63 // called on the same thread in which the datatype resides. |
| 64 // | 64 // |
| 65 // TODO(zea): Have all datatypes using the new API switch to returning | 65 // TODO(zea): Have all datatypes using the new API switch to returning |
| 66 // SyncableService weak pointers instead of SyncComponents (crbug.com/100114). | 66 // SyncableService weak pointers instead of SyncComponents (crbug.com/100114). |
| 67 struct SyncComponents { | 67 struct SyncComponents { |
| 68 browser_sync::AssociatorInterface* model_associator; | 68 sync_driver::AssociatorInterface* model_associator; |
| 69 browser_sync::ChangeProcessor* change_processor; | 69 sync_driver::ChangeProcessor* change_processor; |
| 70 SyncComponents(browser_sync::AssociatorInterface* ma, | 70 SyncComponents(sync_driver::AssociatorInterface* ma, |
| 71 browser_sync::ChangeProcessor* cp) | 71 sync_driver::ChangeProcessor* cp) |
| 72 : model_associator(ma), change_processor(cp) {} | 72 : model_associator(ma), change_processor(cp) {} |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 virtual ~ProfileSyncComponentsFactory() OVERRIDE {} | 75 virtual ~ProfileSyncComponentsFactory() OVERRIDE {} |
| 76 | 76 |
| 77 // Creates and registers enabled datatypes with the provided | 77 // Creates and registers enabled datatypes with the provided |
| 78 // ProfileSyncService. | 78 // ProfileSyncService. |
| 79 virtual void RegisterDataTypes(ProfileSyncService* pss) = 0; | 79 virtual void RegisterDataTypes(ProfileSyncService* pss) = 0; |
| 80 | 80 |
| 81 // Instantiates a new DataTypeManager with a SyncBackendHost, a list of data | 81 // Instantiates a new DataTypeManager with a SyncBackendHost, a list of data |
| 82 // type controllers and a DataTypeManagerObserver. The return pointer is | 82 // type controllers and a DataTypeManagerObserver. The return pointer is |
| 83 // owned by the caller. | 83 // owned by the caller. |
| 84 virtual browser_sync::DataTypeManager* CreateDataTypeManager( | 84 virtual sync_driver::DataTypeManager* CreateDataTypeManager( |
| 85 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& | 85 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& |
| 86 debug_info_listener, | 86 debug_info_listener, |
| 87 const browser_sync::DataTypeController::TypeMap* controllers, | 87 const sync_driver::DataTypeController::TypeMap* controllers, |
| 88 const browser_sync::DataTypeEncryptionHandler* encryption_handler, | 88 const sync_driver::DataTypeEncryptionHandler* encryption_handler, |
| 89 browser_sync::SyncBackendHost* backend, | 89 browser_sync::SyncBackendHost* backend, |
| 90 browser_sync::DataTypeManagerObserver* observer, | 90 sync_driver::DataTypeManagerObserver* observer, |
| 91 browser_sync::FailedDataTypesHandler* failed_data_types_handler) = 0; | 91 sync_driver::FailedDataTypesHandler* failed_data_types_handler) = 0; |
| 92 | 92 |
| 93 // Creating this in the factory helps us mock it out in testing. | 93 // Creating this in the factory helps us mock it out in testing. |
| 94 virtual browser_sync::SyncBackendHost* CreateSyncBackendHost( | 94 virtual browser_sync::SyncBackendHost* CreateSyncBackendHost( |
| 95 const std::string& name, | 95 const std::string& name, |
| 96 Profile* profile, | 96 Profile* profile, |
| 97 invalidation::InvalidationService* invalidator, | 97 invalidation::InvalidationService* invalidator, |
| 98 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, | 98 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, |
| 99 const base::FilePath& sync_folder) = 0; | 99 const base::FilePath& sync_folder) = 0; |
| 100 | 100 |
| 101 // Creating this in the factory helps us mock it out in testing. | 101 // Creating this in the factory helps us mock it out in testing. |
| 102 virtual scoped_ptr<browser_sync::LocalDeviceInfoProvider> | 102 virtual scoped_ptr<browser_sync::LocalDeviceInfoProvider> |
| 103 CreateLocalDeviceInfoProvider() = 0; | 103 CreateLocalDeviceInfoProvider() = 0; |
| 104 | 104 |
| 105 // Legacy datatypes that need to be converted to the SyncableService API. | 105 // Legacy datatypes that need to be converted to the SyncableService API. |
| 106 virtual SyncComponents CreateBookmarkSyncComponents( | 106 virtual SyncComponents CreateBookmarkSyncComponents( |
| 107 ProfileSyncService* profile_sync_service, | 107 ProfileSyncService* profile_sync_service, |
| 108 browser_sync::DataTypeErrorHandler* error_handler) = 0; | 108 sync_driver::DataTypeErrorHandler* error_handler) = 0; |
| 109 virtual SyncComponents CreateTypedUrlSyncComponents( | 109 virtual SyncComponents CreateTypedUrlSyncComponents( |
| 110 ProfileSyncService* profile_sync_service, | 110 ProfileSyncService* profile_sync_service, |
| 111 history::HistoryBackend* history_backend, | 111 history::HistoryBackend* history_backend, |
| 112 browser_sync::DataTypeErrorHandler* error_handler) = 0; | 112 sync_driver::DataTypeErrorHandler* error_handler) = 0; |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_H__ | 115 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_H__ |
| OLD | NEW |