| 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 <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 const std::vector<SBChunkDelete>& chunk_deletes) = 0; | 164 const std::vector<SBChunkDelete>& chunk_deletes) = 0; |
| 165 virtual void UpdateFinished(bool update_succeeded) = 0; | 165 virtual void UpdateFinished(bool update_succeeded) = 0; |
| 166 | 166 |
| 167 // Store the results of a GetHash response. In the case of empty results, we | 167 // Store the results of a GetHash response. In the case of empty results, we |
| 168 // cache the prefixes until the next update so that we don't have to issue | 168 // cache the prefixes until the next update so that we don't have to issue |
| 169 // further GetHash requests we know will be empty. | 169 // further GetHash requests we know will be empty. |
| 170 virtual void CacheHashResults( | 170 virtual void CacheHashResults( |
| 171 const std::vector<SBPrefix>& prefixes, | 171 const std::vector<SBPrefix>& prefixes, |
| 172 const std::vector<SBFullHashResult>& full_hits) = 0; | 172 const std::vector<SBFullHashResult>& full_hits) = 0; |
| 173 | 173 |
| 174 virtual bool MalwareIPMatchKillSwitchOn() = 0; | |
| 175 | |
| 176 // The name of the bloom-filter file for the given database file. | 174 // The name of the bloom-filter file for the given database file. |
| 177 // NOTE(shess): OBSOLETE. Present for deleting stale files. | 175 // NOTE(shess): OBSOLETE. Present for deleting stale files. |
| 178 static base::FilePath BloomFilterForFilename( | 176 static base::FilePath BloomFilterForFilename( |
| 179 const base::FilePath& db_filename); | 177 const base::FilePath& db_filename); |
| 180 | 178 |
| 181 // The name of the prefix set file for the given database file. | 179 // The name of the prefix set file for the given database file. |
| 182 static base::FilePath PrefixSetForFilename(const base::FilePath& db_filename); | 180 static base::FilePath PrefixSetForFilename(const base::FilePath& db_filename); |
| 183 | 181 |
| 184 // Filename for malware and phishing URL database. | 182 // Filename for malware and phishing URL database. |
| 185 static base::FilePath BrowseDBFilename( | 183 static base::FilePath BrowseDBFilename( |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 virtual bool UpdateStarted(std::vector<SBListChunkRanges>* lists) OVERRIDE; | 290 virtual bool UpdateStarted(std::vector<SBListChunkRanges>* lists) OVERRIDE; |
| 293 virtual void InsertChunks(const std::string& list_name, | 291 virtual void InsertChunks(const std::string& list_name, |
| 294 const SBChunkList& chunks) OVERRIDE; | 292 const SBChunkList& chunks) OVERRIDE; |
| 295 virtual void DeleteChunks( | 293 virtual void DeleteChunks( |
| 296 const std::vector<SBChunkDelete>& chunk_deletes) OVERRIDE; | 294 const std::vector<SBChunkDelete>& chunk_deletes) OVERRIDE; |
| 297 virtual void UpdateFinished(bool update_succeeded) OVERRIDE; | 295 virtual void UpdateFinished(bool update_succeeded) OVERRIDE; |
| 298 virtual void CacheHashResults( | 296 virtual void CacheHashResults( |
| 299 const std::vector<SBPrefix>& prefixes, | 297 const std::vector<SBPrefix>& prefixes, |
| 300 const std::vector<SBFullHashResult>& full_hits) OVERRIDE; | 298 const std::vector<SBFullHashResult>& full_hits) OVERRIDE; |
| 301 | 299 |
| 302 // Returns the value of malware_kill_switch_; | |
| 303 virtual bool MalwareIPMatchKillSwitchOn() OVERRIDE; | |
| 304 | |
| 305 private: | 300 private: |
| 306 friend class SafeBrowsingDatabaseTest; | 301 friend class SafeBrowsingDatabaseTest; |
| 307 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseTest, HashCaching); | 302 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingDatabaseTest, HashCaching); |
| 308 | 303 |
| 309 // A SafeBrowsing whitelist contains a list of whitelisted full-hashes (stored | 304 // A SafeBrowsing whitelist contains a list of whitelisted full-hashes (stored |
| 310 // in a sorted vector) as well as a boolean flag indicating whether all | 305 // in a sorted vector) as well as a boolean flag indicating whether all |
| 311 // lookups in the whitelist should be considered matches for safety. | 306 // lookups in the whitelist should be considered matches for safety. |
| 312 typedef std::pair<std::vector<SBFullHash>, bool> SBWhitelist; | 307 typedef std::pair<std::vector<SBFullHash>, bool> SBWhitelist; |
| 313 | 308 |
| 314 // Returns true if the whitelist is disabled or if any of the given hashes | 309 // 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... |
| 366 void UpdateWhitelistStore(const base::FilePath& store_filename, | 361 void UpdateWhitelistStore(const base::FilePath& store_filename, |
| 367 SafeBrowsingStore* store, | 362 SafeBrowsingStore* store, |
| 368 SBWhitelist* whitelist); | 363 SBWhitelist* whitelist); |
| 369 | 364 |
| 370 // Used to verify that various calls are made from the thread the | 365 // Used to verify that various calls are made from the thread the |
| 371 // object was created on. | 366 // object was created on. |
| 372 base::MessageLoop* creation_loop_; | 367 base::MessageLoop* creation_loop_; |
| 373 | 368 |
| 374 // Lock for protecting access to variables that may be used on the | 369 // Lock for protecting access to variables that may be used on the |
| 375 // IO thread. This includes |prefix_set_|, |full_browse_hashes_|, | 370 // IO thread. This includes |prefix_set_|, |full_browse_hashes_|, |
| 376 // |pending_browse_hashes_|, |prefix_miss_cache_|, |csd_whitelist_|. | 371 // |pending_browse_hashes_|, |prefix_miss_cache_|, |csd_whitelist_|, |
| 372 // and |csd_whitelist_all_urls_|. |
| 377 base::Lock lookup_lock_; | 373 base::Lock lookup_lock_; |
| 378 | 374 |
| 379 // Underlying persistent store for chunk data. | 375 // Underlying persistent store for chunk data. |
| 380 // For browsing related (phishing and malware URLs) chunks and prefixes. | 376 // For browsing related (phishing and malware URLs) chunks and prefixes. |
| 381 base::FilePath browse_filename_; | 377 base::FilePath browse_filename_; |
| 382 scoped_ptr<SafeBrowsingStore> browse_store_; | 378 scoped_ptr<SafeBrowsingStore> browse_store_; |
| 383 | 379 |
| 384 // For download related (download URL and binary hash) chunks and prefixes. | 380 // For download related (download URL and binary hash) chunks and prefixes. |
| 385 base::FilePath download_filename_; | 381 base::FilePath download_filename_; |
| 386 scoped_ptr<SafeBrowsingStore> download_store_; | 382 scoped_ptr<SafeBrowsingStore> download_store_; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 // Used to check if a prefix was in the browse database. | 431 // Used to check if a prefix was in the browse database. |
| 436 base::FilePath browse_prefix_set_filename_; | 432 base::FilePath browse_prefix_set_filename_; |
| 437 scoped_ptr<safe_browsing::PrefixSet> browse_prefix_set_; | 433 scoped_ptr<safe_browsing::PrefixSet> browse_prefix_set_; |
| 438 | 434 |
| 439 // Used to check if a prefix was in the browse database. | 435 // Used to check if a prefix was in the browse database. |
| 440 base::FilePath side_effect_free_whitelist_prefix_set_filename_; | 436 base::FilePath side_effect_free_whitelist_prefix_set_filename_; |
| 441 scoped_ptr<safe_browsing::PrefixSet> side_effect_free_whitelist_prefix_set_; | 437 scoped_ptr<safe_browsing::PrefixSet> side_effect_free_whitelist_prefix_set_; |
| 442 }; | 438 }; |
| 443 | 439 |
| 444 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ | 440 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ |
| OLD | NEW |