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

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

Issue 1421003007: [Sync] Componentize ProfileSyncComponentsFactoryImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 5 years, 1 month 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 "chrome/browser/sync/profile_sync_service_factory.h" 5 #include "chrome/browser/sync/profile_sync_service_factory.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "chrome/browser/autofill/personal_data_manager_factory.h" 11 #include "chrome/browser/autofill/personal_data_manager_factory.h"
12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 12 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/defaults.h" 14 #include "chrome/browser/defaults.h"
15 #include "chrome/browser/history/history_service_factory.h" 15 #include "chrome/browser/history/history_service_factory.h"
16 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" 16 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
17 #include "chrome/browser/password_manager/password_store_factory.h" 17 #include "chrome/browser/password_manager/password_store_factory.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/browser/search_engines/template_url_service_factory.h" 20 #include "chrome/browser/search_engines/template_url_service_factory.h"
21 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 21 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
22 #include "chrome/browser/sessions/tab_restore_service_factory.h" 22 #include "chrome/browser/sessions/tab_restore_service_factory.h"
23 #include "chrome/browser/signin/about_signin_internals_factory.h" 23 #include "chrome/browser/signin/about_signin_internals_factory.h"
24 #include "chrome/browser/signin/chrome_signin_client_factory.h" 24 #include "chrome/browser/signin/chrome_signin_client_factory.h"
25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
26 #include "chrome/browser/signin/signin_manager_factory.h" 26 #include "chrome/browser/signin/signin_manager_factory.h"
27 #include "chrome/browser/sync/chrome_sync_client.h" 27 #include "chrome/browser/sync/chrome_sync_client.h"
28 #include "chrome/browser/sync/profile_sync_components_factory_impl.h"
29 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" 28 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h"
30 #include "chrome/browser/themes/theme_service_factory.h" 29 #include "chrome/browser/themes/theme_service_factory.h"
31 #include "chrome/browser/web_data_service_factory.h" 30 #include "chrome/browser/web_data_service_factory.h"
32 #include "chrome/common/channel_info.h" 31 #include "chrome/common/channel_info.h"
32 #include "chrome/common/pref_names.h"
33 #include "components/browser_sync/browser/profile_sync_components_factory_impl.h "
33 #include "components/browser_sync/browser/profile_sync_service.h" 34 #include "components/browser_sync/browser/profile_sync_service.h"
34 #include "components/keyed_service/content/browser_context_dependency_manager.h" 35 #include "components/keyed_service/content/browser_context_dependency_manager.h"
35 #include "components/network_time/network_time_tracker.h" 36 #include "components/network_time/network_time_tracker.h"
36 #include "components/signin/core/browser/profile_oauth2_token_service.h"
37 #include "components/signin/core/browser/signin_manager.h" 37 #include "components/signin/core/browser/signin_manager.h"
38 #include "components/sync_driver/signin_manager_wrapper.h" 38 #include "components/sync_driver/signin_manager_wrapper.h"
39 #include "components/sync_driver/startup_controller.h" 39 #include "components/sync_driver/startup_controller.h"
40 #include "components/sync_driver/sync_util.h" 40 #include "components/sync_driver/sync_util.h"
41 #include "components/variations/variations_associated_data.h" 41 #include "components/variations/variations_associated_data.h"
42 #include "content/public/browser/browser_thread.h" 42 #include "content/public/browser/browser_thread.h"
43 #include "ui/base/device_form_factor.h"
43 #include "url/gurl.h" 44 #include "url/gurl.h"
44 45
45 #if defined(ENABLE_EXTENSIONS) 46 #if defined(ENABLE_EXTENSIONS)
46 #include "extensions/browser/extension_system_provider.h" 47 #include "extensions/browser/extension_system_provider.h"
47 #include "extensions/browser/extensions_browser_client.h" 48 #include "extensions/browser/extensions_browser_client.h"
48 #endif 49 #endif
49 50
50 #if !defined(OS_ANDROID) 51 #if !defined(OS_ANDROID)
51 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 52 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
52 #endif 53 #endif
53 54
54 namespace { 55 namespace {
55 56
57 class ProfileOauth2TokenService;
58
56 void UpdateNetworkTimeOnUIThread(base::Time network_time, 59 void UpdateNetworkTimeOnUIThread(base::Time network_time,
57 base::TimeDelta resolution, 60 base::TimeDelta resolution,
58 base::TimeDelta latency, 61 base::TimeDelta latency,
59 base::TimeTicks post_time) { 62 base::TimeTicks post_time) {
60 g_browser_process->network_time_tracker()->UpdateNetworkTime( 63 g_browser_process->network_time_tracker()->UpdateNetworkTime(
61 network_time, resolution, latency, post_time); 64 network_time, resolution, latency, post_time);
62 } 65 }
63 66
64 void UpdateNetworkTime(const base::Time& network_time, 67 void UpdateNetworkTime(const base::Time& network_time,
65 const base::TimeDelta& resolution, 68 const base::TimeDelta& resolution,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 159
157 // TODO(atwilson): Change AboutSigninInternalsFactory to load on startup 160 // TODO(atwilson): Change AboutSigninInternalsFactory to load on startup
158 // once http://crbug.com/171406 has been fixed. 161 // once http://crbug.com/171406 has been fixed.
159 AboutSigninInternalsFactory::GetForProfile(profile); 162 AboutSigninInternalsFactory::GetForProfile(profile);
160 163
161 const GURL sync_service_url = GetSyncServiceURL( 164 const GURL sync_service_url = GetSyncServiceURL(
162 *base::CommandLine::ForCurrentProcess(), chrome::GetChannel()); 165 *base::CommandLine::ForCurrentProcess(), chrome::GetChannel());
163 166
164 scoped_ptr<SigninManagerWrapper> signin_wrapper( 167 scoped_ptr<SigninManagerWrapper> signin_wrapper(
165 new SupervisedUserSigninManagerWrapper(profile, signin)); 168 new SupervisedUserSigninManagerWrapper(profile, signin));
166 std::string account_id = signin_wrapper->GetAccountIdToUse();
167 OAuth2TokenService::ScopeSet scope_set;
168 scope_set.insert(signin_wrapper->GetSyncScopeToUse());
169 ProfileOAuth2TokenService* token_service = 169 ProfileOAuth2TokenService* token_service =
170 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); 170 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
171 net::URLRequestContextGetter* url_request_context_getter = 171 net::URLRequestContextGetter* url_request_context_getter =
172 profile->GetRequestContext(); 172 profile->GetRequestContext();
173 173
174 // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync 174 // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync
175 // is set up and *not* a browser restart for a manual-start platform (where 175 // is set up and *not* a browser restart for a manual-start platform (where
176 // sync has already been set up, and should be able to start without user 176 // sync has already been set up, and should be able to start without user
177 // intervention). We can get rid of the browser_default eventually, but 177 // intervention). We can get rid of the browser_default eventually, but
178 // need to take care that ProfileSyncService doesn't get tripped up between 178 // need to take care that ProfileSyncService doesn't get tripped up between
179 // those two cases. Bug 88109. 179 // those two cases. Bug 88109.
180 browser_sync::ProfileSyncServiceStartBehavior behavior = 180 browser_sync::ProfileSyncServiceStartBehavior behavior =
181 browser_defaults::kSyncAutoStarts ? browser_sync::AUTO_START 181 browser_defaults::kSyncAutoStarts ? browser_sync::AUTO_START
182 : browser_sync::MANUAL_START; 182 : browser_sync::MANUAL_START;
183 scoped_ptr<sync_driver::SyncApiComponentFactory> sync_factory( 183 browser_sync::ChromeSyncClient* chrome_sync_client =
184 new browser_sync::ChromeSyncClient(profile);
185 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.
184 new ProfileSyncComponentsFactoryImpl( 186 new ProfileSyncComponentsFactoryImpl(
185 profile, base::CommandLine::ForCurrentProcess(), sync_service_url, 187 chrome_sync_client, chrome::GetChannel(), chrome::GetVersionString(),
186 token_service, url_request_context_getter)); 188 ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET,
187 scoped_ptr<browser_sync::ChromeSyncClient> sync_client( 189 *base::CommandLine::ForCurrentProcess(),
188 new browser_sync::ChromeSyncClient(profile, sync_factory.Pass())); 190 prefs::kSavingBrowserHistoryDisabled, sync_service_url,
191 content::BrowserThread::GetMessageLoopProxyForThread(
192 content::BrowserThread::UI),
193 content::BrowserThread::GetMessageLoopProxyForThread(
194 content::BrowserThread::DB),
195 token_service, url_request_context_getter);
189 ProfileSyncService* pss = new ProfileSyncService( 196 ProfileSyncService* pss = new ProfileSyncService(
190 sync_client.Pass(), signin_wrapper.Pass(), token_service, 197 make_scoped_ptr(chrome_sync_client), signin_wrapper.Pass(), token_service,
191 behavior, base::Bind(&UpdateNetworkTime), profile->GetPath(), 198 behavior, base::Bind(&UpdateNetworkTime), profile->GetPath(),
192 profile->GetRequestContext(), profile->GetDebugName(), 199 profile->GetRequestContext(), profile->GetDebugName(),
193 chrome::GetChannel(), 200 chrome::GetChannel(),
194 content::BrowserThread::GetMessageLoopProxyForThread( 201 content::BrowserThread::GetMessageLoopProxyForThread(
195 content::BrowserThread::DB), 202 content::BrowserThread::DB),
196 content::BrowserThread::GetMessageLoopProxyForThread( 203 content::BrowserThread::GetMessageLoopProxyForThread(
197 content::BrowserThread::FILE), 204 content::BrowserThread::FILE),
198 content::BrowserThread::GetBlockingPool()); 205 content::BrowserThread::GetBlockingPool());
206
207 // The order in which these are performed matters. The PSS depends on the
208 // SyncClient being initialized before it can initalize itself.
209 chrome_sync_client->Initialize(make_scoped_ptr(sync_factory), pss);
199 pss->Initialize(); 210 pss->Initialize();
200 return pss; 211 return pss;
201 } 212 }
202 213
203 // static 214 // static
204 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { 215 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) {
205 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; 216 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL;
206 } 217 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698