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 TRACE_EVENT0("browser", "ProfileImpl::OnLocaleReady"); |
807 SCOPED_UMA_HISTOGRAM_TIMER("Profile.OnPrefsLoadedTime"); | 807 SCOPED_UMA_HISTOGRAM_TIMER("Profile.OnLocaleReadyTime"); |
808 if (!success) { | |
809 if (delegate_) | |
810 delegate_->OnProfileCreated(this, false, false); | |
811 return; | |
812 } | |
813 | |
814 // Migrate obsolete prefs. | 808 // Migrate obsolete prefs. |
815 if (g_browser_process->local_state()) | 809 if (g_browser_process->local_state()) |
816 chrome::MigrateObsoleteBrowserPrefs(this, g_browser_process->local_state()); | 810 chrome::MigrateObsoleteBrowserPrefs(this, g_browser_process->local_state()); |
817 chrome::MigrateObsoleteProfilePrefs(this); | 811 chrome::MigrateObsoleteProfilePrefs(this); |
818 | 812 |
819 // |kSessionExitType| was added after |kSessionExitedCleanly|. If the pref | 813 // |kSessionExitType| was added after |kSessionExitedCleanly|. If the pref |
820 // value is empty fallback to checking for |kSessionExitedCleanly|. | 814 // value is empty fallback to checking for |kSessionExitedCleanly|. |
821 const std::string exit_type_pref_value( | 815 const std::string exit_type_pref_value( |
822 prefs_->GetString(prefs::kSessionExitType)); | 816 prefs_->GetString(prefs::kSessionExitType)); |
823 if (exit_type_pref_value.empty()) { | 817 if (exit_type_pref_value.empty()) { |
(...skipping 30 matching lines...) Expand all Loading... |
854 TRACE_EVENT0("browser", "ProfileImpl::OnPrefsLoaded:NetPrefObserver") | 848 TRACE_EVENT0("browser", "ProfileImpl::OnPrefsLoaded:NetPrefObserver") |
855 net_pref_observer_.reset(new NetPrefObserver(prefs_.get())); | 849 net_pref_observer_.reset(new NetPrefObserver(prefs_.get())); |
856 } | 850 } |
857 | 851 |
858 chrome_prefs::SchedulePrefsFilePathVerification(path_); | 852 chrome_prefs::SchedulePrefsFilePathVerification(path_); |
859 | 853 |
860 ChromeVersionService::OnProfileLoaded(prefs_.get(), IsNewProfile()); | 854 ChromeVersionService::OnProfileLoaded(prefs_.get(), IsNewProfile()); |
861 DoFinalInit(); | 855 DoFinalInit(); |
862 } | 856 } |
863 | 857 |
| 858 void ProfileImpl::OnPrefsLoaded(CreateMode create_mode, bool success) { |
| 859 TRACE_EVENT0("browser", "ProfileImpl::OnPrefsLoaded"); |
| 860 if (!success) { |
| 861 if (delegate_) |
| 862 delegate_->OnProfileCreated(this, false, false); |
| 863 return; |
| 864 } |
| 865 |
| 866 #if defined(OS_CHROMEOS) |
| 867 if (create_mode == CREATE_MODE_SYNCHRONOUS) { |
| 868 // Synchronous create mode implies that either it is restart after crash, |
| 869 // or we are in tests. In both cases the first loaded locale is correct. |
| 870 OnLocaleReady(); |
| 871 } else { |
| 872 chromeos::UserSessionManager::GetInstance()->RespectLocalePreferenceWrapper( |
| 873 this, base::Bind(&ProfileImpl::OnLocaleReady, base::Unretained(this))); |
| 874 } |
| 875 #else |
| 876 OnLocaleReady(); |
| 877 #endif |
| 878 } |
| 879 |
864 bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) { | 880 bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) { |
865 Version profile_version(ChromeVersionService::GetVersion(prefs_.get())); | 881 Version profile_version(ChromeVersionService::GetVersion(prefs_.get())); |
866 Version arg_version(version); | 882 Version arg_version(version); |
867 return (profile_version.CompareTo(arg_version) >= 0); | 883 return (profile_version.CompareTo(arg_version) >= 0); |
868 } | 884 } |
869 | 885 |
870 void ProfileImpl::SetExitType(ExitType exit_type) { | 886 void ProfileImpl::SetExitType(ExitType exit_type) { |
871 #if defined(OS_CHROMEOS) | 887 #if defined(OS_CHROMEOS) |
872 if (chromeos::ProfileHelper::IsSigninProfile(this)) | 888 if (chromeos::ProfileHelper::IsSigninProfile(this)) |
873 return; | 889 return; |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 ProfileImpl::CreateDomainReliabilityMonitor(PrefService* local_state) { | 1312 ProfileImpl::CreateDomainReliabilityMonitor(PrefService* local_state) { |
1297 domain_reliability::DomainReliabilityService* service = | 1313 domain_reliability::DomainReliabilityService* service = |
1298 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> | 1314 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> |
1299 GetForBrowserContext(this); | 1315 GetForBrowserContext(this); |
1300 if (!service) | 1316 if (!service) |
1301 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); | 1317 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); |
1302 | 1318 |
1303 return service->CreateMonitor( | 1319 return service->CreateMonitor( |
1304 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 1320 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
1305 } | 1321 } |
OLD | NEW |