| 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 | |
| 22 // hash). | |
| 23 typedef size_t PrefixSize; | |
| 24 | |
| 25 // A hash prefix sent by the SafeBrowsing PVer4 service. | |
| 26 typedef std::string HashPrefix; | |
| 27 | |
| 28 // The sorted list of hash prefixes. | |
| 29 typedef std::string HashPrefixes; | |
| 30 | |
| 31 // Stores the list of sorted hash prefixes, by size. | 21 // Stores the list of sorted hash prefixes, by size. |
| 32 // For instance: {4: ["abcd", "bcde", "cdef", "gggg"], 5: ["fffff"]} | 22 // For instance: {4: ["abcd", "bcde", "cdef", "gggg"], 5: ["fffff"]} |
| 33 typedef base::hash_map<PrefixSize, HashPrefixes> HashPrefixMap; | 23 typedef base::hash_map<PrefixSize, HashPrefixes> HashPrefixMap; |
| 34 | 24 |
| 35 // Stores the iterator to the last element merged from the HashPrefixMap for a | 25 // Stores the iterator to the last element merged from the HashPrefixMap for a |
| 36 // given prefix size. | 26 // given prefix size. |
| 37 // For instance: {4:iter(3), 5:iter(1)} means that we have already merged | 27 // For instance: {4:iter(3), 5:iter(1)} means that we have already merged |
| 38 // 3 hash prefixes of length 4, and 1 hash prefix of length 5. | 28 // 3 hash prefixes of length 4, and 1 hash prefix of length 5. |
| 39 typedef base::hash_map<PrefixSize, HashPrefixes::const_iterator> IteratorMap; | 29 typedef base::hash_map<PrefixSize, HashPrefixes::const_iterator> IteratorMap; |
| 40 | 30 |
| 41 // A full SHA256 hash. | |
| 42 typedef HashPrefix FullHash; | |
| 43 | |
| 44 // Enumerate different failure events while parsing the file read from disk for | 31 // Enumerate different failure events while parsing the file read from disk for |
| 45 // histogramming purposes. DO NOT CHANGE THE ORDERING OF THESE VALUES. | 32 // histogramming purposes. DO NOT CHANGE THE ORDERING OF THESE VALUES. |
| 46 enum StoreReadResult { | 33 enum StoreReadResult { |
| 47 // No errors. | 34 // No errors. |
| 48 READ_SUCCESS = 0, | 35 READ_SUCCESS = 0, |
| 49 | 36 |
| 50 // Reserved for errors in parsing this enum. | 37 // Reserved for errors in parsing this enum. |
| 51 UNEXPECTED_READ_FAILURE = 1, | 38 UNEXPECTED_READ_FAILURE = 1, |
| 52 | 39 |
| 53 // The contents of the file could not be read. | 40 // The contents of the file could not be read. |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 const base::FilePath store_path_; | 316 const base::FilePath store_path_; |
| 330 HashPrefixMap hash_prefix_map_; | 317 HashPrefixMap hash_prefix_map_; |
| 331 const scoped_refptr<base::SequencedTaskRunner> task_runner_; | 318 const scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 332 }; | 319 }; |
| 333 | 320 |
| 334 std::ostream& operator<<(std::ostream& os, const V4Store& store); | 321 std::ostream& operator<<(std::ostream& os, const V4Store& store); |
| 335 | 322 |
| 336 } // namespace safe_browsing | 323 } // namespace safe_browsing |
| 337 | 324 |
| 338 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ | 325 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ |
| OLD | NEW |