diff options
author | rdsmith@chromium.org <rdsmith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-16 00:00:44 +0000 |
---|---|---|
committer | rdsmith@chromium.org <rdsmith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-16 00:00:44 +0000 |
commit | 855adf0fa36a65f20ce3a512f1cd1a232d2d7494 (patch) | |
tree | 56f7865f75ac3cf6df307c10cd20648eba0e7bec /content/browser/download | |
parent | fd0a645508f9b2a4a4c0b2498fca24ddc0a772b0 (diff) | |
download | chromium_src-855adf0fa36a65f20ce3a512f1cd1a232d2d7494.zip chromium_src-855adf0fa36a65f20ce3a512f1cd1a232d2d7494.tar.gz chromium_src-855adf0fa36a65f20ce3a512f1cd1a232d2d7494.tar.bz2 |
Create a Null DownloadRequestHandle for use by SavePackage DownloadItems.
This will mean that when things like cancel are done on downloads resulting
from a Save Page As ..., chrome will not crash. They also won't do anything,
but that's the previous (broken :-{) behavior.
BUG=103590
R=cbentzel@chromium.org
Review URL: http://codereview.chromium.org/8519008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110216 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/download')
-rw-r--r-- | content/browser/download/download_item.cc | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/content/browser/download/download_item.cc b/content/browser/download/download_item.cc index e3eff99..e71366b 100644 --- a/content/browser/download/download_item.cc +++ b/content/browser/download/download_item.cc @@ -110,6 +110,31 @@ DownloadItem::DangerType GetDangerType(bool dangerous_file, DownloadItem::DANGEROUS_FILE : DownloadItem::NOT_DANGEROUS; } +// Classes to null out request handle calls (for SavePage DownloadItems, which +// may have, e.g., Cancel() called on them without it doing anything) +// and to DCHECK on them (for history DownloadItems, which should never have +// any operation that implies an off-thread component, since they don't +// have any). +class NullDownloadRequestHandle : public DownloadRequestHandleInterface { + public: + NullDownloadRequestHandle() {} + + // DownloadRequestHandleInterface calls + virtual TabContents* GetTabContents() const OVERRIDE { + return NULL; + } + virtual DownloadManager* GetDownloadManager() const OVERRIDE { + return NULL; + } + virtual void PauseRequest() const OVERRIDE {} + virtual void ResumeRequest() const OVERRIDE {} + virtual void CancelRequest() const OVERRIDE {} + virtual std::string DebugString() const OVERRIDE { + return "Null DownloadRequestHandle"; + } +}; + + } // namespace // Our download table ID starts at 1, so we use 0 to represent a download that @@ -201,7 +226,8 @@ DownloadItem::DownloadItem(DownloadManager* download_manager, const GURL& url, bool is_otr, DownloadId download_id) - : download_id_(download_id), + : request_handle_(new NullDownloadRequestHandle()), + download_id_(download_id), full_path_(path), url_chain_(1, url), referrer_url_(GURL()), @@ -684,6 +710,10 @@ DownloadPersistentStoreInfo DownloadItem::GetPersistentStoreInfo() const { } TabContents* DownloadItem::GetTabContents() const { + // TODO(rdsmith): Remove null check after removing GetTabContents() from + // paths that might be used by DownloadItems created from history import. + // Currently such items have null request_handle_s, where other items + // (regular and SavePackage downloads) have actual objects off the pointer. if (request_handle_.get()) return request_handle_->GetTabContents(); return NULL; |