Delete DownloadActionDelegate::SetDownloadStatus() method.
This method is only used by the caller to detect a programming error in
the DownloadAction (calling BytesReceived when not downloading) and log
a message. This patch removes the method from the delegate interface
and makes sure it doesn't issue a call to BytesReceived when not
activelly downloading.
Bug: 25773375
TEST=FEATURES=test emerge-link update_engine
Change-Id: I8ff5c53f1fd40c0777b3f6523703a8bee71c019d
diff --git a/payload_consumer/download_action.h b/payload_consumer/download_action.h
index c0f0688..e57ffb3 100644
--- a/payload_consumer/download_action.h
+++ b/payload_consumer/download_action.h
@@ -42,15 +42,9 @@
public:
virtual ~DownloadActionDelegate() = default;
- // 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.
+ // Called periodically after bytes are received. This method will be invoked
+ // only if the DownloadAction is running. |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;
};
@@ -142,6 +136,7 @@
// For reporting status to outsiders
DownloadActionDelegate* delegate_;
uint64_t bytes_received_;
+ bool download_active_{false};
// The file-id for the file we're sharing or the empty string
// if we're not using p2p to share.