Index: chrome/browser/supervised_user/supervised_user_settings_service.cc |
diff --git a/chrome/browser/supervised_user/supervised_user_settings_service.cc b/chrome/browser/supervised_user/supervised_user_settings_service.cc |
index 55ff2f419da4ffb3c9b91bf5e6e754dd1c00ddc7..69c0acf1fa698be8c3f176ddf2906e4ed9eab010 100644 |
--- a/chrome/browser/supervised_user/supervised_user_settings_service.cc |
+++ b/chrome/browser/supervised_user/supervised_user_settings_service.cc |
@@ -50,7 +50,10 @@ bool SettingShouldApplyToPrefs(const std::string& name) { |
} // namespace |
SupervisedUserSettingsService::SupervisedUserSettingsService() |
- : active_(false), local_settings_(new base::DictionaryValue) {} |
+ : active_(false), |
+ initialization_failed_(false), |
+ local_settings_(new base::DictionaryValue) { |
+} |
SupervisedUserSettingsService::~SupervisedUserSettingsService() {} |
@@ -97,7 +100,9 @@ void SupervisedUserSettingsService::SetActive(bool active) { |
} |
bool SupervisedUserSettingsService::IsReady() { |
- return store_->IsInitializationComplete(); |
+ // Initialization cannot be complete but have failed at the same time. |
+ DCHECK(!(store_->IsInitializationComplete() && initialization_failed_)); |
+ return initialization_failed_ || store_->IsInitializationComplete(); |
} |
void SupervisedUserSettingsService::Clear() { |
@@ -299,9 +304,16 @@ void SupervisedUserSettingsService::OnPrefValueChanged(const std::string& key) { |
} |
void SupervisedUserSettingsService::OnInitializationCompleted(bool success) { |
+ if (!success) { |
+ // If this happens, it means the profile directory was not found. There is |
+ // not much we can do, but the whole profile will probably be useless |
+ // anyway. Just mark initialization as failed and continue otherwise, |
+ // because subscribers might still expect to be called back. |
+ initialization_failed_ = true; |
+ } |
+ |
// TODO(bauerb): Temporary CHECK while investigating https://crbug.com/425785. |
// Remove (or change back to DCHECK) once the bug is fixed. |
- CHECK(success); |
CHECK(IsReady()); |
InformSubscribers(); |
} |
@@ -354,7 +366,7 @@ base::DictionaryValue* SupervisedUserSettingsService::GetDictionaryAndSplitKey( |
scoped_ptr<base::DictionaryValue> SupervisedUserSettingsService::GetSettings() { |
DCHECK(IsReady()); |
- if (!active_) |
+ if (!active_ || initialization_failed_) |
return scoped_ptr<base::DictionaryValue>(); |
scoped_ptr<base::DictionaryValue> settings(local_settings_->DeepCopy()); |