diff options
author | benjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-20 20:20:11 +0000 |
---|---|---|
committer | benjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-20 20:20:11 +0000 |
commit | 6434fe2bf49698f235a8e815c78873e166733266 (patch) | |
tree | eb4ffa63a65e364ef7ae7d73431568c89e7fd93a /content | |
parent | c5e8f606d15bd2033cef185e7ced6a3751a753b2 (diff) | |
download | chromium_src-6434fe2bf49698f235a8e815c78873e166733266.zip chromium_src-6434fe2bf49698f235a8e815c78873e166733266.tar.gz chromium_src-6434fe2bf49698f235a8e815c78873e166733266.tar.bz2 |
The apitest needs a handler on the testserver that does not return a dangerous file and finishes quickly. "/slow?0" appears to work.
DownloadRequestHandle::GetTabContents() returns NULL in the test framework. Make DRH::GetDownloadManager() use RVH->process().browser_context() directly instead.
Make MockDownloadManagerDelegate::AddItemToPersistentStore() call DM::OnItemAddedToPersistentStore() so that items are added to the history_downloads_ map even in the test framework.
Review URL: http://codereview.chromium.org/8060042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106560 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
3 files changed, 25 insertions, 7 deletions
diff --git a/content/browser/download/download_request_handle.cc b/content/browser/download/download_request_handle.cc index e5d9b60..de6d5aa 100644 --- a/content/browser/download/download_request_handle.cc +++ b/content/browser/download/download_request_handle.cc @@ -61,15 +61,16 @@ TabContents* DownloadRequestHandle::GetTabContents() const { } DownloadManager* DownloadRequestHandle::GetDownloadManager() const { - TabContents* contents = GetTabContents(); - if (!contents) + RenderViewHost* rvh = RenderViewHost::FromID(child_id_, render_view_id_); + if (rvh == NULL) return NULL; - - content::BrowserContext* browser_context = contents->browser_context(); - if (!browser_context) + RenderProcessHost* rph = rvh->process(); + if (rph == NULL) return NULL; - - return browser_context->GetDownloadManager(); + content::BrowserContext* context = rph->browser_context(); + if (context == NULL) + return NULL; + return context->GetDownloadManager(); } void DownloadRequestHandle::PauseRequest() const { diff --git a/content/browser/download/mock_download_manager_delegate.cc b/content/browser/download/mock_download_manager_delegate.cc index e5b8b66..edf0371 100644 --- a/content/browser/download/mock_download_manager_delegate.cc +++ b/content/browser/download/mock_download_manager_delegate.cc @@ -3,10 +3,19 @@ // found in the LICENSE file. #include "content/browser/download/mock_download_manager_delegate.h" +#include "content/browser/download/download_item.h" +#include "content/browser/download/download_manager.h" + +MockDownloadManagerDelegate::MockDownloadManagerDelegate() { +} MockDownloadManagerDelegate::~MockDownloadManagerDelegate() { } +void MockDownloadManagerDelegate::SetDownloadManager(DownloadManager* dm) { + download_manager_ = dm; +} + void MockDownloadManagerDelegate::Shutdown() { } @@ -53,6 +62,7 @@ void MockDownloadManagerDelegate::OnResponseCompleted(DownloadItem* item, } void MockDownloadManagerDelegate::AddItemToPersistentStore(DownloadItem* item) { + download_manager_->OnItemAddedToPersistentStore(item->id(), item->id()); } void MockDownloadManagerDelegate::UpdateItemInPersistentStore( diff --git a/content/browser/download/mock_download_manager_delegate.h b/content/browser/download/mock_download_manager_delegate.h index b2fbfc2..5d9f87f 100644 --- a/content/browser/download/mock_download_manager_delegate.h +++ b/content/browser/download/mock_download_manager_delegate.h @@ -9,9 +9,13 @@ #include "base/compiler_specific.h" #include "content/public/browser/download_manager_delegate.h" +class DownloadManager; + class MockDownloadManagerDelegate : public content::DownloadManagerDelegate { public: + MockDownloadManagerDelegate(); virtual ~MockDownloadManagerDelegate(); + void SetDownloadManager(DownloadManager* dm); virtual void Shutdown() OVERRIDE; virtual bool ShouldStartDownload(int32 download_id) OVERRIDE; virtual void ChooseDownloadPath(TabContents* tab_contents, @@ -42,6 +46,9 @@ class MockDownloadManagerDelegate : public content::DownloadManagerDelegate { const FilePath& suggested_path, bool can_save_as_complete) OVERRIDE; virtual void DownloadProgressUpdated() OVERRIDE; + + private: + scoped_refptr<DownloadManager> download_manager_; }; #endif // CONTENT_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_DELEGATE_H_ |