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

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: 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..7109381db7474139c796c154de7d0f7689b32d4b 100644
--- a/chrome/browser/extensions/api/storage/policy_value_store.cc
+++ b/chrome/browser/extensions/api/storage/policy_value_store.cc
@@ -57,6 +57,13 @@ 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.
+ if (read_result->IsCorrupted()) {
+ if (delegate_->Restore())
+ read_result = delegate_->Get();
not at google - send to devlin 2014/02/19 18:40:37 I still don't think this is quite right though, be
Devlin 2014/02/19 19:13:55 Yes, the extension will be notified of all keys be
+ }
+
if (read_result->HasError()) {
LOG(WARNING) << "Failed to read managed settings for extension "
<< extension_id_ << ": " << read_result->error().message;
@@ -161,4 +168,10 @@ ValueStore::WriteResult PolicyValueStore::Clear() {
return MakeWriteResult(ReadOnlyError(util::NoKey()));
}
+bool PolicyValueStore::Restore() { return delegate_->Restore(); }
not at google - send to devlin 2014/02/19 18:40:37 GRR GIT CL FORMAT IS WRONG. anyhow, it seems like
not at google - send to devlin 2014/02/19 18:48:26 I suppose if Restore actually does manage to resto
Devlin 2014/02/19 19:13:55 Ideally, yes, Restore() would give more informatio
+
+bool PolicyValueStore::RestoreKey(const std::string& key) {
+ return delegate_->RestoreKey(key);
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698