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

Side by Side Diff: chrome/browser/sync/profile_sync_factory.h

Issue 8065016: [Sync] Refactor non-frontend DTC to handle new API properly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase++++ Created 9 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 | Annotate | Revision Log
OLDNEW
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 class WebDataService; 24 class WebDataService;
24 25
25 namespace browser_sync { 26 namespace browser_sync {
26 class DataTypeManager; 27 class DataTypeManager;
28 class GenericChangeProcessor;
29 class SharedChangeProcessor;
27 class SyncBackendHost; 30 class SyncBackendHost;
28 class UnrecoverableErrorHandler; 31 class UnrecoverableErrorHandler;
29 } 32 }
30 33
31 namespace history { 34 namespace history {
32 class HistoryBackend; 35 class HistoryBackend;
33 }; 36 };
34 37
35 // Factory class for all profile sync related classes. 38 // Factory class for all profile sync related classes.
36 class ProfileSyncFactory { 39 class ProfileSyncFactory {
37 public: 40 public:
38 // The various factory methods for the data type model associators 41 // The various factory methods for the data type model associators
39 // and change processors all return this struct. This is needed 42 // and change processors all return this struct. This is needed
40 // because the change processors typically require a type-specific 43 // because the change processors typically require a type-specific
41 // model associator at construction time. 44 // 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).
42 struct SyncComponents { 54 struct SyncComponents {
43 browser_sync::AssociatorInterface* model_associator; 55 browser_sync::AssociatorInterface* model_associator;
44 browser_sync::ChangeProcessor* change_processor; 56 browser_sync::ChangeProcessor* change_processor;
45 SyncComponents(browser_sync::AssociatorInterface* ma, 57 SyncComponents(browser_sync::AssociatorInterface* ma,
46 browser_sync::ChangeProcessor* cp) 58 browser_sync::ChangeProcessor* cp)
47 : model_associator(ma), change_processor(cp) {} 59 : model_associator(ma), change_processor(cp) {}
48 }; 60 };
49 61
50 virtual ~ProfileSyncFactory() {} 62 virtual ~ProfileSyncFactory() {}
51 63
52 // Instantiates a new ProfileSyncService. The return pointer is owned by the 64 // Instantiates a new ProfileSyncService. The return pointer is owned by the
53 // caller. 65 // caller.
54 virtual ProfileSyncService* CreateProfileSyncService( 66 virtual ProfileSyncService* CreateProfileSyncService(
55 const std::string& cros_user) = 0; 67 const std::string& cros_user) = 0;
56 68
57 // Creates and registers enabled datatypes with the provided 69 // Creates and registers enabled datatypes with the provided
58 // ProfileSyncService. 70 // ProfileSyncService.
59 virtual void RegisterDataTypes(ProfileSyncService* pss) = 0; 71 virtual void RegisterDataTypes(ProfileSyncService* pss) = 0;
60 72
61 // Instantiates a new DataTypeManager with a SyncBackendHost and a 73 // Instantiates a new DataTypeManager with a SyncBackendHost and a
62 // list of data type controllers. The return pointer is owned by 74 // list of data type controllers. The return pointer is owned by
63 // the caller. 75 // the caller.
64 virtual browser_sync::DataTypeManager* CreateDataTypeManager( 76 virtual browser_sync::DataTypeManager* CreateDataTypeManager(
65 browser_sync::SyncBackendHost* backend, 77 browser_sync::SyncBackendHost* backend,
66 const browser_sync::DataTypeController::TypeMap* controllers) = 0; 78 const browser_sync::DataTypeController::TypeMap* controllers) = 0;
67 79
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
68 // Instantiates both a model associator and change processor for the 89 // Instantiates both a model associator and change processor for the
69 // app data type. The pointers in the return struct are 90 // app data type. The pointers in the return struct are
70 // owned by the caller. 91 // owned by the caller.
71 virtual SyncComponents CreateAppSyncComponents( 92 virtual SyncComponents CreateAppSyncComponents(
72 ProfileSyncService* profile_sync_service, 93 ProfileSyncService* profile_sync_service,
73 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; 94 browser_sync::UnrecoverableErrorHandler* error_handler) = 0;
74 95
75 // Instantiates both a model associator and change processor for the 96 // Instantiates both a model associator and change processor for the
76 // autofill data type. The pointers in the return struct are owned 97 // autofill data type. The pointers in the return struct are owned
77 // by the caller. 98 // by the caller.
78 virtual SyncComponents CreateAutofillSyncComponents( 99 virtual SyncComponents CreateAutofillSyncComponents(
79 ProfileSyncService* profile_sync_service, 100 ProfileSyncService* profile_sync_service,
80 WebDatabase* web_database, 101 WebDatabase* web_database,
81 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; 102 browser_sync::UnrecoverableErrorHandler* error_handler) = 0;
82 103
83 // Instantiates both a model associator and change processor for the 104 // Returns a weak pointer to the SyncableService associated with the datatype.
84 // autofill data type. The pointers in the return struct are owned 105 // The SyncableService is not owned by Sync, but by the backend service
85 // by the caller. 106 // itself.
86 virtual SyncComponents CreateAutofillProfileSyncComponents( 107 virtual base::WeakPtr<SyncableService> GetAutofillProfileSyncableService(
87 ProfileSyncService* profile_sync_service, 108 WebDataService* web_data_service) const = 0;
88 WebDataService* web_data_service,
89 browser_sync::UnrecoverableErrorHandler* error_handler) = 0;
90 109
91 // Instantiates both a model associator and change processor for the 110 // Instantiates both a model associator and change processor for the
92 // bookmark data type. The pointers in the return struct are owned 111 // bookmark data type. The pointers in the return struct are owned
93 // by the caller. 112 // by the caller.
94 virtual SyncComponents CreateBookmarkSyncComponents( 113 virtual SyncComponents CreateBookmarkSyncComponents(
95 ProfileSyncService* profile_sync_service, 114 ProfileSyncService* profile_sync_service,
96 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; 115 browser_sync::UnrecoverableErrorHandler* error_handler) = 0;
97 116
98 // Instantiates both a model associator and change processor for the 117 // Instantiates both a model associator and change processor for the
99 // extension setting data type. The pointers in the return struct are 118 // extension setting data type. The pointers in the return struct are
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 168
150 // Instantiates both a model associator and change processor for the search 169 // Instantiates both a model associator and change processor for the search
151 // engine data type. The pointers in the return struct are owned by the 170 // engine data type. The pointers in the return struct are owned by the
152 // caller. 171 // caller.
153 virtual SyncComponents CreateSearchEngineSyncComponents( 172 virtual SyncComponents CreateSearchEngineSyncComponents(
154 ProfileSyncService* profile_sync_service, 173 ProfileSyncService* profile_sync_service,
155 browser_sync::UnrecoverableErrorHandler* error_handler) = 0; 174 browser_sync::UnrecoverableErrorHandler* error_handler) = 0;
156 }; 175 };
157 176
158 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_FACTORY_H__ 177 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_FACTORY_H__
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/syncable_service_adapter.cc ('k') | chrome/browser/sync/profile_sync_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698