| 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, | 1795 if (base::EndsWith(filename, kPrefixSetFileSuffix, true)) { |
| 1796 base::CompareCase::SENSITIVE)) { | |
| 1797 histogram_name = "SB2.PrefixSetSizeKilobytes"; | 1796 histogram_name = "SB2.PrefixSetSizeKilobytes"; |
| 1798 // Clear the PrefixSet suffix to have the histogram suffix selector below | 1797 // Clear the PrefixSet suffix to have the histogram suffix selector below |
| 1799 // work the same for PrefixSet-based storage as it does for simple safe | 1798 // work the same for PrefixSet-based storage as it does for simple safe |
| 1800 // browsing stores. | 1799 // browsing stores. |
| 1801 // The size of the kPrefixSetFileSuffix is the size of its array minus 1 as | 1800 // The size of the kPrefixSetFileSuffix is the size of its array minus 1 as |
| 1802 // the array includes the terminating '\0'. | 1801 // the array includes the terminating '\0'. |
| 1803 const size_t kPrefixSetSuffixSize = arraysize(kPrefixSetFileSuffix) - 1; | 1802 const size_t kPrefixSetSuffixSize = arraysize(kPrefixSetFileSuffix) - 1; |
| 1804 filename.erase(filename.size() - kPrefixSetSuffixSize); | 1803 filename.erase(filename.size() - kPrefixSetSuffixSize); |
| 1805 } | 1804 } |
| 1806 | 1805 |
| 1807 // Changes to histogram suffixes below need to be mirrored in the | 1806 // Changes to histogram suffixes below need to be mirrored in the |
| 1808 // SafeBrowsingLists suffix enum in histograms.xml. | 1807 // SafeBrowsingLists suffix enum in histograms.xml. |
| 1809 if (base::EndsWith(filename, kBrowseDBFile, base::CompareCase::SENSITIVE)) | 1808 if (base::EndsWith(filename, kBrowseDBFile, true)) |
| 1810 histogram_name.append(".Browse"); | 1809 histogram_name.append(".Browse"); |
| 1811 else if (base::EndsWith(filename, kDownloadDBFile, | 1810 else if (base::EndsWith(filename, kDownloadDBFile, true)) |
| 1812 base::CompareCase::SENSITIVE)) | |
| 1813 histogram_name.append(".Download"); | 1811 histogram_name.append(".Download"); |
| 1814 else if (base::EndsWith(filename, kCsdWhitelistDBFile, | 1812 else if (base::EndsWith(filename, kCsdWhitelistDBFile, true)) |
| 1815 base::CompareCase::SENSITIVE)) | |
| 1816 histogram_name.append(".CsdWhitelist"); | 1813 histogram_name.append(".CsdWhitelist"); |
| 1817 else if (base::EndsWith(filename, kDownloadWhitelistDBFile, | 1814 else if (base::EndsWith(filename, kDownloadWhitelistDBFile, true)) |
| 1818 base::CompareCase::SENSITIVE)) | |
| 1819 histogram_name.append(".DownloadWhitelist"); | 1815 histogram_name.append(".DownloadWhitelist"); |
| 1820 else if (base::EndsWith(filename, kInclusionWhitelistDBFile, | 1816 else if (base::EndsWith(filename, kInclusionWhitelistDBFile, true)) |
| 1821 base::CompareCase::SENSITIVE)) | |
| 1822 histogram_name.append(".InclusionWhitelist"); | 1817 histogram_name.append(".InclusionWhitelist"); |
| 1823 else if (base::EndsWith(filename, kExtensionBlacklistDBFile, | 1818 else if (base::EndsWith(filename, kExtensionBlacklistDBFile, true)) |
| 1824 base::CompareCase::SENSITIVE)) | |
| 1825 histogram_name.append(".ExtensionBlacklist"); | 1819 histogram_name.append(".ExtensionBlacklist"); |
| 1826 else if (base::EndsWith(filename, kIPBlacklistDBFile, | 1820 else if (base::EndsWith(filename, kIPBlacklistDBFile, true)) |
| 1827 base::CompareCase::SENSITIVE)) | |
| 1828 histogram_name.append(".IPBlacklist"); | 1821 histogram_name.append(".IPBlacklist"); |
| 1829 else if (base::EndsWith(filename, kUnwantedSoftwareDBFile, | 1822 else if (base::EndsWith(filename, kUnwantedSoftwareDBFile, true)) |
| 1830 base::CompareCase::SENSITIVE)) | |
| 1831 histogram_name.append(".UnwantedSoftware"); | 1823 histogram_name.append(".UnwantedSoftware"); |
| 1832 else | 1824 else |
| 1833 NOTREACHED(); // Add support for new lists above. | 1825 NOTREACHED(); // Add support for new lists above. |
| 1834 | 1826 |
| 1835 // Histogram properties as in UMA_HISTOGRAM_COUNTS macro. | 1827 // Histogram properties as in UMA_HISTOGRAM_COUNTS macro. |
| 1836 base::HistogramBase* histogram_pointer = base::Histogram::FactoryGet( | 1828 base::HistogramBase* histogram_pointer = base::Histogram::FactoryGet( |
| 1837 histogram_name, 1, 1000000, 50, | 1829 histogram_name, 1, 1000000, 50, |
| 1838 base::HistogramBase::kUmaTargetedHistogramFlag); | 1830 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 1839 | 1831 |
| 1840 histogram_pointer->Add(file_size_kilobytes); | 1832 histogram_pointer->Add(file_size_kilobytes); |
| 1841 } | 1833 } |
| OLD | NEW |