Commit 1dba5873 authored by Xing Liu's avatar Xing Liu Committed by Commit Bot

Reland: "Download: Fix an issue that download percentage can move backwards."

On certain Android devices, when disconnecting from WIFI, the network
code will report NETWORK_TIMEOUT before NETWORK_DISCONNECT and trigger
auto download resumption. And we erase the data downloaded by parallel
requests, so the download percentage will go backwards.

Instead, we should keep the slice info when resume with an error.

TBR=dtrainor@chromium.org, qinmin@chromium.org

Bug: 837128
Change-Id: I59ddb7ff57551beb862884febe2de3f3ee9e1359
Reviewed-on: https://chromium-review.googlesource.com/1130349Reviewed-by: default avatarXing Liu <xingliu@chromium.org>
Commit-Queue: Xing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#573547}
parent e6bb68b6
...@@ -1443,17 +1443,14 @@ void DownloadItemImpl::Start( ...@@ -1443,17 +1443,14 @@ void DownloadItemImpl::Start(
// DownloadCreateInfo with an intact DownloadSaveInfo. // DownloadCreateInfo with an intact DownloadSaveInfo.
DCHECK(new_create_info.save_info); DCHECK(new_create_info.save_info);
int64_t offset = new_create_info.save_info->offset;
std::unique_ptr<crypto::SecureHash> hash_state = std::unique_ptr<crypto::SecureHash> hash_state =
new_create_info.save_info->hash_state new_create_info.save_info->hash_state
? new_create_info.save_info->hash_state->Clone() ? new_create_info.save_info->hash_state->Clone()
: nullptr; : nullptr;
destination_info_.received_bytes = offset;
hash_state_ = std::move(hash_state); hash_state_ = std::move(hash_state);
destination_info_.hash.clear(); destination_info_.hash.clear();
deferred_interrupt_reason_ = new_create_info.result; deferred_interrupt_reason_ = new_create_info.result;
received_slices_.clear();
TransitionTo(INTERRUPTED_TARGET_PENDING_INTERNAL); TransitionTo(INTERRUPTED_TARGET_PENDING_INTERNAL);
DetermineDownloadTarget(); DetermineDownloadTarget();
return; return;
......
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