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

Side by Side Diff: components/sync/driver/sync_api_component_factory.h

Issue 2388673002: Revert of [Sync] Move //components/sync to the syncer namespace. (patchset #5 id:40001 of https://co (Closed)
Patch Set: Created 4 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
OLDNEW
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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "components/sync/api/data_type_error_handler.h" 12 #include "components/sync/api/data_type_error_handler.h"
13 #include "components/sync/api/syncable_service.h" 13 #include "components/sync/api/syncable_service.h"
14 #include "components/sync/base/model_type.h" 14 #include "components/sync/base/model_type.h"
15 #include "components/sync/core/attachments/attachment_service.h" 15 #include "components/sync/core/attachments/attachment_service.h"
16 #include "components/sync/driver/data_type_controller.h" 16 #include "components/sync/driver/data_type_controller.h"
17 17
18 namespace base { 18 namespace base {
19 class FilePath; 19 class FilePath;
20 } // namespace base 20 } // namespace base
21 21
22 namespace browser_sync {
23 class SyncBackendHost;
24 } // namespace browser_sync
25
22 namespace history { 26 namespace history {
23 class HistoryBackend; 27 class HistoryBackend;
24 } 28 }
25 29
26 namespace invalidation { 30 namespace invalidation {
27 class InvalidationService; 31 class InvalidationService;
28 } // namespace invalidation 32 } // namespace invalidation
29 33
30 namespace syncer { 34 namespace syncer {
35 class DataTypeDebugInfoListener;
36 class SyncableService;
37
38 struct UserShare;
39 } // namespace syncer
40
41 namespace sync_driver {
31 42
32 class AssociatorInterface; 43 class AssociatorInterface;
33 class ChangeProcessor; 44 class ChangeProcessor;
34 class DataTypeDebugInfoListener;
35 class DataTypeEncryptionHandler; 45 class DataTypeEncryptionHandler;
36 class DataTypeManager; 46 class DataTypeManager;
37 class DataTypeManagerObserver; 47 class DataTypeManagerObserver;
38 class DataTypeStatusTable; 48 class DataTypeStatusTable;
39 class GenericChangeProcessor; 49 class GenericChangeProcessor;
40 class LocalDeviceInfoProvider; 50 class LocalDeviceInfoProvider;
41 class SyncBackendHost; 51 class SyncPrefs;
42 class SyncClient; 52 class SyncClient;
43 class SyncPrefs;
44 class SyncService; 53 class SyncService;
45 class SyncableService;
46 struct UserShare;
47 54
48 // 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
49 // service (like SyncableService) implementations. 56 // service (like SyncableService) implementations.
50 class SyncApiComponentFactory { 57 class SyncApiComponentFactory {
51 public: 58 public:
52 virtual ~SyncApiComponentFactory() {} 59 virtual ~SyncApiComponentFactory() {}
53 // Callback to allow platform-specific datatypes to register themselves as 60 // Callback to allow platform-specific datatypes to register themselves as
54 // data type controllers. 61 // data type controllers.
55 // |disabled_types| and |enabled_types| control the disable/enable state of 62 // |disabled_types| and |enabled_types| control the disable/enable state of
56 // types that are on or off by default (respectively). 63 // types that are on or off by default (respectively).
57 typedef base::Callback<void(SyncService* sync_service, 64 typedef base::Callback<void(sync_driver::SyncService* sync_service,
58 ModelTypeSet disabled_types, 65 syncer::ModelTypeSet disabled_types,
59 ModelTypeSet enabled_types)> 66 syncer::ModelTypeSet enabled_types)>
60 RegisterDataTypesMethod; 67 RegisterDataTypesMethod;
61 68
62 // The various factory methods for the data type model associators 69 // The various factory methods for the data type model associators
63 // and change processors all return this struct. This is needed 70 // and change processors all return this struct. This is needed
64 // because the change processors typically require a type-specific 71 // because the change processors typically require a type-specific
65 // model associator at construction time. 72 // model associator at construction time.
66 // 73 //
67 // Note: This interface is deprecated in favor of the SyncableService API. 74 // Note: This interface is deprecated in favor of the SyncableService API.
68 // New datatypes that do not live on the UI thread should directly return a 75 // New datatypes that do not live on the UI thread should directly return a
69 // weak pointer to a SyncableService. All others continue to return 76 // weak pointer to a syncer::SyncableService. All others continue to return
70 // SyncComponents. It is safe to assume that the factory methods below are 77 // SyncComponents. It is safe to assume that the factory methods below are
71 // called on the same thread in which the datatype resides. 78 // called on the same thread in which the datatype resides.
72 // 79 //
73 // TODO(zea): Have all datatypes using the new API switch to returning 80 // TODO(zea): Have all datatypes using the new API switch to returning
74 // SyncableService weak pointers instead of SyncComponents (crbug.com/100114). 81 // SyncableService weak pointers instead of SyncComponents (crbug.com/100114).
75 struct SyncComponents { 82 struct SyncComponents {
76 AssociatorInterface* model_associator; 83 sync_driver::AssociatorInterface* model_associator;
77 ChangeProcessor* change_processor; 84 sync_driver::ChangeProcessor* change_processor;
78 SyncComponents(AssociatorInterface* ma, ChangeProcessor* cp) 85 SyncComponents(sync_driver::AssociatorInterface* ma,
86 sync_driver::ChangeProcessor* cp)
79 : model_associator(ma), change_processor(cp) {} 87 : model_associator(ma), change_processor(cp) {}
80 }; 88 };
81 89
82 // Creates and registers enabled datatypes with the provided SyncClient. 90 // Creates and registers enabled datatypes with the provided SyncClient.
83 virtual void RegisterDataTypes( 91 virtual void RegisterDataTypes(
84 SyncService* sync_service, 92 sync_driver::SyncService* sync_service,
85 const RegisterDataTypesMethod& register_platform_types_method) = 0; 93 const RegisterDataTypesMethod& register_platform_types_method) = 0;
86 94
87 // Instantiates a new DataTypeManager with a SyncBackendHost, a list of data 95 // Instantiates a new DataTypeManager with a SyncBackendHost, a list of data
88 // type controllers and a DataTypeManagerObserver. The return pointer is 96 // type controllers and a DataTypeManagerObserver. The return pointer is
89 // owned by the caller. 97 // owned by the caller.
90 virtual DataTypeManager* CreateDataTypeManager( 98 virtual sync_driver::DataTypeManager* CreateDataTypeManager(
91 const WeakHandle<DataTypeDebugInfoListener>& debug_info_listener, 99 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
92 const DataTypeController::TypeMap* controllers, 100 debug_info_listener,
93 const DataTypeEncryptionHandler* encryption_handler, 101 const sync_driver::DataTypeController::TypeMap* controllers,
94 SyncBackendHost* backend, 102 const sync_driver::DataTypeEncryptionHandler* encryption_handler,
95 DataTypeManagerObserver* observer) = 0; 103 browser_sync::SyncBackendHost* backend,
104 sync_driver::DataTypeManagerObserver* observer) = 0;
96 105
97 // Creating this in the factory helps us mock it out in testing. 106 // Creating this in the factory helps us mock it out in testing.
98 virtual SyncBackendHost* CreateSyncBackendHost( 107 virtual browser_sync::SyncBackendHost* CreateSyncBackendHost(
99 const std::string& name, 108 const std::string& name,
100 invalidation::InvalidationService* invalidator, 109 invalidation::InvalidationService* invalidator,
101 const base::WeakPtr<SyncPrefs>& sync_prefs, 110 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs,
102 const base::FilePath& sync_folder) = 0; 111 const base::FilePath& sync_folder) = 0;
103 112
104 // Creating this in the factory helps us mock it out in testing. 113 // Creating this in the factory helps us mock it out in testing.
105 virtual std::unique_ptr<LocalDeviceInfoProvider> 114 virtual std::unique_ptr<sync_driver::LocalDeviceInfoProvider>
106 CreateLocalDeviceInfoProvider() = 0; 115 CreateLocalDeviceInfoProvider() = 0;
107 116
108 // Legacy datatypes that need to be converted to the SyncableService API. 117 // Legacy datatypes that need to be converted to the SyncableService API.
109 virtual SyncComponents CreateBookmarkSyncComponents( 118 virtual SyncComponents CreateBookmarkSyncComponents(
110 SyncService* sync_service, 119 sync_driver::SyncService* sync_service,
111 std::unique_ptr<DataTypeErrorHandler> error_handler) = 0; 120 std::unique_ptr<syncer::DataTypeErrorHandler> error_handler) = 0;
112 121
113 // Creates attachment service. 122 // Creates attachment service.
114 // Note: Should only be called from the model type thread. 123 // Note: Should only be called from the model type thread.
115 // 124 //
116 // |store_birthday| is the store birthday. Must not be empty. 125 // |store_birthday| is the store birthday. Must not be empty.
117 // 126 //
118 // |model_type| is the model type this AttachmentService will be used with. 127 // |model_type| is the model type this AttachmentService will be used with.
119 // 128 //
120 // |delegate| is optional delegate for AttachmentService to notify about 129 // |delegate| is optional delegate for AttachmentService to notify about
121 // asynchronous events (AttachmentUploaded). Pass NULL if delegate is not 130 // asynchronous events (AttachmentUploaded). Pass NULL if delegate is not
122 // provided. AttachmentService doesn't take ownership of delegate, the pointer 131 // provided. AttachmentService doesn't take ownership of delegate, the pointer
123 // must be valid throughout AttachmentService lifetime. 132 // must be valid throughout AttachmentService lifetime.
124 virtual std::unique_ptr<AttachmentService> CreateAttachmentService( 133 virtual std::unique_ptr<syncer::AttachmentService> CreateAttachmentService(
125 std::unique_ptr<AttachmentStoreForSync> attachment_store, 134 std::unique_ptr<syncer::AttachmentStoreForSync> attachment_store,
126 const UserShare& user_share, 135 const syncer::UserShare& user_share,
127 const std::string& store_birthday, 136 const std::string& store_birthday,
128 ModelType model_type, 137 syncer::ModelType model_type,
129 AttachmentService::Delegate* delegate) = 0; 138 syncer::AttachmentService::Delegate* delegate) = 0;
130 }; 139 };
131 140
132 } // namespace syncer 141 } // namespace sync_driver
133 142
134 #endif // COMPONENTS_SYNC_DRIVER_SYNC_API_COMPONENT_FACTORY_H_ 143 #endif // COMPONENTS_SYNC_DRIVER_SYNC_API_COMPONENT_FACTORY_H_
OLDNEW
« no previous file with comments | « components/sync/driver/startup_controller_unittest.cc ('k') | components/sync/driver/sync_api_component_factory_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698