From: liusi Date: Fri, 24 Feb 2017 06:08:21 +0000 (+0800) Subject: remove the call to download_item_->Remove() on cancel X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ff513f2a84225b1e9bffd1c372fd7eff926f3996;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git remove the call to download_item_->Remove() on cancel --- diff --git a/atom/browser/api/atom_api_download_item.cc b/atom/browser/api/atom_api_download_item.cc index 80e37ba..3e5932c 100644 --- a/atom/browser/api/atom_api_download_item.cc +++ b/atom/browser/api/atom_api_download_item.cc @@ -58,7 +58,7 @@ std::map> g_download_item_objects; DownloadItem::DownloadItem(v8::Isolate* isolate, content::DownloadItem* download_item) - : download_item_(download_item), done_emitted_(false) { + : download_item_(download_item) { download_item_->AddObserver(this); Init(isolate); AttachAsUserData(download_item); @@ -76,16 +76,13 @@ DownloadItem::~DownloadItem() { } void DownloadItem::OnDownloadUpdated(content::DownloadItem* item) { - if (!download_item_->IsDone()) { - Emit("updated", item->GetState()); - - } else if (!done_emitted_) { + if (download_item_->IsDone()) { Emit("done", item->GetState()); - done_emitted_ = true; - // Destroy the item once item is downloaded. base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, GetDestroyClosure()); + } else { + Emit("updated", item->GetState()); } } @@ -113,7 +110,6 @@ bool DownloadItem::CanResume() const { void DownloadItem::Cancel() { download_item_->Cancel(true); - download_item_->Remove(); } int64_t DownloadItem::GetReceivedBytes() const { diff --git a/atom/browser/api/atom_api_download_item.h b/atom/browser/api/atom_api_download_item.h index 8840a4c..fbc74b1 100644 --- a/atom/browser/api/atom_api_download_item.h +++ b/atom/browser/api/atom_api_download_item.h @@ -59,7 +59,6 @@ class DownloadItem : public mate::TrackableObject, private: base::FilePath save_path_; content::DownloadItem* download_item_; - bool done_emitted_; DISALLOW_COPY_AND_ASSIGN(DownloadItem); };