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

Side by Side Diff: chrome/browser/sync/chrome_sync_client.cc

Issue 2388673002: Revert of [Sync] Move //components/sync to the syncer namespace. (patchset #5 id:40001 of https://co (Closed)
Patch Set: 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/sync/chrome_sync_client.h" 5 #include "chrome/browser/sync/chrome_sync_client.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 #include "components/wifi_sync/wifi_credential_syncable_service.h" 107 #include "components/wifi_sync/wifi_credential_syncable_service.h"
108 #include "components/wifi_sync/wifi_credential_syncable_service_factory.h" 108 #include "components/wifi_sync/wifi_credential_syncable_service_factory.h"
109 #endif 109 #endif
110 110
111 using content::BrowserThread; 111 using content::BrowserThread;
112 #if defined(ENABLE_EXTENSIONS) 112 #if defined(ENABLE_EXTENSIONS)
113 using browser_sync::ExtensionDataTypeController; 113 using browser_sync::ExtensionDataTypeController;
114 using browser_sync::ExtensionSettingDataTypeController; 114 using browser_sync::ExtensionSettingDataTypeController;
115 #endif 115 #endif
116 using browser_sync::SearchEngineDataTypeController; 116 using browser_sync::SearchEngineDataTypeController;
117 using syncer::UIDataTypeController; 117 using sync_driver::UIDataTypeController;
118 118
119 namespace browser_sync { 119 namespace browser_sync {
120 120
121 // Chrome implementation of SyncSessionsClient. Needs to be in a separate class 121 // Chrome implementation of SyncSessionsClient. Needs to be in a separate class
122 // due to possible multiple inheritance issues, wherein ChromeSyncClient might 122 // due to possible multiple inheritance issues, wherein ChromeSyncClient might
123 // inherit from other interfaces with same methods. 123 // inherit from other interfaces with same methods.
124 class SyncSessionsClientImpl : public sync_sessions::SyncSessionsClient { 124 class SyncSessionsClientImpl : public sync_sessions::SyncSessionsClient {
125 public: 125 public:
126 explicit SyncSessionsClientImpl(Profile* profile) : profile_(profile) { 126 explicit SyncSessionsClientImpl(Profile* profile) : profile_(profile) {
127 window_delegates_getter_.reset( 127 window_delegates_getter_.reset(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 void ChromeSyncClient::Initialize() { 192 void ChromeSyncClient::Initialize() {
193 DCHECK_CURRENTLY_ON(BrowserThread::UI); 193 DCHECK_CURRENTLY_ON(BrowserThread::UI);
194 194
195 web_data_service_ = WebDataServiceFactory::GetAutofillWebDataForProfile( 195 web_data_service_ = WebDataServiceFactory::GetAutofillWebDataForProfile(
196 profile_, ServiceAccessType::IMPLICIT_ACCESS); 196 profile_, ServiceAccessType::IMPLICIT_ACCESS);
197 password_store_ = PasswordStoreFactory::GetForProfile( 197 password_store_ = PasswordStoreFactory::GetForProfile(
198 profile_, ServiceAccessType::IMPLICIT_ACCESS); 198 profile_, ServiceAccessType::IMPLICIT_ACCESS);
199 199
200 // Component factory may already be set in tests. 200 // Component factory may already be set in tests.
201 if (!GetSyncApiComponentFactory()) { 201 if (!GetSyncApiComponentFactory()) {
202 const GURL sync_service_url = syncer::GetSyncServiceURL( 202 const GURL sync_service_url = GetSyncServiceURL(
203 *base::CommandLine::ForCurrentProcess(), chrome::GetChannel()); 203 *base::CommandLine::ForCurrentProcess(), chrome::GetChannel());
204 ProfileOAuth2TokenService* token_service = 204 ProfileOAuth2TokenService* token_service =
205 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); 205 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
206 net::URLRequestContextGetter* url_request_context_getter = 206 net::URLRequestContextGetter* url_request_context_getter =
207 profile_->GetRequestContext(); 207 profile_->GetRequestContext();
208 208
209 component_factory_.reset(new ProfileSyncComponentsFactoryImpl( 209 component_factory_.reset(new ProfileSyncComponentsFactoryImpl(
210 this, chrome::GetChannel(), chrome::GetVersionString(), 210 this, chrome::GetChannel(), chrome::GetVersionString(),
211 ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET, 211 ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET,
212 *base::CommandLine::ForCurrentProcess(), 212 *base::CommandLine::ForCurrentProcess(),
213 prefs::kSavingBrowserHistoryDisabled, sync_service_url, 213 prefs::kSavingBrowserHistoryDisabled, sync_service_url,
214 content::BrowserThread::GetTaskRunnerForThread( 214 content::BrowserThread::GetTaskRunnerForThread(
215 content::BrowserThread::UI), 215 content::BrowserThread::UI),
216 content::BrowserThread::GetTaskRunnerForThread( 216 content::BrowserThread::GetTaskRunnerForThread(
217 content::BrowserThread::DB), 217 content::BrowserThread::DB),
218 token_service, url_request_context_getter, web_data_service_, 218 token_service, url_request_context_getter, web_data_service_,
219 password_store_)); 219 password_store_));
220 } 220 }
221 } 221 }
222 222
223 syncer::SyncService* ChromeSyncClient::GetSyncService() { 223 sync_driver::SyncService* ChromeSyncClient::GetSyncService() {
224 DCHECK_CURRENTLY_ON(BrowserThread::UI); 224 DCHECK_CURRENTLY_ON(BrowserThread::UI);
225 return ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile_); 225 return ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile_);
226 } 226 }
227 227
228 PrefService* ChromeSyncClient::GetPrefService() { 228 PrefService* ChromeSyncClient::GetPrefService() {
229 DCHECK_CURRENTLY_ON(BrowserThread::UI); 229 DCHECK_CURRENTLY_ON(BrowserThread::UI);
230 return profile_->GetPrefs(); 230 return profile_->GetPrefs();
231 } 231 }
232 232
233 bookmarks::BookmarkModel* ChromeSyncClient::GetBookmarkModel() { 233 bookmarks::BookmarkModel* ChromeSyncClient::GetBookmarkModel() {
(...skipping 17 matching lines...) Expand all
251 DCHECK_CURRENTLY_ON(BrowserThread::UI); 251 DCHECK_CURRENTLY_ON(BrowserThread::UI);
252 return autofill::PersonalDataManagerFactory::GetForProfile(profile_); 252 return autofill::PersonalDataManagerFactory::GetForProfile(profile_);
253 } 253 }
254 254
255 base::Closure ChromeSyncClient::GetPasswordStateChangedCallback() { 255 base::Closure ChromeSyncClient::GetPasswordStateChangedCallback() {
256 return base::Bind( 256 return base::Bind(
257 &PasswordStoreFactory::OnPasswordsSyncedStatePotentiallyChanged, 257 &PasswordStoreFactory::OnPasswordsSyncedStatePotentiallyChanged,
258 base::Unretained(profile_)); 258 base::Unretained(profile_));
259 } 259 }
260 260
261 syncer::SyncApiComponentFactory::RegisterDataTypesMethod 261 sync_driver::SyncApiComponentFactory::RegisterDataTypesMethod
262 ChromeSyncClient::GetRegisterPlatformTypesCallback() { 262 ChromeSyncClient::GetRegisterPlatformTypesCallback() {
263 return base::Bind( 263 return base::Bind(
264 #if BUILDFLAG(ANDROID_JAVA_UI) 264 #if BUILDFLAG(ANDROID_JAVA_UI)
265 &ChromeSyncClient::RegisterAndroidDataTypes, 265 &ChromeSyncClient::RegisterAndroidDataTypes,
266 #else 266 #else
267 &ChromeSyncClient::RegisterDesktopDataTypes, 267 &ChromeSyncClient::RegisterDesktopDataTypes,
268 #endif // BUILDFLAG(ANDROID_JAVA_UI) 268 #endif // BUILDFLAG(ANDROID_JAVA_UI)
269 weak_ptr_factory_.GetWeakPtr()); 269 weak_ptr_factory_.GetWeakPtr());
270 } 270 }
271 271
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 #endif 419 #endif
420 default: 420 default:
421 // The following datatypes still need to be transitioned to the 421 // The following datatypes still need to be transitioned to the
422 // syncer::SyncableService API: 422 // syncer::SyncableService API:
423 // Bookmarks 423 // Bookmarks
424 NOTREACHED(); 424 NOTREACHED();
425 return base::WeakPtr<syncer::SyncableService>(); 425 return base::WeakPtr<syncer::SyncableService>();
426 } 426 }
427 } 427 }
428 428
429 base::WeakPtr<syncer::ModelTypeService> 429 base::WeakPtr<syncer_v2::ModelTypeService>
430 ChromeSyncClient::GetModelTypeServiceForType(syncer::ModelType type) { 430 ChromeSyncClient::GetModelTypeServiceForType(syncer::ModelType type) {
431 switch (type) { 431 switch (type) {
432 case syncer::DEVICE_INFO: 432 case syncer::DEVICE_INFO:
433 return ProfileSyncServiceFactory::GetForProfile(profile_) 433 return ProfileSyncServiceFactory::GetForProfile(profile_)
434 ->GetDeviceInfoService() 434 ->GetDeviceInfoService()
435 ->AsWeakPtr(); 435 ->AsWeakPtr();
436 default: 436 default:
437 NOTREACHED(); 437 NOTREACHED();
438 return base::WeakPtr<syncer::ModelTypeService>(); 438 return base::WeakPtr<syncer_v2::ModelTypeService>();
439 } 439 }
440 } 440 }
441 441
442 scoped_refptr<syncer::ModelSafeWorker> 442 scoped_refptr<syncer::ModelSafeWorker>
443 ChromeSyncClient::CreateModelWorkerForGroup( 443 ChromeSyncClient::CreateModelWorkerForGroup(
444 syncer::ModelSafeGroup group, 444 syncer::ModelSafeGroup group,
445 syncer::WorkerLoopDestructionObserver* observer) { 445 syncer::WorkerLoopDestructionObserver* observer) {
446 DCHECK_CURRENTLY_ON(BrowserThread::UI); 446 DCHECK_CURRENTLY_ON(BrowserThread::UI);
447 switch (group) { 447 switch (group) {
448 case syncer::GROUP_DB: 448 case syncer::GROUP_DB:
449 return new syncer::BrowserThreadModelWorker( 449 return new BrowserThreadModelWorker(
450 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB), 450 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB),
451 syncer::GROUP_DB, observer); 451 syncer::GROUP_DB, observer);
452 case syncer::GROUP_FILE: 452 case syncer::GROUP_FILE:
453 return new syncer::BrowserThreadModelWorker( 453 return new BrowserThreadModelWorker(
454 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), 454 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE),
455 syncer::GROUP_FILE, observer); 455 syncer::GROUP_FILE, observer);
456 case syncer::GROUP_UI: 456 case syncer::GROUP_UI:
457 return new syncer::UIModelWorker( 457 return new UIModelWorker(
458 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), observer); 458 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), observer);
459 case syncer::GROUP_PASSIVE: 459 case syncer::GROUP_PASSIVE:
460 return new syncer::PassiveModelWorker(observer); 460 return new syncer::PassiveModelWorker(observer);
461 case syncer::GROUP_HISTORY: { 461 case syncer::GROUP_HISTORY: {
462 history::HistoryService* history_service = GetHistoryService(); 462 history::HistoryService* history_service = GetHistoryService();
463 if (!history_service) 463 if (!history_service)
464 return nullptr; 464 return nullptr;
465 return new HistoryModelWorker( 465 return new HistoryModelWorker(
466 history_service->AsWeakPtr(), 466 history_service->AsWeakPtr(),
467 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), observer); 467 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), observer);
468 } 468 }
469 case syncer::GROUP_PASSWORD: { 469 case syncer::GROUP_PASSWORD: {
470 if (!password_store_.get()) 470 if (!password_store_.get())
471 return nullptr; 471 return nullptr;
472 return new PasswordModelWorker(password_store_, observer); 472 return new PasswordModelWorker(password_store_, observer);
473 } 473 }
474 default: 474 default:
475 return nullptr; 475 return nullptr;
476 } 476 }
477 } 477 }
478 478
479 syncer::SyncApiComponentFactory* 479 sync_driver::SyncApiComponentFactory*
480 ChromeSyncClient::GetSyncApiComponentFactory() { 480 ChromeSyncClient::GetSyncApiComponentFactory() {
481 return component_factory_.get(); 481 return component_factory_.get();
482 } 482 }
483 483
484 void ChromeSyncClient::SetSyncApiComponentFactoryForTesting( 484 void ChromeSyncClient::SetSyncApiComponentFactoryForTesting(
485 std::unique_ptr<syncer::SyncApiComponentFactory> component_factory) { 485 std::unique_ptr<sync_driver::SyncApiComponentFactory> component_factory) {
486 component_factory_ = std::move(component_factory); 486 component_factory_ = std::move(component_factory);
487 } 487 }
488 488
489 // static 489 // static
490 void ChromeSyncClient::GetDeviceInfoTrackers( 490 void ChromeSyncClient::GetDeviceInfoTrackers(
491 std::vector<const syncer::DeviceInfoTracker*>* trackers) { 491 std::vector<const sync_driver::DeviceInfoTracker*>* trackers) {
492 DCHECK(trackers); 492 DCHECK(trackers);
493 ProfileManager* profile_manager = g_browser_process->profile_manager(); 493 ProfileManager* profile_manager = g_browser_process->profile_manager();
494 std::vector<Profile*> profile_list = profile_manager->GetLoadedProfiles(); 494 std::vector<Profile*> profile_list = profile_manager->GetLoadedProfiles();
495 for (Profile* profile : profile_list) { 495 for (Profile* profile : profile_list) {
496 const browser_sync::ProfileSyncService* profile_sync_service = 496 const browser_sync::ProfileSyncService* profile_sync_service =
497 ProfileSyncServiceFactory::GetForProfile(profile); 497 ProfileSyncServiceFactory::GetForProfile(profile);
498 if (profile_sync_service != nullptr) { 498 if (profile_sync_service != nullptr) {
499 const syncer::DeviceInfoTracker* tracker = 499 const sync_driver::DeviceInfoTracker* tracker =
500 profile_sync_service->GetDeviceInfoTracker(); 500 profile_sync_service->GetDeviceInfoTracker();
501 if (tracker != nullptr) { 501 if (tracker != nullptr) {
502 // Even when sync is disabled and/or user is signed out, a tracker will 502 // Even when sync is disabled and/or user is signed out, a tracker will
503 // still be present. It will only be missing when the ProfileSyncService 503 // still be present. It will only be missing when the ProfileSyncService
504 // has not sufficiently initialized yet. 504 // has not sufficiently initialized yet.
505 trackers->push_back(tracker); 505 trackers->push_back(tracker);
506 } 506 }
507 } 507 }
508 } 508 }
509 } 509 }
510 510
511 void ChromeSyncClient::RegisterDesktopDataTypes( 511 void ChromeSyncClient::RegisterDesktopDataTypes(
512 syncer::SyncService* sync_service, 512 sync_driver::SyncService* sync_service,
513 syncer::ModelTypeSet disabled_types, 513 syncer::ModelTypeSet disabled_types,
514 syncer::ModelTypeSet enabled_types) { 514 syncer::ModelTypeSet enabled_types) {
515 base::Closure error_callback = 515 base::Closure error_callback =
516 base::Bind(&syncer::ChromeReportUnrecoverableError, chrome::GetChannel()); 516 base::Bind(&ChromeReportUnrecoverableError, chrome::GetChannel());
517 517
518 #if defined(ENABLE_EXTENSIONS) 518 #if defined(ENABLE_EXTENSIONS)
519 // App sync is enabled by default. Register unless explicitly 519 // App sync is enabled by default. Register unless explicitly
520 // disabled. 520 // disabled.
521 if (!disabled_types.Has(syncer::APPS)) { 521 if (!disabled_types.Has(syncer::APPS)) {
522 sync_service->RegisterDataTypeController( 522 sync_service->RegisterDataTypeController(
523 base::MakeUnique<ExtensionDataTypeController>( 523 base::MakeUnique<ExtensionDataTypeController>(
524 syncer::APPS, error_callback, this, profile_)); 524 syncer::APPS, error_callback, this, profile_));
525 } 525 }
526 526
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 error_callback, this)); 611 error_callback, this));
612 } 612 }
613 // TODO(lgcheng): Add switch for this. 613 // TODO(lgcheng): Add switch for this.
614 sync_service->RegisterDataTypeController( 614 sync_service->RegisterDataTypeController(
615 base::MakeUnique<ArcPackageSyncDataTypeController>( 615 base::MakeUnique<ArcPackageSyncDataTypeController>(
616 syncer::ARC_PACKAGE, error_callback, this, profile_)); 616 syncer::ARC_PACKAGE, error_callback, this, profile_));
617 #endif 617 #endif
618 } 618 }
619 619
620 void ChromeSyncClient::RegisterAndroidDataTypes( 620 void ChromeSyncClient::RegisterAndroidDataTypes(
621 syncer::SyncService* sync_service, 621 sync_driver::SyncService* sync_service,
622 syncer::ModelTypeSet disabled_types, 622 syncer::ModelTypeSet disabled_types,
623 syncer::ModelTypeSet enabled_types) { 623 syncer::ModelTypeSet enabled_types) {
624 base::Closure error_callback = 624 base::Closure error_callback =
625 base::Bind(&syncer::ChromeReportUnrecoverableError, chrome::GetChannel()); 625 base::Bind(&ChromeReportUnrecoverableError, chrome::GetChannel());
626 #if defined(ENABLE_SUPERVISED_USERS) 626 #if defined(ENABLE_SUPERVISED_USERS)
627 sync_service->RegisterDataTypeController( 627 sync_service->RegisterDataTypeController(
628 base::MakeUnique<SupervisedUserSyncDataTypeController>( 628 base::MakeUnique<SupervisedUserSyncDataTypeController>(
629 syncer::SUPERVISED_USER_SETTINGS, error_callback, this, profile_)); 629 syncer::SUPERVISED_USER_SETTINGS, error_callback, this, profile_));
630 sync_service->RegisterDataTypeController( 630 sync_service->RegisterDataTypeController(
631 base::MakeUnique<SupervisedUserSyncDataTypeController>( 631 base::MakeUnique<SupervisedUserSyncDataTypeController>(
632 syncer::SUPERVISED_USER_WHITELISTS, error_callback, this, profile_)); 632 syncer::SUPERVISED_USER_WHITELISTS, error_callback, this, profile_));
633 #endif 633 #endif
634 } 634 }
635 635
636 } // namespace browser_sync 636 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/chrome_sync_client.h ('k') | chrome/browser/sync/glue/extension_data_type_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698