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_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "chrome/browser/safe_browsing/safe_browsing_store.h" | 11 #include "chrome/browser/safe_browsing/safe_browsing_store.h" |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/file_util.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/files/scoped_file.h" |
15 | 16 |
16 // Implement SafeBrowsingStore in terms of a flat file. The file | 17 // Implement SafeBrowsingStore in terms of a flat file. The file |
17 // format is pretty literal: | 18 // format is pretty literal: |
18 // | 19 // |
19 // int32 magic; // magic number "validating" file | 20 // int32 magic; // magic number "validating" file |
20 // int32 version; // format version | 21 // int32 version; // format version |
21 // | 22 // |
22 // // Counts for the various data which follows the header. | 23 // // Counts for the various data which follows the header. |
23 // uint32 add_chunk_count; // Chunks seen, including empties. | 24 // uint32 add_chunk_count; // Chunks seen, including empties. |
24 // uint32 sub_chunk_count; // Ditto. | 25 // uint32 sub_chunk_count; // Ditto. |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 std::vector<SBSubFullHash> sub_hashes_; | 260 std::vector<SBSubFullHash> sub_hashes_; |
260 | 261 |
261 // Count of chunks collected in |new_file_|. | 262 // Count of chunks collected in |new_file_|. |
262 int chunks_written_; | 263 int chunks_written_; |
263 | 264 |
264 // Name of the main database file. | 265 // Name of the main database file. |
265 base::FilePath filename_; | 266 base::FilePath filename_; |
266 | 267 |
267 // Handles to the main and scratch files. |empty_| is true if the | 268 // Handles to the main and scratch files. |empty_| is true if the |
268 // main file didn't exist when the update was started. | 269 // main file didn't exist when the update was started. |
269 file_util::ScopedFILE file_; | 270 base::ScopedFILE file_; |
270 file_util::ScopedFILE new_file_; | 271 base::ScopedFILE new_file_; |
271 bool empty_; | 272 bool empty_; |
272 | 273 |
273 // Cache of chunks which have been seen. Loaded from the database | 274 // Cache of chunks which have been seen. Loaded from the database |
274 // on BeginUpdate() so that it can be queried during the | 275 // on BeginUpdate() so that it can be queried during the |
275 // transaction. | 276 // transaction. |
276 std::set<int32> add_chunks_cache_; | 277 std::set<int32> add_chunks_cache_; |
277 std::set<int32> sub_chunks_cache_; | 278 std::set<int32> sub_chunks_cache_; |
278 | 279 |
279 // Cache the set of deleted chunks during a transaction, applied on | 280 // Cache the set of deleted chunks during a transaction, applied on |
280 // FinishUpdate(). | 281 // FinishUpdate(). |
281 // TODO(shess): If the set is small enough, hash_set<> might be | 282 // TODO(shess): If the set is small enough, hash_set<> might be |
282 // slower than plain set<>. | 283 // slower than plain set<>. |
283 base::hash_set<int32> add_del_cache_; | 284 base::hash_set<int32> add_del_cache_; |
284 base::hash_set<int32> sub_del_cache_; | 285 base::hash_set<int32> sub_del_cache_; |
285 | 286 |
286 base::Closure corruption_callback_; | 287 base::Closure corruption_callback_; |
287 | 288 |
288 // Tracks whether corruption has already been seen in the current | 289 // Tracks whether corruption has already been seen in the current |
289 // update, so that only one instance is recorded in the stats. | 290 // update, so that only one instance is recorded in the stats. |
290 // TODO(shess): Remove with format-migration support. | 291 // TODO(shess): Remove with format-migration support. |
291 bool corruption_seen_; | 292 bool corruption_seen_; |
292 | 293 |
293 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStoreFile); | 294 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStoreFile); |
294 }; | 295 }; |
295 | 296 |
296 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ | 297 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ |
OLD | NEW |