| 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_BLOOM_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_BLOOM_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_BLOOM_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_BLOOM_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 SUB_CHUNK = 1, | 104 SUB_CHUNK = 1, |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 // Checks if a chunk is in the database. | 107 // Checks if a chunk is in the database. |
| 108 bool ChunkExists(int list_id, ChunkType type, int chunk_id); | 108 bool ChunkExists(int list_id, ChunkType type, int chunk_id); |
| 109 | 109 |
| 110 // Return a comma separated list of chunk ids that are in the database for | 110 // Return a comma separated list of chunk ids that are in the database for |
| 111 // the given list and chunk type. | 111 // the given list and chunk type. |
| 112 void GetChunkIds(int list_id, ChunkType type, std::string* list); | 112 void GetChunkIds(int list_id, ChunkType type, std::string* list); |
| 113 | 113 |
| 114 // Converts between the SafeBrowsing list names and their enumerated value. | |
| 115 // If the list names change, both of these methods must be updated. | |
| 116 enum ListType { | |
| 117 MALWARE = 0, | |
| 118 PHISH = 1, | |
| 119 }; | |
| 120 static int GetListId(const std::string& name); | |
| 121 static std::string GetListName(int list_id); | |
| 122 | |
| 123 // Generate a bloom filter. | 114 // Generate a bloom filter. |
| 124 virtual void BuildBloomFilter(); | 115 virtual void BuildBloomFilter(); |
| 125 | 116 |
| 126 // Helpers for building the bloom filter. | 117 // Helpers for building the bloom filter. |
| 127 typedef struct { | 118 typedef struct { |
| 128 int chunk_id; | 119 int chunk_id; |
| 129 SBPrefix prefix; | 120 SBPrefix prefix; |
| 130 } SBPair; | 121 } SBPair; |
| 131 | 122 |
| 132 static int PairCompare(const void* arg1, const void* arg2); | 123 static int PairCompare(const void* arg1, const void* arg2); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 // Lock for protecting access to the bloom filter and hash cache. | 248 // Lock for protecting access to the bloom filter and hash cache. |
| 258 Lock lookup_lock_; | 249 Lock lookup_lock_; |
| 259 | 250 |
| 260 // A store for GetHash results that have not yet been written to the database. | 251 // A store for GetHash results that have not yet been written to the database. |
| 261 HashList pending_full_hashes_; | 252 HashList pending_full_hashes_; |
| 262 | 253 |
| 263 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingDatabaseBloom); | 254 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingDatabaseBloom); |
| 264 }; | 255 }; |
| 265 | 256 |
| 266 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_BLOOM_H_ | 257 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_BLOOM_H_ |
| OLD | NEW |