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>())); |