OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_DATABASE_IMPL_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_IMPL_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_IMPL_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_IMPL_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <list> | 9 #include <list> |
10 #include <queue> | 10 #include <queue> |
(...skipping 28 matching lines...) Expand all Loading... |
39 // Deletes the current database and creates a new one. | 39 // Deletes the current database and creates a new one. |
40 virtual bool ResetDatabase(); | 40 virtual bool ResetDatabase(); |
41 | 41 |
42 // Returns false if the given url is not in the database. If it returns | 42 // Returns false if the given url is not in the database. If it returns |
43 // true, then either "list" is the name of the matching list, or prefix_hits | 43 // true, then either "list" is the name of the matching list, or prefix_hits |
44 // contains the matching hash prefixes. | 44 // contains the matching hash prefixes. |
45 virtual bool ContainsUrl(const GURL& url, | 45 virtual bool ContainsUrl(const GURL& url, |
46 std::string* matching_list, | 46 std::string* matching_list, |
47 std::vector<SBPrefix>* prefix_hits, | 47 std::vector<SBPrefix>* prefix_hits, |
48 std::vector<SBFullHashResult>* full_hits, | 48 std::vector<SBFullHashResult>* full_hits, |
49 Time last_update); | 49 base::Time last_update); |
50 | 50 |
51 // Processes add/sub commands. Database will free the chunks when it's done. | 51 // Processes add/sub commands. Database will free the chunks when it's done. |
52 virtual void InsertChunks(const std::string& list_name, | 52 virtual void InsertChunks(const std::string& list_name, |
53 std::deque<SBChunk>* chunks); | 53 std::deque<SBChunk>* chunks); |
54 | 54 |
55 // Processs adddel/subdel commands. Database will free chunk_deletes when | 55 // Processs adddel/subdel commands. Database will free chunk_deletes when |
56 // it's done. | 56 // it's done. |
57 virtual void DeleteChunks(std::vector<SBChunkDelete>* chunk_deletes); | 57 virtual void DeleteChunks(std::vector<SBChunkDelete>* chunk_deletes); |
58 | 58 |
59 // Returns the lists and their add/sub chunks. | 59 // Returns the lists and their add/sub chunks. |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 // from that add chunk id. | 178 // from that add chunk id. |
179 void AddDel(const std::string& list_name, int add_chunk_id); | 179 void AddDel(const std::string& list_name, int add_chunk_id); |
180 | 180 |
181 // Processes a sub-del command, which just removes the sub chunk id from | 181 // Processes a sub-del command, which just removes the sub chunk id from |
182 // our list. | 182 // our list. |
183 void SubDel(const std::string& list_name, int sub_chunk_id); | 183 void SubDel(const std::string& list_name, int sub_chunk_id); |
184 | 184 |
185 // Looks up any cached full hashes we may have. | 185 // Looks up any cached full hashes we may have. |
186 void GetCachedFullHashes(const std::vector<SBPrefix>* prefix_hits, | 186 void GetCachedFullHashes(const std::vector<SBPrefix>* prefix_hits, |
187 std::vector<SBFullHashResult>* full_hits, | 187 std::vector<SBFullHashResult>* full_hits, |
188 Time last_update); | 188 base::Time last_update); |
189 | 189 |
190 // Remove cached entries that have prefixes contained in the entry. | 190 // Remove cached entries that have prefixes contained in the entry. |
191 void ClearCachedHashes(const SBEntry* entry); | 191 void ClearCachedHashes(const SBEntry* entry); |
192 | 192 |
193 // Remove all GetHash entries that match the list and chunk id from an AddDel. | 193 // Remove all GetHash entries that match the list and chunk id from an AddDel. |
194 void ClearCachedHashesForChunk(int list_id, int add_chunk_id); | 194 void ClearCachedHashesForChunk(int list_id, int add_chunk_id); |
195 | 195 |
196 void HandleCorruptDatabase(); | 196 void HandleCorruptDatabase(); |
197 void OnHandleCorruptDatabase(); | 197 void OnHandleCorruptDatabase(); |
198 | 198 |
(...skipping 19 matching lines...) Expand all Loading... |
218 // asynchronously in small chunks. | 218 // asynchronously in small chunks. |
219 bool asynchronous_; | 219 bool asynchronous_; |
220 | 220 |
221 // False positive hit rate tracking. | 221 // False positive hit rate tracking. |
222 int bloom_filter_fp_count_; | 222 int bloom_filter_fp_count_; |
223 int bloom_filter_read_count_; | 223 int bloom_filter_read_count_; |
224 | 224 |
225 // These are temp variables used when rebuilding the bloom filter. | 225 // These are temp variables used when rebuilding the bloom filter. |
226 bool bloom_filter_building_; | 226 bool bloom_filter_building_; |
227 std::vector<int> bloom_filter_temp_hostkeys_; | 227 std::vector<int> bloom_filter_temp_hostkeys_; |
228 Time bloom_filter_rebuild_time_; | 228 base::Time bloom_filter_rebuild_time_; |
229 | 229 |
230 // Used to store throttled work for commands that write to the database. | 230 // Used to store throttled work for commands that write to the database. |
231 std::queue<std::deque<SBChunk>*> pending_chunks_; | 231 std::queue<std::deque<SBChunk>*> pending_chunks_; |
232 | 232 |
233 // Used during processing of an add chunk. | 233 // Used during processing of an add chunk. |
234 std::string add_chunk_modified_hosts_; | 234 std::string add_chunk_modified_hosts_; |
235 | 235 |
236 struct AddDelWork { | 236 struct AddDelWork { |
237 int list_id; | 237 int list_id; |
238 int add_chunk_id; | 238 int add_chunk_id; |
(...skipping 18 matching lines...) Expand all Loading... |
257 ScopedRunnableMethodFactory<SafeBrowsingDatabaseImpl> reset_factory_; | 257 ScopedRunnableMethodFactory<SafeBrowsingDatabaseImpl> reset_factory_; |
258 | 258 |
259 // Used to schedule resuming from a lower power state. | 259 // Used to schedule resuming from a lower power state. |
260 ScopedRunnableMethodFactory<SafeBrowsingDatabaseImpl> resume_factory_; | 260 ScopedRunnableMethodFactory<SafeBrowsingDatabaseImpl> resume_factory_; |
261 | 261 |
262 // Used for caching GetHash results. | 262 // Used for caching GetHash results. |
263 typedef struct HashCacheEntry { | 263 typedef struct HashCacheEntry { |
264 SBFullHash full_hash; | 264 SBFullHash full_hash; |
265 int list_id; | 265 int list_id; |
266 int add_chunk_id; | 266 int add_chunk_id; |
267 Time received; | 267 base::Time received; |
268 } HashCacheEntry; | 268 } HashCacheEntry; |
269 | 269 |
270 typedef std::list<HashCacheEntry> HashList; | 270 typedef std::list<HashCacheEntry> HashList; |
271 typedef base::hash_map<SBPrefix, HashList> HashCache; | 271 typedef base::hash_map<SBPrefix, HashList> HashCache; |
272 HashCache hash_cache_; | 272 HashCache hash_cache_; |
273 | 273 |
274 // Cache of prefixes that returned empty results (no full hash match). | 274 // Cache of prefixes that returned empty results (no full hash match). |
275 std::set<SBPrefix> prefix_miss_cache_; | 275 std::set<SBPrefix> prefix_miss_cache_; |
276 | 276 |
277 // The amount of time, in milliseconds, to wait before the next disk write. | 277 // The amount of time, in milliseconds, to wait before the next disk write. |
278 int disk_delay_; | 278 int disk_delay_; |
279 | 279 |
280 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingDatabaseImpl); | 280 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingDatabaseImpl); |
281 }; | 281 }; |
282 | 282 |
283 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_IMPL_H_ | 283 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_IMPL_H_ |
OLD | NEW |