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_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 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // in parallel. At this time this code does the sorting internally, | 139 // in parallel. At this time this code does the sorting internally, |
140 // but it might make sense to make sorting an API requirement so that | 140 // but it might make sense to make sorting an API requirement so that |
141 // the storage can optimize for it. | 141 // the storage can optimize for it. |
142 void SBProcessSubs(SBAddPrefixes* add_prefixes, | 142 void SBProcessSubs(SBAddPrefixes* add_prefixes, |
143 SBSubPrefixes* sub_prefixes, | 143 SBSubPrefixes* sub_prefixes, |
144 std::vector<SBAddFullHash>* add_full_hashes, | 144 std::vector<SBAddFullHash>* add_full_hashes, |
145 std::vector<SBSubFullHash>* sub_full_hashes, | 145 std::vector<SBSubFullHash>* sub_full_hashes, |
146 const base::hash_set<int32>& add_chunks_deleted, | 146 const base::hash_set<int32>& add_chunks_deleted, |
147 const base::hash_set<int32>& sub_chunks_deleted); | 147 const base::hash_set<int32>& sub_chunks_deleted); |
148 | 148 |
149 // Records a histogram of the number of items in |prefix_misses| which | |
150 // are not in |add_prefixes|. | |
151 void SBCheckPrefixMisses(const SBAddPrefixes& add_prefixes, | |
152 const std::set<SBPrefix>& prefix_misses); | |
153 | |
154 // TODO(shess): This uses int32 rather than int because it's writing | 149 // TODO(shess): This uses int32 rather than int because it's writing |
155 // specifically-sized items to files. SBPrefix should likewise be | 150 // specifically-sized items to files. SBPrefix should likewise be |
156 // explicitly sized. | 151 // explicitly sized. |
157 | 152 |
158 // Abstract interface for storing data. | 153 // Abstract interface for storing data. |
159 class SafeBrowsingStore { | 154 class SafeBrowsingStore { |
160 public: | 155 public: |
161 SafeBrowsingStore() {} | 156 SafeBrowsingStore() {} |
162 virtual ~SafeBrowsingStore() {} | 157 virtual ~SafeBrowsingStore() {} |
163 | 158 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 // whereas SafeBrowsingStoreFile checksums the data. For now, this | 222 // whereas SafeBrowsingStoreFile checksums the data. For now, this |
228 // distinction doesn't matter. | 223 // distinction doesn't matter. |
229 virtual bool CheckValidity() = 0; | 224 virtual bool CheckValidity() = 0; |
230 | 225 |
231 // Pass the collected chunks through SBPRocessSubs() and commit to | 226 // Pass the collected chunks through SBPRocessSubs() and commit to |
232 // permanent storage. The resulting add prefixes and hashes will be | 227 // permanent storage. The resulting add prefixes and hashes will be |
233 // stored in |add_prefixes_result| and |add_full_hashes_result|. | 228 // stored in |add_prefixes_result| and |add_full_hashes_result|. |
234 // |pending_adds| is the set of full hashes which have been received | 229 // |pending_adds| is the set of full hashes which have been received |
235 // since the previous update, and is provided as a convenience | 230 // since the previous update, and is provided as a convenience |
236 // (could be written via WriteAddHash(), but that would flush the | 231 // (could be written via WriteAddHash(), but that would flush the |
237 // chunk to disk). |prefix_misses| is the set of prefixes where the | 232 // chunk to disk). |
238 // |GetHash()| request returned no full hashes, used for diagnostic | |
239 // purposes. | |
240 virtual bool FinishUpdate( | 233 virtual bool FinishUpdate( |
241 const std::vector<SBAddFullHash>& pending_adds, | 234 const std::vector<SBAddFullHash>& pending_adds, |
242 const std::set<SBPrefix>& prefix_misses, | |
243 SBAddPrefixes* add_prefixes_result, | 235 SBAddPrefixes* add_prefixes_result, |
244 std::vector<SBAddFullHash>* add_full_hashes_result) = 0; | 236 std::vector<SBAddFullHash>* add_full_hashes_result) = 0; |
245 | 237 |
246 // Cancel the update in process and remove any temporary disk | 238 // Cancel the update in process and remove any temporary disk |
247 // storage, leaving the original data unmodified. | 239 // storage, leaving the original data unmodified. |
248 virtual bool CancelUpdate() = 0; | 240 virtual bool CancelUpdate() = 0; |
249 | 241 |
250 private: | 242 private: |
251 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStore); | 243 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStore); |
252 }; | 244 }; |
253 | 245 |
254 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_H_ | 246 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_H_ |
OLD | NEW |