AU: Update status to DOWNLOADING only after receiving some bytes from server.
This ensures that users don't see an update download notification until
after a download has successfully started.
Also, added some DownloadActionDelegate unit tests.
BUG=5822
TEST=unit tests, gmerged to device, made sure updates happened and
notifications received
Change-Id: I96912dcd98a53e9bd7eecc63dab704f959a06441
Review URL: http://codereview.chromium.org/3131022
diff --git a/download_action.cc b/download_action.cc
index 5ecb99e..5096703 100644
--- a/download_action.cc
+++ b/download_action.cc
@@ -74,6 +74,9 @@
return;
}
}
+ if (delegate_) {
+ delegate_->SetDownloadStatus(true); // Set to active.
+ }
http_fetcher_->BeginTransfer(install_plan_.download_url);
}
@@ -82,6 +85,9 @@
CHECK_EQ(writer_->Close(), 0);
writer_ = NULL;
http_fetcher_->TerminateTransfer();
+ if (delegate_) {
+ delegate_->SetDownloadStatus(false); // Set to inactive.
+ }
}
void DownloadAction::ReceivedBytes(HttpFetcher *fetcher,
@@ -116,6 +122,9 @@
CHECK_EQ(writer_->Close(), 0) << errno;
writer_ = NULL;
}
+ if (delegate_) {
+ delegate_->SetDownloadStatus(false); // Set to inactive.
+ }
ActionExitCode code =
successful ? kActionCodeSuccess : kActionCodeDownloadTransferError;
if (code == kActionCodeSuccess) {