From a13e34d173d91b3a7ef816859b86e1235f109785 Mon Sep 17 00:00:00 2001 From: Min Qin Date: Fri, 9 Apr 2021 21:55:51 +0000 Subject: [PATCH] Add more download cancel reasons to study silently failing download Some downloads are cancelled silently without obvious reasons. This CL adds more enums to figure out those. BUG=1180747 Change-Id: I5354793cafc52c7b51317f5507383e279193a6a8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2816191 Commit-Queue: Min Qin Reviewed-by: Shakti Sahu Reviewed-by: Xing Liu Cr-Commit-Position: refs/heads/master@{#871125} --- chrome/browser/download/download_stats.h | 10 +++++++++- chrome/browser/download/download_target_determiner.cc | 5 +++++ tools/metrics/histograms/enums.xml | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/chrome/browser/download/download_stats.h b/chrome/browser/download/download_stats.h index 078c3b133f3958..c458da93d80106 100644 --- a/chrome/browser/download/download_stats.h +++ b/chrome/browser/download/download_stats.h @@ -102,7 +102,15 @@ enum class DownloadCancelReason { kExistingDownloadPath = 0, // Canceled due to download target determiner confirmation result. kTargetConfirmationResult = 1, - kMaxValue = kTargetConfirmationResult + // Canceled due to no valid virtual path. + kNoValidPath = 2, + // Canceled due to no mixed content. + kMixedContent = 3, + // Canceled due to failed path reservacation. + kFailedPathReservation = 4, + // Canceled due to empty local path. + kEmptyLocalPath = 5, + kMaxValue = kEmptyLocalPath }; // Increment one of the above counts. diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/browser/download/download_target_determiner.cc index f094105ac70c8d..f920f3044088c5 100644 --- a/chrome/browser/download/download_target_determiner.cc +++ b/chrome/browser/download/download_target_determiner.cc @@ -210,6 +210,7 @@ DownloadTargetDeterminer::Result // target determination process and wait for self deletion. RecordDownloadPathGeneration(DownloadPathGenerationEvent::NO_VALID_PATH, true); + RecordDownloadCancelReason(DownloadCancelReason::kNoValidPath); ScheduleCallbackAndDeleteSelf( download::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED); return QUIT_DOLOOP; @@ -350,6 +351,7 @@ void DownloadTargetDeterminer::GetMixedContentStatusDone( mixed_content_status_ = status; if (status == download::DownloadItem::MixedContentStatus::SILENT_BLOCK) { + RecordDownloadCancelReason(DownloadCancelReason::kMixedContent); ScheduleCallbackAndDeleteSelf( download::DOWNLOAD_INTERRUPT_REASON_FILE_BLOCKED); return; @@ -459,6 +461,8 @@ void DownloadTargetDeterminer::ReserveVirtualPathDone( case download::PathValidationResult::PATH_NOT_WRITABLE: case download::PathValidationResult::NAME_TOO_LONG: case download::PathValidationResult::CONFLICT: + RecordDownloadCancelReason( + DownloadCancelReason::kFailedPathReservation); ScheduleCallbackAndDeleteSelf( download::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED); return; @@ -600,6 +604,7 @@ void DownloadTargetDeterminer::DetermineLocalPathDone( // Google Drive logic (e.g. filesystem error while trying to create the // cache file). We are going to return a generic error here since a more // specific one is unlikely to be helpful to the user. + RecordDownloadCancelReason(DownloadCancelReason::kEmptyLocalPath); ScheduleCallbackAndDeleteSelf( download::DOWNLOAD_INTERRUPT_REASON_FILE_FAILED); return; diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index ee5187de416055..1b607af4c4d043 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml @@ -19875,6 +19875,10 @@ Called by update_document_policy_enum.py.--> + + + +