Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(883)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_database.cc

Issue 814993003: Finalize thread-safety design for SafeBrowsingDatabase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a5_threadSafeStoreManager
Patch Set: fix compile post-merge Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_database.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 SafeBrowsingStore* browse_store, 663 SafeBrowsingStore* browse_store,
664 SafeBrowsingStore* download_store, 664 SafeBrowsingStore* download_store,
665 SafeBrowsingStore* csd_whitelist_store, 665 SafeBrowsingStore* csd_whitelist_store,
666 SafeBrowsingStore* download_whitelist_store, 666 SafeBrowsingStore* download_whitelist_store,
667 SafeBrowsingStore* inclusion_whitelist_store, 667 SafeBrowsingStore* inclusion_whitelist_store,
668 SafeBrowsingStore* extension_blacklist_store, 668 SafeBrowsingStore* extension_blacklist_store,
669 SafeBrowsingStore* side_effect_free_whitelist_store, 669 SafeBrowsingStore* side_effect_free_whitelist_store,
670 SafeBrowsingStore* ip_blacklist_store, 670 SafeBrowsingStore* ip_blacklist_store,
671 SafeBrowsingStore* unwanted_software_store) 671 SafeBrowsingStore* unwanted_software_store)
672 : state_manager_(thread_checker_), 672 : state_manager_(thread_checker_),
673 db_state_manager_(thread_checker_),
673 browse_store_(browse_store), 674 browse_store_(browse_store),
674 download_store_(download_store), 675 download_store_(download_store),
675 csd_whitelist_store_(csd_whitelist_store), 676 csd_whitelist_store_(csd_whitelist_store),
676 download_whitelist_store_(download_whitelist_store), 677 download_whitelist_store_(download_whitelist_store),
677 inclusion_whitelist_store_(inclusion_whitelist_store), 678 inclusion_whitelist_store_(inclusion_whitelist_store),
678 extension_blacklist_store_(extension_blacklist_store), 679 extension_blacklist_store_(extension_blacklist_store),
679 side_effect_free_whitelist_store_(side_effect_free_whitelist_store), 680 side_effect_free_whitelist_store_(side_effect_free_whitelist_store),
680 ip_blacklist_store_(ip_blacklist_store), 681 ip_blacklist_store_(ip_blacklist_store),
681 unwanted_software_store_(unwanted_software_store), 682 unwanted_software_store_(unwanted_software_store),
682 corruption_detected_(false),
683 change_detected_(false),
684 reset_factory_(this) { 683 reset_factory_(this) {
685 DCHECK(browse_store_.get()); 684 DCHECK(browse_store_.get());
686 } 685 }
687 686
688 SafeBrowsingDatabaseNew::~SafeBrowsingDatabaseNew() { 687 SafeBrowsingDatabaseNew::~SafeBrowsingDatabaseNew() {
689 // The DCHECK is disabled due to crbug.com/338486 . 688 // The DCHECK is disabled due to crbug.com/338486 .
690 // DCHECK(thread_checker_.CalledOnValidThread()); 689 // DCHECK(thread_checker_.CalledOnValidThread());
691 } 690 }
692 691
693 void SafeBrowsingDatabaseNew::Init(const base::FilePath& filename_base) { 692 void SafeBrowsingDatabaseNew::Init(const base::FilePath& filename_base) {
694 DCHECK(thread_checker_.CalledOnValidThread()); 693 DCHECK(thread_checker_.CalledOnValidThread());
695 694
696 // This should not be run multiple times. 695 db_state_manager_.init_filename_base(filename_base);
697 DCHECK(filename_base_.empty());
698
699 filename_base_ = filename_base;
700 696
701 // TODO(shess): The various stores are really only necessary while doing 697 // TODO(shess): The various stores are really only necessary while doing
702 // updates (see |UpdateFinished()|) or when querying a store directly (see 698 // updates (see |UpdateFinished()|) or when querying a store directly (see
703 // |ContainsDownloadUrl()|). 699 // |ContainsDownloadUrl()|).
704 // The store variables are also tested to see if a list is enabled. Perhaps 700 // The store variables are also tested to see if a list is enabled. Perhaps
705 // the stores could be refactored into an update object so that they are only 701 // the stores could be refactored into an update object so that they are only
706 // live in memory while being actively used. The sense of enabled probably 702 // live in memory while being actively used. The sense of enabled probably
707 // belongs in protocol_manager or database_manager. 703 // belongs in protocol_manager or database_manager.
708 704
709 { 705 {
710 // NOTE: A transaction here is overkill as there are no pointers to this 706 // NOTE: A transaction here is overkill as there are no pointers to this
711 // class on other threads until this function returns, but it's also 707 // class on other threads until this function returns, but it's also
712 // harmless as that also means there is no possibility of contention on the 708 // harmless as that also means there is no possibility of contention on the
713 // lock. 709 // lock.
714 scoped_ptr<WriteTransaction> txn = state_manager_.BeginWriteTransaction(); 710 scoped_ptr<WriteTransaction> txn = state_manager_.BeginWriteTransaction();
715 711
716 txn->clear_prefix_gethash_cache(); 712 txn->clear_prefix_gethash_cache();
717 713
718 browse_store_->Init( 714 browse_store_->Init(
719 BrowseDBFilename(filename_base_), 715 BrowseDBFilename(db_state_manager_.filename_base()),
720 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase, 716 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase,
721 base::Unretained(this))); 717 base::Unretained(this)));
722 718
723 if (unwanted_software_store_.get()) { 719 if (unwanted_software_store_.get()) {
724 unwanted_software_store_->Init( 720 unwanted_software_store_->Init(
725 UnwantedSoftwareDBFilename(filename_base_), 721 UnwantedSoftwareDBFilename(db_state_manager_.filename_base()),
726 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase, 722 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase,
727 base::Unretained(this))); 723 base::Unretained(this)));
728 } 724 }
729 LoadPrefixSet(BrowseDBFilename(filename_base_), txn.get(), 725 LoadPrefixSet(BrowseDBFilename(db_state_manager_.filename_base()),
730 PrefixSetId::BROWSE, FAILURE_BROWSE_PREFIX_SET_READ); 726 txn.get(), PrefixSetId::BROWSE,
727 FAILURE_BROWSE_PREFIX_SET_READ);
731 if (unwanted_software_store_.get()) { 728 if (unwanted_software_store_.get()) {
732 LoadPrefixSet(UnwantedSoftwareDBFilename(filename_base_), txn.get(), 729 LoadPrefixSet(
733 PrefixSetId::UNWANTED_SOFTWARE, 730 UnwantedSoftwareDBFilename(db_state_manager_.filename_base()),
734 FAILURE_UNWANTED_SOFTWARE_PREFIX_SET_READ); 731 txn.get(), PrefixSetId::UNWANTED_SOFTWARE,
732 FAILURE_UNWANTED_SOFTWARE_PREFIX_SET_READ);
735 } 733 }
736 734
737 if (side_effect_free_whitelist_store_.get()) { 735 if (side_effect_free_whitelist_store_.get()) {
738 const base::FilePath side_effect_free_whitelist_filename = 736 const base::FilePath side_effect_free_whitelist_filename =
739 SideEffectFreeWhitelistDBFilename(filename_base_); 737 SideEffectFreeWhitelistDBFilename(db_state_manager_.filename_base());
740 side_effect_free_whitelist_store_->Init( 738 side_effect_free_whitelist_store_->Init(
741 side_effect_free_whitelist_filename, 739 side_effect_free_whitelist_filename,
742 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase, 740 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase,
743 base::Unretained(this))); 741 base::Unretained(this)));
744 742
745 LoadPrefixSet(side_effect_free_whitelist_filename, txn.get(), 743 LoadPrefixSet(side_effect_free_whitelist_filename, txn.get(),
746 PrefixSetId::SIDE_EFFECT_FREE_WHITELIST, 744 PrefixSetId::SIDE_EFFECT_FREE_WHITELIST,
747 FAILURE_SIDE_EFFECT_FREE_WHITELIST_PREFIX_SET_READ); 745 FAILURE_SIDE_EFFECT_FREE_WHITELIST_PREFIX_SET_READ);
748 } else { 746 } else {
749 // Delete any files of the side-effect free sidelist that may be around 747 // Delete any files of the side-effect free sidelist that may be around
750 // from when it was previously enabled. 748 // from when it was previously enabled.
751 SafeBrowsingStoreFile::DeleteStore( 749 SafeBrowsingStoreFile::DeleteStore(
752 SideEffectFreeWhitelistDBFilename(filename_base_)); 750 SideEffectFreeWhitelistDBFilename(db_state_manager_.filename_base()));
753 base::DeleteFile(PrefixSetForFilename( 751 base::DeleteFile(PrefixSetForFilename(SideEffectFreeWhitelistDBFilename(
754 SideEffectFreeWhitelistDBFilename(filename_base_)), 752 db_state_manager_.filename_base())),
755 false); 753 false);
756 } 754 }
757 } 755 }
758 // Note: End the transaction early because LoadWhiteList() and 756 // Note: End the transaction early because LoadWhiteList() and
759 // WhitelistEverything() manage their own transactions. 757 // WhitelistEverything() manage their own transactions.
760 758
761 if (download_store_.get()) { 759 if (download_store_.get()) {
762 download_store_->Init( 760 download_store_->Init(
763 DownloadDBFilename(filename_base_), 761 DownloadDBFilename(db_state_manager_.filename_base()),
764 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase, 762 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase,
765 base::Unretained(this))); 763 base::Unretained(this)));
766 } 764 }
767 765
768 if (csd_whitelist_store_.get()) { 766 if (csd_whitelist_store_.get()) {
769 csd_whitelist_store_->Init( 767 csd_whitelist_store_->Init(
770 CsdWhitelistDBFilename(filename_base_), 768 CsdWhitelistDBFilename(db_state_manager_.filename_base()),
771 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase, 769 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase,
772 base::Unretained(this))); 770 base::Unretained(this)));
773 771
774 std::vector<SBAddFullHash> full_hashes; 772 std::vector<SBAddFullHash> full_hashes;
775 if (csd_whitelist_store_->GetAddFullHashes(&full_hashes)) { 773 if (csd_whitelist_store_->GetAddFullHashes(&full_hashes)) {
776 LoadWhitelist(full_hashes, SBWhitelistId::CSD); 774 LoadWhitelist(full_hashes, SBWhitelistId::CSD);
777 } else { 775 } else {
778 state_manager_.BeginWriteTransaction()->WhitelistEverything( 776 state_manager_.BeginWriteTransaction()->WhitelistEverything(
779 SBWhitelistId::CSD); 777 SBWhitelistId::CSD);
780 } 778 }
781 } else { 779 } else {
782 state_manager_.BeginWriteTransaction()->WhitelistEverything( 780 state_manager_.BeginWriteTransaction()->WhitelistEverything(
783 SBWhitelistId::CSD); // Just to be safe. 781 SBWhitelistId::CSD); // Just to be safe.
784 } 782 }
785 783
786 if (download_whitelist_store_.get()) { 784 if (download_whitelist_store_.get()) {
787 download_whitelist_store_->Init( 785 download_whitelist_store_->Init(
788 DownloadWhitelistDBFilename(filename_base_), 786 DownloadWhitelistDBFilename(db_state_manager_.filename_base()),
789 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase, 787 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase,
790 base::Unretained(this))); 788 base::Unretained(this)));
791 789
792 std::vector<SBAddFullHash> full_hashes; 790 std::vector<SBAddFullHash> full_hashes;
793 if (download_whitelist_store_->GetAddFullHashes(&full_hashes)) { 791 if (download_whitelist_store_->GetAddFullHashes(&full_hashes)) {
794 LoadWhitelist(full_hashes, SBWhitelistId::DOWNLOAD); 792 LoadWhitelist(full_hashes, SBWhitelistId::DOWNLOAD);
795 } else { 793 } else {
796 state_manager_.BeginWriteTransaction()->WhitelistEverything( 794 state_manager_.BeginWriteTransaction()->WhitelistEverything(
797 SBWhitelistId::DOWNLOAD); 795 SBWhitelistId::DOWNLOAD);
798 } 796 }
799 } else { 797 } else {
800 state_manager_.BeginWriteTransaction()->WhitelistEverything( 798 state_manager_.BeginWriteTransaction()->WhitelistEverything(
801 SBWhitelistId::DOWNLOAD); // Just to be safe. 799 SBWhitelistId::DOWNLOAD); // Just to be safe.
802 } 800 }
803 801
804 if (inclusion_whitelist_store_.get()) { 802 if (inclusion_whitelist_store_.get()) {
805 inclusion_whitelist_store_->Init( 803 inclusion_whitelist_store_->Init(
806 InclusionWhitelistDBFilename(filename_base_), 804 InclusionWhitelistDBFilename(db_state_manager_.filename_base()),
807 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase, 805 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase,
808 base::Unretained(this))); 806 base::Unretained(this)));
809 807
810 std::vector<SBAddFullHash> full_hashes; 808 std::vector<SBAddFullHash> full_hashes;
811 if (inclusion_whitelist_store_->GetAddFullHashes(&full_hashes)) { 809 if (inclusion_whitelist_store_->GetAddFullHashes(&full_hashes)) {
812 LoadWhitelist(full_hashes, SBWhitelistId::INCLUSION); 810 LoadWhitelist(full_hashes, SBWhitelistId::INCLUSION);
813 } else { 811 } else {
814 state_manager_.BeginWriteTransaction()->WhitelistEverything( 812 state_manager_.BeginWriteTransaction()->WhitelistEverything(
815 SBWhitelistId::INCLUSION); 813 SBWhitelistId::INCLUSION);
816 } 814 }
817 } else { 815 } else {
818 state_manager_.BeginWriteTransaction()->WhitelistEverything( 816 state_manager_.BeginWriteTransaction()->WhitelistEverything(
819 SBWhitelistId::INCLUSION); // Just to be safe. 817 SBWhitelistId::INCLUSION); // Just to be safe.
820 } 818 }
821 819
822 if (extension_blacklist_store_.get()) { 820 if (extension_blacklist_store_.get()) {
823 extension_blacklist_store_->Init( 821 extension_blacklist_store_->Init(
824 ExtensionBlacklistDBFilename(filename_base_), 822 ExtensionBlacklistDBFilename(db_state_manager_.filename_base()),
825 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase, 823 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase,
826 base::Unretained(this))); 824 base::Unretained(this)));
827 } 825 }
828 826
829 if (ip_blacklist_store_.get()) { 827 if (ip_blacklist_store_.get()) {
830 ip_blacklist_store_->Init( 828 ip_blacklist_store_->Init(
831 IpBlacklistDBFilename(filename_base_), 829 IpBlacklistDBFilename(db_state_manager_.filename_base()),
832 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase, 830 base::Bind(&SafeBrowsingDatabaseNew::HandleCorruptDatabase,
833 base::Unretained(this))); 831 base::Unretained(this)));
834 832
835 std::vector<SBAddFullHash> full_hashes; 833 std::vector<SBAddFullHash> full_hashes;
836 if (ip_blacklist_store_->GetAddFullHashes(&full_hashes)) { 834 if (ip_blacklist_store_->GetAddFullHashes(&full_hashes)) {
837 LoadIpBlacklist(full_hashes); 835 LoadIpBlacklist(full_hashes);
838 } else { 836 } else {
839 LoadIpBlacklist(std::vector<SBAddFullHash>()); // Clear the list. 837 LoadIpBlacklist(std::vector<SBAddFullHash>()); // Clear the list.
840 } 838 }
841 } 839 }
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 chunk_data.FullHashAt(i)); 1129 chunk_data.FullHashAt(i));
1132 } 1130 }
1133 } 1131 }
1134 } 1132 }
1135 1133
1136 void SafeBrowsingDatabaseNew::InsertChunks( 1134 void SafeBrowsingDatabaseNew::InsertChunks(
1137 const std::string& list_name, 1135 const std::string& list_name,
1138 const std::vector<SBChunkData*>& chunks) { 1136 const std::vector<SBChunkData*>& chunks) {
1139 DCHECK(thread_checker_.CalledOnValidThread()); 1137 DCHECK(thread_checker_.CalledOnValidThread());
1140 1138
1141 if (corruption_detected_ || chunks.empty()) 1139 if (db_state_manager_.corruption_detected() || chunks.empty())
1142 return; 1140 return;
1143 1141
1144 const base::TimeTicks before = base::TimeTicks::Now(); 1142 const base::TimeTicks before = base::TimeTicks::Now();
1145 1143
1146 // TODO(shess): The caller should just pass list_id. 1144 // TODO(shess): The caller should just pass list_id.
1147 const safe_browsing_util::ListType list_id = 1145 const safe_browsing_util::ListType list_id =
1148 safe_browsing_util::GetListId(list_name); 1146 safe_browsing_util::GetListId(list_name);
1149 1147
1150 SafeBrowsingStore* store = GetStore(list_id); 1148 SafeBrowsingStore* store = GetStore(list_id);
1151 if (!store) return; 1149 if (!store) return;
1152 1150
1153 change_detected_ = true; 1151 db_state_manager_.set_change_detected();
1154 1152
1155 // TODO(shess): I believe that the list is always add or sub. Can this use 1153 // TODO(shess): I believe that the list is always add or sub. Can this use
1156 // that productively? 1154 // that productively?
1157 store->BeginChunk(); 1155 store->BeginChunk();
1158 for (size_t i = 0; i < chunks.size(); ++i) { 1156 for (size_t i = 0; i < chunks.size(); ++i) {
1159 if (chunks[i]->IsAdd()) { 1157 if (chunks[i]->IsAdd()) {
1160 InsertAddChunk(store, list_id, *chunks[i]); 1158 InsertAddChunk(store, list_id, *chunks[i]);
1161 } else if (chunks[i]->IsSub()) { 1159 } else if (chunks[i]->IsSub()) {
1162 InsertSubChunk(store, list_id, *chunks[i]); 1160 InsertSubChunk(store, list_id, *chunks[i]);
1163 } else { 1161 } else {
1164 NOTREACHED(); 1162 NOTREACHED();
1165 } 1163 }
1166 } 1164 }
1167 store->FinishChunk(); 1165 store->FinishChunk();
1168 1166
1169 UMA_HISTOGRAM_TIMES("SB2.ChunkInsert", base::TimeTicks::Now() - before); 1167 UMA_HISTOGRAM_TIMES("SB2.ChunkInsert", base::TimeTicks::Now() - before);
1170 } 1168 }
1171 1169
1172 void SafeBrowsingDatabaseNew::DeleteChunks( 1170 void SafeBrowsingDatabaseNew::DeleteChunks(
1173 const std::vector<SBChunkDelete>& chunk_deletes) { 1171 const std::vector<SBChunkDelete>& chunk_deletes) {
1174 DCHECK(thread_checker_.CalledOnValidThread()); 1172 DCHECK(thread_checker_.CalledOnValidThread());
1175 1173
1176 if (corruption_detected_ || chunk_deletes.empty()) 1174 if (db_state_manager_.corruption_detected() || chunk_deletes.empty())
1177 return; 1175 return;
1178 1176
1179 const std::string& list_name = chunk_deletes.front().list_name; 1177 const std::string& list_name = chunk_deletes.front().list_name;
1180 const safe_browsing_util::ListType list_id = 1178 const safe_browsing_util::ListType list_id =
1181 safe_browsing_util::GetListId(list_name); 1179 safe_browsing_util::GetListId(list_name);
1182 1180
1183 SafeBrowsingStore* store = GetStore(list_id); 1181 SafeBrowsingStore* store = GetStore(list_id);
1184 if (!store) return; 1182 if (!store) return;
1185 1183
1186 change_detected_ = true; 1184 db_state_manager_.set_change_detected();
1187 1185
1188 for (size_t i = 0; i < chunk_deletes.size(); ++i) { 1186 for (size_t i = 0; i < chunk_deletes.size(); ++i) {
1189 std::vector<int> chunk_numbers; 1187 std::vector<int> chunk_numbers;
1190 RangesToChunks(chunk_deletes[i].chunk_del, &chunk_numbers); 1188 RangesToChunks(chunk_deletes[i].chunk_del, &chunk_numbers);
1191 for (size_t j = 0; j < chunk_numbers.size(); ++j) { 1189 for (size_t j = 0; j < chunk_numbers.size(); ++j) {
1192 const int encoded_chunk_id = EncodeChunkId(chunk_numbers[j], list_id); 1190 const int encoded_chunk_id = EncodeChunkId(chunk_numbers[j], list_id);
1193 if (chunk_deletes[i].is_sub_del) 1191 if (chunk_deletes[i].is_sub_del)
1194 store->DeleteSubChunk(encoded_chunk_id); 1192 store->DeleteSubChunk(encoded_chunk_id);
1195 else 1193 else
1196 store->DeleteAddChunk(encoded_chunk_id); 1194 store->DeleteAddChunk(encoded_chunk_id);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 UpdateChunkRangesForList(side_effect_free_whitelist_store_.get(), 1313 UpdateChunkRangesForList(side_effect_free_whitelist_store_.get(),
1316 safe_browsing_util::kSideEffectFreeWhitelist, lists); 1314 safe_browsing_util::kSideEffectFreeWhitelist, lists);
1317 1315
1318 UpdateChunkRangesForList(ip_blacklist_store_.get(), 1316 UpdateChunkRangesForList(ip_blacklist_store_.get(),
1319 safe_browsing_util::kIPBlacklist, lists); 1317 safe_browsing_util::kIPBlacklist, lists);
1320 1318
1321 UpdateChunkRangesForList(unwanted_software_store_.get(), 1319 UpdateChunkRangesForList(unwanted_software_store_.get(),
1322 safe_browsing_util::kUnwantedUrlList, 1320 safe_browsing_util::kUnwantedUrlList,
1323 lists); 1321 lists);
1324 1322
1325 corruption_detected_ = false; 1323 db_state_manager_.reset_corruption_detected();
1326 change_detected_ = false; 1324 db_state_manager_.reset_change_detected();
1327 return true; 1325 return true;
1328 } 1326 }
1329 1327
1330 void SafeBrowsingDatabaseNew::UpdateFinished(bool update_succeeded) { 1328 void SafeBrowsingDatabaseNew::UpdateFinished(bool update_succeeded) {
1331 DCHECK(thread_checker_.CalledOnValidThread()); 1329 DCHECK(thread_checker_.CalledOnValidThread());
1332 1330
1333 // The update may have failed due to corrupt storage (for instance, 1331 // The update may have failed due to corrupt storage (for instance,
1334 // an excessive number of invalid add_chunks and sub_chunks). 1332 // an excessive number of invalid add_chunks and sub_chunks).
1335 // Double-check that the databases are valid. 1333 // Double-check that the databases are valid.
1336 // TODO(shess): Providing a checksum for the add_chunk and sub_chunk 1334 // TODO(shess): Providing a checksum for the add_chunk and sub_chunk
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 if (ip_blacklist_store_ && !ip_blacklist_store_->CheckValidity()) { 1368 if (ip_blacklist_store_ && !ip_blacklist_store_->CheckValidity()) {
1371 DLOG(ERROR) << "Safe-browsing IP blacklist database corrupt."; 1369 DLOG(ERROR) << "Safe-browsing IP blacklist database corrupt.";
1372 } 1370 }
1373 1371
1374 if (unwanted_software_store_ && 1372 if (unwanted_software_store_ &&
1375 !unwanted_software_store_->CheckValidity()) { 1373 !unwanted_software_store_->CheckValidity()) {
1376 DLOG(ERROR) << "Unwanted software url list database corrupt."; 1374 DLOG(ERROR) << "Unwanted software url list database corrupt.";
1377 } 1375 }
1378 } 1376 }
1379 1377
1380 if (corruption_detected_) 1378 if (db_state_manager_.corruption_detected())
1381 return; 1379 return;
1382 1380
1383 // Unroll the transaction if there was a protocol error or if the 1381 // Unroll the transaction if there was a protocol error or if the
1384 // transaction was empty. This will leave the prefix set, the 1382 // transaction was empty. This will leave the prefix set, the
1385 // pending hashes, and the prefix miss cache in place. 1383 // pending hashes, and the prefix miss cache in place.
1386 if (!update_succeeded || !change_detected_) { 1384 if (!update_succeeded || !db_state_manager_.change_detected()) {
1387 // Track empty updates to answer questions at http://crbug.com/72216 . 1385 // Track empty updates to answer questions at http://crbug.com/72216 .
1388 if (update_succeeded && !change_detected_) 1386 if (update_succeeded && !db_state_manager_.change_detected())
1389 UMA_HISTOGRAM_COUNTS("SB2.DatabaseUpdateKilobytes", 0); 1387 UMA_HISTOGRAM_COUNTS("SB2.DatabaseUpdateKilobytes", 0);
1390 browse_store_->CancelUpdate(); 1388 browse_store_->CancelUpdate();
1391 if (download_store_.get()) 1389 if (download_store_.get())
1392 download_store_->CancelUpdate(); 1390 download_store_->CancelUpdate();
1393 if (csd_whitelist_store_.get()) 1391 if (csd_whitelist_store_.get())
1394 csd_whitelist_store_->CancelUpdate(); 1392 csd_whitelist_store_->CancelUpdate();
1395 if (download_whitelist_store_.get()) 1393 if (download_whitelist_store_.get())
1396 download_whitelist_store_->CancelUpdate(); 1394 download_whitelist_store_->CancelUpdate();
1397 if (inclusion_whitelist_store_.get()) 1395 if (inclusion_whitelist_store_.get())
1398 inclusion_whitelist_store_->CancelUpdate(); 1396 inclusion_whitelist_store_->CancelUpdate();
1399 if (extension_blacklist_store_) 1397 if (extension_blacklist_store_)
1400 extension_blacklist_store_->CancelUpdate(); 1398 extension_blacklist_store_->CancelUpdate();
1401 if (side_effect_free_whitelist_store_) 1399 if (side_effect_free_whitelist_store_)
1402 side_effect_free_whitelist_store_->CancelUpdate(); 1400 side_effect_free_whitelist_store_->CancelUpdate();
1403 if (ip_blacklist_store_) 1401 if (ip_blacklist_store_)
1404 ip_blacklist_store_->CancelUpdate(); 1402 ip_blacklist_store_->CancelUpdate();
1405 if (unwanted_software_store_) 1403 if (unwanted_software_store_)
1406 unwanted_software_store_->CancelUpdate(); 1404 unwanted_software_store_->CancelUpdate();
1407 return; 1405 return;
1408 } 1406 }
1409 1407
1410 if (download_store_) { 1408 if (download_store_) {
1411 UpdateHashPrefixStore(DownloadDBFilename(filename_base_), 1409 UpdateHashPrefixStore(DownloadDBFilename(db_state_manager_.filename_base()),
1412 download_store_.get(), 1410 download_store_.get(),
1413 FAILURE_DOWNLOAD_DATABASE_UPDATE_FINISH); 1411 FAILURE_DOWNLOAD_DATABASE_UPDATE_FINISH);
1414 } 1412 }
1415 1413
1416 UpdatePrefixSetUrlStore(BrowseDBFilename(filename_base_), 1414 UpdatePrefixSetUrlStore(BrowseDBFilename(db_state_manager_.filename_base()),
1417 browse_store_.get(), 1415 browse_store_.get(), PrefixSetId::BROWSE,
1418 PrefixSetId::BROWSE,
1419 FAILURE_BROWSE_DATABASE_UPDATE_FINISH, 1416 FAILURE_BROWSE_DATABASE_UPDATE_FINISH,
1420 FAILURE_BROWSE_PREFIX_SET_WRITE, 1417 FAILURE_BROWSE_PREFIX_SET_WRITE, true);
1421 true);
1422 1418
1423 UpdateWhitelistStore(CsdWhitelistDBFilename(filename_base_), 1419 UpdateWhitelistStore(
1424 csd_whitelist_store_.get(), 1420 CsdWhitelistDBFilename(db_state_manager_.filename_base()),
1425 SBWhitelistId::CSD); 1421 csd_whitelist_store_.get(), SBWhitelistId::CSD);
1426 UpdateWhitelistStore(DownloadWhitelistDBFilename(filename_base_), 1422 UpdateWhitelistStore(
1427 download_whitelist_store_.get(), 1423 DownloadWhitelistDBFilename(db_state_manager_.filename_base()),
1428 SBWhitelistId::DOWNLOAD); 1424 download_whitelist_store_.get(), SBWhitelistId::DOWNLOAD);
1429 UpdateWhitelistStore(InclusionWhitelistDBFilename(filename_base_), 1425 UpdateWhitelistStore(
1430 inclusion_whitelist_store_.get(), 1426 InclusionWhitelistDBFilename(db_state_manager_.filename_base()),
1431 SBWhitelistId::INCLUSION); 1427 inclusion_whitelist_store_.get(), SBWhitelistId::INCLUSION);
1432 1428
1433 if (extension_blacklist_store_) { 1429 if (extension_blacklist_store_) {
1434 UpdateHashPrefixStore(ExtensionBlacklistDBFilename(filename_base_), 1430 UpdateHashPrefixStore(
1435 extension_blacklist_store_.get(), 1431 ExtensionBlacklistDBFilename(db_state_manager_.filename_base()),
1436 FAILURE_EXTENSION_BLACKLIST_UPDATE_FINISH); 1432 extension_blacklist_store_.get(),
1433 FAILURE_EXTENSION_BLACKLIST_UPDATE_FINISH);
1437 } 1434 }
1438 1435
1439 if (side_effect_free_whitelist_store_) { 1436 if (side_effect_free_whitelist_store_) {
1440 UpdatePrefixSetUrlStore(SideEffectFreeWhitelistDBFilename(filename_base_), 1437 UpdatePrefixSetUrlStore(
1441 side_effect_free_whitelist_store_.get(), 1438 SideEffectFreeWhitelistDBFilename(db_state_manager_.filename_base()),
1442 PrefixSetId::SIDE_EFFECT_FREE_WHITELIST, 1439 side_effect_free_whitelist_store_.get(),
1443 FAILURE_SIDE_EFFECT_FREE_WHITELIST_UPDATE_FINISH, 1440 PrefixSetId::SIDE_EFFECT_FREE_WHITELIST,
1444 FAILURE_SIDE_EFFECT_FREE_WHITELIST_PREFIX_SET_WRITE, 1441 FAILURE_SIDE_EFFECT_FREE_WHITELIST_UPDATE_FINISH,
1445 false); 1442 FAILURE_SIDE_EFFECT_FREE_WHITELIST_PREFIX_SET_WRITE, false);
1446 } 1443 }
1447 1444
1448 if (ip_blacklist_store_) 1445 if (ip_blacklist_store_)
1449 UpdateIpBlacklistStore(); 1446 UpdateIpBlacklistStore();
1450 1447
1451 if (unwanted_software_store_) { 1448 if (unwanted_software_store_) {
1452 UpdatePrefixSetUrlStore(UnwantedSoftwareDBFilename(filename_base_), 1449 UpdatePrefixSetUrlStore(
1453 unwanted_software_store_.get(), 1450 UnwantedSoftwareDBFilename(db_state_manager_.filename_base()),
1454 PrefixSetId::UNWANTED_SOFTWARE, 1451 unwanted_software_store_.get(), PrefixSetId::UNWANTED_SOFTWARE,
1455 FAILURE_UNWANTED_SOFTWARE_DATABASE_UPDATE_FINISH, 1452 FAILURE_UNWANTED_SOFTWARE_DATABASE_UPDATE_FINISH,
1456 FAILURE_UNWANTED_SOFTWARE_PREFIX_SET_WRITE, 1453 FAILURE_UNWANTED_SOFTWARE_PREFIX_SET_WRITE, true);
1457 true);
1458 } 1454 }
1459 } 1455 }
1460 1456
1461 void SafeBrowsingDatabaseNew::UpdateWhitelistStore( 1457 void SafeBrowsingDatabaseNew::UpdateWhitelistStore(
1462 const base::FilePath& store_filename, 1458 const base::FilePath& store_filename,
1463 SafeBrowsingStore* store, 1459 SafeBrowsingStore* store,
1464 SBWhitelistId whitelist_id) { 1460 SBWhitelistId whitelist_id) {
1465 DCHECK(thread_checker_.CalledOnValidThread()); 1461 DCHECK(thread_checker_.CalledOnValidThread());
1466 1462
1467 if (!store) 1463 if (!store)
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 // stores all full-length hashes as both full and prefix hashes. 1596 // stores all full-length hashes as both full and prefix hashes.
1601 PrefixSetBuilder builder; 1597 PrefixSetBuilder builder;
1602 std::vector<SBAddFullHash> full_hashes; 1598 std::vector<SBAddFullHash> full_hashes;
1603 if (!ip_blacklist_store_->FinishUpdate(&builder, &full_hashes)) { 1599 if (!ip_blacklist_store_->FinishUpdate(&builder, &full_hashes)) {
1604 RecordFailure(FAILURE_IP_BLACKLIST_UPDATE_FINISH); 1600 RecordFailure(FAILURE_IP_BLACKLIST_UPDATE_FINISH);
1605 LoadIpBlacklist(std::vector<SBAddFullHash>()); // Clear the list. 1601 LoadIpBlacklist(std::vector<SBAddFullHash>()); // Clear the list.
1606 return; 1602 return;
1607 } 1603 }
1608 1604
1609 const base::FilePath ip_blacklist_filename = 1605 const base::FilePath ip_blacklist_filename =
1610 IpBlacklistDBFilename(filename_base_); 1606 IpBlacklistDBFilename(db_state_manager_.filename_base());
1611 1607
1612 RecordFileSizeHistogram(ip_blacklist_filename); 1608 RecordFileSizeHistogram(ip_blacklist_filename);
1613 1609
1614 #if defined(OS_MACOSX) 1610 #if defined(OS_MACOSX)
1615 base::mac::SetFileBackupExclusion(ip_blacklist_filename); 1611 base::mac::SetFileBackupExclusion(ip_blacklist_filename);
1616 #endif 1612 #endif
1617 1613
1618 LoadIpBlacklist(full_hashes); 1614 LoadIpBlacklist(full_hashes);
1619 } 1615 }
1620 1616
1621 void SafeBrowsingDatabaseNew::HandleCorruptDatabase() { 1617 void SafeBrowsingDatabaseNew::HandleCorruptDatabase() {
1622 DCHECK(thread_checker_.CalledOnValidThread()); 1618 DCHECK(thread_checker_.CalledOnValidThread());
1623 1619
1624 // Reset the database after the current task has unwound (but only 1620 // Reset the database after the current task has unwound (but only
1625 // reset once within the scope of a given task). 1621 // reset once within the scope of a given task).
1626 if (!reset_factory_.HasWeakPtrs()) { 1622 if (!reset_factory_.HasWeakPtrs()) {
1627 RecordFailure(FAILURE_DATABASE_CORRUPT); 1623 RecordFailure(FAILURE_DATABASE_CORRUPT);
1628 base::MessageLoop::current()->PostTask(FROM_HERE, 1624 base::MessageLoop::current()->PostTask(FROM_HERE,
1629 base::Bind(&SafeBrowsingDatabaseNew::OnHandleCorruptDatabase, 1625 base::Bind(&SafeBrowsingDatabaseNew::OnHandleCorruptDatabase,
1630 reset_factory_.GetWeakPtr())); 1626 reset_factory_.GetWeakPtr()));
1631 } 1627 }
1632 } 1628 }
1633 1629
1634 void SafeBrowsingDatabaseNew::OnHandleCorruptDatabase() { 1630 void SafeBrowsingDatabaseNew::OnHandleCorruptDatabase() {
1635 DCHECK(thread_checker_.CalledOnValidThread()); 1631 DCHECK(thread_checker_.CalledOnValidThread());
1636 1632
1637 RecordFailure(FAILURE_DATABASE_CORRUPT_HANDLER); 1633 RecordFailure(FAILURE_DATABASE_CORRUPT_HANDLER);
1638 corruption_detected_ = true; // Stop updating the database. 1634 db_state_manager_.set_corruption_detected(); // Stop updating the database.
1639 ResetDatabase(); 1635 ResetDatabase();
1640 1636
1641 // NOTE(shess): ResetDatabase() should remove the corruption, so this should 1637 // NOTE(shess): ResetDatabase() should remove the corruption, so this should
1642 // only happen once. If you are here because you are hitting this after a 1638 // only happen once. If you are here because you are hitting this after a
1643 // restart, then I would be very interested in working with you to figure out 1639 // restart, then I would be very interested in working with you to figure out
1644 // what is happening, since it may affect real users. 1640 // what is happening, since it may affect real users.
1645 DLOG(FATAL) << "SafeBrowsing database was corrupt and reset"; 1641 DLOG(FATAL) << "SafeBrowsing database was corrupt and reset";
1646 } 1642 }
1647 1643
1648 // TODO(shess): I'm not clear why this code doesn't have any 1644 // TODO(shess): I'm not clear why this code doesn't have any
1649 // real error-handling. 1645 // real error-handling.
1650 void SafeBrowsingDatabaseNew::LoadPrefixSet(const base::FilePath& db_filename, 1646 void SafeBrowsingDatabaseNew::LoadPrefixSet(const base::FilePath& db_filename,
1651 WriteTransaction* txn, 1647 WriteTransaction* txn,
1652 PrefixSetId prefix_set_id, 1648 PrefixSetId prefix_set_id,
1653 FailureType read_failure_type) { 1649 FailureType read_failure_type) {
1654 DCHECK(thread_checker_.CalledOnValidThread()); 1650 DCHECK(thread_checker_.CalledOnValidThread());
1655 DCHECK(txn); 1651 DCHECK(txn);
1656 DCHECK(!filename_base_.empty()); 1652 DCHECK(!db_state_manager_.filename_base().empty());
1657 1653
1658 // Only use the prefix set if database is present and non-empty. 1654 // Only use the prefix set if database is present and non-empty.
1659 if (!GetFileSizeOrZero(db_filename)) 1655 if (!GetFileSizeOrZero(db_filename))
1660 return; 1656 return;
1661 1657
1662 // Cleanup any stale bloom filter (no longer used). 1658 // Cleanup any stale bloom filter (no longer used).
1663 // TODO(shess): Track existence to drive removal of this code? 1659 // TODO(shess): Track existence to drive removal of this code?
1664 const base::FilePath bloom_filter_filename = 1660 const base::FilePath bloom_filter_filename =
1665 BloomFilterForFilename(db_filename); 1661 BloomFilterForFilename(db_filename);
1666 base::DeleteFile(bloom_filter_filename, false); 1662 base::DeleteFile(bloom_filter_filename, false);
1667 1663
1668 const base::TimeTicks before = base::TimeTicks::Now(); 1664 const base::TimeTicks before = base::TimeTicks::Now();
1669 scoped_ptr<const PrefixSet> new_prefix_set = 1665 scoped_ptr<const PrefixSet> new_prefix_set =
1670 PrefixSet::LoadFile(PrefixSetForFilename(db_filename)); 1666 PrefixSet::LoadFile(PrefixSetForFilename(db_filename));
1671 if (!new_prefix_set.get()) 1667 if (!new_prefix_set.get())
1672 RecordFailure(read_failure_type); 1668 RecordFailure(read_failure_type);
1673 txn->SwapPrefixSet(prefix_set_id, new_prefix_set.Pass()); 1669 txn->SwapPrefixSet(prefix_set_id, new_prefix_set.Pass());
1674 UMA_HISTOGRAM_TIMES("SB2.PrefixSetLoad", base::TimeTicks::Now() - before); 1670 UMA_HISTOGRAM_TIMES("SB2.PrefixSetLoad", base::TimeTicks::Now() - before);
1675 } 1671 }
1676 1672
1677 bool SafeBrowsingDatabaseNew::Delete() { 1673 bool SafeBrowsingDatabaseNew::Delete() {
1678 DCHECK(thread_checker_.CalledOnValidThread()); 1674 DCHECK(thread_checker_.CalledOnValidThread());
1679 DCHECK(!filename_base_.empty()); 1675 DCHECK(!db_state_manager_.filename_base().empty());
1680 1676
1681 // TODO(shess): This is a mess. SafeBrowsingFileStore::Delete() closes the 1677 // TODO(shess): This is a mess. SafeBrowsingFileStore::Delete() closes the
1682 // store before calling DeleteStore(). DeleteStore() deletes transient files 1678 // store before calling DeleteStore(). DeleteStore() deletes transient files
1683 // in addition to the main file. Probably all of these should be converted to 1679 // in addition to the main file. Probably all of these should be converted to
1684 // a helper which calls Delete() if the store exists, else DeleteStore() on 1680 // a helper which calls Delete() if the store exists, else DeleteStore() on
1685 // the generated filename. 1681 // the generated filename.
1686 1682
1687 // TODO(shess): Determine if the histograms are useful in any way. I cannot 1683 // TODO(shess): Determine if the histograms are useful in any way. I cannot
1688 // recall any action taken as a result of their values, in which case it might 1684 // recall any action taken as a result of their values, in which case it might
1689 // make more sense to histogram an overall thumbs-up/-down and just dig deeper 1685 // make more sense to histogram an overall thumbs-up/-down and just dig deeper
(...skipping 15 matching lines...) Expand all
1705 const bool r4 = download_whitelist_store_.get() ? 1701 const bool r4 = download_whitelist_store_.get() ?
1706 download_whitelist_store_->Delete() : true; 1702 download_whitelist_store_->Delete() : true;
1707 if (!r4) 1703 if (!r4)
1708 RecordFailure(FAILURE_DATABASE_STORE_DELETE); 1704 RecordFailure(FAILURE_DATABASE_STORE_DELETE);
1709 1705
1710 const bool r5 = inclusion_whitelist_store_.get() ? 1706 const bool r5 = inclusion_whitelist_store_.get() ?
1711 inclusion_whitelist_store_->Delete() : true; 1707 inclusion_whitelist_store_->Delete() : true;
1712 if (!r5) 1708 if (!r5)
1713 RecordFailure(FAILURE_DATABASE_STORE_DELETE); 1709 RecordFailure(FAILURE_DATABASE_STORE_DELETE);
1714 1710
1715 const base::FilePath browse_filename = BrowseDBFilename(filename_base_); 1711 const base::FilePath browse_filename =
1712 BrowseDBFilename(db_state_manager_.filename_base());
1716 const base::FilePath bloom_filter_filename = 1713 const base::FilePath bloom_filter_filename =
1717 BloomFilterForFilename(browse_filename); 1714 BloomFilterForFilename(browse_filename);
1718 const bool r6 = base::DeleteFile(bloom_filter_filename, false); 1715 const bool r6 = base::DeleteFile(bloom_filter_filename, false);
1719 if (!r6) 1716 if (!r6)
1720 RecordFailure(FAILURE_DATABASE_FILTER_DELETE); 1717 RecordFailure(FAILURE_DATABASE_FILTER_DELETE);
1721 1718
1722 const base::FilePath browse_prefix_set_filename = 1719 const base::FilePath browse_prefix_set_filename =
1723 PrefixSetForFilename(browse_filename); 1720 PrefixSetForFilename(browse_filename);
1724 const bool r7 = base::DeleteFile(browse_prefix_set_filename, false); 1721 const bool r7 = base::DeleteFile(browse_prefix_set_filename, false);
1725 if (!r7) 1722 if (!r7)
1726 RecordFailure(FAILURE_BROWSE_PREFIX_SET_DELETE); 1723 RecordFailure(FAILURE_BROWSE_PREFIX_SET_DELETE);
1727 1724
1728 const base::FilePath extension_blacklist_filename = 1725 const base::FilePath extension_blacklist_filename =
1729 ExtensionBlacklistDBFilename(filename_base_); 1726 ExtensionBlacklistDBFilename(db_state_manager_.filename_base());
1730 const bool r8 = base::DeleteFile(extension_blacklist_filename, false); 1727 const bool r8 = base::DeleteFile(extension_blacklist_filename, false);
1731 if (!r8) 1728 if (!r8)
1732 RecordFailure(FAILURE_EXTENSION_BLACKLIST_DELETE); 1729 RecordFailure(FAILURE_EXTENSION_BLACKLIST_DELETE);
1733 1730
1734 const base::FilePath side_effect_free_whitelist_filename = 1731 const base::FilePath side_effect_free_whitelist_filename =
1735 SideEffectFreeWhitelistDBFilename(filename_base_); 1732 SideEffectFreeWhitelistDBFilename(db_state_manager_.filename_base());
1736 const bool r9 = base::DeleteFile(side_effect_free_whitelist_filename, 1733 const bool r9 = base::DeleteFile(side_effect_free_whitelist_filename,
1737 false); 1734 false);
1738 if (!r9) 1735 if (!r9)
1739 RecordFailure(FAILURE_SIDE_EFFECT_FREE_WHITELIST_DELETE); 1736 RecordFailure(FAILURE_SIDE_EFFECT_FREE_WHITELIST_DELETE);
1740 1737
1741 const base::FilePath side_effect_free_whitelist_prefix_set_filename = 1738 const base::FilePath side_effect_free_whitelist_prefix_set_filename =
1742 PrefixSetForFilename(side_effect_free_whitelist_filename); 1739 PrefixSetForFilename(side_effect_free_whitelist_filename);
1743 const bool r10 = base::DeleteFile( 1740 const bool r10 = base::DeleteFile(
1744 side_effect_free_whitelist_prefix_set_filename, 1741 side_effect_free_whitelist_prefix_set_filename,
1745 false); 1742 false);
1746 if (!r10) 1743 if (!r10)
1747 RecordFailure(FAILURE_SIDE_EFFECT_FREE_WHITELIST_PREFIX_SET_DELETE); 1744 RecordFailure(FAILURE_SIDE_EFFECT_FREE_WHITELIST_PREFIX_SET_DELETE);
1748 1745
1749 const bool r11 = base::DeleteFile(IpBlacklistDBFilename(filename_base_), 1746 const bool r11 = base::DeleteFile(
1750 false); 1747 IpBlacklistDBFilename(db_state_manager_.filename_base()), false);
1751 if (!r11) 1748 if (!r11)
1752 RecordFailure(FAILURE_IP_BLACKLIST_DELETE); 1749 RecordFailure(FAILURE_IP_BLACKLIST_DELETE);
1753 1750
1754 const bool r12 = 1751 const bool r12 = base::DeleteFile(
1755 base::DeleteFile(UnwantedSoftwareDBFilename(filename_base_), false); 1752 UnwantedSoftwareDBFilename(db_state_manager_.filename_base()), false);
1756 if (!r12) 1753 if (!r12)
1757 RecordFailure(FAILURE_UNWANTED_SOFTWARE_PREFIX_SET_DELETE); 1754 RecordFailure(FAILURE_UNWANTED_SOFTWARE_PREFIX_SET_DELETE);
1758 1755
1759 return r1 && r2 && r3 && r4 && r5 && r6 && r7 && r8 && r9 && r10 && r11 && 1756 return r1 && r2 && r3 && r4 && r5 && r6 && r7 && r8 && r9 && r10 && r11 &&
1760 r12; 1757 r12;
1761 } 1758 }
1762 1759
1763 void SafeBrowsingDatabaseNew::WritePrefixSet(const base::FilePath& db_filename, 1760 void SafeBrowsingDatabaseNew::WritePrefixSet(const base::FilePath& db_filename,
1764 PrefixSetId prefix_set_id, 1761 PrefixSetId prefix_set_id,
1765 FailureType write_failure_type) { 1762 FailureType write_failure_type) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1921 else 1918 else
1922 NOTREACHED(); // Add support for new lists above. 1919 NOTREACHED(); // Add support for new lists above.
1923 1920
1924 // Histogram properties as in UMA_HISTOGRAM_COUNTS macro. 1921 // Histogram properties as in UMA_HISTOGRAM_COUNTS macro.
1925 base::HistogramBase* histogram_pointer = base::Histogram::FactoryGet( 1922 base::HistogramBase* histogram_pointer = base::Histogram::FactoryGet(
1926 histogram_name, 1, 1000000, 50, 1923 histogram_name, 1, 1000000, 50,
1927 base::HistogramBase::kUmaTargetedHistogramFlag); 1924 base::HistogramBase::kUmaTargetedHistogramFlag);
1928 1925
1929 histogram_pointer->Add(file_size_kilobytes); 1926 histogram_pointer->Add(file_size_kilobytes);
1930 } 1927 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_database.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698