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