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

Unified Diff: chrome/browser/supervised_user/supervised_user_settings_service.cc

Issue 960233003: Handle unsucessful JsonPrefStore initialization in SupervisedUserSettingsService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 5 years, 10 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 | « chrome/browser/supervised_user/supervised_user_settings_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « chrome/browser/supervised_user/supervised_user_settings_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698