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

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

Issue 1310553005: [Sync] Replace ProfileSyncComponentsFactory with SyncClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self review Created 5 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 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 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_COMPONENTS_FACTORY_IMPL_H__ 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_H__
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_H__ 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_H__
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/sync/chrome_sync_client.h" 13 #include "chrome/browser/sync/chrome_sync_client.h"
14 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" 14 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
15 #include "components/sync_driver/profile_sync_components_factory.h" 15 #include "components/sync_driver/sync_api_component_factory.h"
16 #include "google_apis/gaia/oauth2_token_service.h" 16 #include "google_apis/gaia/oauth2_token_service.h"
17 #include "sync/internal_api/public/base/model_type.h" 17 #include "sync/internal_api/public/base/model_type.h"
18 18
19 class Profile; 19 class Profile;
20 20
21 namespace base { 21 namespace base {
22 class CommandLine; 22 class CommandLine;
23 } 23 }
24 24
25 namespace extensions { 25 namespace extensions {
26 class ExtensionSystem; 26 class ExtensionSystem;
27 } 27 }
28 28
29 class ProfileSyncComponentsFactoryImpl : public ProfileSyncComponentsFactory { 29 class ProfileSyncComponentsFactoryImpl
30 : public sync_driver::SyncApiComponentFactory {
30 public: 31 public:
31 // Constructs a ProfileSyncComponentsFactoryImpl. 32 // Constructs a ProfileSyncComponentsFactoryImpl.
32 // 33 //
33 // |sync_service_url| is the base URL of the sync server. 34 // |sync_service_url| is the base URL of the sync server.
34 // 35 //
35 // |token_service| must outlive the ProfileSyncComponentsFactoryImpl. 36 // |token_service| must outlive the ProfileSyncComponentsFactoryImpl.
36 // 37 //
37 // |url_request_context_getter| must outlive the 38 // |url_request_context_getter| must outlive the
38 // ProfileSyncComponentsFactoryImpl. 39 // ProfileSyncComponentsFactoryImpl.
39 ProfileSyncComponentsFactoryImpl( 40 ProfileSyncComponentsFactoryImpl(
40 Profile* profile, 41 Profile* profile,
41 base::CommandLine* command_line, 42 base::CommandLine* command_line,
42 const GURL& sync_service_url, 43 const GURL& sync_service_url,
43 OAuth2TokenService* token_service, 44 OAuth2TokenService* token_service,
44 net::URLRequestContextGetter* url_request_context_getter); 45 net::URLRequestContextGetter* url_request_context_getter);
45 ~ProfileSyncComponentsFactoryImpl() override; 46 ~ProfileSyncComponentsFactoryImpl() override;
46 47
47 void RegisterDataTypes(ProfileSyncService* pss) override; 48 // Initializes internal state after construction.
49 void Initialize(sync_driver::SyncService* sync_service) override;
50
51 void RegisterDataTypes(sync_driver::SyncService* pss) override;
48 52
49 sync_driver::DataTypeManager* CreateDataTypeManager( 53 sync_driver::DataTypeManager* CreateDataTypeManager(
50 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& 54 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
51 debug_info_listener, 55 debug_info_listener,
52 const sync_driver::DataTypeController::TypeMap* controllers, 56 const sync_driver::DataTypeController::TypeMap* controllers,
53 const sync_driver::DataTypeEncryptionHandler* encryption_handler, 57 const sync_driver::DataTypeEncryptionHandler* encryption_handler,
54 browser_sync::SyncBackendHost* backend, 58 browser_sync::SyncBackendHost* backend,
55 sync_driver::DataTypeManagerObserver* observer) override; 59 sync_driver::DataTypeManagerObserver* observer) override;
56 60
57 browser_sync::SyncBackendHost* CreateSyncBackendHost( 61 browser_sync::SyncBackendHost* CreateSyncBackendHost(
58 const std::string& name, 62 const std::string& name,
59 Profile* profile,
60 invalidation::InvalidationService* invalidator, 63 invalidation::InvalidationService* invalidator,
61 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, 64 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs,
62 const base::FilePath& sync_folder) override; 65 const base::FilePath& sync_folder) override;
63 66
64 scoped_ptr<sync_driver::LocalDeviceInfoProvider> 67 scoped_ptr<sync_driver::LocalDeviceInfoProvider>
65 CreateLocalDeviceInfoProvider() override; 68 CreateLocalDeviceInfoProvider() override;
66 69
67 // TODO(zea): crbug.com/512768 Remove GetSyncableServiceForType from
68 // ProfileSyncComponentsFactory and have everything use the SyncClient
69 // instead.
70 base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType(
71 syncer::ModelType type) override;
72 scoped_ptr<syncer::AttachmentService> CreateAttachmentService( 70 scoped_ptr<syncer::AttachmentService> CreateAttachmentService(
73 scoped_ptr<syncer::AttachmentStoreForSync> attachment_store, 71 scoped_ptr<syncer::AttachmentStoreForSync> attachment_store,
74 const syncer::UserShare& user_share, 72 const syncer::UserShare& user_share,
75 const std::string& store_birthday, 73 const std::string& store_birthday,
76 syncer::ModelType model_type, 74 syncer::ModelType model_type,
77 syncer::AttachmentService::Delegate* delegate) override; 75 syncer::AttachmentService::Delegate* delegate) override;
78 76
79 // Legacy datatypes that need to be converted to the SyncableService API. 77 // Legacy datatypes that need to be converted to the SyncableService API.
80 SyncComponents CreateBookmarkSyncComponents( 78 sync_driver::SyncApiComponentFactory::SyncComponents
81 ProfileSyncService* profile_sync_service, 79 CreateBookmarkSyncComponents(
80 sync_driver::SyncService* sync_service,
82 sync_driver::DataTypeErrorHandler* error_handler) override; 81 sync_driver::DataTypeErrorHandler* error_handler) override;
83 SyncComponents CreateTypedUrlSyncComponents( 82 sync_driver::SyncApiComponentFactory::SyncComponents
84 ProfileSyncService* profile_sync_service, 83 CreateTypedUrlSyncComponents(
84 sync_driver::SyncService* sync_service,
85 history::HistoryBackend* history_backend, 85 history::HistoryBackend* history_backend,
86 sync_driver::DataTypeErrorHandler* error_handler) override; 86 sync_driver::DataTypeErrorHandler* error_handler) override;
87 87
88 private: 88 private:
89 // Register data types which are enabled on desktop platforms only. 89 // Register data types which are enabled on desktop platforms only.
90 // |disabled_types| and |enabled_types| correspond only to those types 90 // |disabled_types| and |enabled_types| correspond only to those types
91 // being explicitly enabled/disabled by the command line. 91 // being explicitly enabled/disabled by the command line.
92 void RegisterDesktopDataTypes(syncer::ModelTypeSet disabled_types, 92 void RegisterDesktopDataTypes(syncer::ModelTypeSet disabled_types,
93 syncer::ModelTypeSet enabled_types, 93 syncer::ModelTypeSet enabled_types,
94 ProfileSyncService* pss); 94 sync_driver::SyncService* pss);
95 // Register data types which are enabled on both desktop and mobile. 95 // Register data types which are enabled on both desktop and mobile.
96 // |disabled_types| and |enabled_types| correspond only to those types 96 // |disabled_types| and |enabled_types| correspond only to those types
97 // being explicitly enabled/disabled by the command line. 97 // being explicitly enabled/disabled by the command line.
98 void RegisterCommonDataTypes(syncer::ModelTypeSet disabled_types, 98 void RegisterCommonDataTypes(syncer::ModelTypeSet disabled_types,
99 syncer::ModelTypeSet enabled_types, 99 syncer::ModelTypeSet enabled_types,
100 ProfileSyncService* pss); 100 sync_driver::SyncService* pss);
101 // Used to bind a callback to give to DataTypeControllers to disable 101 // Used to bind a callback to give to DataTypeControllers to disable
102 // data types. 102 // data types.
103 sync_driver::DataTypeController::DisableTypeCallback 103 sync_driver::DataTypeController::DisableTypeCallback
104 MakeDisableCallbackFor(syncer::ModelType type); 104 MakeDisableCallbackFor(syncer::ModelType type);
105 void DisableBrokenType(syncer::ModelType type, 105 void DisableBrokenType(syncer::ModelType type,
106 const tracked_objects::Location& from_here, 106 const tracked_objects::Location& from_here,
107 const std::string& message); 107 const std::string& message);
108 108
109 Profile* profile_; 109 Profile* profile_;
110 base::CommandLine* command_line_; 110 base::CommandLine* command_line_;
111 scoped_refptr<autofill::AutofillWebDataService> web_data_service_; 111 scoped_refptr<autofill::AutofillWebDataService> web_data_service_;
112 112
113 const GURL sync_service_url_; 113 const GURL sync_service_url_;
114 OAuth2TokenService* const token_service_; 114 OAuth2TokenService* const token_service_;
115 net::URLRequestContextGetter* const url_request_context_getter_; 115 net::URLRequestContextGetter* const url_request_context_getter_;
116 116
117 // Chrome specific implementation of SyncClient. 117 // Chrome specific implementation of SyncClient.
118 // TODO(zea): Move the creation of this into the ProfileSyncServiceFactory,
119 // and ownership to the ProfileSyncService itself.
118 browser_sync::ChromeSyncClient chrome_sync_client_; 120 browser_sync::ChromeSyncClient chrome_sync_client_;
119 121
120 base::WeakPtrFactory<ProfileSyncComponentsFactoryImpl> weak_factory_; 122 base::WeakPtrFactory<ProfileSyncComponentsFactoryImpl> weak_factory_;
121 123
122 DISALLOW_COPY_AND_ASSIGN(ProfileSyncComponentsFactoryImpl); 124 DISALLOW_COPY_AND_ASSIGN(ProfileSyncComponentsFactoryImpl);
123 }; 125 };
124 126
125 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_H__ 127 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698