OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/safe_browsing/safe_browsing_database.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_database.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 side_effect_free_whitelist_prefix_set_filename_ = | 604 side_effect_free_whitelist_prefix_set_filename_ = |
605 PrefixSetForFilename(side_effect_free_whitelist_filename_); | 605 PrefixSetForFilename(side_effect_free_whitelist_filename_); |
606 side_effect_free_whitelist_store_->Init( | 606 side_effect_free_whitelist_store_->Init( |
607 side_effect_free_whitelist_filename_, | 607 side_effect_free_whitelist_filename_, |
608 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase, | 608 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase, |
609 base::Unretained(this))); | 609 base::Unretained(this))); |
610 DVLOG(1) << "Init side-effect free whitelist store: " | 610 DVLOG(1) << "Init side-effect free whitelist store: " |
611 << side_effect_free_whitelist_filename_.value(); | 611 << side_effect_free_whitelist_filename_.value(); |
612 | 612 |
613 // If there is no database, the filter cannot be used. | 613 // If there is no database, the filter cannot be used. |
614 base::PlatformFileInfo db_info; | 614 base::File::Info db_info; |
615 if (base::GetFileInfo(side_effect_free_whitelist_filename_, &db_info) | 615 if (base::GetFileInfo(side_effect_free_whitelist_filename_, &db_info) |
616 && db_info.size != 0) { | 616 && db_info.size != 0) { |
617 const base::TimeTicks before = base::TimeTicks::Now(); | 617 const base::TimeTicks before = base::TimeTicks::Now(); |
618 side_effect_free_whitelist_prefix_set_.reset( | 618 side_effect_free_whitelist_prefix_set_.reset( |
619 safe_browsing::PrefixSet::LoadFile( | 619 safe_browsing::PrefixSet::LoadFile( |
620 side_effect_free_whitelist_prefix_set_filename_)); | 620 side_effect_free_whitelist_prefix_set_filename_)); |
621 DVLOG(1) << "SafeBrowsingDatabaseNew read side-effect free whitelist " | 621 DVLOG(1) << "SafeBrowsingDatabaseNew read side-effect free whitelist " |
622 << "prefix set in " | 622 << "prefix set in " |
623 << (base::TimeTicks::Now() - before).InMilliseconds() << " ms"; | 623 << (base::TimeTicks::Now() - before).InMilliseconds() << " ms"; |
624 UMA_HISTOGRAM_TIMES("SB2.SideEffectFreeWhitelistPrefixSetLoad", | 624 UMA_HISTOGRAM_TIMES("SB2.SideEffectFreeWhitelistPrefixSetLoad", |
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1601 DLOG(FATAL) << "SafeBrowsing database was corrupt and reset"; | 1601 DLOG(FATAL) << "SafeBrowsing database was corrupt and reset"; |
1602 } | 1602 } |
1603 | 1603 |
1604 // TODO(shess): I'm not clear why this code doesn't have any | 1604 // TODO(shess): I'm not clear why this code doesn't have any |
1605 // real error-handling. | 1605 // real error-handling. |
1606 void SafeBrowsingDatabaseNew::LoadPrefixSet() { | 1606 void SafeBrowsingDatabaseNew::LoadPrefixSet() { |
1607 DCHECK_EQ(creation_loop_, base::MessageLoop::current()); | 1607 DCHECK_EQ(creation_loop_, base::MessageLoop::current()); |
1608 DCHECK(!browse_prefix_set_filename_.empty()); | 1608 DCHECK(!browse_prefix_set_filename_.empty()); |
1609 | 1609 |
1610 // If there is no database, the filter cannot be used. | 1610 // If there is no database, the filter cannot be used. |
1611 base::PlatformFileInfo db_info; | 1611 base::File::Info db_info; |
1612 if (!base::GetFileInfo(browse_filename_, &db_info) || db_info.size == 0) | 1612 if (!base::GetFileInfo(browse_filename_, &db_info) || db_info.size == 0) |
1613 return; | 1613 return; |
1614 | 1614 |
1615 // Cleanup any stale bloom filter (no longer used). | 1615 // Cleanup any stale bloom filter (no longer used). |
1616 // TODO(shess): Track failure to delete? | 1616 // TODO(shess): Track failure to delete? |
1617 base::FilePath bloom_filter_filename = | 1617 base::FilePath bloom_filter_filename = |
1618 BloomFilterForFilename(browse_filename_); | 1618 BloomFilterForFilename(browse_filename_); |
1619 base::DeleteFile(bloom_filter_filename, false); | 1619 base::DeleteFile(bloom_filter_filename, false); |
1620 | 1620 |
1621 const base::TimeTicks before = base::TimeTicks::Now(); | 1621 const base::TimeTicks before = base::TimeTicks::Now(); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1783 } | 1783 } |
1784 | 1784 |
1785 bool SafeBrowsingDatabaseNew::IsMalwareIPMatchKillSwitchOn() { | 1785 bool SafeBrowsingDatabaseNew::IsMalwareIPMatchKillSwitchOn() { |
1786 SBFullHash malware_kill_switch; | 1786 SBFullHash malware_kill_switch; |
1787 crypto::SHA256HashString(kMalwareIPKillSwitchUrl, &malware_kill_switch, | 1787 crypto::SHA256HashString(kMalwareIPKillSwitchUrl, &malware_kill_switch, |
1788 sizeof(malware_kill_switch)); | 1788 sizeof(malware_kill_switch)); |
1789 std::vector<SBFullHash> full_hashes; | 1789 std::vector<SBFullHash> full_hashes; |
1790 full_hashes.push_back(malware_kill_switch); | 1790 full_hashes.push_back(malware_kill_switch); |
1791 return ContainsWhitelistedHashes(csd_whitelist_, full_hashes); | 1791 return ContainsWhitelistedHashes(csd_whitelist_, full_hashes); |
1792 } | 1792 } |
OLD | NEW |