remove the call to download_item_->Remove() on cancel
This commit is contained in:
parent
d56c1909df
commit
ff513f2a84
2 changed files with 4 additions and 9 deletions
|
@ -58,7 +58,7 @@ std::map<uint32_t, v8::Global<v8::Object>> g_download_item_objects;
|
||||||
|
|
||||||
DownloadItem::DownloadItem(v8::Isolate* isolate,
|
DownloadItem::DownloadItem(v8::Isolate* isolate,
|
||||||
content::DownloadItem* download_item)
|
content::DownloadItem* download_item)
|
||||||
: download_item_(download_item), done_emitted_(false) {
|
: download_item_(download_item) {
|
||||||
download_item_->AddObserver(this);
|
download_item_->AddObserver(this);
|
||||||
Init(isolate);
|
Init(isolate);
|
||||||
AttachAsUserData(download_item);
|
AttachAsUserData(download_item);
|
||||||
|
@ -76,16 +76,13 @@ DownloadItem::~DownloadItem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadItem::OnDownloadUpdated(content::DownloadItem* item) {
|
void DownloadItem::OnDownloadUpdated(content::DownloadItem* item) {
|
||||||
if (!download_item_->IsDone()) {
|
if (download_item_->IsDone()) {
|
||||||
Emit("updated", item->GetState());
|
|
||||||
|
|
||||||
} else if (!done_emitted_) {
|
|
||||||
Emit("done", item->GetState());
|
Emit("done", item->GetState());
|
||||||
done_emitted_ = true;
|
|
||||||
|
|
||||||
// Destroy the item once item is downloaded.
|
// Destroy the item once item is downloaded.
|
||||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||||
FROM_HERE, GetDestroyClosure());
|
FROM_HERE, GetDestroyClosure());
|
||||||
|
} else {
|
||||||
|
Emit("updated", item->GetState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +110,6 @@ bool DownloadItem::CanResume() const {
|
||||||
|
|
||||||
void DownloadItem::Cancel() {
|
void DownloadItem::Cancel() {
|
||||||
download_item_->Cancel(true);
|
download_item_->Cancel(true);
|
||||||
download_item_->Remove();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t DownloadItem::GetReceivedBytes() const {
|
int64_t DownloadItem::GetReceivedBytes() const {
|
||||||
|
|
|
@ -59,7 +59,6 @@ class DownloadItem : public mate::TrackableObject<DownloadItem>,
|
||||||
private:
|
private:
|
||||||
base::FilePath save_path_;
|
base::FilePath save_path_;
|
||||||
content::DownloadItem* download_item_;
|
content::DownloadItem* download_item_;
|
||||||
bool done_emitted_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(DownloadItem);
|
DISALLOW_COPY_AND_ASSIGN(DownloadItem);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue