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" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 // The version of the file is different from expected and Chromium doesn't | 63 // The version of the file is different from expected and Chromium doesn't |
64 // know how to interpret this version of the file. | 64 // know how to interpret this version of the file. |
65 FILE_VERSION_INCOMPATIBLE_FAILURE = 6, | 65 FILE_VERSION_INCOMPATIBLE_FAILURE = 6, |
66 | 66 |
67 // The rest of the file could not be parsed as a ListUpdateResponse protobuf. | 67 // The rest of the file could not be parsed as a ListUpdateResponse protobuf. |
68 // This can happen if the machine crashed before the file was fully written to | 68 // This can happen if the machine crashed before the file was fully written to |
69 // disk or if there was disk corruption. | 69 // disk or if there was disk corruption. |
70 HASH_PREFIX_INFO_MISSING_FAILURE = 7, | 70 HASH_PREFIX_INFO_MISSING_FAILURE = 7, |
71 | 71 |
| 72 // Unable to generate the hash prefix map from the updates on disk. |
| 73 HASH_PREFIX_MAP_GENERATION_FAILURE = 8, |
| 74 |
72 // Memory space for histograms is determined by the max. ALWAYS | 75 // Memory space for histograms is determined by the max. ALWAYS |
73 // ADD NEW VALUES BEFORE THIS ONE. | 76 // ADD NEW VALUES BEFORE THIS ONE. |
74 STORE_READ_RESULT_MAX | 77 STORE_READ_RESULT_MAX |
75 }; | 78 }; |
76 | 79 |
77 // Enumerate different failure events while writing the file to disk after | 80 // Enumerate different failure events while writing the file to disk after |
78 // applying updates for histogramming purposes. | 81 // applying updates for histogramming purposes. |
79 // DO NOT CHANGE THE ORDERING OF THESE VALUES. | 82 // DO NOT CHANGE THE ORDERING OF THESE VALUES. |
80 enum StoreWriteResult { | 83 enum StoreWriteResult { |
81 // No errors. | 84 // No errors. |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 TestGetNextSmallestPrefixSizeWithEmptyPrefixMap); | 188 TestGetNextSmallestPrefixSizeWithEmptyPrefixMap); |
186 FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestGetNextSmallestPrefixSize); | 189 FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestGetNextSmallestPrefixSize); |
187 FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestGetNextUnmergedPrefix); | 190 FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestGetNextUnmergedPrefix); |
188 FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestMergeUpdatesWithSameSizesInEachMap); | 191 FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestMergeUpdatesWithSameSizesInEachMap); |
189 FRIEND_TEST_ALL_PREFIXES(V4StoreTest, | 192 FRIEND_TEST_ALL_PREFIXES(V4StoreTest, |
190 TestMergeUpdatesWithDifferentSizesInEachMap); | 193 TestMergeUpdatesWithDifferentSizesInEachMap); |
191 FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestMergeUpdatesOldMapRunsOutFirst); | 194 FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestMergeUpdatesOldMapRunsOutFirst); |
192 FRIEND_TEST_ALL_PREFIXES(V4StoreTest, | 195 FRIEND_TEST_ALL_PREFIXES(V4StoreTest, |
193 TestMergeUpdatesAdditionsMapRunsOutFirst); | 196 TestMergeUpdatesAdditionsMapRunsOutFirst); |
194 FRIEND_TEST_ALL_PREFIXES(V4StoreTest, | 197 FRIEND_TEST_ALL_PREFIXES(V4StoreTest, |
195 TestMergeUpdatesFailsForRepeatedhashPrefix); | 198 TestMergeUpdatesFailsForRepeatedHashPrefix); |
| 199 FRIEND_TEST_ALL_PREFIXES(V4StoreTest, |
| 200 TestReadFullResponseWithValidHashPrefixMap); |
| 201 FRIEND_TEST_ALL_PREFIXES(V4StoreTest, |
| 202 TestReadFullResponseWithInvalidHashPrefixMap); |
196 | 203 |
197 // If |prefix_size| is within expected range, and |raw_hashes| is not invalid, | 204 // If |prefix_size| is within expected range, and |raw_hashes| is not invalid, |
198 // then it sets |raw_hashes| as the value at key |prefix_size| in | 205 // then it sets |raw_hashes| as the value at key |prefix_size| in |
199 // |additions_map| | 206 // |additions_map| |
200 static ApplyUpdateResult AddUnlumpedHashes(PrefixSize prefix_size, | 207 static ApplyUpdateResult AddUnlumpedHashes(PrefixSize prefix_size, |
201 const std::string& raw_hashes, | 208 const std::string& raw_hashes, |
202 HashPrefixMap* additions_map); | 209 HashPrefixMap* additions_map); |
203 | 210 |
204 // Get the size of the next unmerged hash prefix in dictionary order from | 211 // Get the size of the next unmerged hash prefix in dictionary order from |
205 // |hash_prefix_map|. |counter_map| is used to determine which hash prefixes | 212 // |hash_prefix_map|. |counter_map| is used to determine which hash prefixes |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 const base::FilePath store_path_; | 262 const base::FilePath store_path_; |
256 HashPrefixMap hash_prefix_map_; | 263 HashPrefixMap hash_prefix_map_; |
257 const scoped_refptr<base::SequencedTaskRunner> task_runner_; | 264 const scoped_refptr<base::SequencedTaskRunner> task_runner_; |
258 }; | 265 }; |
259 | 266 |
260 std::ostream& operator<<(std::ostream& os, const V4Store& store); | 267 std::ostream& operator<<(std::ostream& os, const V4Store& store); |
261 | 268 |
262 } // namespace safe_browsing | 269 } // namespace safe_browsing |
263 | 270 |
264 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ | 271 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ |
OLD | NEW |