OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ | 5 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ |
6 #define COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ | 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "components/safe_browsing_db/v4_protocol_manager_util.h" | 12 #include "components/safe_browsing_db/v4_protocol_manager_util.h" |
13 | 13 |
14 namespace safe_browsing { | 14 namespace safe_browsing { |
15 | 15 |
16 class V4Store; | 16 class V4Store; |
17 | 17 |
18 typedef base::Callback<void(std::unique_ptr<V4Store>)> | 18 typedef base::Callback<void(std::unique_ptr<V4Store>)> |
19 UpdatedStoreReadyCallback; | 19 UpdatedStoreReadyCallback; |
20 | 20 |
21 // The size of the hash prefix, in bytes. It should be between 4 to 32 (full | 21 // The size of the hash prefix, in bytes. It should be between 4 to 32 (full |
22 // hash). | 22 // hash). |
23 typedef size_t PrefixSize; | 23 typedef size_t PrefixSize; |
24 | 24 |
| 25 // A hash prefix sent by the SafeBrowsing PVer4 service. |
| 26 typedef std::string HashPrefix; |
| 27 |
25 // The sorted list of hash prefixes. | 28 // The sorted list of hash prefixes. |
26 typedef std::string HashPrefixes; | 29 typedef std::string HashPrefixes; |
27 | 30 |
28 // Stores the list of sorted hash prefixes, by size. | 31 // Stores the list of sorted hash prefixes, by size. |
29 // For instance: {4: ["abcd", "bcde", "cdef", "gggg"], 5: ["fffff"]} | 32 // For instance: {4: ["abcd", "bcde", "cdef", "gggg"], 5: ["fffff"]} |
30 typedef base::hash_map<PrefixSize, HashPrefixes> HashPrefixMap; | 33 typedef base::hash_map<PrefixSize, HashPrefixes> HashPrefixMap; |
31 | 34 |
32 // Stores the iterator to the last element merged from the HashPrefixMap for a | 35 // Stores the iterator to the last element merged from the HashPrefixMap for a |
33 // given prefix size. | 36 // given prefix size. |
34 // For instance: {4:iter(3), 5:iter(1)} means that we have already merged | 37 // For instance: {4:iter(3), 5:iter(1)} means that we have already merged |
35 // 3 hash prefixes of length 4, and 1 hash prefix of length 5. | 38 // 3 hash prefixes of length 4, and 1 hash prefix of length 5. |
36 typedef base::hash_map<PrefixSize, HashPrefixes::const_iterator> IteratorMap; | 39 typedef base::hash_map<PrefixSize, HashPrefixes::const_iterator> IteratorMap; |
37 | 40 |
| 41 // A full SHA256 hash. |
| 42 typedef HashPrefix FullHash; |
| 43 |
38 // Enumerate different failure events while parsing the file read from disk for | 44 // Enumerate different failure events while parsing the file read from disk for |
39 // histogramming purposes. DO NOT CHANGE THE ORDERING OF THESE VALUES. | 45 // histogramming purposes. DO NOT CHANGE THE ORDERING OF THESE VALUES. |
40 enum StoreReadResult { | 46 enum StoreReadResult { |
41 // No errors. | 47 // No errors. |
42 READ_SUCCESS = 0, | 48 READ_SUCCESS = 0, |
43 | 49 |
44 // Reserved for errors in parsing this enum. | 50 // Reserved for errors in parsing this enum. |
45 UNEXPECTED_READ_FAILURE = 1, | 51 UNEXPECTED_READ_FAILURE = 1, |
46 | 52 |
47 // The contents of the file could not be read. | 53 // The contents of the file could not be read. |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 const base::FilePath store_path_; | 329 const base::FilePath store_path_; |
324 HashPrefixMap hash_prefix_map_; | 330 HashPrefixMap hash_prefix_map_; |
325 const scoped_refptr<base::SequencedTaskRunner> task_runner_; | 331 const scoped_refptr<base::SequencedTaskRunner> task_runner_; |
326 }; | 332 }; |
327 | 333 |
328 std::ostream& operator<<(std::ostream& os, const V4Store& store); | 334 std::ostream& operator<<(std::ostream& os, const V4Store& store); |
329 | 335 |
330 } // namespace safe_browsing | 336 } // namespace safe_browsing |
331 | 337 |
332 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ | 338 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ |
OLD | NEW |