Skip to content

Commit

Permalink
Add more download cancel reasons to study silently failing download
Browse files Browse the repository at this point in the history
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 <qinmin@chromium.org>
Reviewed-by: Shakti Sahu <shaktisahu@chromium.org>
Reviewed-by: Xing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#871125}
  • Loading branch information
Min Qin authored and Chromium LUCI CQ committed Apr 9, 2021
1 parent ab64505 commit a13e34d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
10 changes: 9 additions & 1 deletion chrome/browser/download/download_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/download/download_target_determiner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions tools/metrics/histograms/enums.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19875,6 +19875,10 @@ Called by update_document_policy_enum.py.-->
<enum name="DownloadCancelReason">
<int value="0" label="Existing download path"/>
<int value="1" label="Target confirmation result"/>
<int value="2" label="No valid path"/>
<int value="3" label="Mixed content"/>
<int value="4" label="Failed path reservation"/>
<int value="5" label="Empty local path"/>
</enum>

<enum name="DownloadConnectionSecurity">
Expand Down

0 comments on commit a13e34d

Please sign in to comment.