| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SYNC_DRIVER_SYNC_API_COMPONENT_FACTORY_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_SYNC_API_COMPONENT_FACTORY_H_ |
| 6 #define COMPONENTS_SYNC_DRIVER_SYNC_API_COMPONENT_FACTORY_H_ | 6 #define COMPONENTS_SYNC_DRIVER_SYNC_API_COMPONENT_FACTORY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 class LocalDeviceInfoProvider; | 50 class LocalDeviceInfoProvider; |
| 51 class SyncPrefs; | 51 class SyncPrefs; |
| 52 class SyncClient; | 52 class SyncClient; |
| 53 class SyncService; | 53 class SyncService; |
| 54 | 54 |
| 55 // This factory provides sync driver code with the model type specific sync/api | 55 // This factory provides sync driver code with the model type specific sync/api |
| 56 // service (like SyncableService) implementations. | 56 // service (like SyncableService) implementations. |
| 57 class SyncApiComponentFactory { | 57 class SyncApiComponentFactory { |
| 58 public: | 58 public: |
| 59 virtual ~SyncApiComponentFactory() {} | 59 virtual ~SyncApiComponentFactory() {} |
| 60 // Callback to allow platform-specific datatypes to register themselves as | |
| 61 // data type controllers. | |
| 62 // |disabled_types| and |enabled_types| control the disable/enable state of | |
| 63 // types that are on or off by default (respectively). | |
| 64 typedef base::Callback<void(syncer::ModelTypeSet disabled_types, | |
| 65 syncer::ModelTypeSet enabled_types)> | |
| 66 RegisterDataTypesMethod; | |
| 67 | 60 |
| 68 // The various factory methods for the data type model associators | 61 // The various factory methods for the data type model associators |
| 69 // and change processors all return this struct. This is needed | 62 // and change processors all return this struct. This is needed |
| 70 // because the change processors typically require a type-specific | 63 // because the change processors typically require a type-specific |
| 71 // model associator at construction time. | 64 // model associator at construction time. |
| 72 // | 65 // |
| 73 // Note: This interface is deprecated in favor of the SyncableService API. | 66 // Note: This interface is deprecated in favor of the SyncableService API. |
| 74 // New datatypes that do not live on the UI thread should directly return a | 67 // New datatypes that do not live on the UI thread should directly return a |
| 75 // weak pointer to a syncer::SyncableService. All others continue to return | 68 // weak pointer to a syncer::SyncableService. All others continue to return |
| 76 // SyncComponents. It is safe to assume that the factory methods below are | 69 // SyncComponents. It is safe to assume that the factory methods below are |
| 77 // called on the same thread in which the datatype resides. | 70 // called on the same thread in which the datatype resides. |
| 78 // | 71 // |
| 79 // TODO(zea): Have all datatypes using the new API switch to returning | 72 // TODO(zea): Have all datatypes using the new API switch to returning |
| 80 // SyncableService weak pointers instead of SyncComponents (crbug.com/100114). | 73 // SyncableService weak pointers instead of SyncComponents (crbug.com/100114). |
| 81 struct SyncComponents { | 74 struct SyncComponents { |
| 82 sync_driver::AssociatorInterface* model_associator; | 75 sync_driver::AssociatorInterface* model_associator; |
| 83 sync_driver::ChangeProcessor* change_processor; | 76 sync_driver::ChangeProcessor* change_processor; |
| 84 SyncComponents(sync_driver::AssociatorInterface* ma, | 77 SyncComponents(sync_driver::AssociatorInterface* ma, |
| 85 sync_driver::ChangeProcessor* cp) | 78 sync_driver::ChangeProcessor* cp) |
| 86 : model_associator(ma), change_processor(cp) {} | 79 : model_associator(ma), change_processor(cp) {} |
| 87 }; | 80 }; |
| 88 | 81 |
| 89 // Creates and registers enabled datatypes with the provided SyncClient. | 82 // Creates and registers enabled datatypes with the provided SyncClient. |
| 90 virtual void RegisterDataTypes( | 83 virtual void RegisterDataTypes(sync_driver::SyncClient* sync_client) = 0; |
| 91 const RegisterDataTypesMethod& register_platform_types_method) = 0; | |
| 92 | 84 |
| 93 // Instantiates a new DataTypeManager with a SyncBackendHost, a list of data | 85 // Instantiates a new DataTypeManager with a SyncBackendHost, a list of data |
| 94 // type controllers and a DataTypeManagerObserver. The return pointer is | 86 // type controllers and a DataTypeManagerObserver. The return pointer is |
| 95 // owned by the caller. | 87 // owned by the caller. |
| 96 virtual sync_driver::DataTypeManager* CreateDataTypeManager( | 88 virtual sync_driver::DataTypeManager* CreateDataTypeManager( |
| 97 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& | 89 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& |
| 98 debug_info_listener, | 90 debug_info_listener, |
| 99 const sync_driver::DataTypeController::TypeMap* controllers, | 91 const sync_driver::DataTypeController::TypeMap* controllers, |
| 100 const sync_driver::DataTypeEncryptionHandler* encryption_handler, | 92 const sync_driver::DataTypeEncryptionHandler* encryption_handler, |
| 101 browser_sync::SyncBackendHost* backend, | 93 browser_sync::SyncBackendHost* backend, |
| 102 sync_driver::DataTypeManagerObserver* observer) = 0; | 94 sync_driver::DataTypeManagerObserver* observer) = 0; |
| 103 | 95 |
| 104 // Creating this in the factory helps us mock it out in testing. | 96 // Creating this in the factory helps us mock it out in testing. |
| 105 virtual browser_sync::SyncBackendHost* CreateSyncBackendHost( | 97 virtual browser_sync::SyncBackendHost* CreateSyncBackendHost( |
| 106 const std::string& name, | 98 const std::string& name, |
| 99 SyncClient* sync_client, |
| 107 invalidation::InvalidationService* invalidator, | 100 invalidation::InvalidationService* invalidator, |
| 108 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, | 101 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, |
| 109 const base::FilePath& sync_folder) = 0; | 102 const base::FilePath& sync_folder) = 0; |
| 110 | 103 |
| 111 // Creating this in the factory helps us mock it out in testing. | 104 // Creating this in the factory helps us mock it out in testing. |
| 112 virtual scoped_ptr<sync_driver::LocalDeviceInfoProvider> | 105 virtual scoped_ptr<sync_driver::LocalDeviceInfoProvider> |
| 113 CreateLocalDeviceInfoProvider() = 0; | 106 CreateLocalDeviceInfoProvider() = 0; |
| 114 | 107 |
| 115 // Legacy datatypes that need to be converted to the SyncableService API. | 108 // Legacy datatypes that need to be converted to the SyncableService API. |
| 116 virtual SyncComponents CreateBookmarkSyncComponents( | 109 virtual SyncComponents CreateBookmarkSyncComponents( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 136 scoped_ptr<syncer::AttachmentStoreForSync> attachment_store, | 129 scoped_ptr<syncer::AttachmentStoreForSync> attachment_store, |
| 137 const syncer::UserShare& user_share, | 130 const syncer::UserShare& user_share, |
| 138 const std::string& store_birthday, | 131 const std::string& store_birthday, |
| 139 syncer::ModelType model_type, | 132 syncer::ModelType model_type, |
| 140 syncer::AttachmentService::Delegate* delegate) = 0; | 133 syncer::AttachmentService::Delegate* delegate) = 0; |
| 141 }; | 134 }; |
| 142 | 135 |
| 143 } // namespace sync_driver | 136 } // namespace sync_driver |
| 144 | 137 |
| 145 #endif // COMPONENTS_SYNC_DRIVER_SYNC_API_COMPONENT_FACTORY_H_ | 138 #endif // COMPONENTS_SYNC_DRIVER_SYNC_API_COMPONENT_FACTORY_H_ |
| OLD | NEW |