Commit f363f54c authored by Eugene But's avatar Eugene But Committed by Commit Bot

Add Download.IOSDownloadedFileNetError to New Download Manager.

This is an existing histogram logged for the Old Download Manager.
The histogram is already a part of histograms.xml file.

Bug: 791806
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I720221f6a5b395d947a96a99ce7e4d6fe7bee09e
Reviewed-on: https://chromium-review.googlesource.com/979267Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545722}
parent 077ec79c
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <memory> #include <memory>
#import "base/logging.h" #import "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h" #include "base/metrics/user_metrics_action.h"
...@@ -49,6 +50,10 @@ class UnopenedDownloadsTracker : public web::DownloadTaskObserver { ...@@ -49,6 +50,10 @@ class UnopenedDownloadsTracker : public web::DownloadTaskObserver {
? DownloadFileResult::Failure ? DownloadFileResult::Failure
: DownloadFileResult::Completed, : DownloadFileResult::Completed,
DownloadFileResult::Count); DownloadFileResult::Count);
if (task->GetErrorCode()) {
base::UmaHistogramSparse("Download.IOSDownloadedFileNetError",
-task->GetErrorCode());
}
} }
} }
void OnDownloadDestroyed(web::DownloadTask* task) override { void OnDownloadDestroyed(web::DownloadTask* task) override {
......
...@@ -407,6 +407,7 @@ TEST_F(DownloadManagerCoordinatorTest, OpenIn) { ...@@ -407,6 +407,7 @@ TEST_F(DownloadManagerCoordinatorTest, OpenIn) {
// Download task is destroyed without opening the file. // Download task is destroyed without opening the file.
task = nullptr; task = nullptr;
histogram_tester_.ExpectTotalCount("Download.IOSDownloadedFileNetError", 0);
histogram_tester_.ExpectUniqueSample( histogram_tester_.ExpectUniqueSample(
"Download.IOSDownloadFileResult", "Download.IOSDownloadFileResult",
static_cast<base::HistogramBase::Sample>(DownloadFileResult::Completed), static_cast<base::HistogramBase::Sample>(DownloadFileResult::Completed),
...@@ -444,6 +445,7 @@ TEST_F(DownloadManagerCoordinatorTest, DestroyInProgressDownload) { ...@@ -444,6 +445,7 @@ TEST_F(DownloadManagerCoordinatorTest, DestroyInProgressDownload) {
// Download task is destroyed before the download is complete. // Download task is destroyed before the download is complete.
task = nullptr; task = nullptr;
histogram_tester_.ExpectTotalCount("Download.IOSDownloadedFileNetError", 0);
histogram_tester_.ExpectTotalCount("Download.IOSDownloadedFileAction", 0); histogram_tester_.ExpectTotalCount("Download.IOSDownloadedFileAction", 0);
histogram_tester_.ExpectUniqueSample( histogram_tester_.ExpectUniqueSample(
"Download.IOSDownloadFileResult", "Download.IOSDownloadFileResult",
...@@ -499,6 +501,7 @@ TEST_F(DownloadManagerCoordinatorTest, OpenInDrive) { ...@@ -499,6 +501,7 @@ TEST_F(DownloadManagerCoordinatorTest, OpenInDrive) {
willBeginSendingToApplication:kGoogleDriveAppBundleID]; willBeginSendingToApplication:kGoogleDriveAppBundleID];
} }
histogram_tester_.ExpectTotalCount("Download.IOSDownloadedFileNetError", 0);
histogram_tester_.ExpectTotalCount("Download.IOSDownloadFileResult", 0); histogram_tester_.ExpectTotalCount("Download.IOSDownloadFileResult", 0);
histogram_tester_.ExpectUniqueSample("Download.IOSDownloadedFileAction", histogram_tester_.ExpectUniqueSample("Download.IOSDownloadedFileAction",
static_cast<base::HistogramBase::Sample>( static_cast<base::HistogramBase::Sample>(
...@@ -555,6 +558,7 @@ TEST_F(DownloadManagerCoordinatorTest, OpenInOtherApp) { ...@@ -555,6 +558,7 @@ TEST_F(DownloadManagerCoordinatorTest, OpenInOtherApp) {
willBeginSendingToApplication:@"foo-app-id"]; willBeginSendingToApplication:@"foo-app-id"];
} }
histogram_tester_.ExpectTotalCount("Download.IOSDownloadedFileNetError", 0);
histogram_tester_.ExpectTotalCount("Download.IOSDownloadFileResult", 0); histogram_tester_.ExpectTotalCount("Download.IOSDownloadFileResult", 0);
histogram_tester_.ExpectUniqueSample( histogram_tester_.ExpectUniqueSample(
"Download.IOSDownloadedFileAction", "Download.IOSDownloadedFileAction",
...@@ -744,6 +748,8 @@ TEST_F(DownloadManagerCoordinatorTest, RetryingDownload) { ...@@ -744,6 +748,8 @@ TEST_F(DownloadManagerCoordinatorTest, RetryingDownload) {
return task_ptr->GetState() == web::DownloadTask::State::kInProgress; return task_ptr->GetState() == web::DownloadTask::State::kInProgress;
})); }));
histogram_tester_.ExpectUniqueSample("Download.IOSDownloadedFileNetError",
-net::ERR_INTERNET_DISCONNECTED, 1);
histogram_tester_.ExpectUniqueSample( histogram_tester_.ExpectUniqueSample(
"Download.IOSDownloadFileResult", "Download.IOSDownloadFileResult",
static_cast<base::HistogramBase::Sample>(DownloadFileResult::Failure), 1); static_cast<base::HistogramBase::Sample>(DownloadFileResult::Failure), 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment