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

Side by Side Diff: chrome/browser/profile_impl.cc

Issue 3305003: New authorization framework for sync. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/profile_impl.h" 5 #include "chrome/browser/profile_impl.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 472
473 // Remove pref observers. 473 // Remove pref observers.
474 PrefService* prefs = GetPrefs(); 474 PrefService* prefs = GetPrefs();
475 prefs->RemovePrefObserver(prefs::kSpellCheckDictionary, this); 475 prefs->RemovePrefObserver(prefs::kSpellCheckDictionary, this);
476 prefs->RemovePrefObserver(prefs::kEnableSpellCheck, this); 476 prefs->RemovePrefObserver(prefs::kEnableSpellCheck, this);
477 prefs->RemovePrefObserver(prefs::kEnableAutoSpellCorrect, this); 477 prefs->RemovePrefObserver(prefs::kEnableAutoSpellCorrect, this);
478 478
479 // Delete the NTP resource cache so we can unregister pref observers. 479 // Delete the NTP resource cache so we can unregister pref observers.
480 ntp_resource_cache_.reset(); 480 ntp_resource_cache_.reset();
481 481
482 // The sync service needs to be deleted before the services it calls.
482 sync_service_.reset(); 483 sync_service_.reset();
483 484
484 // Both HistoryService and WebDataService maintain threads for background 485 // Both HistoryService and WebDataService maintain threads for background
485 // processing. Its possible each thread still has tasks on it that have 486 // processing. Its possible each thread still has tasks on it that have
486 // increased the ref count of the service. In such a situation, when we 487 // increased the ref count of the service. In such a situation, when we
487 // decrement the refcount, it won't be 0, and the threads/databases aren't 488 // decrement the refcount, it won't be 0, and the threads/databases aren't
488 // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the 489 // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the
489 // databases are properly closed. 490 // databases are properly closed.
490 if (web_data_service_.get()) 491 if (web_data_service_.get())
491 web_data_service_->Shutdown(); 492 web_data_service_->Shutdown();
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 } 1229 }
1229 1230
1230 TokenService* ProfileImpl::GetTokenService() { 1231 TokenService* ProfileImpl::GetTokenService() {
1231 if (!token_service_.get()) { 1232 if (!token_service_.get()) {
1232 token_service_.reset(new TokenService()); 1233 token_service_.reset(new TokenService());
1233 } 1234 }
1234 return token_service_.get(); 1235 return token_service_.get();
1235 } 1236 }
1236 1237
1237 ProfileSyncService* ProfileImpl::GetProfileSyncService() { 1238 ProfileSyncService* ProfileImpl::GetProfileSyncService() {
1239 return GetProfileSyncService("");
1240 }
1241
1242 ProfileSyncService* ProfileImpl::GetProfileSyncService(
1243 const std::string& cros_user) {
1244
1238 if (!ProfileSyncService::IsSyncEnabled()) 1245 if (!ProfileSyncService::IsSyncEnabled())
1239 return NULL; 1246 return NULL;
1240 if (!sync_service_.get()) 1247 if (!sync_service_.get())
1241 InitSyncService(); 1248 InitSyncService(cros_user);
1242 return sync_service_.get(); 1249 return sync_service_.get();
1243 } 1250 }
1244 1251
1245 CloudPrintProxyService* ProfileImpl::GetCloudPrintProxyService() { 1252 CloudPrintProxyService* ProfileImpl::GetCloudPrintProxyService() {
1246 if (!cloud_print_proxy_service_.get()) 1253 if (!cloud_print_proxy_service_.get())
1247 InitCloudPrintProxyService(); 1254 InitCloudPrintProxyService();
1248 return cloud_print_proxy_service_.get(); 1255 return cloud_print_proxy_service_.get();
1249 } 1256 }
1250 1257
1251 void ProfileImpl::InitSyncService() { 1258 void ProfileImpl::InitSyncService(const std::string& cros_user) {
1252 profile_sync_factory_.reset( 1259 profile_sync_factory_.reset(
1253 new ProfileSyncFactoryImpl(this, CommandLine::ForCurrentProcess())); 1260 new ProfileSyncFactoryImpl(this, CommandLine::ForCurrentProcess()));
1254 sync_service_.reset( 1261 sync_service_.reset(
1255 profile_sync_factory_->CreateProfileSyncService()); 1262 profile_sync_factory_->CreateProfileSyncService(cros_user));
1256 sync_service_->Initialize(); 1263 sync_service_->Initialize();
1257 } 1264 }
1258 1265
1259 void ProfileImpl::InitCloudPrintProxyService() { 1266 void ProfileImpl::InitCloudPrintProxyService() {
1260 cloud_print_proxy_service_.reset(new CloudPrintProxyService(this)); 1267 cloud_print_proxy_service_.reset(new CloudPrintProxyService(this));
1261 cloud_print_proxy_service_->Initialize(); 1268 cloud_print_proxy_service_->Initialize();
1262 } 1269 }
1263 1270
1264 ChromeBlobStorageContext* ProfileImpl::GetBlobStorageContext() { 1271 ChromeBlobStorageContext* ProfileImpl::GetBlobStorageContext() {
1265 if (!blob_storage_context_) { 1272 if (!blob_storage_context_) {
1266 blob_storage_context_ = new ChromeBlobStorageContext(); 1273 blob_storage_context_ = new ChromeBlobStorageContext();
1267 ChromeThread::PostTask( 1274 ChromeThread::PostTask(
1268 ChromeThread::IO, FROM_HERE, 1275 ChromeThread::IO, FROM_HERE,
1269 NewRunnableMethod(blob_storage_context_.get(), 1276 NewRunnableMethod(blob_storage_context_.get(),
1270 &ChromeBlobStorageContext::InitializeOnIOThread)); 1277 &ChromeBlobStorageContext::InitializeOnIOThread));
1271 } 1278 }
1272 return blob_storage_context_; 1279 return blob_storage_context_;
1273 } 1280 }
1274 1281
1275 #if defined(OS_CHROMEOS) 1282 #if defined(OS_CHROMEOS)
1276 chromeos::ProxyConfigServiceImpl* 1283 chromeos::ProxyConfigServiceImpl*
1277 ProfileImpl::GetChromeOSProxyConfigServiceImpl() { 1284 ProfileImpl::GetChromeOSProxyConfigServiceImpl() {
1278 if (!chromeos_proxy_config_service_impl_) { 1285 if (!chromeos_proxy_config_service_impl_) {
1279 chromeos_proxy_config_service_impl_ = 1286 chromeos_proxy_config_service_impl_ =
1280 new chromeos::ProxyConfigServiceImpl(); 1287 new chromeos::ProxyConfigServiceImpl();
1281 } 1288 }
1282 return chromeos_proxy_config_service_impl_; 1289 return chromeos_proxy_config_service_impl_;
1283 } 1290 }
1284 #endif // defined(OS_CHROMEOS) 1291 #endif // defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698