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

Unified Diff: chrome/browser/profiles/profile_manager.cc

Issue 1119323002: Checking PrefService* validity before its usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_manager.cc
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index e2d2cc1cb85530ec4436bfe0169bf0aa87f6f62d..31421ede8b43b735fc68c7064ca0f4d9ba9a4450 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -707,8 +707,10 @@ void ProfileManager::ScheduleProfileForDeletion(
// On the Mac, the browser process is not killed when all browser windows are
// closed, so just in case we are deleting the active profile, and no other
// profile has been loaded, we must pre-load a next one.
+ PrefService* local_state = g_browser_process->local_state();
+ DCHECK(local_state);
const std::string last_used_profile =
- g_browser_process->local_state()->GetString(prefs::kProfileLastUsed);
+ local_state->GetString(prefs::kProfileLastUsed);
if (last_used_profile == profile_dir.BaseName().MaybeAsASCII() ||
last_used_profile == GetGuestProfilePath().BaseName().MaybeAsASCII()) {
CreateProfileAsync(last_non_supervised_profile_path,
@@ -742,6 +744,7 @@ void ProfileManager::AutoloadProfiles() {
// If running in the background is disabled for the browser, do not autoload
// any profiles.
PrefService* local_state = g_browser_process->local_state();
+ DCHECK(local_state);
if (!local_state->HasPrefPath(prefs::kBackgroundModeEnabled) ||
!local_state->GetBoolean(prefs::kBackgroundModeEnabled)) {
return;
@@ -1174,9 +1177,10 @@ void ProfileManager::FinishDeletingProfile(
const base::FilePath& new_active_profile_dir) {
// Update the last used profile pref before closing browser windows. This
// way the correct last used profile is set for any notification observers.
- g_browser_process->local_state()->SetString(
- prefs::kProfileLastUsed,
- new_active_profile_dir.BaseName().MaybeAsASCII());
+ PrefService* local_state = g_browser_process->local_state();
+ DCHECK(local_state);
+ local_state->SetString(prefs::kProfileLastUsed,
+ new_active_profile_dir.BaseName().MaybeAsASCII());
ProfileInfoCache& cache = GetProfileInfoCache();
// TODO(sail): Due to bug 88586 we don't delete the profile instance. Once we
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698