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 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1785 | 1785 |
1786 void SafeBrowsingDatabaseNew::RecordFileSizeHistogram( | 1786 void SafeBrowsingDatabaseNew::RecordFileSizeHistogram( |
1787 const base::FilePath& file_path) { | 1787 const base::FilePath& file_path) { |
1788 const int64 file_size = GetFileSizeOrZero(file_path); | 1788 const int64 file_size = GetFileSizeOrZero(file_path); |
1789 const int file_size_kilobytes = static_cast<int>(file_size / 1024); | 1789 const int file_size_kilobytes = static_cast<int>(file_size / 1024); |
1790 | 1790 |
1791 base::FilePath::StringType filename = file_path.BaseName().value(); | 1791 base::FilePath::StringType filename = file_path.BaseName().value(); |
1792 | 1792 |
1793 // Default to logging DB sizes unless |file_path| points at PrefixSet storage. | 1793 // Default to logging DB sizes unless |file_path| points at PrefixSet storage. |
1794 std::string histogram_name("SB2.DatabaseSizeKilobytes"); | 1794 std::string histogram_name("SB2.DatabaseSizeKilobytes"); |
1795 if (base::EndsWith(filename, kPrefixSetFileSuffix, true)) { | 1795 if (base::EndsWith(filename, kPrefixSetFileSuffix, |
| 1796 base::CompareCase::SENSITIVE)) { |
1796 histogram_name = "SB2.PrefixSetSizeKilobytes"; | 1797 histogram_name = "SB2.PrefixSetSizeKilobytes"; |
1797 // Clear the PrefixSet suffix to have the histogram suffix selector below | 1798 // Clear the PrefixSet suffix to have the histogram suffix selector below |
1798 // work the same for PrefixSet-based storage as it does for simple safe | 1799 // work the same for PrefixSet-based storage as it does for simple safe |
1799 // browsing stores. | 1800 // browsing stores. |
1800 // The size of the kPrefixSetFileSuffix is the size of its array minus 1 as | 1801 // The size of the kPrefixSetFileSuffix is the size of its array minus 1 as |
1801 // the array includes the terminating '\0'. | 1802 // the array includes the terminating '\0'. |
1802 const size_t kPrefixSetSuffixSize = arraysize(kPrefixSetFileSuffix) - 1; | 1803 const size_t kPrefixSetSuffixSize = arraysize(kPrefixSetFileSuffix) - 1; |
1803 filename.erase(filename.size() - kPrefixSetSuffixSize); | 1804 filename.erase(filename.size() - kPrefixSetSuffixSize); |
1804 } | 1805 } |
1805 | 1806 |
1806 // Changes to histogram suffixes below need to be mirrored in the | 1807 // Changes to histogram suffixes below need to be mirrored in the |
1807 // SafeBrowsingLists suffix enum in histograms.xml. | 1808 // SafeBrowsingLists suffix enum in histograms.xml. |
1808 if (base::EndsWith(filename, kBrowseDBFile, true)) | 1809 if (base::EndsWith(filename, kBrowseDBFile, base::CompareCase::SENSITIVE)) |
1809 histogram_name.append(".Browse"); | 1810 histogram_name.append(".Browse"); |
1810 else if (base::EndsWith(filename, kDownloadDBFile, true)) | 1811 else if (base::EndsWith(filename, kDownloadDBFile, |
| 1812 base::CompareCase::SENSITIVE)) |
1811 histogram_name.append(".Download"); | 1813 histogram_name.append(".Download"); |
1812 else if (base::EndsWith(filename, kCsdWhitelistDBFile, true)) | 1814 else if (base::EndsWith(filename, kCsdWhitelistDBFile, |
| 1815 base::CompareCase::SENSITIVE)) |
1813 histogram_name.append(".CsdWhitelist"); | 1816 histogram_name.append(".CsdWhitelist"); |
1814 else if (base::EndsWith(filename, kDownloadWhitelistDBFile, true)) | 1817 else if (base::EndsWith(filename, kDownloadWhitelistDBFile, |
| 1818 base::CompareCase::SENSITIVE)) |
1815 histogram_name.append(".DownloadWhitelist"); | 1819 histogram_name.append(".DownloadWhitelist"); |
1816 else if (base::EndsWith(filename, kInclusionWhitelistDBFile, true)) | 1820 else if (base::EndsWith(filename, kInclusionWhitelistDBFile, |
| 1821 base::CompareCase::SENSITIVE)) |
1817 histogram_name.append(".InclusionWhitelist"); | 1822 histogram_name.append(".InclusionWhitelist"); |
1818 else if (base::EndsWith(filename, kExtensionBlacklistDBFile, true)) | 1823 else if (base::EndsWith(filename, kExtensionBlacklistDBFile, |
| 1824 base::CompareCase::SENSITIVE)) |
1819 histogram_name.append(".ExtensionBlacklist"); | 1825 histogram_name.append(".ExtensionBlacklist"); |
1820 else if (base::EndsWith(filename, kIPBlacklistDBFile, true)) | 1826 else if (base::EndsWith(filename, kIPBlacklistDBFile, |
| 1827 base::CompareCase::SENSITIVE)) |
1821 histogram_name.append(".IPBlacklist"); | 1828 histogram_name.append(".IPBlacklist"); |
1822 else if (base::EndsWith(filename, kUnwantedSoftwareDBFile, true)) | 1829 else if (base::EndsWith(filename, kUnwantedSoftwareDBFile, |
| 1830 base::CompareCase::SENSITIVE)) |
1823 histogram_name.append(".UnwantedSoftware"); | 1831 histogram_name.append(".UnwantedSoftware"); |
1824 else | 1832 else |
1825 NOTREACHED(); // Add support for new lists above. | 1833 NOTREACHED(); // Add support for new lists above. |
1826 | 1834 |
1827 // Histogram properties as in UMA_HISTOGRAM_COUNTS macro. | 1835 // Histogram properties as in UMA_HISTOGRAM_COUNTS macro. |
1828 base::HistogramBase* histogram_pointer = base::Histogram::FactoryGet( | 1836 base::HistogramBase* histogram_pointer = base::Histogram::FactoryGet( |
1829 histogram_name, 1, 1000000, 50, | 1837 histogram_name, 1, 1000000, 50, |
1830 base::HistogramBase::kUmaTargetedHistogramFlag); | 1838 base::HistogramBase::kUmaTargetedHistogramFlag); |
1831 | 1839 |
1832 histogram_pointer->Add(file_size_kilobytes); | 1840 histogram_pointer->Add(file_size_kilobytes); |
1833 } | 1841 } |
OLD | NEW |