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

Side by Side Diff: components/browser_sync/profile_sync_components_factory_impl.cc

Issue 2376123003: [Sync] Move //components/sync to the syncer namespace. (Closed)
Patch Set: Fix tools and iOS. Created 4 years, 2 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 #include "components/browser_sync/profile_sync_components_factory_impl.h" 5 #include "components/browser_sync/profile_sync_components_factory_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/dump_without_crashing.h" 10 #include "base/debug/dump_without_crashing.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "components/sync_bookmarks/bookmark_model_associator.h" 46 #include "components/sync_bookmarks/bookmark_model_associator.h"
47 #include "components/sync_sessions/session_data_type_controller.h" 47 #include "components/sync_sessions/session_data_type_controller.h"
48 #include "google_apis/gaia/oauth2_token_service.h" 48 #include "google_apis/gaia/oauth2_token_service.h"
49 #include "google_apis/gaia/oauth2_token_service_request.h" 49 #include "google_apis/gaia/oauth2_token_service_request.h"
50 #include "net/url_request/url_request_context_getter.h" 50 #include "net/url_request/url_request_context_getter.h"
51 51
52 using bookmarks::BookmarkModel; 52 using bookmarks::BookmarkModel;
53 using sync_bookmarks::BookmarkChangeProcessor; 53 using sync_bookmarks::BookmarkChangeProcessor;
54 using sync_bookmarks::BookmarkDataTypeController; 54 using sync_bookmarks::BookmarkDataTypeController;
55 using sync_bookmarks::BookmarkModelAssociator; 55 using sync_bookmarks::BookmarkModelAssociator;
56 using sync_driver::DataTypeController; 56 using syncer::DataTypeController;
57 using sync_driver::DataTypeManager; 57 using syncer::DataTypeManager;
58 using sync_driver::DataTypeManagerImpl; 58 using syncer::DataTypeManagerImpl;
59 using sync_driver::DataTypeManagerObserver; 59 using syncer::DataTypeManagerObserver;
60 using sync_driver::DeviceInfoDataTypeController; 60 using syncer::DeviceInfoDataTypeController;
61 using sync_driver::ProxyDataTypeController; 61 using syncer::ProxyDataTypeController;
62 using sync_driver::UIDataTypeController; 62 using syncer::UIDataTypeController;
63 using sync_driver_v2::UIModelTypeController; 63 using syncer::UIModelTypeController;
64 using sync_sessions::SessionDataTypeController; 64 using sync_sessions::SessionDataTypeController;
65 65
66 namespace browser_sync { 66 namespace browser_sync {
67 67
68 namespace { 68 namespace {
69 69
70 syncer::ModelTypeSet GetDisabledTypesFromCommandLine( 70 syncer::ModelTypeSet GetDisabledTypesFromCommandLine(
71 const base::CommandLine& command_line) { 71 const base::CommandLine& command_line) {
72 syncer::ModelTypeSet disabled_types; 72 syncer::ModelTypeSet disabled_types;
73 std::string disabled_types_str = 73 std::string disabled_types_str =
(...skipping 11 matching lines...) Expand all
85 // Used to gate syncing preferences, see crbug.com/374865 for more information. 85 // Used to gate syncing preferences, see crbug.com/374865 for more information.
86 // Has always been on for desktop/ChromeOS, so default to on. This feature is 86 // Has always been on for desktop/ChromeOS, so default to on. This feature is
87 // mainly to give us a kill switch should something go wrong with starting to 87 // mainly to give us a kill switch should something go wrong with starting to
88 // sync prefs on mobile. 88 // sync prefs on mobile.
89 const base::Feature kSyncPreferencesFeature{"SyncPreferences", 89 const base::Feature kSyncPreferencesFeature{"SyncPreferences",
90 base::FEATURE_ENABLED_BY_DEFAULT}; 90 base::FEATURE_ENABLED_BY_DEFAULT};
91 91
92 } // namespace 92 } // namespace
93 93
94 ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl( 94 ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl(
95 sync_driver::SyncClient* sync_client, 95 syncer::SyncClient* sync_client,
96 version_info::Channel channel, 96 version_info::Channel channel,
97 const std::string& version, 97 const std::string& version,
98 bool is_tablet, 98 bool is_tablet,
99 const base::CommandLine& command_line, 99 const base::CommandLine& command_line,
100 const char* history_disabled_pref, 100 const char* history_disabled_pref,
101 const GURL& sync_service_url, 101 const GURL& sync_service_url,
102 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, 102 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
103 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, 103 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread,
104 OAuth2TokenService* token_service, 104 OAuth2TokenService* token_service,
105 net::URLRequestContextGetter* url_request_context_getter, 105 net::URLRequestContextGetter* url_request_context_getter,
(...skipping 13 matching lines...) Expand all
119 web_data_service_(web_data_service), 119 web_data_service_(web_data_service),
120 password_store_(password_store), 120 password_store_(password_store),
121 weak_factory_(this) { 121 weak_factory_(this) {
122 DCHECK(token_service_); 122 DCHECK(token_service_);
123 DCHECK(url_request_context_getter_); 123 DCHECK(url_request_context_getter_);
124 } 124 }
125 125
126 ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() {} 126 ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() {}
127 127
128 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes( 128 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes(
129 sync_driver::SyncService* sync_service, 129 syncer::SyncService* sync_service,
130 const RegisterDataTypesMethod& register_platform_types_method) { 130 const RegisterDataTypesMethod& register_platform_types_method) {
131 syncer::ModelTypeSet disabled_types = 131 syncer::ModelTypeSet disabled_types =
132 GetDisabledTypesFromCommandLine(command_line_); 132 GetDisabledTypesFromCommandLine(command_line_);
133 syncer::ModelTypeSet enabled_types = 133 syncer::ModelTypeSet enabled_types =
134 GetEnabledTypesFromCommandLine(command_line_); 134 GetEnabledTypesFromCommandLine(command_line_);
135 RegisterCommonDataTypes(sync_service, disabled_types, enabled_types); 135 RegisterCommonDataTypes(sync_service, disabled_types, enabled_types);
136 if (!register_platform_types_method.is_null()) 136 if (!register_platform_types_method.is_null())
137 register_platform_types_method.Run(sync_service, disabled_types, 137 register_platform_types_method.Run(sync_service, disabled_types,
138 enabled_types); 138 enabled_types);
139 } 139 }
140 140
141 void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes( 141 void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes(
142 sync_driver::SyncService* sync_service, 142 syncer::SyncService* sync_service,
143 syncer::ModelTypeSet disabled_types, 143 syncer::ModelTypeSet disabled_types,
144 syncer::ModelTypeSet enabled_types) { 144 syncer::ModelTypeSet enabled_types) {
145 base::Closure error_callback = 145 base::Closure error_callback =
146 base::Bind(&ChromeReportUnrecoverableError, channel_); 146 base::Bind(&syncer::ChromeReportUnrecoverableError, channel_);
147 147
148 // TODO(stanisc): can DEVICE_INFO be one of disabled datatypes? 148 // TODO(stanisc): can DEVICE_INFO be one of disabled datatypes?
149 if (base::FeatureList::IsEnabled(switches::kSyncUSSDeviceInfo)) { 149 if (base::FeatureList::IsEnabled(switches::kSyncUSSDeviceInfo)) {
150 // Use an error callback that always uploads a stacktrace if it can to help 150 // Use an error callback that always uploads a stacktrace if it can to help
151 // get USS as stable as possible. 151 // get USS as stable as possible.
152 sync_service->RegisterDataTypeController( 152 sync_service->RegisterDataTypeController(
153 base::MakeUnique<UIModelTypeController>( 153 base::MakeUnique<UIModelTypeController>(
154 syncer::DEVICE_INFO, base::Bind(&base::debug::DumpWithoutCrashing), 154 syncer::DEVICE_INFO, base::Bind(&base::debug::DumpWithoutCrashing),
155 sync_client_)); 155 sync_client_));
156 } else { 156 } else {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 sync_service->RegisterDataTypeController( 281 sync_service->RegisterDataTypeController(
282 base::MakeUnique<UIDataTypeController>(syncer::ARTICLES, error_callback, 282 base::MakeUnique<UIDataTypeController>(syncer::ARTICLES, error_callback,
283 sync_client_)); 283 sync_client_));
284 } 284 }
285 } 285 }
286 286
287 DataTypeManager* ProfileSyncComponentsFactoryImpl::CreateDataTypeManager( 287 DataTypeManager* ProfileSyncComponentsFactoryImpl::CreateDataTypeManager(
288 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& 288 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
289 debug_info_listener, 289 debug_info_listener,
290 const DataTypeController::TypeMap* controllers, 290 const DataTypeController::TypeMap* controllers,
291 const sync_driver::DataTypeEncryptionHandler* encryption_handler, 291 const syncer::DataTypeEncryptionHandler* encryption_handler,
292 SyncBackendHost* backend, 292 syncer::SyncBackendHost* backend,
293 DataTypeManagerObserver* observer) { 293 DataTypeManagerObserver* observer) {
294 return new DataTypeManagerImpl(debug_info_listener, controllers, 294 return new DataTypeManagerImpl(debug_info_listener, controllers,
295 encryption_handler, backend, observer); 295 encryption_handler, backend, observer);
296 } 296 }
297 297
298 SyncBackendHost* ProfileSyncComponentsFactoryImpl::CreateSyncBackendHost( 298 syncer::SyncBackendHost*
299 ProfileSyncComponentsFactoryImpl::CreateSyncBackendHost(
299 const std::string& name, 300 const std::string& name,
300 invalidation::InvalidationService* invalidator, 301 invalidation::InvalidationService* invalidator,
301 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, 302 const base::WeakPtr<syncer::SyncPrefs>& sync_prefs,
302 const base::FilePath& sync_folder) { 303 const base::FilePath& sync_folder) {
303 return new SyncBackendHostImpl(name, sync_client_, ui_thread_, invalidator, 304 return new syncer::SyncBackendHostImpl(name, sync_client_, ui_thread_,
304 sync_prefs, sync_folder); 305 invalidator, sync_prefs, sync_folder);
305 } 306 }
306 307
307 std::unique_ptr<sync_driver::LocalDeviceInfoProvider> 308 std::unique_ptr<syncer::LocalDeviceInfoProvider>
308 ProfileSyncComponentsFactoryImpl::CreateLocalDeviceInfoProvider() { 309 ProfileSyncComponentsFactoryImpl::CreateLocalDeviceInfoProvider() {
309 return base::MakeUnique<LocalDeviceInfoProviderImpl>(channel_, version_, 310 return base::MakeUnique<syncer::LocalDeviceInfoProviderImpl>(
310 is_tablet_); 311 channel_, version_, is_tablet_);
311 } 312 }
312 313
313 class TokenServiceProvider 314 class TokenServiceProvider
314 : public OAuth2TokenServiceRequest::TokenServiceProvider { 315 : public OAuth2TokenServiceRequest::TokenServiceProvider {
315 public: 316 public:
316 TokenServiceProvider( 317 TokenServiceProvider(
317 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 318 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
318 OAuth2TokenService* token_service); 319 OAuth2TokenService* token_service);
319 320
320 // OAuth2TokenServiceRequest::TokenServiceProvider implementation. 321 // OAuth2TokenServiceRequest::TokenServiceProvider implementation.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 base::TimeDelta::FromMinutes(30); 389 base::TimeDelta::FromMinutes(30);
389 const base::TimeDelta max_backoff_delay = base::TimeDelta::FromHours(4); 390 const base::TimeDelta max_backoff_delay = base::TimeDelta::FromHours(4);
390 std::unique_ptr<syncer::AttachmentService> attachment_service( 391 std::unique_ptr<syncer::AttachmentService> attachment_service(
391 new syncer::AttachmentServiceImpl( 392 new syncer::AttachmentServiceImpl(
392 std::move(attachment_store), std::move(attachment_uploader), 393 std::move(attachment_store), std::move(attachment_uploader),
393 std::move(attachment_downloader), delegate, initial_backoff_delay, 394 std::move(attachment_downloader), delegate, initial_backoff_delay,
394 max_backoff_delay)); 395 max_backoff_delay));
395 return attachment_service; 396 return attachment_service;
396 } 397 }
397 398
398 sync_driver::SyncApiComponentFactory::SyncComponents 399 syncer::SyncApiComponentFactory::SyncComponents
399 ProfileSyncComponentsFactoryImpl::CreateBookmarkSyncComponents( 400 ProfileSyncComponentsFactoryImpl::CreateBookmarkSyncComponents(
400 sync_driver::SyncService* sync_service, 401 syncer::SyncService* sync_service,
401 std::unique_ptr<syncer::DataTypeErrorHandler> error_handler) { 402 std::unique_ptr<syncer::DataTypeErrorHandler> error_handler) {
402 BookmarkModel* bookmark_model = 403 BookmarkModel* bookmark_model =
403 sync_service->GetSyncClient()->GetBookmarkModel(); 404 sync_service->GetSyncClient()->GetBookmarkModel();
404 syncer::UserShare* user_share = sync_service->GetUserShare(); 405 syncer::UserShare* user_share = sync_service->GetUserShare();
405 // TODO(akalin): We may want to propagate this switch up eventually. 406 // TODO(akalin): We may want to propagate this switch up eventually.
406 #if defined(OS_ANDROID) || defined(OS_IOS) 407 #if defined(OS_ANDROID) || defined(OS_IOS)
407 const bool kExpectMobileBookmarksFolder = true; 408 const bool kExpectMobileBookmarksFolder = true;
408 #else 409 #else
409 const bool kExpectMobileBookmarksFolder = false; 410 const bool kExpectMobileBookmarksFolder = false;
410 #endif 411 #endif
411 BookmarkModelAssociator* model_associator = new BookmarkModelAssociator( 412 BookmarkModelAssociator* model_associator = new BookmarkModelAssociator(
412 bookmark_model, sync_service->GetSyncClient(), user_share, 413 bookmark_model, sync_service->GetSyncClient(), user_share,
413 error_handler->Copy(), kExpectMobileBookmarksFolder); 414 error_handler->Copy(), kExpectMobileBookmarksFolder);
414 BookmarkChangeProcessor* change_processor = 415 BookmarkChangeProcessor* change_processor =
415 new BookmarkChangeProcessor(sync_service->GetSyncClient(), 416 new BookmarkChangeProcessor(sync_service->GetSyncClient(),
416 model_associator, std::move(error_handler)); 417 model_associator, std::move(error_handler));
417 return SyncComponents(model_associator, change_processor); 418 return SyncComponents(model_associator, change_processor);
418 } 419 }
419 420
420 // static 421 // static
421 void ProfileSyncComponentsFactoryImpl::OverridePrefsForUssTest(bool use_uss) { 422 void ProfileSyncComponentsFactoryImpl::OverridePrefsForUssTest(bool use_uss) {
422 override_prefs_controller_to_uss_for_test_ = use_uss; 423 override_prefs_controller_to_uss_for_test_ = use_uss;
423 } 424 }
424 425
425 bool ProfileSyncComponentsFactoryImpl:: 426 bool ProfileSyncComponentsFactoryImpl::
426 override_prefs_controller_to_uss_for_test_ = false; 427 override_prefs_controller_to_uss_for_test_ = false;
427 428
428 } // namespace browser_sync 429 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698