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.h b/download_action.h
index e1e8aeb..a46124f 100644
--- a/download_action.h
+++ b/download_action.h
@@ -35,10 +35,15 @@
class DownloadActionDelegate {
public:
- // Called before any bytes are received and periodically after
- // bytes are received.
- // bytes_received is the number of bytes downloaded thus far.
- // total is the number of bytes expected.
+ // Called right before starting the download with |active| set to
+ // true. Called after completing the download with |active| set to
+ // false.
+ virtual void SetDownloadStatus(bool active) = 0;
+
+ // Called periodically after bytes are received. This method will be
+ // invoked only if the download is active. |bytes_received| is the
+ // number of bytes downloaded thus far. |total| is the number of
+ // bytes expected.
virtual void BytesReceived(uint64_t bytes_received, uint64_t total) = 0;
};
@@ -106,11 +111,11 @@
// Used to find the hash of the bytes downloaded
OmahaHashCalculator omaha_hash_calculator_;
-
+
// For reporting status to outsiders
DownloadActionDelegate* delegate_;
uint64_t bytes_received_;
-
+
DISALLOW_COPY_AND_ASSIGN(DownloadAction);
};