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 <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 // Init()). | 490 // Init()). |
491 void LoadPrefixSet(const base::FilePath& db_filename, | 491 void LoadPrefixSet(const base::FilePath& db_filename, |
492 ThreadSafeStateManager::WriteTransaction* txn, | 492 ThreadSafeStateManager::WriteTransaction* txn, |
493 PrefixSetId prefix_set_id, | 493 PrefixSetId prefix_set_id, |
494 FailureType read_failure_type); | 494 FailureType read_failure_type); |
495 | 495 |
496 // Writes the current prefix set "|db_filename| Prefix Set" on disk. | 496 // Writes the current prefix set "|db_filename| Prefix Set" on disk. |
497 // |write_failure_type| provides a caller-specific error code to be used on | 497 // |write_failure_type| provides a caller-specific error code to be used on |
498 // failure. | 498 // failure. |
499 void WritePrefixSet(const base::FilePath& db_filename, | 499 void WritePrefixSet(const base::FilePath& db_filename, |
500 const safe_browsing::PrefixSet* prefix_set, | 500 PrefixSetId prefix_set_id, |
501 FailureType write_failure_type); | 501 FailureType write_failure_type); |
502 | 502 |
503 // Loads the given full-length hashes to the given whitelist. If the number | 503 // Loads the given full-length hashes to the given whitelist. If the number |
504 // of hashes is too large or if the kill switch URL is on the whitelist | 504 // of hashes is too large or if the kill switch URL is on the whitelist |
505 // we will whitelist everything. | 505 // we will whitelist everything. |
506 void LoadWhitelist(const std::vector<SBAddFullHash>& full_hashes, | 506 void LoadWhitelist(const std::vector<SBAddFullHash>& full_hashes, |
507 SBWhitelistId whitelist_id); | 507 SBWhitelistId whitelist_id); |
508 | 508 |
509 // Call this method if an error occured with the given whitelist. This will | 509 // Call this method if an error occured with the given whitelist. This will |
510 // result in all lookups to the whitelist to return true. | 510 // result in all lookups to the whitelist to return true. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 void UpdateWhitelistStore(const base::FilePath& store_filename, | 555 void UpdateWhitelistStore(const base::FilePath& store_filename, |
556 SafeBrowsingStore* store, | 556 SafeBrowsingStore* store, |
557 SBWhitelistId whitelist_id); | 557 SBWhitelistId whitelist_id); |
558 void UpdateIpBlacklistStore(); | 558 void UpdateIpBlacklistStore(); |
559 | 559 |
560 // Returns a raw pointer to ThreadSafeStateManager's PrefixGetHashCache for | 560 // Returns a raw pointer to ThreadSafeStateManager's PrefixGetHashCache for |
561 // testing. This should only be used in unit tests (where multi-threading and | 561 // testing. This should only be used in unit tests (where multi-threading and |
562 // synchronization are not problematic). | 562 // synchronization are not problematic). |
563 PrefixGetHashCache* GetUnsynchronizedPrefixGetHashCacheForTesting(); | 563 PrefixGetHashCache* GetUnsynchronizedPrefixGetHashCacheForTesting(); |
564 | 564 |
| 565 // Records |sample| for |histogram_name_base| suffixed by the appropriate |
| 566 // histogram suffix for |(prefix_set_id|whitelist_id)|. |
| 567 void RecordPrefixSetCountsHistogram(const std::string& histogram_name_base, |
| 568 PrefixSetId prefix_set_id, |
| 569 int sample); |
| 570 void RecordSBWhitelistCountsHistogram(const std::string& histogram_name_base, |
| 571 SBWhitelistId whitelist_id, |
| 572 int sample); |
| 573 |
565 base::ThreadChecker thread_checker_; | 574 base::ThreadChecker thread_checker_; |
566 | 575 |
567 ThreadSafeStateManager state_manager_; | 576 ThreadSafeStateManager state_manager_; |
568 | 577 |
569 // The base filename passed to Init(), used to generate the store and prefix | 578 // The base filename passed to Init(), used to generate the store and prefix |
570 // set filenames used to store data on disk. | 579 // set filenames used to store data on disk. |
571 base::FilePath filename_base_; | 580 base::FilePath filename_base_; |
572 | 581 |
573 // Underlying persistent store for chunk data. | 582 // Underlying persistent store for chunk data. |
574 // For browsing related (phishing and malware URLs) chunks and prefixes. | 583 // For browsing related (phishing and malware URLs) chunks and prefixes. |
(...skipping 29 matching lines...) Expand all Loading... |
604 | 613 |
605 // Set to true if any chunks are added or deleted during an update. | 614 // Set to true if any chunks are added or deleted during an update. |
606 // Used to optimize away database update. | 615 // Used to optimize away database update. |
607 bool change_detected_; | 616 bool change_detected_; |
608 | 617 |
609 // Used to schedule resetting the database because of corruption. | 618 // Used to schedule resetting the database because of corruption. |
610 base::WeakPtrFactory<SafeBrowsingDatabaseNew> reset_factory_; | 619 base::WeakPtrFactory<SafeBrowsingDatabaseNew> reset_factory_; |
611 }; | 620 }; |
612 | 621 |
613 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ | 622 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ |
OLD | NEW |