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

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: 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/value_store.h
diff --git a/chrome/browser/value_store/value_store.h b/chrome/browser/value_store/value_store.h
index 2b203ea57b779297a647e991b0825b64e64de9ae..3eaa1c91bba457daf601bf2b13cd86ecee102684 100644
--- a/chrome/browser/value_store/value_store.h
+++ b/chrome/browser/value_store/value_store.h
@@ -191,6 +191,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 needs to read (and possibly delete) the whole database,
not at google - send to devlin 2014/02/14 19:35:56 why does it need to read the whole database?
Devlin 2014/02/18 23:55:22 Because it relies on Get() to ensure that there's
not at google - send to devlin 2014/02/19 21:25:29 Ok. That's an implementation detail though. It may
Devlin 2014/02/19 23:12:28 Done.
+ // so it is slow and should be used 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_

Powered by Google App Engine
This is Rietveld 408576698