OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_VALUE_STORE_VALUE_STORE_H_ | 5 #ifndef CHROME_BROWSER_VALUE_STORE_VALUE_STORE_H_ |
6 #define CHROME_BROWSER_VALUE_STORE_VALUE_STORE_H_ | 6 #define CHROME_BROWSER_VALUE_STORE_VALUE_STORE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 WriteOptions options, const base::DictionaryValue& values) = 0; | 184 WriteOptions options, const base::DictionaryValue& values) = 0; |
185 | 185 |
186 // Removes a key from the storage. | 186 // Removes a key from the storage. |
187 virtual WriteResult Remove(const std::string& key) = 0; | 187 virtual WriteResult Remove(const std::string& key) = 0; |
188 | 188 |
189 // Removes multiple keys from the storage. | 189 // Removes multiple keys from the storage. |
190 virtual WriteResult Remove(const std::vector<std::string>& keys) = 0; | 190 virtual WriteResult Remove(const std::vector<std::string>& keys) = 0; |
191 | 191 |
192 // Clears the storage. | 192 // Clears the storage. |
193 virtual WriteResult Clear() = 0; | 193 virtual WriteResult Clear() = 0; |
194 | |
195 // In the event of corruption, the ValueStore should be able to restore | |
196 // itself. This means deleting local corrupted files. If only a few keys are | |
197 // corrupted, then some of the database may be saved. If the full database is | |
198 // corrupted, this will erase it in its entirety. | |
199 // Returns true on success, false on failure. The only way this will fail is | |
200 // if we also cannot delete the database file. | |
201 // 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.
| |
202 // so it is slow and should be used sparingly. | |
203 // Note: This method (and the following RestoreKey()) are rude, and do not | |
204 // make any logs, track changes, or other generally polite things. Please do | |
205 // not use these as substitutes for Clear() and Remove(). | |
206 virtual bool Restore() = 0; | |
207 | |
208 // Similar to Restore(), but for only a particular key. If the key is corrupt, | |
209 // this will forcefully remove the key. It does not look at the database on | |
210 // the whole, which makes it faster, but does not guarantee there is no | |
211 // additional corruption. | |
212 // Returns true on success, and false on failure. If false, the next step is | |
213 // probably to Restore() the whole database. | |
214 virtual bool RestoreKey(const std::string& key) = 0; | |
194 }; | 215 }; |
195 | 216 |
196 #endif // CHROME_BROWSER_VALUE_STORE_VALUE_STORE_H_ | 217 #endif // CHROME_BROWSER_VALUE_STORE_VALUE_STORE_H_ |
OLD | NEW |