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

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

Issue 1807253002: Properly handle the Module SBDatabase when it's corrupted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 return false; 834 return false;
835 835
836 // Reset objects in memory. 836 // Reset objects in memory.
837 scoped_ptr<WriteTransaction> txn = state_manager_.BeginWriteTransaction(); 837 scoped_ptr<WriteTransaction> txn = state_manager_.BeginWriteTransaction();
838 txn->clear_prefix_gethash_cache(); 838 txn->clear_prefix_gethash_cache();
839 txn->SwapPrefixSet(PrefixSetId::BROWSE, nullptr); 839 txn->SwapPrefixSet(PrefixSetId::BROWSE, nullptr);
840 txn->SwapPrefixSet(PrefixSetId::UNWANTED_SOFTWARE, nullptr); 840 txn->SwapPrefixSet(PrefixSetId::UNWANTED_SOFTWARE, nullptr);
841 txn->clear_ip_blacklist(); 841 txn->clear_ip_blacklist();
842 txn->WhitelistEverything(SBWhitelistId::CSD); 842 txn->WhitelistEverything(SBWhitelistId::CSD);
843 txn->WhitelistEverything(SBWhitelistId::DOWNLOAD); 843 txn->WhitelistEverything(SBWhitelistId::DOWNLOAD);
844 txn->WhitelistEverything(SBWhitelistId::MODULE);
844 return true; 845 return true;
845 } 846 }
846 847
847 bool SafeBrowsingDatabaseNew::ContainsBrowseUrl( 848 bool SafeBrowsingDatabaseNew::ContainsBrowseUrl(
848 const GURL& url, 849 const GURL& url,
849 std::vector<SBPrefix>* prefix_hits, 850 std::vector<SBPrefix>* prefix_hits,
850 std::vector<SBFullHashResult>* cache_hits) { 851 std::vector<SBFullHashResult>* cache_hits) {
851 return PrefixSetContainsUrl(url, PrefixSetId::BROWSE, prefix_hits, 852 return PrefixSetContainsUrl(url, PrefixSetId::BROWSE, prefix_hits,
852 cache_hits); 853 cache_hits);
853 } 854 }
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 const bool r10 = base::DeleteFile( 1724 const bool r10 = base::DeleteFile(
1724 UnwantedSoftwareDBFilename(db_state_manager_.filename_base()), false); 1725 UnwantedSoftwareDBFilename(db_state_manager_.filename_base()), false);
1725 if (!r10) 1726 if (!r10)
1726 RecordFailure(FAILURE_UNWANTED_SOFTWARE_PREFIX_SET_DELETE); 1727 RecordFailure(FAILURE_UNWANTED_SOFTWARE_PREFIX_SET_DELETE);
1727 1728
1728 const bool r11 = base::DeleteFile( 1729 const bool r11 = base::DeleteFile(
1729 ResourceBlacklistDBFilename(db_state_manager_.filename_base()), false); 1730 ResourceBlacklistDBFilename(db_state_manager_.filename_base()), false);
1730 if (!r11) 1731 if (!r11)
1731 RecordFailure(FAILURE_RESOURCE_BLACKLIST_DELETE); 1732 RecordFailure(FAILURE_RESOURCE_BLACKLIST_DELETE);
1732 1733
1733 return r1 && r2 && r3 && r4 && r5 && r6 && r7 && r8 && r9 && r10 && r11; 1734 const bool r12 =
1735 module_whitelist_store_.get() ? module_whitelist_store_->Delete() : true;
Nathan Parker 2016/03/17 16:46:39 This seems better than the above methods, overall,
proberge 2016/03/17 18:11:00 It's the same as the other whitelist delete logic
1736 if (!r12)
1737 RecordFailure(FAILURE_MODULE_WHITELIST_DELETE);
1738
1739 return r1 && r2 && r3 && r4 && r5 && r6 && r7 && r8 && r9 && r10 && r11 &&
1740 r12;
1734 } 1741 }
1735 1742
1736 void SafeBrowsingDatabaseNew::WritePrefixSet(const base::FilePath& db_filename, 1743 void SafeBrowsingDatabaseNew::WritePrefixSet(const base::FilePath& db_filename,
1737 PrefixSetId prefix_set_id, 1744 PrefixSetId prefix_set_id,
1738 FailureType write_failure_type) { 1745 FailureType write_failure_type) {
1739 DCHECK(db_task_runner_->RunsTasksOnCurrentThread()); 1746 DCHECK(db_task_runner_->RunsTasksOnCurrentThread());
1740 1747
1741 // Do not grab the lock to avoid contention while writing to disk. This is 1748 // Do not grab the lock to avoid contention while writing to disk. This is
1742 // safe as only this task runner can ever modify |state_manager_|'s prefix 1749 // safe as only this task runner can ever modify |state_manager_|'s prefix
1743 // sets anyways. 1750 // sets anyways.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 1921
1915 // Histogram properties as in UMA_HISTOGRAM_COUNTS macro. 1922 // Histogram properties as in UMA_HISTOGRAM_COUNTS macro.
1916 base::HistogramBase* histogram_pointer = base::Histogram::FactoryGet( 1923 base::HistogramBase* histogram_pointer = base::Histogram::FactoryGet(
1917 histogram_name, 1, 1000000, 50, 1924 histogram_name, 1, 1000000, 50,
1918 base::HistogramBase::kUmaTargetedHistogramFlag); 1925 base::HistogramBase::kUmaTargetedHistogramFlag);
1919 1926
1920 histogram_pointer->Add(file_size_kilobytes); 1927 histogram_pointer->Add(file_size_kilobytes);
1921 } 1928 }
1922 1929
1923 } // namespace safe_browsing 1930 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698