Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / sync / profile_sync_components_factory.h
blob9fa6ab1cebaf5e2a2b3f162e9bc9eb59c1a098c8
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_H__
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_H__
8 #include <string>
10 #include "base/files/file_path.h"
11 #include "base/memory/weak_ptr.h"
12 #include "components/invalidation/public/invalidation_service.h"
13 #include "components/sync_driver/data_type_controller.h"
14 #include "components/sync_driver/data_type_error_handler.h"
15 #include "components/sync_driver/sync_api_component_factory.h"
16 #include "sync/api/sync_merge_result.h"
17 #include "sync/internal_api/public/util/unrecoverable_error_handler.h"
18 #include "sync/internal_api/public/util/weak_handle.h"
20 class PasswordStore;
21 class Profile;
22 class ProfileSyncService;
24 namespace browser_sync {
25 class SyncBackendHost;
26 } // namespace browser_sync
28 namespace sync_driver {
29 class AssociatorInterface;
30 class ChangeProcessor;
31 class DataTypeEncryptionHandler;
32 class DataTypeErrorHandler;
33 class DataTypeManager;
34 class DataTypeManagerObserver;
35 class DataTypeStatusTable;
36 class GenericChangeProcessor;
37 class LocalDeviceInfoProvider;
38 class SyncPrefs;
39 } // namespace sync_driver
41 namespace syncer {
42 class DataTypeDebugInfoListener;
43 class SyncableService;
44 } // namespace syncer
46 namespace history {
47 class HistoryBackend;
48 } // namespace history
50 // Factory class for all profile sync related classes.
51 class ProfileSyncComponentsFactory
52 : public sync_driver::SyncApiComponentFactory {
53 public:
54 // The various factory methods for the data type model associators
55 // and change processors all return this struct. This is needed
56 // because the change processors typically require a type-specific
57 // model associator at construction time.
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
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
63 // called on the same thread in which the datatype resides.
65 // TODO(zea): Have all datatypes using the new API switch to returning
66 // SyncableService weak pointers instead of SyncComponents (crbug.com/100114).
67 struct SyncComponents {
68 sync_driver::AssociatorInterface* model_associator;
69 sync_driver::ChangeProcessor* change_processor;
70 SyncComponents(sync_driver::AssociatorInterface* ma,
71 sync_driver::ChangeProcessor* cp)
72 : model_associator(ma), change_processor(cp) {}
75 ~ProfileSyncComponentsFactory() override {}
77 // Creates and registers enabled datatypes with the provided
78 // ProfileSyncService.
79 virtual void RegisterDataTypes(ProfileSyncService* pss) = 0;
81 // Instantiates a new DataTypeManager with a SyncBackendHost, a list of data
82 // type controllers and a DataTypeManagerObserver. The return pointer is
83 // owned by the caller.
84 virtual sync_driver::DataTypeManager* CreateDataTypeManager(
85 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
86 debug_info_listener,
87 const sync_driver::DataTypeController::TypeMap* controllers,
88 const sync_driver::DataTypeEncryptionHandler* encryption_handler,
89 browser_sync::SyncBackendHost* backend,
90 sync_driver::DataTypeManagerObserver* observer) = 0;
92 // Creating this in the factory helps us mock it out in testing.
93 virtual browser_sync::SyncBackendHost* CreateSyncBackendHost(
94 const std::string& name,
95 Profile* profile,
96 invalidation::InvalidationService* invalidator,
97 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs,
98 const base::FilePath& sync_folder) = 0;
100 // Creating this in the factory helps us mock it out in testing.
101 virtual scoped_ptr<sync_driver::LocalDeviceInfoProvider>
102 CreateLocalDeviceInfoProvider() = 0;
104 // Legacy datatypes that need to be converted to the SyncableService API.
105 virtual SyncComponents CreateBookmarkSyncComponents(
106 ProfileSyncService* profile_sync_service,
107 sync_driver::DataTypeErrorHandler* error_handler) = 0;
108 virtual SyncComponents CreateTypedUrlSyncComponents(
109 ProfileSyncService* profile_sync_service,
110 history::HistoryBackend* history_backend,
111 sync_driver::DataTypeErrorHandler* error_handler) = 0;
114 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_H__