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

Unified Diff: chrome/browser/value_store/value_store.h

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
« no previous file with comments | « chrome/browser/value_store/testing_value_store.cc ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/value_store/value_store.h
diff --git a/chrome/browser/value_store/value_store.h b/chrome/browser/value_store/value_store.h
index 2b203ea57b779297a647e991b0825b64e64de9ae..199afe4b4c5f568d2354484f7ee571a79a67e96b 100644
--- a/chrome/browser/value_store/value_store.h
+++ b/chrome/browser/value_store/value_store.h
@@ -77,6 +77,10 @@ class ValueStore {
bool HasError() const { return error_; }
+ bool IsCorrupted() const {
+ return error_.get() && error_->code == CORRUPTION;
+ }
+
// Gets the settings read from the storage. Note that this represents
// the root object. If you request the value for key "foo", that value will
// be in |settings|.|foo|.
@@ -191,6 +195,27 @@ class ValueStore {
// Clears the storage.
virtual WriteResult Clear() = 0;
+
+ // In the event of corruption, the ValueStore should be able to restore
+ // itself. This means deleting local corrupted files. If only a few keys are
+ // corrupted, then some of the database may be saved. If the full database is
+ // corrupted, this will erase it in its entirety.
+ // Returns true on success, false on failure. The only way this will fail is
+ // if we also cannot delete the database file.
+ // Note: This method may be expensive; some implementations may need to read
+ // the entire database to restore. Use sparingly.
+ // Note: This method (and the following RestoreKey()) are rude, and do not
+ // make any logs, track changes, or other generally polite things. Please do
+ // not use these as substitutes for Clear() and Remove().
+ virtual bool Restore() = 0;
+
+ // Similar to Restore(), but for only a particular key. If the key is corrupt,
+ // this will forcefully remove the key. It does not look at the database on
+ // the whole, which makes it faster, but does not guarantee there is no
+ // additional corruption.
+ // Returns true on success, and false on failure. If false, the next step is
+ // probably to Restore() the whole database.
+ virtual bool RestoreKey(const std::string& key) = 0;
};
#endif // CHROME_BROWSER_VALUE_STORE_VALUE_STORE_H_
« no previous file with comments | « chrome/browser/value_store/testing_value_store.cc ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698