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

Unified Diff: chrome/browser/extensions/api/storage/policy_value_store.cc

Issue 165223003: Add a Restore() method to ValueStore and make StorageAPI use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 6 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
Index: chrome/browser/extensions/api/storage/policy_value_store.cc
diff --git a/chrome/browser/extensions/api/storage/policy_value_store.cc b/chrome/browser/extensions/api/storage/policy_value_store.cc
index f5da68205785a23105b728cac0fa2feef3c39eba..9691e2bf01c832a43b7e6db4d6c8710d2d7858f6 100644
--- a/chrome/browser/extensions/api/storage/policy_value_store.cc
+++ b/chrome/browser/extensions/api/storage/policy_value_store.cc
@@ -57,6 +57,17 @@ void PolicyValueStore::SetCurrentPolicy(const policy::PolicyMap& policy) {
// must be removed.
base::DictionaryValue previous_policy;
ValueStore::ReadResult read_result = delegate_->Get();
+
+ // If the database is corrupted, try to restore it.
+ // This may have the unfortunate side-effect of incorrectly informing the
+ // extension of a "new" key, which isn't new and was corrupted. Unfortunately,
+ // there's not always a way around this - if the database is corrupted, there
+ // may be no way of telling which keys were previously present.
+ if (read_result->IsCorrupted()) {
+ if (delegate_->Restore())
+ read_result = delegate_->Get();
+ }
+
if (read_result->HasError()) {
LOG(WARNING) << "Failed to read managed settings for extension "
<< extension_id_ << ": " << read_result->error().message;
@@ -161,4 +172,10 @@ ValueStore::WriteResult PolicyValueStore::Clear() {
return MakeWriteResult(ReadOnlyError(util::NoKey()));
}
+bool PolicyValueStore::Restore() { return delegate_->Restore(); }
+
+bool PolicyValueStore::RestoreKey(const std::string& key) {
+ return delegate_->RestoreKey(key);
+}
+
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/api/storage/policy_value_store.h ('k') | chrome/browser/extensions/api/storage/settings_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698