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.
5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_H__
6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_H__
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/sync/chrome_sync_client.h"
14 #include "components/sync_driver/sync_api_component_factory.h"
15 #include "sync/internal_api/public/base/model_type.h"
18 class OAuth2TokenService
;
26 class URLRequestContextGetter
;
29 class ProfileSyncComponentsFactoryImpl
30 : public sync_driver::SyncApiComponentFactory
{
32 // Constructs a ProfileSyncComponentsFactoryImpl.
34 // |sync_service_url| is the base URL of the sync server.
36 // |token_service| must outlive the ProfileSyncComponentsFactoryImpl.
38 // |url_request_context_getter| must outlive the
39 // ProfileSyncComponentsFactoryImpl.
40 ProfileSyncComponentsFactoryImpl(
42 base::CommandLine
* command_line
,
43 const GURL
& sync_service_url
,
44 OAuth2TokenService
* token_service
,
45 net::URLRequestContextGetter
* url_request_context_getter
);
46 ~ProfileSyncComponentsFactoryImpl() override
;
48 // Initializes internal state after construction.
49 void Initialize(sync_driver::SyncService
* sync_service
) override
;
51 void RegisterDataTypes() override
;
53 sync_driver::DataTypeManager
* CreateDataTypeManager(
54 const syncer::WeakHandle
<syncer::DataTypeDebugInfoListener
>&
56 const sync_driver::DataTypeController::TypeMap
* controllers
,
57 const sync_driver::DataTypeEncryptionHandler
* encryption_handler
,
58 browser_sync::SyncBackendHost
* backend
,
59 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
;
67 scoped_ptr
<sync_driver::LocalDeviceInfoProvider
>
68 CreateLocalDeviceInfoProvider() override
;
70 scoped_ptr
<syncer::AttachmentService
> CreateAttachmentService(
71 scoped_ptr
<syncer::AttachmentStoreForSync
> attachment_store
,
72 const syncer::UserShare
& user_share
,
73 const std::string
& store_birthday
,
74 syncer::ModelType model_type
,
75 syncer::AttachmentService::Delegate
* delegate
) override
;
77 // Legacy datatypes that need to be converted to the SyncableService API.
78 sync_driver::SyncApiComponentFactory::SyncComponents
79 CreateBookmarkSyncComponents(
80 sync_driver::SyncService
* sync_service
,
81 sync_driver::DataTypeErrorHandler
* error_handler
) override
;
82 sync_driver::SyncApiComponentFactory::SyncComponents
83 CreateTypedUrlSyncComponents(
84 sync_driver::SyncService
* sync_service
,
85 history::HistoryBackend
* history_backend
,
86 sync_driver::DataTypeErrorHandler
* error_handler
) override
;
89 // Register data types which are enabled on desktop platforms only.
90 // |disabled_types| and |enabled_types| correspond only to those types
91 // being explicitly enabled/disabled by the command line.
92 void RegisterDesktopDataTypes(syncer::ModelTypeSet disabled_types
,
93 syncer::ModelTypeSet enabled_types
);
94 // Register data types which are enabled on both desktop and mobile.
95 // |disabled_types| and |enabled_types| correspond only to those types
96 // being explicitly enabled/disabled by the command line.
97 void RegisterCommonDataTypes(syncer::ModelTypeSet disabled_types
,
98 syncer::ModelTypeSet enabled_types
);
100 void DisableBrokenType(syncer::ModelType type
,
101 const tracked_objects::Location
& from_here
,
102 const std::string
& message
);
105 base::CommandLine
* command_line_
;
107 const GURL sync_service_url_
;
108 OAuth2TokenService
* const token_service_
;
109 net::URLRequestContextGetter
* const url_request_context_getter_
;
111 // Chrome specific implementation of SyncClient.
112 // TODO(zea): Move the creation of this into the ProfileSyncServiceFactory,
113 // and ownership to the ProfileSyncService itself.
114 browser_sync::ChromeSyncClient chrome_sync_client_
;
116 base::WeakPtrFactory
<ProfileSyncComponentsFactoryImpl
> weak_factory_
;
118 DISALLOW_COPY_AND_ASSIGN(ProfileSyncComponentsFactoryImpl
);
121 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_H__