Fix use-after-free in HDDDTC shutdown
[chromium-blink-merge.git] / chrome / browser / sync / profile_sync_components_factory_impl.h
blob5ccd6c2635c312a769943583979035b75f70288f
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__
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/sync/profile_sync_components_factory.h"
14 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
15 #include "google_apis/gaia/oauth2_token_service.h"
17 class Profile;
19 namespace base {
20 class CommandLine;
23 namespace extensions {
24 class ExtensionSystem;
27 class ProfileSyncComponentsFactoryImpl : public ProfileSyncComponentsFactory {
28 public:
29 // Constructs a ProfileSyncComponentsFactoryImpl.
31 // |sync_service_url| is the base URL of the sync server.
33 // |token_service| must outlive the ProfileSyncComponentsFactoryImpl.
35 // |url_request_context_getter| must outlive the
36 // ProfileSyncComponentsFactoryImpl.
37 ProfileSyncComponentsFactoryImpl(
38 Profile* profile,
39 base::CommandLine* command_line,
40 const GURL& sync_service_url,
41 OAuth2TokenService* token_service,
42 net::URLRequestContextGetter* url_request_context_getter);
43 virtual ~ProfileSyncComponentsFactoryImpl();
45 virtual void RegisterDataTypes(ProfileSyncService* pss) OVERRIDE;
47 virtual sync_driver::DataTypeManager* CreateDataTypeManager(
48 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
49 debug_info_listener,
50 const sync_driver::DataTypeController::TypeMap* controllers,
51 const sync_driver::DataTypeEncryptionHandler* encryption_handler,
52 browser_sync::SyncBackendHost* backend,
53 sync_driver::DataTypeManagerObserver* observer)
54 OVERRIDE;
56 virtual browser_sync::SyncBackendHost* CreateSyncBackendHost(
57 const std::string& name,
58 Profile* profile,
59 invalidation::InvalidationService* invalidator,
60 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs,
61 const base::FilePath& sync_folder) OVERRIDE;
63 virtual scoped_ptr<browser_sync::LocalDeviceInfoProvider>
64 CreateLocalDeviceInfoProvider() OVERRIDE;
66 virtual base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType(
67 syncer::ModelType type) OVERRIDE;
68 virtual scoped_ptr<syncer::AttachmentService> CreateAttachmentService(
69 const syncer::UserShare& user_share,
70 syncer::AttachmentService::Delegate* delegate) OVERRIDE;
72 // Legacy datatypes that need to be converted to the SyncableService API.
73 virtual SyncComponents CreateBookmarkSyncComponents(
74 ProfileSyncService* profile_sync_service,
75 sync_driver::DataTypeErrorHandler* error_handler) OVERRIDE;
76 virtual SyncComponents CreateTypedUrlSyncComponents(
77 ProfileSyncService* profile_sync_service,
78 history::HistoryBackend* history_backend,
79 sync_driver::DataTypeErrorHandler* error_handler) OVERRIDE;
81 private:
82 // Register data types which are enabled on desktop platforms only.
83 // |disabled_types| and |enabled_types| correspond only to those types
84 // being explicitly enabled/disabled by the command line.
85 void RegisterDesktopDataTypes(syncer::ModelTypeSet disabled_types,
86 syncer::ModelTypeSet enabled_types,
87 ProfileSyncService* pss);
88 // Register data types which are enabled on both desktop and mobile.
89 // |disabled_types| and |enabled_types| correspond only to those types
90 // being explicitly enabled/disabled by the command line.
91 void RegisterCommonDataTypes(syncer::ModelTypeSet disabled_types,
92 syncer::ModelTypeSet enabled_types,
93 ProfileSyncService* pss);
94 // Used to bind a callback to give to DataTypeControllers to disable
95 // data types.
96 sync_driver::DataTypeController::DisableTypeCallback
97 MakeDisableCallbackFor(syncer::ModelType type);
98 void DisableBrokenType(syncer::ModelType type,
99 const tracked_objects::Location& from_here,
100 const std::string& message);
102 Profile* profile_;
103 base::CommandLine* command_line_;
104 scoped_refptr<autofill::AutofillWebDataService> web_data_service_;
106 const GURL sync_service_url_;
107 OAuth2TokenService* const token_service_;
108 net::URLRequestContextGetter* const url_request_context_getter_;
110 base::WeakPtrFactory<ProfileSyncComponentsFactoryImpl> weak_factory_;
112 DISALLOW_COPY_AND_ASSIGN(ProfileSyncComponentsFactoryImpl);
115 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_COMPONENTS_FACTORY_IMPL_H__