OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_SAFE_BROWSING_SAFE_BROWSING_STORE_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 virtual void GetAddChunks(std::vector<int32>* out) = 0; | 213 virtual void GetAddChunks(std::vector<int32>* out) = 0; |
214 virtual void SetSubChunk(int32 chunk_id) = 0; | 214 virtual void SetSubChunk(int32 chunk_id) = 0; |
215 virtual bool CheckSubChunk(int32 chunk_id) = 0; | 215 virtual bool CheckSubChunk(int32 chunk_id) = 0; |
216 virtual void GetSubChunks(std::vector<int32>* out) = 0; | 216 virtual void GetSubChunks(std::vector<int32>* out) = 0; |
217 | 217 |
218 // Delete the indicated chunk_id. The chunk will continue to be | 218 // Delete the indicated chunk_id. The chunk will continue to be |
219 // visible until the end of the transaction. | 219 // visible until the end of the transaction. |
220 virtual void DeleteAddChunk(int32 chunk_id) = 0; | 220 virtual void DeleteAddChunk(int32 chunk_id) = 0; |
221 virtual void DeleteSubChunk(int32 chunk_id) = 0; | 221 virtual void DeleteSubChunk(int32 chunk_id) = 0; |
222 | 222 |
| 223 // May be called during update to verify that the storage is valid. |
| 224 // Return true if the store seems valid. If corruption is detected, |
| 225 // calls the corruption callback and return false. |
| 226 // NOTE(shess): When storage was SQLite, there was no guarantee that |
| 227 // a structurally sound database actually contained valid data, |
| 228 // whereas SafeBrowsingStoreFile checksums the data. For now, this |
| 229 // distinction doesn't matter. |
| 230 virtual bool CheckValidity() = 0; |
| 231 |
223 // Pass the collected chunks through SBPRocessSubs() and commit to | 232 // Pass the collected chunks through SBPRocessSubs() and commit to |
224 // permanent storage. The resulting add prefixes and hashes will be | 233 // permanent storage. The resulting add prefixes and hashes will be |
225 // stored in |add_prefixes_result| and |add_full_hashes_result|. | 234 // stored in |add_prefixes_result| and |add_full_hashes_result|. |
226 // |pending_adds| is the set of full hashes which have been received | 235 // |pending_adds| is the set of full hashes which have been received |
227 // since the previous update, and is provided as a convenience | 236 // since the previous update, and is provided as a convenience |
228 // (could be written via WriteAddHash(), but that would flush the | 237 // (could be written via WriteAddHash(), but that would flush the |
229 // chunk to disk). |prefix_misses| is the set of prefixes where the | 238 // chunk to disk). |prefix_misses| is the set of prefixes where the |
230 // |GetHash()| request returned no full hashes, used for diagnostic | 239 // |GetHash()| request returned no full hashes, used for diagnostic |
231 // purposes. | 240 // purposes. |
232 virtual bool FinishUpdate( | 241 virtual bool FinishUpdate( |
233 const std::vector<SBAddFullHash>& pending_adds, | 242 const std::vector<SBAddFullHash>& pending_adds, |
234 const std::set<SBPrefix>& prefix_misses, | 243 const std::set<SBPrefix>& prefix_misses, |
235 SBAddPrefixes* add_prefixes_result, | 244 SBAddPrefixes* add_prefixes_result, |
236 std::vector<SBAddFullHash>* add_full_hashes_result) = 0; | 245 std::vector<SBAddFullHash>* add_full_hashes_result) = 0; |
237 | 246 |
238 // Cancel the update in process and remove any temporary disk | 247 // Cancel the update in process and remove any temporary disk |
239 // storage, leaving the original data unmodified. | 248 // storage, leaving the original data unmodified. |
240 virtual bool CancelUpdate() = 0; | 249 virtual bool CancelUpdate() = 0; |
241 | 250 |
242 private: | 251 private: |
243 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStore); | 252 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStore); |
244 }; | 253 }; |
245 | 254 |
246 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_H_ | 255 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_H_ |
OLD | NEW |