| 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 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1479 | 1479 |
| 1480 // If there is no database, the filter cannot be used. | 1480 // If there is no database, the filter cannot be used. |
| 1481 base::PlatformFileInfo db_info; | 1481 base::PlatformFileInfo db_info; |
| 1482 if (!file_util::GetFileInfo(browse_filename_, &db_info) || db_info.size == 0) | 1482 if (!file_util::GetFileInfo(browse_filename_, &db_info) || db_info.size == 0) |
| 1483 return; | 1483 return; |
| 1484 | 1484 |
| 1485 // Cleanup any stale bloom filter (no longer used). | 1485 // Cleanup any stale bloom filter (no longer used). |
| 1486 // TODO(shess): Track failure to delete? | 1486 // TODO(shess): Track failure to delete? |
| 1487 base::FilePath bloom_filter_filename = | 1487 base::FilePath bloom_filter_filename = |
| 1488 BloomFilterForFilename(browse_filename_); | 1488 BloomFilterForFilename(browse_filename_); |
| 1489 file_util::Delete(bloom_filter_filename, false); | 1489 base::Delete(bloom_filter_filename, false); |
| 1490 | 1490 |
| 1491 const base::TimeTicks before = base::TimeTicks::Now(); | 1491 const base::TimeTicks before = base::TimeTicks::Now(); |
| 1492 browse_prefix_set_.reset(safe_browsing::PrefixSet::LoadFile( | 1492 browse_prefix_set_.reset(safe_browsing::PrefixSet::LoadFile( |
| 1493 browse_prefix_set_filename_)); | 1493 browse_prefix_set_filename_)); |
| 1494 DVLOG(1) << "SafeBrowsingDatabaseNew read prefix set in " | 1494 DVLOG(1) << "SafeBrowsingDatabaseNew read prefix set in " |
| 1495 << (base::TimeTicks::Now() - before).InMilliseconds() << " ms"; | 1495 << (base::TimeTicks::Now() - before).InMilliseconds() << " ms"; |
| 1496 UMA_HISTOGRAM_TIMES("SB2.PrefixSetLoad", base::TimeTicks::Now() - before); | 1496 UMA_HISTOGRAM_TIMES("SB2.PrefixSetLoad", base::TimeTicks::Now() - before); |
| 1497 | 1497 |
| 1498 if (!browse_prefix_set_.get()) | 1498 if (!browse_prefix_set_.get()) |
| 1499 RecordFailure(FAILURE_BROWSE_PREFIX_SET_READ); | 1499 RecordFailure(FAILURE_BROWSE_PREFIX_SET_READ); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1515 if (!r3) | 1515 if (!r3) |
| 1516 RecordFailure(FAILURE_DATABASE_STORE_DELETE); | 1516 RecordFailure(FAILURE_DATABASE_STORE_DELETE); |
| 1517 | 1517 |
| 1518 const bool r4 = download_whitelist_store_.get() ? | 1518 const bool r4 = download_whitelist_store_.get() ? |
| 1519 download_whitelist_store_->Delete() : true; | 1519 download_whitelist_store_->Delete() : true; |
| 1520 if (!r4) | 1520 if (!r4) |
| 1521 RecordFailure(FAILURE_DATABASE_STORE_DELETE); | 1521 RecordFailure(FAILURE_DATABASE_STORE_DELETE); |
| 1522 | 1522 |
| 1523 base::FilePath bloom_filter_filename = | 1523 base::FilePath bloom_filter_filename = |
| 1524 BloomFilterForFilename(browse_filename_); | 1524 BloomFilterForFilename(browse_filename_); |
| 1525 const bool r5 = file_util::Delete(bloom_filter_filename, false); | 1525 const bool r5 = base::Delete(bloom_filter_filename, false); |
| 1526 if (!r5) | 1526 if (!r5) |
| 1527 RecordFailure(FAILURE_DATABASE_FILTER_DELETE); | 1527 RecordFailure(FAILURE_DATABASE_FILTER_DELETE); |
| 1528 | 1528 |
| 1529 const bool r6 = file_util::Delete(browse_prefix_set_filename_, false); | 1529 const bool r6 = base::Delete(browse_prefix_set_filename_, false); |
| 1530 if (!r6) | 1530 if (!r6) |
| 1531 RecordFailure(FAILURE_BROWSE_PREFIX_SET_DELETE); | 1531 RecordFailure(FAILURE_BROWSE_PREFIX_SET_DELETE); |
| 1532 | 1532 |
| 1533 const bool r7 = file_util::Delete(extension_blacklist_filename_, false); | 1533 const bool r7 = base::Delete(extension_blacklist_filename_, false); |
| 1534 if (!r7) | 1534 if (!r7) |
| 1535 RecordFailure(FAILURE_EXTENSION_BLACKLIST_DELETE); | 1535 RecordFailure(FAILURE_EXTENSION_BLACKLIST_DELETE); |
| 1536 | 1536 |
| 1537 const bool r8 = file_util::Delete(side_effect_free_whitelist_filename_, | 1537 const bool r8 = base::Delete(side_effect_free_whitelist_filename_, |
| 1538 false); | 1538 false); |
| 1539 if (!r8) | 1539 if (!r8) |
| 1540 RecordFailure(FAILURE_SIDE_EFFECT_FREE_WHITELIST_DELETE); | 1540 RecordFailure(FAILURE_SIDE_EFFECT_FREE_WHITELIST_DELETE); |
| 1541 | 1541 |
| 1542 const bool r9 = file_util::Delete( | 1542 const bool r9 = base::Delete( |
| 1543 side_effect_free_whitelist_prefix_set_filename_, | 1543 side_effect_free_whitelist_prefix_set_filename_, |
| 1544 false); | 1544 false); |
| 1545 if (!r9) | 1545 if (!r9) |
| 1546 RecordFailure(FAILURE_SIDE_EFFECT_FREE_WHITELIST_PREFIX_SET_DELETE); | 1546 RecordFailure(FAILURE_SIDE_EFFECT_FREE_WHITELIST_PREFIX_SET_DELETE); |
| 1547 | 1547 |
| 1548 return r1 && r2 && r3 && r4 && r5 && r6 && r7 && r8 && r9; | 1548 return r1 && r2 && r3 && r4 && r5 && r6 && r7 && r8 && r9; |
| 1549 } | 1549 } |
| 1550 | 1550 |
| 1551 void SafeBrowsingDatabaseNew::WritePrefixSet() { | 1551 void SafeBrowsingDatabaseNew::WritePrefixSet() { |
| 1552 DCHECK_EQ(creation_loop_, base::MessageLoop::current()); | 1552 DCHECK_EQ(creation_loop_, base::MessageLoop::current()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1598 if (std::binary_search(new_whitelist.begin(), new_whitelist.end(), | 1598 if (std::binary_search(new_whitelist.begin(), new_whitelist.end(), |
| 1599 kill_switch)) { | 1599 kill_switch)) { |
| 1600 // The kill switch is whitelisted hence we whitelist all URLs. | 1600 // The kill switch is whitelisted hence we whitelist all URLs. |
| 1601 WhitelistEverything(whitelist); | 1601 WhitelistEverything(whitelist); |
| 1602 } else { | 1602 } else { |
| 1603 base::AutoLock locked(lookup_lock_); | 1603 base::AutoLock locked(lookup_lock_); |
| 1604 whitelist->second = false; | 1604 whitelist->second = false; |
| 1605 whitelist->first.swap(new_whitelist); | 1605 whitelist->first.swap(new_whitelist); |
| 1606 } | 1606 } |
| 1607 } | 1607 } |
| OLD | NEW |