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

Reset percent_complete and received_bytes when DownloadTask is started.

When download is restarted after the failure the progress should be 0%.
This CL fixes the bug where download UI displayed 100% progress after
restarting the failed download.

Bug: 823968
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ia44961f9602ea76b0a731bae1829d48fa5fc533f
Reviewed-on: https://chromium-review.googlesource.com/972575Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544722}
parent b8bc6981
...@@ -219,6 +219,8 @@ void DownloadTaskImpl::Start( ...@@ -219,6 +219,8 @@ void DownloadTaskImpl::Start(
DCHECK_CURRENTLY_ON(web::WebThread::UI); DCHECK_CURRENTLY_ON(web::WebThread::UI);
DCHECK_NE(state_, State::kInProgress); DCHECK_NE(state_, State::kInProgress);
writer_ = std::move(writer); writer_ = std::move(writer);
percent_complete_ = 0;
received_bytes_ = 0;
state_ = State::kInProgress; state_ = State::kInProgress;
GetCookies(base::Bind(&DownloadTaskImpl::StartWithCookies, GetCookies(base::Bind(&DownloadTaskImpl::StartWithCookies,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
......
...@@ -344,10 +344,12 @@ TEST_F(DownloadTaskImplTest, Restarting) { ...@@ -344,10 +344,12 @@ TEST_F(DownloadTaskImplTest, Restarting) {
ASSERT_TRUE(WaitUntilConditionOrTimeout(kWaitForDownloadTimeout, ^{ ASSERT_TRUE(WaitUntilConditionOrTimeout(kWaitForDownloadTimeout, ^{
return task_->IsDone(); return task_->IsDone();
})); }));
EXPECT_EQ(100, task_->GetPercentComplete());
// Restart the task. // Restart the task.
EXPECT_CALL(task_observer_, OnDownloadUpdated(task_.get())); EXPECT_CALL(task_observer_, OnDownloadUpdated(task_.get()));
session_task = Start(); session_task = Start();
EXPECT_EQ(0, task_->GetPercentComplete());
ASSERT_TRUE(session_task); ASSERT_TRUE(session_task);
testing::Mock::VerifyAndClearExpectations(&task_observer_); testing::Mock::VerifyAndClearExpectations(&task_observer_);
......
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