Chromium Code Reviews| Index: chrome/browser/sync/profile_sync_service_factory.cc |
| diff --git a/chrome/browser/sync/profile_sync_service_factory.cc b/chrome/browser/sync/profile_sync_service_factory.cc |
| index 1478dc352e9ed5cff20009ca2bab196ef78cd6f8..c1bf3ffaa2e96b9b98fda361720278e9497901ea 100644 |
| --- a/chrome/browser/sync/profile_sync_service_factory.cc |
| +++ b/chrome/browser/sync/profile_sync_service_factory.cc |
| @@ -25,21 +25,22 @@ |
| #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| #include "chrome/browser/signin/signin_manager_factory.h" |
| #include "chrome/browser/sync/chrome_sync_client.h" |
| -#include "chrome/browser/sync/profile_sync_components_factory_impl.h" |
| #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" |
| #include "chrome/browser/themes/theme_service_factory.h" |
| #include "chrome/browser/web_data_service_factory.h" |
| #include "chrome/common/channel_info.h" |
| +#include "chrome/common/pref_names.h" |
| +#include "components/browser_sync/browser/profile_sync_components_factory_impl.h" |
| #include "components/browser_sync/browser/profile_sync_service.h" |
| #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| #include "components/network_time/network_time_tracker.h" |
| -#include "components/signin/core/browser/profile_oauth2_token_service.h" |
| #include "components/signin/core/browser/signin_manager.h" |
| #include "components/sync_driver/signin_manager_wrapper.h" |
| #include "components/sync_driver/startup_controller.h" |
| #include "components/sync_driver/sync_util.h" |
| #include "components/variations/variations_associated_data.h" |
| #include "content/public/browser/browser_thread.h" |
| +#include "ui/base/device_form_factor.h" |
| #include "url/gurl.h" |
| #if defined(ENABLE_EXTENSIONS) |
| @@ -53,6 +54,8 @@ |
| namespace { |
| +class ProfileOauth2TokenService; |
| + |
| void UpdateNetworkTimeOnUIThread(base::Time network_time, |
| base::TimeDelta resolution, |
| base::TimeDelta latency, |
| @@ -163,9 +166,6 @@ KeyedService* ProfileSyncServiceFactory::BuildServiceInstanceFor( |
| scoped_ptr<SigninManagerWrapper> signin_wrapper( |
| new SupervisedUserSigninManagerWrapper(profile, signin)); |
| - std::string account_id = signin_wrapper->GetAccountIdToUse(); |
| - OAuth2TokenService::ScopeSet scope_set; |
| - scope_set.insert(signin_wrapper->GetSyncScopeToUse()); |
| ProfileOAuth2TokenService* token_service = |
| ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| net::URLRequestContextGetter* url_request_context_getter = |
| @@ -180,14 +180,21 @@ KeyedService* ProfileSyncServiceFactory::BuildServiceInstanceFor( |
| browser_sync::ProfileSyncServiceStartBehavior behavior = |
| browser_defaults::kSyncAutoStarts ? browser_sync::AUTO_START |
| : browser_sync::MANUAL_START; |
| - scoped_ptr<sync_driver::SyncApiComponentFactory> sync_factory( |
| + browser_sync::ChromeSyncClient* chrome_sync_client = |
| + new browser_sync::ChromeSyncClient(profile); |
| + sync_driver::SyncApiComponentFactory* sync_factory = |
|
blundell
2015/11/13 09:33:56
nit: This could be a scoped_ptr variable right?
Nicolas Zea
2015/11/14 00:52:26
This has been removed.
|
| new ProfileSyncComponentsFactoryImpl( |
| - profile, base::CommandLine::ForCurrentProcess(), sync_service_url, |
| - token_service, url_request_context_getter)); |
| - scoped_ptr<browser_sync::ChromeSyncClient> sync_client( |
| - new browser_sync::ChromeSyncClient(profile, sync_factory.Pass())); |
| + chrome_sync_client, chrome::GetChannel(), chrome::GetVersionString(), |
| + ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET, |
| + *base::CommandLine::ForCurrentProcess(), |
| + prefs::kSavingBrowserHistoryDisabled, sync_service_url, |
| + content::BrowserThread::GetMessageLoopProxyForThread( |
| + content::BrowserThread::UI), |
| + content::BrowserThread::GetMessageLoopProxyForThread( |
| + content::BrowserThread::DB), |
| + token_service, url_request_context_getter); |
| ProfileSyncService* pss = new ProfileSyncService( |
| - sync_client.Pass(), signin_wrapper.Pass(), token_service, |
| + make_scoped_ptr(chrome_sync_client), signin_wrapper.Pass(), token_service, |
| behavior, base::Bind(&UpdateNetworkTime), profile->GetPath(), |
| profile->GetRequestContext(), profile->GetDebugName(), |
| chrome::GetChannel(), |
| @@ -196,6 +203,10 @@ KeyedService* ProfileSyncServiceFactory::BuildServiceInstanceFor( |
| content::BrowserThread::GetMessageLoopProxyForThread( |
| content::BrowserThread::FILE), |
| content::BrowserThread::GetBlockingPool()); |
| + |
| + // The order in which these are performed matters. The PSS depends on the |
| + // SyncClient being initialized before it can initalize itself. |
| + chrome_sync_client->Initialize(make_scoped_ptr(sync_factory), pss); |
| pss->Initialize(); |
| return pss; |
| } |