Destroy the item once item is downloaded

This commit is contained in:
Cheng Zhao 2016-02-02 19:54:41 +08:00
parent 12d311fd29
commit eaa60e9c17

View file

@ -88,7 +88,14 @@ DownloadItem::~DownloadItem() {
}
void DownloadItem::OnDownloadUpdated(content::DownloadItem* item) {
download_item_->IsDone() ? Emit("done", item->GetState()) : Emit("updated");
if (download_item_->IsDone()) {
Emit("done", item->GetState());
// Destroy the item once item is downloaded.
base::MessageLoop::current()->PostTask(FROM_HERE, GetDestroyClosure());
} else {
Emit("updated");
}
}
void DownloadItem::OnDownloadDestroyed(content::DownloadItem* download_item) {