| OLD | NEW |
| 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 COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_H__ |
| 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_H__ | 6 #define COMPONENTS_BROWSER_SYNC_BROWSER_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/command_line.h" |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "components/sync_driver/sync_api_component_factory.h" | 14 #include "components/sync_driver/sync_api_component_factory.h" |
| 15 #include "components/version_info/version_info.h" |
| 14 #include "sync/internal_api/public/base/model_type.h" | 16 #include "sync/internal_api/public/base/model_type.h" |
| 15 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 16 | 18 |
| 17 class OAuth2TokenService; | 19 class OAuth2TokenService; |
| 18 class Profile; | 20 class Profile; |
| 19 | 21 |
| 20 namespace base { | |
| 21 class CommandLine; | |
| 22 } | |
| 23 | |
| 24 namespace net { | 22 namespace net { |
| 25 class URLRequestContextGetter; | 23 class URLRequestContextGetter; |
| 26 } | 24 } |
| 27 | 25 |
| 28 class ProfileSyncComponentsFactoryImpl | 26 class ProfileSyncComponentsFactoryImpl |
| 29 : public sync_driver::SyncApiComponentFactory { | 27 : public sync_driver::SyncApiComponentFactory { |
| 30 public: | 28 public: |
| 31 // Constructs a ProfileSyncComponentsFactoryImpl. | 29 // Constructs a ProfileSyncComponentsFactoryImpl. |
| 32 // | 30 // |
| 33 // |sync_service_url| is the base URL of the sync server. | 31 // |sync_service_url| is the base URL of the sync server. |
| 34 // | 32 // |
| 35 // |token_service| must outlive the ProfileSyncComponentsFactoryImpl. | 33 // |token_service| must outlive the ProfileSyncComponentsFactoryImpl. |
| 36 // | 34 // |
| 37 // |url_request_context_getter| must outlive the | 35 // |url_request_context_getter| must outlive the |
| 38 // ProfileSyncComponentsFactoryImpl. | 36 // ProfileSyncComponentsFactoryImpl. |
| 39 ProfileSyncComponentsFactoryImpl( | 37 ProfileSyncComponentsFactoryImpl( |
| 40 Profile* profile, | 38 sync_driver::SyncClient* sync_client, |
| 41 base::CommandLine* command_line, | 39 version_info::Channel channel, |
| 40 const std::string& version, |
| 41 bool is_tablet, |
| 42 const base::CommandLine& command_line, |
| 43 const char* history_disabled_pref, |
| 42 const GURL& sync_service_url, | 44 const GURL& sync_service_url, |
| 45 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, |
| 46 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, |
| 43 OAuth2TokenService* token_service, | 47 OAuth2TokenService* token_service, |
| 44 net::URLRequestContextGetter* url_request_context_getter); | 48 net::URLRequestContextGetter* url_request_context_getter); |
| 45 ~ProfileSyncComponentsFactoryImpl() override; | 49 ~ProfileSyncComponentsFactoryImpl() override; |
| 46 | 50 |
| 47 void RegisterDataTypes(sync_driver::SyncClient* sync_client) override; | 51 // SyncApiComponentFactory implementation: |
| 48 | 52 void RegisterDataTypes( |
| 53 const RegisterDataTypesMethod& register_platform_types_method) override; |
| 49 sync_driver::DataTypeManager* CreateDataTypeManager( | 54 sync_driver::DataTypeManager* CreateDataTypeManager( |
| 50 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& | 55 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& |
| 51 debug_info_listener, | 56 debug_info_listener, |
| 52 const sync_driver::DataTypeController::TypeMap* controllers, | 57 const sync_driver::DataTypeController::TypeMap* controllers, |
| 53 const sync_driver::DataTypeEncryptionHandler* encryption_handler, | 58 const sync_driver::DataTypeEncryptionHandler* encryption_handler, |
| 54 browser_sync::SyncBackendHost* backend, | 59 browser_sync::SyncBackendHost* backend, |
| 55 sync_driver::DataTypeManagerObserver* observer) override; | 60 sync_driver::DataTypeManagerObserver* observer) override; |
| 56 | |
| 57 browser_sync::SyncBackendHost* CreateSyncBackendHost( | 61 browser_sync::SyncBackendHost* CreateSyncBackendHost( |
| 58 const std::string& name, | 62 const std::string& name, |
| 59 sync_driver::SyncClient* sync_client, | |
| 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 | |
| 64 scoped_ptr<sync_driver::LocalDeviceInfoProvider> | 66 scoped_ptr<sync_driver::LocalDeviceInfoProvider> |
| 65 CreateLocalDeviceInfoProvider() override; | 67 CreateLocalDeviceInfoProvider() override; |
| 66 | |
| 67 scoped_ptr<syncer::AttachmentService> CreateAttachmentService( | 68 scoped_ptr<syncer::AttachmentService> CreateAttachmentService( |
| 68 scoped_ptr<syncer::AttachmentStoreForSync> attachment_store, | 69 scoped_ptr<syncer::AttachmentStoreForSync> attachment_store, |
| 69 const syncer::UserShare& user_share, | 70 const syncer::UserShare& user_share, |
| 70 const std::string& store_birthday, | 71 const std::string& store_birthday, |
| 71 syncer::ModelType model_type, | 72 syncer::ModelType model_type, |
| 72 syncer::AttachmentService::Delegate* delegate) override; | 73 syncer::AttachmentService::Delegate* delegate) override; |
| 73 | |
| 74 // Legacy datatypes that need to be converted to the SyncableService API. | |
| 75 sync_driver::SyncApiComponentFactory::SyncComponents | 74 sync_driver::SyncApiComponentFactory::SyncComponents |
| 76 CreateBookmarkSyncComponents( | 75 CreateBookmarkSyncComponents( |
| 77 sync_driver::SyncService* sync_service, | 76 sync_driver::SyncService* sync_service, |
| 78 sync_driver::DataTypeErrorHandler* error_handler) override; | 77 sync_driver::DataTypeErrorHandler* error_handler) override; |
| 79 sync_driver::SyncApiComponentFactory::SyncComponents | 78 sync_driver::SyncApiComponentFactory::SyncComponents |
| 80 CreateTypedUrlSyncComponents( | 79 CreateTypedUrlSyncComponents( |
| 81 sync_driver::SyncService* sync_service, | 80 sync_driver::SyncService* sync_service, |
| 82 history::HistoryBackend* history_backend, | 81 history::HistoryBackend* history_backend, |
| 83 sync_driver::DataTypeErrorHandler* error_handler) override; | 82 sync_driver::DataTypeErrorHandler* error_handler) override; |
| 84 | 83 |
| 85 private: | 84 private: |
| 86 // Register data types which are enabled on desktop platforms only. | |
| 87 // |disabled_types| and |enabled_types| correspond only to those types | |
| 88 // being explicitly enabled/disabled by the command line. | |
| 89 void RegisterDesktopDataTypes(syncer::ModelTypeSet disabled_types, | |
| 90 syncer::ModelTypeSet enabled_types, | |
| 91 sync_driver::SyncClient* sync_client); | |
| 92 | |
| 93 // Register data types which are enabled on both desktop and mobile. | 85 // Register data types which are enabled on both desktop and mobile. |
| 94 // |disabled_types| and |enabled_types| correspond only to those types | 86 // |disabled_types| and |enabled_types| correspond only to those types |
| 95 // being explicitly enabled/disabled by the command line. | 87 // being explicitly enabled/disabled by the command line. |
| 96 void RegisterCommonDataTypes(syncer::ModelTypeSet disabled_types, | 88 void RegisterCommonDataTypes(syncer::ModelTypeSet disabled_types, |
| 97 syncer::ModelTypeSet enabled_types, | 89 syncer::ModelTypeSet enabled_types); |
| 98 sync_driver::SyncClient* sync_client); | |
| 99 | 90 |
| 100 void DisableBrokenType(syncer::ModelType type, | 91 void DisableBrokenType(syncer::ModelType type, |
| 101 const tracked_objects::Location& from_here, | 92 const tracked_objects::Location& from_here, |
| 102 const std::string& message); | 93 const std::string& message); |
| 103 | 94 |
| 104 Profile* profile_; | 95 // Client/platform specific members. |
| 105 base::CommandLine* command_line_; | 96 sync_driver::SyncClient* const sync_client_; |
| 106 | 97 const version_info::Channel channel_; |
| 98 const std::string version_; |
| 99 const bool is_tablet_; |
| 100 const base::CommandLine command_line_; |
| 101 const char* history_disabled_pref_; |
| 107 const GURL sync_service_url_; | 102 const GURL sync_service_url_; |
| 103 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_; |
| 104 const scoped_refptr<base::SingleThreadTaskRunner> db_thread_; |
| 108 OAuth2TokenService* const token_service_; | 105 OAuth2TokenService* const token_service_; |
| 109 net::URLRequestContextGetter* const url_request_context_getter_; | 106 net::URLRequestContextGetter* const url_request_context_getter_; |
| 110 | 107 |
| 111 base::WeakPtrFactory<ProfileSyncComponentsFactoryImpl> weak_factory_; | 108 base::WeakPtrFactory<ProfileSyncComponentsFactoryImpl> weak_factory_; |
| 112 | 109 |
| 113 DISALLOW_COPY_AND_ASSIGN(ProfileSyncComponentsFactoryImpl); | 110 DISALLOW_COPY_AND_ASSIGN(ProfileSyncComponentsFactoryImpl); |
| 114 }; | 111 }; |
| 115 | 112 |
| 116 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_H__ | 113 #endif // COMPONENTS_BROWSER_SYNC_BROWSER_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_
H__ |
| OLD | NEW |