| OLD | NEW |
| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 user_prefs::UserPrefs::Set(this, prefs_.get()); | 468 user_prefs::UserPrefs::Set(this, prefs_.get()); |
| 469 } | 469 } |
| 470 | 470 |
| 471 startup_metric_utils::ScopedSlowStartupUMA | 471 startup_metric_utils::ScopedSlowStartupUMA |
| 472 scoped_timer("Startup.SlowStartupFinalProfileInit"); | 472 scoped_timer("Startup.SlowStartupFinalProfileInit"); |
| 473 if (async_prefs) { | 473 if (async_prefs) { |
| 474 // Wait for the notification that prefs has been loaded | 474 // Wait for the notification that prefs has been loaded |
| 475 // (successfully or not). Note that we can use base::Unretained | 475 // (successfully or not). Note that we can use base::Unretained |
| 476 // because the PrefService is owned by this class and lives on | 476 // because the PrefService is owned by this class and lives on |
| 477 // the same thread. | 477 // the same thread. |
| 478 prefs_->AddPrefInitObserver(base::Bind(&ProfileImpl::OnPrefsLoaded, | 478 prefs_->AddPrefInitObserver(base::Bind( |
| 479 base::Unretained(this))); | 479 &ProfileImpl::OnPrefsLoaded, base::Unretained(this), create_mode)); |
| 480 } else { | 480 } else { |
| 481 // Prefs were loaded synchronously so we can continue directly. | 481 // Prefs were loaded synchronously so we can continue directly. |
| 482 OnPrefsLoaded(true); | 482 OnPrefsLoaded(create_mode, true); |
| 483 } | 483 } |
| 484 } | 484 } |
| 485 | 485 |
| 486 void ProfileImpl::DoFinalInit() { | 486 void ProfileImpl::DoFinalInit() { |
| 487 TRACE_EVENT0("browser", "ProfileImpl::DoFinalInit") | 487 TRACE_EVENT0("browser", "ProfileImpl::DoFinalInit") |
| 488 SCOPED_UMA_HISTOGRAM_TIMER("Profile.ProfileImplDoFinalInit"); | 488 SCOPED_UMA_HISTOGRAM_TIMER("Profile.ProfileImplDoFinalInit"); |
| 489 | 489 |
| 490 PrefService* prefs = GetPrefs(); | 490 PrefService* prefs = GetPrefs(); |
| 491 pref_change_registrar_.Init(prefs); | 491 pref_change_registrar_.Init(prefs); |
| 492 pref_change_registrar_.Add( | 492 pref_change_registrar_.Add( |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 TRACE_EVENT0("browser", "ProfileImpl::GetExtensionSpecialStoragePolicy") | 795 TRACE_EVENT0("browser", "ProfileImpl::GetExtensionSpecialStoragePolicy") |
| 796 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy( | 796 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy( |
| 797 CookieSettings::Factory::GetForProfile(this).get()); | 797 CookieSettings::Factory::GetForProfile(this).get()); |
| 798 } | 798 } |
| 799 return extension_special_storage_policy_.get(); | 799 return extension_special_storage_policy_.get(); |
| 800 #else | 800 #else |
| 801 return NULL; | 801 return NULL; |
| 802 #endif | 802 #endif |
| 803 } | 803 } |
| 804 | 804 |
| 805 void ProfileImpl::OnPrefsLoaded(bool success) { | 805 void ProfileImpl::OnLocaleReady() { |
| 806 TRACE_EVENT0("browser", "ProfileImpl::OnPrefsLoaded"); | 806 SCOPED_UMA_HISTOGRAM_TIMER("Profile.OnLocaleReadyTime"); |
| 807 SCOPED_UMA_HISTOGRAM_TIMER("Profile.OnPrefsLoadedTime"); | |
| 808 if (!success) { | |
| 809 if (delegate_) | |
| 810 delegate_->OnProfileCreated(this, false, false); | |
| 811 return; | |
| 812 } | |
| 813 | |
| 814 // Migrate obsolete prefs. | 807 // Migrate obsolete prefs. |
| 815 if (g_browser_process->local_state()) | 808 if (g_browser_process->local_state()) |
| 816 chrome::MigrateObsoleteBrowserPrefs(this, g_browser_process->local_state()); | 809 chrome::MigrateObsoleteBrowserPrefs(this, g_browser_process->local_state()); |
| 817 chrome::MigrateObsoleteProfilePrefs(this); | 810 chrome::MigrateObsoleteProfilePrefs(this); |
| 818 | 811 |
| 819 // |kSessionExitType| was added after |kSessionExitedCleanly|. If the pref | 812 // |kSessionExitType| was added after |kSessionExitedCleanly|. If the pref |
| 820 // value is empty fallback to checking for |kSessionExitedCleanly|. | 813 // value is empty fallback to checking for |kSessionExitedCleanly|. |
| 821 const std::string exit_type_pref_value( | 814 const std::string exit_type_pref_value( |
| 822 prefs_->GetString(prefs::kSessionExitType)); | 815 prefs_->GetString(prefs::kSessionExitType)); |
| 823 if (exit_type_pref_value.empty()) { | 816 if (exit_type_pref_value.empty()) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 854 TRACE_EVENT0("browser", "ProfileImpl::OnPrefsLoaded:NetPrefObserver") | 847 TRACE_EVENT0("browser", "ProfileImpl::OnPrefsLoaded:NetPrefObserver") |
| 855 net_pref_observer_.reset(new NetPrefObserver(prefs_.get())); | 848 net_pref_observer_.reset(new NetPrefObserver(prefs_.get())); |
| 856 } | 849 } |
| 857 | 850 |
| 858 chrome_prefs::SchedulePrefsFilePathVerification(path_); | 851 chrome_prefs::SchedulePrefsFilePathVerification(path_); |
| 859 | 852 |
| 860 ChromeVersionService::OnProfileLoaded(prefs_.get(), IsNewProfile()); | 853 ChromeVersionService::OnProfileLoaded(prefs_.get(), IsNewProfile()); |
| 861 DoFinalInit(); | 854 DoFinalInit(); |
| 862 } | 855 } |
| 863 | 856 |
| 857 void ProfileImpl::OnPrefsLoaded(CreateMode create_mode, bool success) { |
| 858 TRACE_EVENT0("browser", "ProfileImpl::OnPrefsLoaded"); |
| 859 if (!success) { |
| 860 if (delegate_) |
| 861 delegate_->OnProfileCreated(this, false, false); |
| 862 |
| 863 return; |
| 864 } |
| 865 |
| 866 #if defined(OS_CHROMEOS) |
| 867 const bool synchronous = (create_mode == CREATE_MODE_SYNCHRONOUS); |
| 868 chromeos::UserSessionManager::GetInstance()->RespectLocalePreferenceWrapper( |
| 869 this, base::Bind(&ProfileImpl::OnLocaleReady, base::Unretained(this)), |
| 870 synchronous); |
| 871 #else |
| 872 OnLocaleReady(); |
| 873 #endif |
| 874 } |
| 875 |
| 864 bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) { | 876 bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) { |
| 865 Version profile_version(ChromeVersionService::GetVersion(prefs_.get())); | 877 Version profile_version(ChromeVersionService::GetVersion(prefs_.get())); |
| 866 Version arg_version(version); | 878 Version arg_version(version); |
| 867 return (profile_version.CompareTo(arg_version) >= 0); | 879 return (profile_version.CompareTo(arg_version) >= 0); |
| 868 } | 880 } |
| 869 | 881 |
| 870 void ProfileImpl::SetExitType(ExitType exit_type) { | 882 void ProfileImpl::SetExitType(ExitType exit_type) { |
| 871 #if defined(OS_CHROMEOS) | 883 #if defined(OS_CHROMEOS) |
| 872 if (chromeos::ProfileHelper::IsSigninProfile(this)) | 884 if (chromeos::ProfileHelper::IsSigninProfile(this)) |
| 873 return; | 885 return; |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 ProfileImpl::CreateDomainReliabilityMonitor(PrefService* local_state) { | 1308 ProfileImpl::CreateDomainReliabilityMonitor(PrefService* local_state) { |
| 1297 domain_reliability::DomainReliabilityService* service = | 1309 domain_reliability::DomainReliabilityService* service = |
| 1298 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> | 1310 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> |
| 1299 GetForBrowserContext(this); | 1311 GetForBrowserContext(this); |
| 1300 if (!service) | 1312 if (!service) |
| 1301 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); | 1313 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); |
| 1302 | 1314 |
| 1303 return service->CreateMonitor( | 1315 return service->CreateMonitor( |
| 1304 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 1316 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
| 1305 } | 1317 } |
| OLD | NEW |