Index: chrome/browser/profiles/profile_manager.cc |
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc |
index 781158517596b62bc8ad0247e744f9e1f8c67142..1b4d88399fbe4516098d5feaa8cc62cfc6cc45e8 100644 |
--- a/chrome/browser/profiles/profile_manager.cc |
+++ b/chrome/browser/profiles/profile_manager.cc |
@@ -379,9 +379,13 @@ Profile* ProfileManager::GetProfile(const base::FilePath& profile_dir) { |
// If the profile is already loaded (e.g., chrome.exe launched twice), just |
// return it. |
Profile* profile = GetProfileByPath(profile_dir); |
- if (NULL != profile) |
+ if (profile) |
return profile; |
+ // If the profile has not been found, check that we have not started loading |
+ // it (which would mean that the profile is not fully initialized yet). |
+ DCHECK(!GetProfileByPathInternal(profile_dir)); |
noms (inactive)
2015/02/18 21:26:21
Hmm, so in non-debug world, if the profile has not
Bernhard Bauer
2015/02/19 10:22:37
Made it a CHECK.
|
+ |
profile = CreateProfileHelper(profile_dir); |
DCHECK(profile); |
if (profile) { |
@@ -560,10 +564,18 @@ std::vector<Profile*> ProfileManager::GetLoadedProfiles() const { |
return profiles; |
} |
+Profile* ProfileManager::GetProfileByPathInternal( |
+ const base::FilePath& path) const { |
+ TRACE_EVENT0("browser", "ProfileManager::GetProfileByPathInternal"); |
+ ProfileInfo* profile_info = GetProfileInfoByPath(path); |
+ return profile_info ? profile_info->profile.get() : nullptr; |
+} |
+ |
Profile* ProfileManager::GetProfileByPath(const base::FilePath& path) const { |
TRACE_EVENT0("browser", "ProfileManager::GetProfileByPath"); |
ProfileInfo* profile_info = GetProfileInfoByPath(path); |
- return profile_info ? profile_info->profile.get() : NULL; |
+ return profile_info && profile_info->created ? profile_info->profile.get() |
+ : nullptr; |
} |
// static |
@@ -865,7 +877,7 @@ void ProfileManager::Observe( |
// Confirm that we hadn't loaded the new profile previously. |
base::FilePath default_profile_dir = user_data_dir_.Append( |
GetInitialProfileDir()); |
- CHECK(!GetProfileByPath(default_profile_dir)) |
+ CHECK(!GetProfileByPathInternal(default_profile_dir)) |
<< "The default profile was loaded before we mounted the cryptohome."; |
} |
return; |
@@ -1129,7 +1141,7 @@ bool ProfileManager::AddProfile(Profile* profile) { |
// Make sure that we're not loading a profile with the same ID as a profile |
// that's already loaded. |
- if (GetProfileByPath(profile->GetPath())) { |
+ if (GetProfileByPathInternal(profile->GetPath())) { |
NOTREACHED() << "Attempted to add profile with the same path (" << |
profile->GetPath().value() << |
") as an already-loaded profile."; |