| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 void GetDownloadUrlPrefixes(const std::vector<GURL>& urls, | 127 void GetDownloadUrlPrefixes(const std::vector<GURL>& urls, |
| 128 std::vector<SBPrefix>* prefixes) { | 128 std::vector<SBPrefix>* prefixes) { |
| 129 std::vector<SBFullHash> full_hashes; | 129 std::vector<SBFullHash> full_hashes; |
| 130 for (size_t i = 0; i < urls.size(); ++i) | 130 for (size_t i = 0; i < urls.size(); ++i) |
| 131 BrowseFullHashesToCheck(urls[i], false, &full_hashes); | 131 BrowseFullHashesToCheck(urls[i], false, &full_hashes); |
| 132 | 132 |
| 133 for (size_t i = 0; i < full_hashes.size(); ++i) | 133 for (size_t i = 0; i < full_hashes.size(); ++i) |
| 134 prefixes->push_back(full_hashes[i].prefix); | 134 prefixes->push_back(full_hashes[i].prefix); |
| 135 } | 135 } |
| 136 | 136 |
| 137 // Helper function to compare addprefixes in |store| with |prefixes|. |
| 138 // The |list_bit| indicates which list (url or hash) to compare. |
| 139 // |
| 140 // Returns true if there is a match, |*prefix_hits| (if non-NULL) will contain |
| 141 // the actual matching prefixes. |
| 142 bool MatchAddPrefixes(SafeBrowsingStore* store, |
| 143 int list_bit, |
| 144 const std::vector<SBPrefix>& prefixes, |
| 145 std::vector<SBPrefix>* prefix_hits) { |
| 146 prefix_hits->clear(); |
| 147 bool found_match = false; |
| 148 |
| 149 SBAddPrefixes add_prefixes; |
| 150 store->GetAddPrefixes(&add_prefixes); |
| 151 for (SBAddPrefixes::const_iterator iter = add_prefixes.begin(); |
| 152 iter != add_prefixes.end(); ++iter) { |
| 153 for (size_t j = 0; j < prefixes.size(); ++j) { |
| 154 const SBPrefix& prefix = prefixes[j]; |
| 155 if (prefix == iter->prefix && |
| 156 GetListIdBit(iter->chunk_id) == list_bit) { |
| 157 prefix_hits->push_back(prefix); |
| 158 found_match = true; |
| 159 } |
| 160 } |
| 161 } |
| 162 return found_match; |
| 163 } |
| 164 |
| 137 // Find the entries in |full_hashes| with prefix in |prefix_hits|, and | 165 // Find the entries in |full_hashes| with prefix in |prefix_hits|, and |
| 138 // add them to |full_hits| if not expired. "Not expired" is when | 166 // add them to |full_hits| if not expired. "Not expired" is when |
| 139 // either |last_update| was recent enough, or the item has been | 167 // either |last_update| was recent enough, or the item has been |
| 140 // received recently enough. Expired items are not deleted because a | 168 // received recently enough. Expired items are not deleted because a |
| 141 // future update may make them acceptable again. | 169 // future update may make them acceptable again. |
| 142 // | 170 // |
| 143 // For efficiency reasons the code walks |prefix_hits| and | 171 // For efficiency reasons the code walks |prefix_hits| and |
| 144 // |full_hashes| in parallel, so they must be sorted by prefix. | 172 // |full_hashes| in parallel, so they must be sorted by prefix. |
| 145 void GetCachedFullHashesForBrowse(const std::vector<SBPrefix>& prefix_hits, | 173 void GetCachedFullHashesForBrowse(const std::vector<SBPrefix>& prefix_hits, |
| 146 const std::vector<SBAddFullHash>& full_hashes, | 174 const std::vector<SBAddFullHash>& full_hashes, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 157 ++piter; | 185 ++piter; |
| 158 } else if (hiter->full_hash.prefix < *piter) { | 186 } else if (hiter->full_hash.prefix < *piter) { |
| 159 ++hiter; | 187 ++hiter; |
| 160 } else { | 188 } else { |
| 161 if (expire_time < last_update || | 189 if (expire_time < last_update || |
| 162 expire_time.ToTimeT() < hiter->received) { | 190 expire_time.ToTimeT() < hiter->received) { |
| 163 SBFullHashResult result; | 191 SBFullHashResult result; |
| 164 const int list_bit = GetListIdBit(hiter->chunk_id); | 192 const int list_bit = GetListIdBit(hiter->chunk_id); |
| 165 DCHECK(list_bit == safe_browsing_util::MALWARE || | 193 DCHECK(list_bit == safe_browsing_util::MALWARE || |
| 166 list_bit == safe_browsing_util::PHISH); | 194 list_bit == safe_browsing_util::PHISH); |
| 167 if (!safe_browsing_util::GetListName(list_bit, &result.list_name)) | 195 const safe_browsing_util::ListType list_id = |
| 196 static_cast<safe_browsing_util::ListType>(list_bit); |
| 197 if (!safe_browsing_util::GetListName(list_id, &result.list_name)) |
| 168 continue; | 198 continue; |
| 169 result.add_chunk_id = DecodeChunkId(hiter->chunk_id); | 199 result.add_chunk_id = DecodeChunkId(hiter->chunk_id); |
| 170 result.hash = hiter->full_hash; | 200 result.hash = hiter->full_hash; |
| 171 full_hits->push_back(result); | 201 full_hits->push_back(result); |
| 172 } | 202 } |
| 173 | 203 |
| 174 // Only increment |hiter|, |piter| might have multiple hits. | 204 // Only increment |hiter|, |piter| might have multiple hits. |
| 175 ++hiter; | 205 ++hiter; |
| 176 } | 206 } |
| 177 } | 207 } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 UMA_HISTOGRAM_ENUMERATION("SB2.DatabaseFailure", failure_type, | 402 UMA_HISTOGRAM_ENUMERATION("SB2.DatabaseFailure", failure_type, |
| 373 FAILURE_DATABASE_MAX); | 403 FAILURE_DATABASE_MAX); |
| 374 } | 404 } |
| 375 | 405 |
| 376 SafeBrowsingDatabaseNew::SafeBrowsingDatabaseNew() | 406 SafeBrowsingDatabaseNew::SafeBrowsingDatabaseNew() |
| 377 : creation_loop_(MessageLoop::current()), | 407 : creation_loop_(MessageLoop::current()), |
| 378 browse_store_(new SafeBrowsingStoreFile), | 408 browse_store_(new SafeBrowsingStoreFile), |
| 379 download_store_(NULL), | 409 download_store_(NULL), |
| 380 csd_whitelist_store_(NULL), | 410 csd_whitelist_store_(NULL), |
| 381 download_whitelist_store_(NULL), | 411 download_whitelist_store_(NULL), |
| 382 ALLOW_THIS_IN_INITIALIZER_LIST(reset_factory_(this)) { | 412 ALLOW_THIS_IN_INITIALIZER_LIST(reset_factory_(this)), |
| 413 corruption_detected_(false), |
| 414 change_detected_(false) { |
| 383 DCHECK(browse_store_.get()); | 415 DCHECK(browse_store_.get()); |
| 384 DCHECK(!download_store_.get()); | 416 DCHECK(!download_store_.get()); |
| 385 DCHECK(!csd_whitelist_store_.get()); | 417 DCHECK(!csd_whitelist_store_.get()); |
| 386 DCHECK(!download_whitelist_store_.get()); | 418 DCHECK(!download_whitelist_store_.get()); |
| 387 } | 419 } |
| 388 | 420 |
| 389 SafeBrowsingDatabaseNew::SafeBrowsingDatabaseNew( | 421 SafeBrowsingDatabaseNew::SafeBrowsingDatabaseNew( |
| 390 SafeBrowsingStore* browse_store, | 422 SafeBrowsingStore* browse_store, |
| 391 SafeBrowsingStore* download_store, | 423 SafeBrowsingStore* download_store, |
| 392 SafeBrowsingStore* csd_whitelist_store, | 424 SafeBrowsingStore* csd_whitelist_store, |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 // updates. | 580 // updates. |
| 549 std::sort(prefix_hits->begin(), prefix_hits->end()); | 581 std::sort(prefix_hits->begin(), prefix_hits->end()); |
| 550 | 582 |
| 551 GetCachedFullHashesForBrowse(*prefix_hits, full_browse_hashes_, | 583 GetCachedFullHashesForBrowse(*prefix_hits, full_browse_hashes_, |
| 552 full_hits, last_update); | 584 full_hits, last_update); |
| 553 GetCachedFullHashesForBrowse(*prefix_hits, pending_browse_hashes_, | 585 GetCachedFullHashesForBrowse(*prefix_hits, pending_browse_hashes_, |
| 554 full_hits, last_update); | 586 full_hits, last_update); |
| 555 return true; | 587 return true; |
| 556 } | 588 } |
| 557 | 589 |
| 558 bool SafeBrowsingDatabaseNew::MatchDownloadAddPrefixes( | |
| 559 int list_bit, | |
| 560 const std::vector<SBPrefix>& prefixes, | |
| 561 std::vector<SBPrefix>* prefix_hits) { | |
| 562 prefix_hits->clear(); | |
| 563 | |
| 564 SBAddPrefixes add_prefixes; | |
| 565 download_store_->GetAddPrefixes(&add_prefixes); | |
| 566 for (SBAddPrefixes::const_iterator iter = add_prefixes.begin(); | |
| 567 iter != add_prefixes.end(); ++iter) { | |
| 568 for (size_t j = 0; j < prefixes.size(); ++j) { | |
| 569 const SBPrefix& prefix = prefixes[j]; | |
| 570 if (prefix == iter->prefix && | |
| 571 GetListIdBit(iter->chunk_id) == list_bit) { | |
| 572 prefix_hits->push_back(prefix); | |
| 573 } | |
| 574 } | |
| 575 } | |
| 576 return !prefix_hits->empty(); | |
| 577 } | |
| 578 | |
| 579 bool SafeBrowsingDatabaseNew::ContainsDownloadUrl( | 590 bool SafeBrowsingDatabaseNew::ContainsDownloadUrl( |
| 580 const std::vector<GURL>& urls, | 591 const std::vector<GURL>& urls, |
| 581 std::vector<SBPrefix>* prefix_hits) { | 592 std::vector<SBPrefix>* prefix_hits) { |
| 582 DCHECK_EQ(creation_loop_, MessageLoop::current()); | 593 DCHECK_EQ(creation_loop_, MessageLoop::current()); |
| 583 | 594 |
| 584 // Ignore this check when download checking is not enabled. | 595 // Ignore this check when download checking is not enabled. |
| 585 if (!download_store_.get()) | 596 if (!download_store_.get()) |
| 586 return false; | 597 return false; |
| 587 | 598 |
| 588 std::vector<SBPrefix> prefixes; | 599 std::vector<SBPrefix> prefixes; |
| 589 GetDownloadUrlPrefixes(urls, &prefixes); | 600 GetDownloadUrlPrefixes(urls, &prefixes); |
| 590 return MatchDownloadAddPrefixes(safe_browsing_util::BINURL % 2, | 601 return MatchAddPrefixes(download_store_.get(), |
| 591 prefixes, | 602 safe_browsing_util::BINURL % 2, |
| 592 prefix_hits); | 603 prefixes, |
| 604 prefix_hits); |
| 593 } | 605 } |
| 594 | 606 |
| 595 bool SafeBrowsingDatabaseNew::ContainsDownloadHashPrefix( | 607 bool SafeBrowsingDatabaseNew::ContainsDownloadHashPrefix( |
| 596 const SBPrefix& prefix) { | 608 const SBPrefix& prefix) { |
| 597 DCHECK_EQ(creation_loop_, MessageLoop::current()); | 609 DCHECK_EQ(creation_loop_, MessageLoop::current()); |
| 598 | 610 |
| 599 // Ignore this check when download store is not available. | 611 // Ignore this check when download store is not available. |
| 600 if (!download_store_.get()) | 612 if (!download_store_.get()) |
| 601 return false; | 613 return false; |
| 602 | 614 |
| 603 std::vector<SBPrefix> prefixes(1, prefix); | |
| 604 std::vector<SBPrefix> prefix_hits; | 615 std::vector<SBPrefix> prefix_hits; |
| 605 return MatchDownloadAddPrefixes(safe_browsing_util::BINHASH % 2, | 616 return MatchAddPrefixes(download_store_.get(), |
| 606 prefixes, | 617 safe_browsing_util::BINHASH % 2, |
| 607 &prefix_hits); | 618 std::vector<SBPrefix>(1, prefix), |
| 619 &prefix_hits); |
| 608 } | 620 } |
| 609 | 621 |
| 610 bool SafeBrowsingDatabaseNew::ContainsCsdWhitelistedUrl(const GURL& url) { | 622 bool SafeBrowsingDatabaseNew::ContainsCsdWhitelistedUrl(const GURL& url) { |
| 611 // This method is theoretically thread-safe but we expect all calls to | 623 // This method is theoretically thread-safe but we expect all calls to |
| 612 // originate from the IO thread. | 624 // originate from the IO thread. |
| 613 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 625 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 614 std::vector<SBFullHash> full_hashes; | 626 std::vector<SBFullHash> full_hashes; |
| 615 BrowseFullHashesToCheck(url, true, &full_hashes); | 627 BrowseFullHashesToCheck(url, true, &full_hashes); |
| 616 return ContainsWhitelistedHashes(csd_whitelist_, full_hashes); | 628 return ContainsWhitelistedHashes(csd_whitelist_, full_hashes); |
| 617 } | 629 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 store->WriteAddPrefix(encoded_chunk_id, prefix); | 693 store->WriteAddPrefix(encoded_chunk_id, prefix); |
| 682 | 694 |
| 683 STATS_COUNTER("SB.PrefixAddFull", 1); | 695 STATS_COUNTER("SB.PrefixAddFull", 1); |
| 684 store->WriteAddHash(encoded_chunk_id, receive_time, full_hash); | 696 store->WriteAddHash(encoded_chunk_id, receive_time, full_hash); |
| 685 } | 697 } |
| 686 } | 698 } |
| 687 } | 699 } |
| 688 | 700 |
| 689 // Helper to iterate over all the entries in the hosts in |chunks| and | 701 // Helper to iterate over all the entries in the hosts in |chunks| and |
| 690 // add them to the store. | 702 // add them to the store. |
| 691 void SafeBrowsingDatabaseNew::InsertAddChunks(const int list_id, | 703 void SafeBrowsingDatabaseNew::InsertAddChunks( |
| 692 const SBChunkList& chunks) { | 704 const safe_browsing_util::ListType list_id, |
| 705 const SBChunkList& chunks) { |
| 693 DCHECK_EQ(creation_loop_, MessageLoop::current()); | 706 DCHECK_EQ(creation_loop_, MessageLoop::current()); |
| 694 | 707 |
| 695 SafeBrowsingStore* store = GetStore(list_id); | 708 SafeBrowsingStore* store = GetStore(list_id); |
| 696 if (!store) return; | 709 if (!store) return; |
| 697 | 710 |
| 698 for (SBChunkList::const_iterator citer = chunks.begin(); | 711 for (SBChunkList::const_iterator citer = chunks.begin(); |
| 699 citer != chunks.end(); ++citer) { | 712 citer != chunks.end(); ++citer) { |
| 700 const int chunk_id = citer->chunk_number; | 713 const int chunk_id = citer->chunk_number; |
| 701 | 714 |
| 702 // The server can give us a chunk that we already have because | 715 // The server can give us a chunk that we already have because |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 store->WriteSubPrefix(encoded_chunk_id, add_chunk_id, full_hash.prefix); | 768 store->WriteSubPrefix(encoded_chunk_id, add_chunk_id, full_hash.prefix); |
| 756 | 769 |
| 757 STATS_COUNTER("SB.PrefixSubFull", 1); | 770 STATS_COUNTER("SB.PrefixSubFull", 1); |
| 758 store->WriteSubHash(encoded_chunk_id, add_chunk_id, full_hash); | 771 store->WriteSubHash(encoded_chunk_id, add_chunk_id, full_hash); |
| 759 } | 772 } |
| 760 } | 773 } |
| 761 } | 774 } |
| 762 | 775 |
| 763 // Helper to iterate over all the entries in the hosts in |chunks| and | 776 // Helper to iterate over all the entries in the hosts in |chunks| and |
| 764 // add them to the store. | 777 // add them to the store. |
| 765 void SafeBrowsingDatabaseNew::InsertSubChunks(int list_id, | 778 void SafeBrowsingDatabaseNew::InsertSubChunks( |
| 766 const SBChunkList& chunks) { | 779 safe_browsing_util::ListType list_id, |
| 780 const SBChunkList& chunks) { |
| 767 DCHECK_EQ(creation_loop_, MessageLoop::current()); | 781 DCHECK_EQ(creation_loop_, MessageLoop::current()); |
| 768 | 782 |
| 769 SafeBrowsingStore* store = GetStore(list_id); | 783 SafeBrowsingStore* store = GetStore(list_id); |
| 770 if (!store) return; | 784 if (!store) return; |
| 771 | 785 |
| 772 for (SBChunkList::const_iterator citer = chunks.begin(); | 786 for (SBChunkList::const_iterator citer = chunks.begin(); |
| 773 citer != chunks.end(); ++citer) { | 787 citer != chunks.end(); ++citer) { |
| 774 const int chunk_id = citer->chunk_number; | 788 const int chunk_id = citer->chunk_number; |
| 775 | 789 |
| 776 // The server can give us a chunk that we already have because | 790 // The server can give us a chunk that we already have because |
| (...skipping 12 matching lines...) Expand all Loading... |
| 789 | 803 |
| 790 void SafeBrowsingDatabaseNew::InsertChunks(const std::string& list_name, | 804 void SafeBrowsingDatabaseNew::InsertChunks(const std::string& list_name, |
| 791 const SBChunkList& chunks) { | 805 const SBChunkList& chunks) { |
| 792 DCHECK_EQ(creation_loop_, MessageLoop::current()); | 806 DCHECK_EQ(creation_loop_, MessageLoop::current()); |
| 793 | 807 |
| 794 if (corruption_detected_ || chunks.empty()) | 808 if (corruption_detected_ || chunks.empty()) |
| 795 return; | 809 return; |
| 796 | 810 |
| 797 const base::TimeTicks before = base::TimeTicks::Now(); | 811 const base::TimeTicks before = base::TimeTicks::Now(); |
| 798 | 812 |
| 799 const int list_id = safe_browsing_util::GetListId(list_name); | 813 const safe_browsing_util::ListType list_id = |
| 814 safe_browsing_util::GetListId(list_name); |
| 800 DVLOG(2) << list_name << ": " << list_id; | 815 DVLOG(2) << list_name << ": " << list_id; |
| 801 | 816 |
| 802 SafeBrowsingStore* store = GetStore(list_id); | 817 SafeBrowsingStore* store = GetStore(list_id); |
| 803 if (!store) return; | 818 if (!store) return; |
| 804 | 819 |
| 805 change_detected_ = true; | 820 change_detected_ = true; |
| 806 | 821 |
| 807 store->BeginChunk(); | 822 store->BeginChunk(); |
| 808 if (chunks.front().is_add) { | 823 if (chunks.front().is_add) { |
| 809 InsertAddChunks(list_id, chunks); | 824 InsertAddChunks(list_id, chunks); |
| 810 } else { | 825 } else { |
| 811 InsertSubChunks(list_id, chunks); | 826 InsertSubChunks(list_id, chunks); |
| 812 } | 827 } |
| 813 store->FinishChunk(); | 828 store->FinishChunk(); |
| 814 | 829 |
| 815 UMA_HISTOGRAM_TIMES("SB2.ChunkInsert", base::TimeTicks::Now() - before); | 830 UMA_HISTOGRAM_TIMES("SB2.ChunkInsert", base::TimeTicks::Now() - before); |
| 816 } | 831 } |
| 817 | 832 |
| 818 void SafeBrowsingDatabaseNew::DeleteChunks( | 833 void SafeBrowsingDatabaseNew::DeleteChunks( |
| 819 const std::vector<SBChunkDelete>& chunk_deletes) { | 834 const std::vector<SBChunkDelete>& chunk_deletes) { |
| 820 DCHECK_EQ(creation_loop_, MessageLoop::current()); | 835 DCHECK_EQ(creation_loop_, MessageLoop::current()); |
| 821 | 836 |
| 822 if (corruption_detected_ || chunk_deletes.empty()) | 837 if (corruption_detected_ || chunk_deletes.empty()) |
| 823 return; | 838 return; |
| 824 | 839 |
| 825 const std::string& list_name = chunk_deletes.front().list_name; | 840 const std::string& list_name = chunk_deletes.front().list_name; |
| 826 const int list_id = safe_browsing_util::GetListId(list_name); | 841 const safe_browsing_util::ListType list_id = |
| 842 safe_browsing_util::GetListId(list_name); |
| 827 | 843 |
| 828 SafeBrowsingStore* store = GetStore(list_id); | 844 SafeBrowsingStore* store = GetStore(list_id); |
| 829 if (!store) return; | 845 if (!store) return; |
| 830 | 846 |
| 831 change_detected_ = true; | 847 change_detected_ = true; |
| 832 | 848 |
| 833 for (size_t i = 0; i < chunk_deletes.size(); ++i) { | 849 for (size_t i = 0; i < chunk_deletes.size(); ++i) { |
| 834 std::vector<int> chunk_numbers; | 850 std::vector<int> chunk_numbers; |
| 835 RangesToChunks(chunk_deletes[i].chunk_del, &chunk_numbers); | 851 RangesToChunks(chunk_deletes[i].chunk_del, &chunk_numbers); |
| 836 for (size_t j = 0; j < chunk_numbers.size(); ++j) { | 852 for (size_t j = 0; j < chunk_numbers.size(); ++j) { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 browse_store_->CancelUpdate(); | 1016 browse_store_->CancelUpdate(); |
| 1001 if (download_store_.get()) | 1017 if (download_store_.get()) |
| 1002 download_store_->CancelUpdate(); | 1018 download_store_->CancelUpdate(); |
| 1003 if (csd_whitelist_store_.get()) | 1019 if (csd_whitelist_store_.get()) |
| 1004 csd_whitelist_store_->CancelUpdate(); | 1020 csd_whitelist_store_->CancelUpdate(); |
| 1005 if (download_whitelist_store_.get()) | 1021 if (download_whitelist_store_.get()) |
| 1006 download_whitelist_store_->CancelUpdate(); | 1022 download_whitelist_store_->CancelUpdate(); |
| 1007 return; | 1023 return; |
| 1008 } | 1024 } |
| 1009 | 1025 |
| 1010 // for download | |
| 1011 UpdateDownloadStore(); | 1026 UpdateDownloadStore(); |
| 1012 // for browsing | |
| 1013 UpdateBrowseStore(); | 1027 UpdateBrowseStore(); |
| 1014 // for csd and download whitelists. | |
| 1015 UpdateWhitelistStore(csd_whitelist_filename_, | 1028 UpdateWhitelistStore(csd_whitelist_filename_, |
| 1016 csd_whitelist_store_.get(), | 1029 csd_whitelist_store_.get(), |
| 1017 &csd_whitelist_); | 1030 &csd_whitelist_); |
| 1018 UpdateWhitelistStore(download_whitelist_filename_, | 1031 UpdateWhitelistStore(download_whitelist_filename_, |
| 1019 download_whitelist_store_.get(), | 1032 download_whitelist_store_.get(), |
| 1020 &download_whitelist_); | 1033 &download_whitelist_); |
| 1021 } | 1034 } |
| 1022 | 1035 |
| 1023 void SafeBrowsingDatabaseNew::UpdateWhitelistStore( | 1036 void SafeBrowsingDatabaseNew::UpdateWhitelistStore( |
| 1024 const FilePath& store_filename, | 1037 const FilePath& store_filename, |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 RecordFailure(FAILURE_DATABASE_STORE_DELETE); | 1270 RecordFailure(FAILURE_DATABASE_STORE_DELETE); |
| 1258 | 1271 |
| 1259 FilePath bloom_filter_filename = BloomFilterForFilename(browse_filename_); | 1272 FilePath bloom_filter_filename = BloomFilterForFilename(browse_filename_); |
| 1260 const bool r5 = file_util::Delete(bloom_filter_filename, false); | 1273 const bool r5 = file_util::Delete(bloom_filter_filename, false); |
| 1261 if (!r5) | 1274 if (!r5) |
| 1262 RecordFailure(FAILURE_DATABASE_FILTER_DELETE); | 1275 RecordFailure(FAILURE_DATABASE_FILTER_DELETE); |
| 1263 | 1276 |
| 1264 const bool r6 = file_util::Delete(prefix_set_filename_, false); | 1277 const bool r6 = file_util::Delete(prefix_set_filename_, false); |
| 1265 if (!r6) | 1278 if (!r6) |
| 1266 RecordFailure(FAILURE_DATABASE_PREFIX_SET_DELETE); | 1279 RecordFailure(FAILURE_DATABASE_PREFIX_SET_DELETE); |
| 1280 |
| 1267 return r1 && r2 && r3 && r4 && r5 && r6; | 1281 return r1 && r2 && r3 && r4 && r5 && r6; |
| 1268 } | 1282 } |
| 1269 | 1283 |
| 1270 void SafeBrowsingDatabaseNew::WritePrefixSet() { | 1284 void SafeBrowsingDatabaseNew::WritePrefixSet() { |
| 1271 DCHECK_EQ(creation_loop_, MessageLoop::current()); | 1285 DCHECK_EQ(creation_loop_, MessageLoop::current()); |
| 1272 | 1286 |
| 1273 if (!prefix_set_.get()) | 1287 if (!prefix_set_.get()) |
| 1274 return; | 1288 return; |
| 1275 | 1289 |
| 1276 const base::TimeTicks before = base::TimeTicks::Now(); | 1290 const base::TimeTicks before = base::TimeTicks::Now(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1316 if (std::binary_search(new_whitelist.begin(), new_whitelist.end(), | 1330 if (std::binary_search(new_whitelist.begin(), new_whitelist.end(), |
| 1317 kill_switch)) { | 1331 kill_switch)) { |
| 1318 // The kill switch is whitelisted hence we whitelist all URLs. | 1332 // The kill switch is whitelisted hence we whitelist all URLs. |
| 1319 WhitelistEverything(whitelist); | 1333 WhitelistEverything(whitelist); |
| 1320 } else { | 1334 } else { |
| 1321 base::AutoLock locked(lookup_lock_); | 1335 base::AutoLock locked(lookup_lock_); |
| 1322 whitelist->second = false; | 1336 whitelist->second = false; |
| 1323 whitelist->first.swap(new_whitelist); | 1337 whitelist->first.swap(new_whitelist); |
| 1324 } | 1338 } |
| 1325 } | 1339 } |
| OLD | NEW |