Index: chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_fetcher_win.cc |
diff --git a/chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_fetcher_win.cc b/chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_fetcher_win.cc |
index 34605c3ef2fe9b458a940a8ba7da4243e33fae60..2d3b8df03efcd65e7282ed3e06048aa409eca2e7 100644 |
--- a/chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_fetcher_win.cc |
+++ b/chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_fetcher_win.cc |
@@ -18,6 +18,7 @@ |
#include "base/macros.h" |
#include "base/memory/ptr_util.h" |
#include "base/memory/ref_counted.h" |
+#include "base/metrics/histogram_macros.h" |
#include "base/sequenced_task_runner.h" |
#include "base/strings/stringprintf.h" |
#include "base/strings/utf_string_conversions.h" |
@@ -52,6 +53,23 @@ base::FilePath::StringType CleanerTempDirectoryPrefix() { |
install_mode); |
} |
+// These values are used to send UMA information and are replicated in the |
+// histograms.xml file, so the order MUST NOT CHANGE. |
+enum CleanerDownloadStatusHistogramValue { |
+ CLEANER_DOWNLOAD_STATUS_SUCCEEDED = 0, |
+ CLEANER_DOWNLOAD_STATUS_OTHER_FAILURE = 1, |
+ CLEANER_DOWNLOAD_STATUS_NOT_FOUND_ON_SERVER = 2, |
+ CLEANER_DOWNLOAD_STATUS_FAILED_TO_CREATE_TEMP_DIR = 3, |
+ |
+ CLEANER_DOWNLOAD_STATUS_MAX, |
+}; |
+ |
+void RecordCleanerDownloadStatusHistogram( |
+ CleanerDownloadStatusHistogramValue value) { |
+ UMA_HISTOGRAM_ENUMERATION("SoftwareReporter.Cleaner.DownloadStatus", value, |
+ CLEANER_DOWNLOAD_STATUS_MAX); |
+} |
+ |
// Class that will attempt to download the Chrome Cleaner executable and call a |
// given callback when done. Instances of ChromeCleanerFetcher own themselves |
// and will self-delete if they encounter an error or when the network request |
@@ -123,6 +141,8 @@ bool ChromeCleanerFetcher::CreateTemporaryDirectory() { |
void ChromeCleanerFetcher::OnTemporaryDirectoryCreated(bool success) { |
if (!success) { |
+ RecordCleanerDownloadStatusHistogram( |
+ CLEANER_DOWNLOAD_STATUS_FAILED_TO_CREATE_TEMP_DIR); |
PostCallbackAndDeleteSelf( |
base::FilePath(), |
ChromeCleanerFetchStatus::kFailedToCreateTemporaryDirectory); |
@@ -166,6 +186,8 @@ void ChromeCleanerFetcher::OnURLFetchComplete(const net::URLFetcher* source) { |
DCHECK(fetched_callback_); |
if (source->GetResponseCode() == net::HTTP_NOT_FOUND) { |
+ RecordCleanerDownloadStatusHistogram( |
+ CLEANER_DOWNLOAD_STATUS_NOT_FOUND_ON_SERVER); |
PostCallbackAndDeleteSelf(base::FilePath(), |
ChromeCleanerFetchStatus::kNotFoundOnServer); |
return; |
@@ -175,6 +197,7 @@ void ChromeCleanerFetcher::OnURLFetchComplete(const net::URLFetcher* source) { |
if (!source->GetStatus().is_success() || |
source->GetResponseCode() != net::HTTP_OK || |
!source->GetResponseAsFilePath(/*take_ownership=*/true, &download_path)) { |
+ RecordCleanerDownloadStatusHistogram(CLEANER_DOWNLOAD_STATUS_OTHER_FAILURE); |
PostCallbackAndDeleteSelf(base::FilePath(), |
ChromeCleanerFetchStatus::kOtherFailure); |
return; |
@@ -186,6 +209,7 @@ void ChromeCleanerFetcher::OnURLFetchComplete(const net::URLFetcher* source) { |
// Take ownership of the scoped temp directory so it is not deleted. |
scoped_temp_dir_->Take(); |
+ RecordCleanerDownloadStatusHistogram(CLEANER_DOWNLOAD_STATUS_SUCCEEDED); |
PostCallbackAndDeleteSelf(std::move(download_path), |
ChromeCleanerFetchStatus::kSuccess); |
} |