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