Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 const std::vector<SBChunkDelete>& chunk_deletes) = 0; | 157 const std::vector<SBChunkDelete>& chunk_deletes) = 0; |
| 158 virtual void UpdateFinished(bool update_succeeded) = 0; | 158 virtual void UpdateFinished(bool update_succeeded) = 0; |
| 159 | 159 |
| 160 // Store the results of a GetHash response. In the case of empty results, we | 160 // Store the results of a GetHash response. In the case of empty results, we |
| 161 // cache the prefixes until the next update so that we don't have to issue | 161 // cache the prefixes until the next update so that we don't have to issue |
| 162 // further GetHash requests we know will be empty. | 162 // further GetHash requests we know will be empty. |
| 163 virtual void CacheHashResults( | 163 virtual void CacheHashResults( |
| 164 const std::vector<SBPrefix>& prefixes, | 164 const std::vector<SBPrefix>& prefixes, |
| 165 const std::vector<SBFullHashResult>& full_hits) = 0; | 165 const std::vector<SBFullHashResult>& full_hits) = 0; |
| 166 | 166 |
| 167 uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu | |
| 168 | |
|
mattm
2013/05/13 20:39:25
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
kewang
2013/05/14 08:21:41
yes, this should be place to declare the virtural
| |
| 167 // The name of the bloom-filter file for the given database file. | 169 // The name of the bloom-filter file for the given database file. |
| 168 // NOTE(shess): OBSOLETE. Present for deleting stale files. | 170 // NOTE(shess): OBSOLETE. Present for deleting stale files. |
| 169 static base::FilePath BloomFilterForFilename( | 171 static base::FilePath BloomFilterForFilename( |
| 170 const base::FilePath& db_filename); | 172 const base::FilePath& db_filename); |
| 171 | 173 |
| 172 // The name of the prefix set file for the given database file. | 174 // The name of the prefix set file for the given database file. |
| 173 static base::FilePath PrefixSetForFilename(const base::FilePath& db_filename); | 175 static base::FilePath PrefixSetForFilename(const base::FilePath& db_filename); |
| 174 | 176 |
| 175 // Filename for malware and phishing URL database. | 177 // Filename for malware and phishing URL database. |
| 176 static base::FilePath BrowseDBFilename( | 178 static base::FilePath BrowseDBFilename( |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 virtual bool UpdateStarted(std::vector<SBListChunkRanges>* lists) OVERRIDE; | 273 virtual bool UpdateStarted(std::vector<SBListChunkRanges>* lists) OVERRIDE; |
| 272 virtual void InsertChunks(const std::string& list_name, | 274 virtual void InsertChunks(const std::string& list_name, |
| 273 const SBChunkList& chunks) OVERRIDE; | 275 const SBChunkList& chunks) OVERRIDE; |
| 274 virtual void DeleteChunks( | 276 virtual void DeleteChunks( |
| 275 const std::vector<SBChunkDelete>& chunk_deletes) OVERRIDE; | 277 const std::vector<SBChunkDelete>& chunk_deletes) OVERRIDE; |
| 276 virtual void UpdateFinished(bool update_succeeded) OVERRIDE; | 278 virtual void UpdateFinished(bool update_succeeded) OVERRIDE; |
| 277 virtual void CacheHashResults( | 279 virtual void CacheHashResults( |
| 278 const std::vector<SBPrefix>& prefixes, | 280 const std::vector<SBPrefix>& prefixes, |
| 279 const std::vector<SBFullHashResult>& full_hits) OVERRIDE; | 281 const std::vector<SBFullHashResult>& full_hits) OVERRIDE; |
| 280 | 282 |
| 283 // Returns the value of malware_kill_switch_; | |
| 284 virtual bool GetMalwareKillSwitch() const { | |
|
mattm
2013/05/13 20:39:25
name the function and the variable more precisely,
kewang
2013/05/14 08:21:41
Done.
| |
| 285 return malware_kill_switch_; | |
|
mattm
2013/05/13 20:39:25
If you are wrapping the setting of this member wit
kewang
2013/05/14 08:21:41
Done.
kewang
2013/05/14 08:21:41
Done.
| |
| 286 } OVERRIDE; | |
|
mattm
2013/05/13 20:39:25
OVERRIDE goes before the {}.
Wait, this isn't actu
| |
| 287 | |
| 281 private: | 288 private: |
| 282 friend class SafeBrowsingDatabaseTest; | 289 friend class SafeBrowsingDatabaseTest; |
| 283 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseTest, HashCaching); | 290 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseTest, HashCaching); |
| 284 | 291 |
| 285 // A SafeBrowsing whitelist contains a list of whitelisted full-hashes (stored | 292 // A SafeBrowsing whitelist contains a list of whitelisted full-hashes (stored |
| 286 // in a sorted vector) as well as a boolean flag indicating whether all | 293 // in a sorted vector) as well as a boolean flag indicating whether all |
| 287 // lookups in the whitelist should be considered matches for safety. | 294 // lookups in the whitelist should be considered matches for safety. |
| 288 typedef std::pair<std::vector<SBFullHash>, bool> SBWhitelist; | 295 typedef std::pair<std::vector<SBFullHash>, bool> SBWhitelist; |
| 289 | 296 |
| 290 // Returns true if the whitelist is disabled or if any of the given hashes | 297 // Returns true if the whitelist is disabled or if any of the given hashes |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 SafeBrowsingStore* store, | 349 SafeBrowsingStore* store, |
| 343 SBWhitelist* whitelist); | 350 SBWhitelist* whitelist); |
| 344 | 351 |
| 345 // Used to verify that various calls are made from the thread the | 352 // Used to verify that various calls are made from the thread the |
| 346 // object was created on. | 353 // object was created on. |
| 347 base::MessageLoop* creation_loop_; | 354 base::MessageLoop* creation_loop_; |
| 348 | 355 |
| 349 // Lock for protecting access to variables that may be used on the | 356 // Lock for protecting access to variables that may be used on the |
| 350 // IO thread. This includes |prefix_set_|, |full_browse_hashes_|, | 357 // IO thread. This includes |prefix_set_|, |full_browse_hashes_|, |
| 351 // |pending_browse_hashes_|, |prefix_miss_cache_|, |csd_whitelist_|, | 358 // |pending_browse_hashes_|, |prefix_miss_cache_|, |csd_whitelist_|, |
| 352 // and |csd_whitelist_all_urls_|. | 359 // and |malware_kill_switch_|. |
| 353 base::Lock lookup_lock_; | 360 base::Lock lookup_lock_; |
| 354 | 361 |
| 355 // Underlying persistent store for chunk data. | 362 // Underlying persistent store for chunk data. |
| 356 // For browsing related (phishing and malware URLs) chunks and prefixes. | 363 // For browsing related (phishing and malware URLs) chunks and prefixes. |
| 357 base::FilePath browse_filename_; | 364 base::FilePath browse_filename_; |
| 358 scoped_ptr<SafeBrowsingStore> browse_store_; | 365 scoped_ptr<SafeBrowsingStore> browse_store_; |
| 359 | 366 |
| 360 // For download related (download URL and binary hash) chunks and prefixes. | 367 // For download related (download URL and binary hash) chunks and prefixes. |
| 361 base::FilePath download_filename_; | 368 base::FilePath download_filename_; |
| 362 scoped_ptr<SafeBrowsingStore> download_store_; | 369 scoped_ptr<SafeBrowsingStore> download_store_; |
| 363 | 370 |
| 364 // For the client-side phishing detection whitelist chunks and full-length | 371 // For the client-side phishing detection whitelist chunks and full-length |
| 365 // hashes. This list only contains 256 bit hashes. | 372 // hashes. This list only contains 256 bit hashes. |
| 366 base::FilePath csd_whitelist_filename_; | 373 base::FilePath csd_whitelist_filename_; |
| 367 scoped_ptr<SafeBrowsingStore> csd_whitelist_store_; | 374 scoped_ptr<SafeBrowsingStore> csd_whitelist_store_; |
| 368 | 375 |
| 369 // For the download whitelist chunks and full-length hashes. This list only | 376 // For the download whitelist chunks and full-length hashes. This list only |
| 370 // contains 256 bit hashes. | 377 // contains 256 bit hashes. |
| 371 base::FilePath download_whitelist_filename_; | 378 base::FilePath download_whitelist_filename_; |
| 372 scoped_ptr<SafeBrowsingStore> download_whitelist_store_; | 379 scoped_ptr<SafeBrowsingStore> download_whitelist_store_; |
| 373 | 380 |
| 374 // For extension IDs. | 381 // For extension IDs. |
| 375 base::FilePath extension_blacklist_filename_; | 382 base::FilePath extension_blacklist_filename_; |
| 376 scoped_ptr<SafeBrowsingStore> extension_blacklist_store_; | 383 scoped_ptr<SafeBrowsingStore> extension_blacklist_store_; |
| 377 | 384 |
| 378 SBWhitelist csd_whitelist_; | 385 SBWhitelist csd_whitelist_; |
| 379 SBWhitelist download_whitelist_; | 386 SBWhitelist download_whitelist_; |
| 380 SBWhitelist extension_blacklist_; | 387 SBWhitelist extension_blacklist_; |
| 388 bool malware_kill_switch_; | |
| 381 | 389 |
| 382 // Cached browse store related full-hash items, ordered by prefix for | 390 // Cached browse store related full-hash items, ordered by prefix for |
| 383 // efficient scanning. | 391 // efficient scanning. |
| 384 // |full_browse_hashes_| are items from |browse_store_|, | 392 // |full_browse_hashes_| are items from |browse_store_|, |
| 385 // |pending_browse_hashes_| are items from |CacheHashResults()|, which | 393 // |pending_browse_hashes_| are items from |CacheHashResults()|, which |
| 386 // will be pushed to the store on the next update. | 394 // will be pushed to the store on the next update. |
| 387 std::vector<SBAddFullHash> full_browse_hashes_; | 395 std::vector<SBAddFullHash> full_browse_hashes_; |
| 388 std::vector<SBAddFullHash> pending_browse_hashes_; | 396 std::vector<SBAddFullHash> pending_browse_hashes_; |
| 389 | 397 |
| 390 // Cache of prefixes that returned empty results (no full hash | 398 // Cache of prefixes that returned empty results (no full hash |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 403 // Set to true if any chunks are added or deleted during an update. | 411 // Set to true if any chunks are added or deleted during an update. |
| 404 // Used to optimize away database update. | 412 // Used to optimize away database update. |
| 405 bool change_detected_; | 413 bool change_detected_; |
| 406 | 414 |
| 407 // Used to check if a prefix was in the database. | 415 // Used to check if a prefix was in the database. |
| 408 base::FilePath prefix_set_filename_; | 416 base::FilePath prefix_set_filename_; |
| 409 scoped_ptr<safe_browsing::PrefixSet> prefix_set_; | 417 scoped_ptr<safe_browsing::PrefixSet> prefix_set_; |
| 410 }; | 418 }; |
| 411 | 419 |
| 412 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ | 420 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ |
| OLD | NEW |