OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_FACTORY_H__ | 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_FACTORY_H__ |
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_FACTORY_H__ | 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_FACTORY_H__ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/task.h" | 12 #include "base/task.h" |
13 #include "chrome/browser/sync/glue/change_processor.h" | 13 #include "chrome/browser/sync/glue/change_processor.h" |
14 #include "chrome/browser/sync/glue/data_type_controller.h" | 14 #include "chrome/browser/sync/glue/data_type_controller.h" |
15 #include "chrome/browser/sync/glue/model_associator.h" | 15 #include "chrome/browser/sync/glue/model_associator.h" |
16 #include "chrome/browser/sync/unrecoverable_error_handler.h" | 16 #include "chrome/browser/sync/unrecoverable_error_handler.h" |
17 | 17 |
18 class ExtensionSettingsBackend; | 18 class ExtensionSettingsBackend; |
19 class PasswordStore; | 19 class PasswordStore; |
20 class PersonalDataManager; | 20 class PersonalDataManager; |
21 class ProfileSyncService; | 21 class ProfileSyncService; |
22 class SyncableService; | |
23 class WebDatabase; | 22 class WebDatabase; |
24 class WebDataService; | 23 class WebDataService; |
25 | 24 |
26 namespace browser_sync { | 25 namespace browser_sync { |
27 class DataTypeManager; | 26 class DataTypeManager; |
28 class GenericChangeProcessor; | |
29 class SharedChangeProcessor; | |
30 class SyncBackendHost; | 27 class SyncBackendHost; |
31 class UnrecoverableErrorHandler; | 28 class UnrecoverableErrorHandler; |
32 } | 29 } |
33 | 30 |
34 namespace history { | 31 namespace history { |
35 class HistoryBackend; | 32 class HistoryBackend; |
36 }; | 33 }; |
37 | 34 |
38 // Factory class for all profile sync related classes. | 35 // Factory class for all profile sync related classes. |
39 class ProfileSyncFactory { | 36 class ProfileSyncFactory { |
40 public: | 37 public: |
41 // The various factory methods for the data type model associators | 38 // The various factory methods for the data type model associators |
42 // and change processors all return this struct. This is needed | 39 // and change processors all return this struct. This is needed |
43 // because the change processors typically require a type-specific | 40 // because the change processors typically require a type-specific |
44 // model associator at construction time. | 41 // model associator at construction time. |
45 // | |
46 // Note: This interface is deprecated in favor of the SyncableService API. | |
47 // New datatypes that do not live on the UI thread should directly return a | |
48 // weak pointer to a SyncableService. All others continue to return | |
49 // SyncComponents. It is safe to assume that the factory methods below are | |
50 // called on the same thread in which the datatype resides. | |
51 // | |
52 // TODO(zea): Have all datatypes using the new API switch to returning | |
53 // SyncableService weak pointers instead of SyncComponents (crbug.com/100114). | |
54 struct SyncComponents { | 42 struct SyncComponents { |
55 browser_sync::AssociatorInterface* model_associator; | 43 browser_sync::AssociatorInterface* model_associator; |
56 browser_sync::ChangeProcessor* change_processor; | 44 browser_sync::ChangeProcessor* change_processor; |
57 SyncComponents(browser_sync::AssociatorInterface* ma, | 45 SyncComponents(browser_sync::AssociatorInterface* ma, |
58 browser_sync::ChangeProcessor* cp) | 46 browser_sync::ChangeProcessor* cp) |
59 : model_associator(ma), change_processor(cp) {} | 47 : model_associator(ma), change_processor(cp) {} |
60 }; | 48 }; |
61 | 49 |
62 virtual ~ProfileSyncFactory() {} | 50 virtual ~ProfileSyncFactory() {} |
63 | 51 |
64 // Instantiates a new ProfileSyncService. The return pointer is owned by the | 52 // Instantiates a new ProfileSyncService. The return pointer is owned by the |
65 // caller. | 53 // caller. |
66 virtual ProfileSyncService* CreateProfileSyncService( | 54 virtual ProfileSyncService* CreateProfileSyncService( |
67 const std::string& cros_user) = 0; | 55 const std::string& cros_user) = 0; |
68 | 56 |
69 // Creates and registers enabled datatypes with the provided | 57 // Creates and registers enabled datatypes with the provided |
70 // ProfileSyncService. | 58 // ProfileSyncService. |
71 virtual void RegisterDataTypes(ProfileSyncService* pss) = 0; | 59 virtual void RegisterDataTypes(ProfileSyncService* pss) = 0; |
72 | 60 |
73 // Instantiates a new DataTypeManager with a SyncBackendHost and a | 61 // Instantiates a new DataTypeManager with a SyncBackendHost and a |
74 // list of data type controllers. The return pointer is owned by | 62 // list of data type controllers. The return pointer is owned by |
75 // the caller. | 63 // the caller. |
76 virtual browser_sync::DataTypeManager* CreateDataTypeManager( | 64 virtual browser_sync::DataTypeManager* CreateDataTypeManager( |
77 browser_sync::SyncBackendHost* backend, | 65 browser_sync::SyncBackendHost* backend, |
78 const browser_sync::DataTypeController::TypeMap* controllers) = 0; | 66 const browser_sync::DataTypeController::TypeMap* controllers) = 0; |
79 | 67 |
80 // Creating this in the factory helps us mock it out in testing. | |
81 virtual browser_sync::GenericChangeProcessor* CreateGenericChangeProcessor( | |
82 ProfileSyncService* profile_sync_service, | |
83 browser_sync::UnrecoverableErrorHandler* error_handler, | |
84 const base::WeakPtr<SyncableService>& local_service) = 0; | |
85 | |
86 virtual browser_sync::SharedChangeProcessor* | |
87 CreateSharedChangeProcessor() = 0; | |
88 | |
89 // Instantiates both a model associator and change processor for the | 68 // Instantiates both a model associator and change processor for the |
90 // app data type. The pointers in the return struct are | 69 // app data type. The pointers in the return struct are |
91 // owned by the caller. | 70 // owned by the caller. |
92 virtual SyncComponents CreateAppSyncComponents( | 71 virtual SyncComponents CreateAppSyncComponents( |
93 ProfileSyncService* profile_sync_service, | 72 ProfileSyncService* profile_sync_service, |
94 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; | 73 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; |
95 | 74 |
96 // Instantiates both a model associator and change processor for the | 75 // Instantiates both a model associator and change processor for the |
97 // autofill data type. The pointers in the return struct are owned | 76 // autofill data type. The pointers in the return struct are owned |
98 // by the caller. | 77 // by the caller. |
99 virtual SyncComponents CreateAutofillSyncComponents( | 78 virtual SyncComponents CreateAutofillSyncComponents( |
100 ProfileSyncService* profile_sync_service, | 79 ProfileSyncService* profile_sync_service, |
101 WebDatabase* web_database, | 80 WebDatabase* web_database, |
102 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; | 81 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; |
103 | 82 |
104 // Returns a weak pointer to the SyncableService associated with the datatype. | 83 // Instantiates both a model associator and change processor for the |
105 // The SyncableService is not owned by Sync, but by the backend service | 84 // autofill data type. The pointers in the return struct are owned |
106 // itself. | 85 // by the caller. |
107 virtual base::WeakPtr<SyncableService> GetAutofillProfileSyncableService( | 86 virtual SyncComponents CreateAutofillProfileSyncComponents( |
108 WebDataService* web_data_service) const = 0; | 87 ProfileSyncService* profile_sync_service, |
| 88 WebDataService* web_data_service, |
| 89 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; |
109 | 90 |
110 // Instantiates both a model associator and change processor for the | 91 // Instantiates both a model associator and change processor for the |
111 // bookmark data type. The pointers in the return struct are owned | 92 // bookmark data type. The pointers in the return struct are owned |
112 // by the caller. | 93 // by the caller. |
113 virtual SyncComponents CreateBookmarkSyncComponents( | 94 virtual SyncComponents CreateBookmarkSyncComponents( |
114 ProfileSyncService* profile_sync_service, | 95 ProfileSyncService* profile_sync_service, |
115 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; | 96 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; |
116 | 97 |
117 // Instantiates both a model associator and change processor for the | 98 // Instantiates both a model associator and change processor for the |
118 // extension setting data type. The pointers in the return struct are | 99 // extension setting data type. The pointers in the return struct are |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 149 |
169 // Instantiates both a model associator and change processor for the search | 150 // Instantiates both a model associator and change processor for the search |
170 // engine data type. The pointers in the return struct are owned by the | 151 // engine data type. The pointers in the return struct are owned by the |
171 // caller. | 152 // caller. |
172 virtual SyncComponents CreateSearchEngineSyncComponents( | 153 virtual SyncComponents CreateSearchEngineSyncComponents( |
173 ProfileSyncService* profile_sync_service, | 154 ProfileSyncService* profile_sync_service, |
174 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; | 155 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; |
175 }; | 156 }; |
176 | 157 |
177 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_FACTORY_H__ | 158 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_FACTORY_H__ |
OLD | NEW |