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