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

Unified Diff: chrome/browser/value_store/testing_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/value_store/testing_value_store.cc
diff --git a/chrome/browser/value_store/testing_value_store.cc b/chrome/browser/value_store/testing_value_store.cc
index c8d177c55147d5f26d0d2ef15853853dbc36cc4d..f9183ea47054fb61ff1a7d6f42a4a14cafb344ca 100644
--- a/chrome/browser/value_store/testing_value_store.cc
+++ b/chrome/browser/value_store/testing_value_store.cc
@@ -124,6 +124,29 @@ ValueStore::WriteResult TestingValueStore::Clear() {
return Remove(keys);
}
+bool TestingValueStore::Restore() {
+ ReadResult result = Get();
+ std::string previous_key;
+ while (result->HasError() && result->error().code == CORRUPTION) {
not at google - send to devlin 2014/02/14 19:35:56 How does this class get corrupted storage? I'm su
Devlin 2014/02/18 23:55:22 Yeah...this might be overkill. My basic thought w
not at google - send to devlin 2014/02/19 21:25:29 Not worth it.
Devlin 2014/02/19 23:12:28 Done.
+ if (!result->error().key.get() || *result->error().key == previous_key ||
+ !RestoreKey(*result->error().key)) {
+ Clear();
+ result = Get();
+ break;
+ }
+ previous_key = *result->error().key;
+ result = Get();
+ }
+ return result->HasError() && result->error().code == CORRUPTION;
+}
+
+bool TestingValueStore::RestoreKey(const std::string& key) {
+ ReadResult result = Get(key);
+ if (result->HasError() && result->error().code == CORRUPTION)
+ Remove(key);
+ return Get(key)->HasError();
+}
+
scoped_ptr<ValueStore::Error> TestingValueStore::TestingError() {
return make_scoped_ptr(new ValueStore::Error(
error_code_, kGenericErrorMessage, scoped_ptr<std::string>()));

Powered by Google App Engine
This is Rietveld 408576698