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

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

Issue 16296002: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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) 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/profiles/profile_impl.h" 5 #include "chrome/browser/profiles/profile_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 CreateMode create_mode) { 244 CreateMode create_mode) {
245 TRACE_EVENT0("browser", "Profile::CreateProfile") 245 TRACE_EVENT0("browser", "Profile::CreateProfile")
246 // Get sequenced task runner for making sure that file operations of 246 // Get sequenced task runner for making sure that file operations of
247 // this profile (defined by |path|) are executed in expected order 247 // this profile (defined by |path|) are executed in expected order
248 // (what was previously assured by the FILE thread). 248 // (what was previously assured by the FILE thread).
249 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner = 249 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner =
250 JsonPrefStore::GetTaskRunnerForFile(path, 250 JsonPrefStore::GetTaskRunnerForFile(path,
251 BrowserThread::GetBlockingPool()); 251 BrowserThread::GetBlockingPool());
252 if (create_mode == CREATE_MODE_ASYNCHRONOUS) { 252 if (create_mode == CREATE_MODE_ASYNCHRONOUS) {
253 DCHECK(delegate); 253 DCHECK(delegate);
254 CreateProfileDirectory(sequenced_task_runner, path); 254 CreateProfileDirectory(sequenced_task_runner.get(), path);
255 } else if (create_mode == CREATE_MODE_SYNCHRONOUS) { 255 } else if (create_mode == CREATE_MODE_SYNCHRONOUS) {
256 if (!file_util::PathExists(path)) { 256 if (!file_util::PathExists(path)) {
257 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the 257 // TODO(tc): http://b/1094718 Bad things happen if we can't write to the
258 // profile directory. We should eventually be able to run in this 258 // profile directory. We should eventually be able to run in this
259 // situation. 259 // situation.
260 if (!file_util::CreateDirectory(path)) 260 if (!file_util::CreateDirectory(path))
261 return NULL; 261 return NULL;
262 } 262 }
263 } else { 263 } else {
264 NOTREACHED(); 264 NOTREACHED();
265 } 265 }
266 266
267 return new ProfileImpl(path, delegate, create_mode, sequenced_task_runner); 267 return new ProfileImpl(
268 path, delegate, create_mode, sequenced_task_runner.get());
268 } 269 }
269 270
270 // static 271 // static
271 int ProfileImpl::create_readme_delay_ms = 60000; 272 int ProfileImpl::create_readme_delay_ms = 60000;
272 273
273 // static 274 // static
274 const char* const ProfileImpl::kPrefExitTypeNormal = "Normal"; 275 const char* const ProfileImpl::kPrefExitTypeNormal = "Normal";
275 276
276 // static 277 // static
277 void ProfileImpl::RegisterUserPrefs( 278 void ProfileImpl::RegisterUserPrefs(
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 #endif 390 #endif
390 #endif 391 #endif
391 profile_policy_connector_ = 392 profile_policy_connector_ =
392 policy::ProfilePolicyConnectorFactory::CreateForProfile( 393 policy::ProfilePolicyConnectorFactory::CreateForProfile(
393 this, force_immediate_policy_load, sequenced_task_runner); 394 this, force_immediate_policy_load, sequenced_task_runner);
394 395
395 DCHECK(create_mode == CREATE_MODE_ASYNCHRONOUS || 396 DCHECK(create_mode == CREATE_MODE_ASYNCHRONOUS ||
396 create_mode == CREATE_MODE_SYNCHRONOUS); 397 create_mode == CREATE_MODE_SYNCHRONOUS);
397 bool async_prefs = create_mode == CREATE_MODE_ASYNCHRONOUS; 398 bool async_prefs = create_mode == CREATE_MODE_ASYNCHRONOUS;
398 399
399 chrome::RegisterUserPrefs(pref_registry_); 400 chrome::RegisterUserPrefs(pref_registry_.get());
400 401
401 { 402 {
402 // On startup, preference loading is always synchronous so a scoped timer 403 // On startup, preference loading is always synchronous so a scoped timer
403 // will work here. 404 // will work here.
404 startup_metric_utils::ScopedSlowStartupUMA 405 startup_metric_utils::ScopedSlowStartupUMA
405 scoped_timer("Startup.SlowStartupPreferenceLoading"); 406 scoped_timer("Startup.SlowStartupPreferenceLoading");
406 prefs_.reset(chrome_prefs::CreateProfilePrefs( 407 prefs_.reset(chrome_prefs::CreateProfilePrefs(
407 GetPrefFilePath(), 408 GetPrefFilePath(),
408 sequenced_task_runner, 409 sequenced_task_runner,
409 profile_policy_connector_->policy_service(), 410 profile_policy_connector_->policy_service(),
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 base::Unretained(this))); 453 base::Unretained(this)));
453 454
454 // It would be nice to use PathService for fetching this directory, but 455 // It would be nice to use PathService for fetching this directory, but
455 // the cache directory depends on the profile directory, which isn't available 456 // the cache directory depends on the profile directory, which isn't available
456 // to PathService. 457 // to PathService.
457 chrome::GetUserCacheDirectory(path_, &base_cache_path_); 458 chrome::GetUserCacheDirectory(path_, &base_cache_path_);
458 // Always create the cache directory asynchronously. 459 // Always create the cache directory asynchronously.
459 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner = 460 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner =
460 JsonPrefStore::GetTaskRunnerForFile(base_cache_path_, 461 JsonPrefStore::GetTaskRunnerForFile(base_cache_path_,
461 BrowserThread::GetBlockingPool()); 462 BrowserThread::GetBlockingPool());
462 CreateProfileDirectory(sequenced_task_runner, base_cache_path_); 463 CreateProfileDirectory(sequenced_task_runner.get(), base_cache_path_);
463 464
464 // Now that the profile is hooked up to receive pref change notifications to 465 // Now that the profile is hooked up to receive pref change notifications to
465 // kGoogleServicesUsername, initialize components that depend on it to reflect 466 // kGoogleServicesUsername, initialize components that depend on it to reflect
466 // the current value. 467 // the current value.
467 UpdateProfileUserNameCache(); 468 UpdateProfileUserNameCache();
468 GAIAInfoUpdateServiceFactory::GetForProfile(this); 469 GAIAInfoUpdateServiceFactory::GetForProfile(this);
469 470
470 PrefService* local_state = g_browser_process->local_state(); 471 PrefService* local_state = g_browser_process->local_state();
471 ssl_config_service_manager_.reset( 472 ssl_config_service_manager_.reset(
472 SSLConfigServiceManager::CreateDefaultManager(local_state)); 473 SSLConfigServiceManager::CreateDefaultManager(local_state));
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 ProfileDestroyer::DestroyOffTheRecordProfileNow( 633 ProfileDestroyer::DestroyOffTheRecordProfileNow(
633 off_the_record_profile_.get()); 634 off_the_record_profile_.get());
634 } else { 635 } else {
635 ExtensionPrefValueMapFactory::GetForProfile(this)-> 636 ExtensionPrefValueMapFactory::GetForProfile(this)->
636 ClearAllIncognitoSessionOnlyPreferences(); 637 ClearAllIncognitoSessionOnlyPreferences();
637 } 638 }
638 639
639 BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices( 640 BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(
640 this); 641 this);
641 642
642 if (top_sites_) 643 if (top_sites_.get())
643 top_sites_->Shutdown(); 644 top_sites_->Shutdown();
644 645
645 if (pref_proxy_config_tracker_) 646 if (pref_proxy_config_tracker_)
646 pref_proxy_config_tracker_->DetachFromPrefService(); 647 pref_proxy_config_tracker_->DetachFromPrefService();
647 648
648 if (host_content_settings_map_) 649 if (host_content_settings_map_.get())
649 host_content_settings_map_->ShutdownOnUIThread(); 650 host_content_settings_map_->ShutdownOnUIThread();
650 651
651 // This causes the Preferences file to be written to disk. 652 // This causes the Preferences file to be written to disk.
652 if (prefs_loaded) 653 if (prefs_loaded)
653 SetExitType(EXIT_NORMAL); 654 SetExitType(EXIT_NORMAL);
654 } 655 }
655 656
656 std::string ProfileImpl::GetProfileName() { 657 std::string ProfileImpl::GetProfileName() {
657 return GetPrefs()->GetString(prefs::kGoogleServicesUsername); 658 return GetPrefs()->GetString(prefs::kGoogleServicesUsername);
658 } 659 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 Profile* ProfileImpl::GetOriginalProfile() { 697 Profile* ProfileImpl::GetOriginalProfile() {
697 return this; 698 return this;
698 } 699 }
699 700
700 ExtensionService* ProfileImpl::GetExtensionService() { 701 ExtensionService* ProfileImpl::GetExtensionService() {
701 return extensions::ExtensionSystem::Get(this)->extension_service(); 702 return extensions::ExtensionSystem::Get(this)->extension_service();
702 } 703 }
703 704
704 ExtensionSpecialStoragePolicy* 705 ExtensionSpecialStoragePolicy*
705 ProfileImpl::GetExtensionSpecialStoragePolicy() { 706 ProfileImpl::GetExtensionSpecialStoragePolicy() {
706 if (!extension_special_storage_policy_) { 707 if (!extension_special_storage_policy_.get()) {
707 TRACE_EVENT0("browser", "ProfileImpl::GetExtensionSpecialStoragePolicy") 708 TRACE_EVENT0("browser", "ProfileImpl::GetExtensionSpecialStoragePolicy")
708 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy( 709 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy(
709 CookieSettings::Factory::GetForProfile(this)); 710 CookieSettings::Factory::GetForProfile(this));
710 } 711 }
711 return extension_special_storage_policy_.get(); 712 return extension_special_storage_policy_.get();
712 } 713 }
713 714
714 void ProfileImpl::OnPrefsLoaded(bool success) { 715 void ProfileImpl::OnPrefsLoaded(bool success) {
715 TRACE_EVENT0("browser", "ProfileImpl::OnPrefsLoaded") 716 TRACE_EVENT0("browser", "ProfileImpl::OnPrefsLoaded")
716 if (!success) { 717 if (!success) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 // BrowserContextKeyedService is trying to create a RequestContext at startup, 879 // BrowserContextKeyedService is trying to create a RequestContext at startup,
879 // but SSLConfigServiceManager is not initialized until DoFinalInit() which is 880 // but SSLConfigServiceManager is not initialized until DoFinalInit() which is
880 // invoked after all BrowserContextKeyedServices have been initialized (see 881 // invoked after all BrowserContextKeyedServices have been initialized (see
881 // http://crbug.com/171406). 882 // http://crbug.com/171406).
882 DCHECK(ssl_config_service_manager_) << 883 DCHECK(ssl_config_service_manager_) <<
883 "SSLConfigServiceManager is not initialized yet"; 884 "SSLConfigServiceManager is not initialized yet";
884 return ssl_config_service_manager_->Get(); 885 return ssl_config_service_manager_->Get();
885 } 886 }
886 887
887 HostContentSettingsMap* ProfileImpl::GetHostContentSettingsMap() { 888 HostContentSettingsMap* ProfileImpl::GetHostContentSettingsMap() {
888 if (!host_content_settings_map_) { 889 if (!host_content_settings_map_.get()) {
889 host_content_settings_map_ = new HostContentSettingsMap(GetPrefs(), false); 890 host_content_settings_map_ = new HostContentSettingsMap(GetPrefs(), false);
890 } 891 }
891 return host_content_settings_map_.get(); 892 return host_content_settings_map_.get();
892 } 893 }
893 894
894 content::GeolocationPermissionContext* 895 content::GeolocationPermissionContext*
895 ProfileImpl::GetGeolocationPermissionContext() { 896 ProfileImpl::GetGeolocationPermissionContext() {
896 return ChromeGeolocationPermissionContextFactory::GetForProfile(this); 897 return ChromeGeolocationPermissionContextFactory::GetForProfile(this);
897 } 898 }
898 899
(...skipping 20 matching lines...) Expand all
919 return true; 920 return true;
920 Profile* otr_profile = off_the_record_profile_.get(); 921 Profile* otr_profile = off_the_record_profile_.get();
921 return otr_profile && profile == otr_profile; 922 return otr_profile && profile == otr_profile;
922 } 923 }
923 924
924 Time ProfileImpl::GetStartTime() const { 925 Time ProfileImpl::GetStartTime() const {
925 return start_time_; 926 return start_time_;
926 } 927 }
927 928
928 history::TopSites* ProfileImpl::GetTopSites() { 929 history::TopSites* ProfileImpl::GetTopSites() {
929 if (!top_sites_) { 930 if (!top_sites_.get()) {
930 top_sites_ = history::TopSites::Create( 931 top_sites_ = history::TopSites::Create(
931 this, GetPath().Append(chrome::kTopSitesFilename)); 932 this, GetPath().Append(chrome::kTopSitesFilename));
932 } 933 }
933 return top_sites_; 934 return top_sites_.get();
934 } 935 }
935 936
936 history::TopSites* ProfileImpl::GetTopSitesWithoutCreating() { 937 history::TopSites* ProfileImpl::GetTopSitesWithoutCreating() {
937 return top_sites_; 938 return top_sites_.get();
938 } 939 }
939 940
940 void ProfileImpl::OnDefaultZoomLevelChanged() { 941 void ProfileImpl::OnDefaultZoomLevelChanged() {
941 HostZoomMap::GetForBrowserContext(this)->SetDefaultZoomLevel( 942 HostZoomMap::GetForBrowserContext(this)->SetDefaultZoomLevel(
942 pref_change_registrar_.prefs()->GetDouble(prefs::kDefaultZoomLevel)); 943 pref_change_registrar_.prefs()->GetDouble(prefs::kDefaultZoomLevel));
943 } 944 }
944 945
945 void ProfileImpl::OnZoomLevelChanged( 946 void ProfileImpl::OnZoomLevelChanged(
946 const HostZoomMap::ZoomLevelChange& change) { 947 const HostZoomMap::ZoomLevelChange& change) {
947 948
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 base::FilePath* cache_path, 1150 base::FilePath* cache_path,
1150 int* max_size) { 1151 int* max_size) {
1151 DCHECK(cache_path); 1152 DCHECK(cache_path);
1152 DCHECK(max_size); 1153 DCHECK(max_size);
1153 base::FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); 1154 base::FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir));
1154 if (!path.empty()) 1155 if (!path.empty())
1155 *cache_path = path; 1156 *cache_path = path;
1156 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : 1157 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) :
1157 prefs_->GetInteger(prefs::kDiskCacheSize); 1158 prefs_->GetInteger(prefs::kDiskCacheSize);
1158 } 1159 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/off_the_record_profile_io_data.cc ('k') | chrome/browser/profiles/profile_impl_io_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698