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