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; |
22 class WebDatabase; | 23 class WebDatabase; |
23 | 24 |
24 namespace browser_sync { | 25 namespace browser_sync { |
25 class DataTypeManager; | 26 class DataTypeManager; |
| 27 class GenericChangeProcessor; |
| 28 class SharedChangeProcessor; |
26 class SyncBackendHost; | 29 class SyncBackendHost; |
27 class UnrecoverableErrorHandler; | 30 class UnrecoverableErrorHandler; |
28 } | 31 } |
29 | 32 |
30 namespace history { | 33 namespace history { |
31 class HistoryBackend; | 34 class HistoryBackend; |
32 }; | 35 }; |
33 | 36 |
34 // Factory class for all profile sync related classes. | 37 // Factory class for all profile sync related classes. |
35 class ProfileSyncFactory { | 38 class ProfileSyncFactory { |
36 public: | 39 public: |
37 // The various factory methods for the data type model associators | 40 // The various factory methods for the data type model associators |
38 // and change processors all return this struct. This is needed | 41 // and change processors all return this struct. This is needed |
39 // because the change processors typically require a type-specific | 42 // because the change processors typically require a type-specific |
40 // model associator at construction time. | 43 // model associator at construction time. |
| 44 // Note: this interface is deprecated in favor of the SyncableService API. |
| 45 // New datatypes that do not live on the UI thread should directly return a |
| 46 // SyncableService. All others continue to return SyncComponents. It is safe |
| 47 // to assume that the factory methods below are called on the same thread |
| 48 // in which the datatype resides. |
| 49 // TODO(zea): Have all datatypes just return their SyncableService pointers. |
41 struct SyncComponents { | 50 struct SyncComponents { |
42 browser_sync::AssociatorInterface* model_associator; | 51 browser_sync::AssociatorInterface* model_associator; |
43 browser_sync::ChangeProcessor* change_processor; | 52 browser_sync::ChangeProcessor* change_processor; |
44 SyncComponents(browser_sync::AssociatorInterface* ma, | 53 SyncComponents(browser_sync::AssociatorInterface* ma, |
45 browser_sync::ChangeProcessor* cp) | 54 browser_sync::ChangeProcessor* cp) |
46 : model_associator(ma), change_processor(cp) {} | 55 : model_associator(ma), change_processor(cp) {} |
47 }; | 56 }; |
48 | 57 |
49 virtual ~ProfileSyncFactory() {} | 58 virtual ~ProfileSyncFactory() {} |
50 | 59 |
51 // Instantiates a new ProfileSyncService. The return pointer is owned by the | 60 // Instantiates a new ProfileSyncService. The return pointer is owned by the |
52 // caller. | 61 // caller. |
53 virtual ProfileSyncService* CreateProfileSyncService( | 62 virtual ProfileSyncService* CreateProfileSyncService( |
54 const std::string& cros_user) = 0; | 63 const std::string& cros_user) = 0; |
55 | 64 |
56 // Creates and registers enabled datatypes with the provided | 65 // Creates and registers enabled datatypes with the provided |
57 // ProfileSyncService. | 66 // ProfileSyncService. |
58 virtual void RegisterDataTypes(ProfileSyncService* pss) = 0; | 67 virtual void RegisterDataTypes(ProfileSyncService* pss) = 0; |
59 | 68 |
60 // Instantiates a new DataTypeManager with a SyncBackendHost and a | 69 // Instantiates a new DataTypeManager with a SyncBackendHost and a |
61 // list of data type controllers. The return pointer is owned by | 70 // list of data type controllers. The return pointer is owned by |
62 // the caller. | 71 // the caller. |
63 virtual browser_sync::DataTypeManager* CreateDataTypeManager( | 72 virtual browser_sync::DataTypeManager* CreateDataTypeManager( |
64 browser_sync::SyncBackendHost* backend, | 73 browser_sync::SyncBackendHost* backend, |
65 const browser_sync::DataTypeController::TypeMap* controllers) = 0; | 74 const browser_sync::DataTypeController::TypeMap* controllers) = 0; |
66 | 75 |
| 76 virtual browser_sync::GenericChangeProcessor* CreateGenericChangeProcessor( |
| 77 ProfileSyncService* profile_sync_service, |
| 78 browser_sync::UnrecoverableErrorHandler* error_handler, |
| 79 SyncableService* local_service) = 0; |
| 80 |
| 81 virtual browser_sync::SharedChangeProcessor* CreateSharedChangeProcessor( |
| 82 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; |
| 83 |
67 // Instantiates both a model associator and change processor for the | 84 // Instantiates both a model associator and change processor for the |
68 // app data type. The pointers in the return struct are | 85 // app data type. The pointers in the return struct are |
69 // owned by the caller. | 86 // owned by the caller. |
70 virtual SyncComponents CreateAppSyncComponents( | 87 virtual SyncComponents CreateAppSyncComponents( |
71 ProfileSyncService* profile_sync_service, | 88 ProfileSyncService* profile_sync_service, |
72 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; | 89 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; |
73 | 90 |
74 // Instantiates both a model associator and change processor for the | 91 // Instantiates both a model associator and change processor for the |
75 // autofill data type. The pointers in the return struct are owned | 92 // autofill data type. The pointers in the return struct are owned |
76 // by the caller. | 93 // by the caller. |
77 virtual SyncComponents CreateAutofillSyncComponents( | 94 virtual SyncComponents CreateAutofillSyncComponents( |
78 ProfileSyncService* profile_sync_service, | 95 ProfileSyncService* profile_sync_service, |
79 WebDatabase* web_database, | 96 WebDatabase* web_database, |
80 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; | 97 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; |
81 | 98 |
82 // Instantiates both a model associator and change processor for the | 99 // Returns a pointer to the SyncableService associated with the datatype. |
83 // autofill data type. The pointers in the return struct are owned | 100 // The SyncableService is not owned by Sync, but by the backend service |
84 // by the caller. | 101 // itself. |
85 virtual SyncComponents CreateAutofillProfileSyncComponents( | 102 virtual SyncableService* CreateAutofillProfileSyncComponents( |
86 ProfileSyncService* profile_sync_service, | 103 ProfileSyncService* profile_sync_service, |
87 WebDatabase* web_database, | 104 WebDatabase* web_database) = 0; |
88 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; | |
89 | 105 |
90 // Instantiates both a model associator and change processor for the | 106 // Instantiates both a model associator and change processor for the |
91 // bookmark data type. The pointers in the return struct are owned | 107 // bookmark data type. The pointers in the return struct are owned |
92 // by the caller. | 108 // by the caller. |
93 virtual SyncComponents CreateBookmarkSyncComponents( | 109 virtual SyncComponents CreateBookmarkSyncComponents( |
94 ProfileSyncService* profile_sync_service, | 110 ProfileSyncService* profile_sync_service, |
95 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; | 111 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; |
96 | 112 |
97 // Instantiates both a model associator and change processor for the | 113 // Instantiates both a model associator and change processor for the |
98 // extension setting data type. The pointers in the return struct are | 114 // extension setting data type. The pointers in the return struct are |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 164 |
149 // Instantiates both a model associator and change processor for the search | 165 // Instantiates both a model associator and change processor for the search |
150 // engine data type. The pointers in the return struct are owned by the | 166 // engine data type. The pointers in the return struct are owned by the |
151 // caller. | 167 // caller. |
152 virtual SyncComponents CreateSearchEngineSyncComponents( | 168 virtual SyncComponents CreateSearchEngineSyncComponents( |
153 ProfileSyncService* profile_sync_service, | 169 ProfileSyncService* profile_sync_service, |
154 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; | 170 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; |
155 }; | 171 }; |
156 | 172 |
157 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_FACTORY_H__ | 173 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_FACTORY_H__ |
OLD | NEW |