diff options
author | rdsmith@chromium.org <rdsmith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-18 18:44:40 +0000 |
---|---|---|
committer | rdsmith@chromium.org <rdsmith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-18 18:44:40 +0000 |
commit | 0c249039587a988a50ea0bdaf6d85c77893cf5d2 (patch) | |
tree | b84a04ff3a5958465154179f2a4caa657a1de32e | |
parent | c7b2fa3f761dfa9652e3528387758d5e508f2dea (diff) | |
download | chromium_src-0c249039587a988a50ea0bdaf6d85c77893cf5d2.zip chromium_src-0c249039587a988a50ea0bdaf6d85c77893cf5d2.tar.gz chromium_src-0c249039587a988a50ea0bdaf6d85c77893cf5d2.tar.bz2 |
Simplify DownloadResourceHandler constructor arguments.
Also applies to some functions upstack from DownloadResourceHandler()
Review URL: https://chromiumcodereview.appspot.com/10553009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142767 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 26 insertions, 39 deletions
diff --git a/content/browser/download/download_resource_handler.cc b/content/browser/download/download_resource_handler.cc index d83fb28..790ea69 100644 --- a/content/browser/download/download_resource_handler.cc +++ b/content/browser/download/download_resource_handler.cc @@ -80,15 +80,10 @@ static void StartOnUIThread( } // namespace DownloadResourceHandler::DownloadResourceHandler( - int render_process_host_id, - int render_view_id, - int request_id, - const GURL& url, net::URLRequest* request, const DownloadResourceHandler::OnStartedCallback& started_cb, const content::DownloadSaveInfo& save_info) - : global_id_(render_process_host_id, request_id), - render_view_id_(render_view_id), + : render_view_id_(0), // Actually initialized below. content_length_(0), request_(request), started_cb_(started_cb), @@ -98,6 +93,10 @@ DownloadResourceHandler::DownloadResourceHandler( pause_count_(0), was_deferred_(false), on_response_started_called_(false) { + ResourceRequestInfoImpl* info(ResourceRequestInfoImpl::ForRequest(request)); + global_id_ = info->GetGlobalRequestID(); + render_view_id_ = info->GetRouteID(); + download_stats::RecordDownloadCount(download_stats::UNTHROTTLED_COUNT); } diff --git a/content/browser/download/download_resource_handler.h b/content/browser/download/download_resource_handler.h index 0f6efb3..9c3550b 100644 --- a/content/browser/download/download_resource_handler.h +++ b/content/browser/download/download_resource_handler.h @@ -40,10 +40,6 @@ class DownloadResourceHandler // started_cb will be called exactly once on the UI thread. DownloadResourceHandler( - int render_process_host_id, - int render_view_id, - int request_id, - const GURL& url, net::URLRequest* request, const OnStartedCallback& started_cb, const content::DownloadSaveInfo& save_info); diff --git a/content/browser/renderer_host/buffered_resource_handler.cc b/content/browser/renderer_host/buffered_resource_handler.cc index ac34b95..b57da4a 100644 --- a/content/browser/renderer_host/buffered_resource_handler.cc +++ b/content/browser/renderer_host/buffered_resource_handler.cc @@ -299,10 +299,6 @@ bool BufferedResourceHandler::CompleteResponseStarted(int request_id, scoped_ptr<ResourceHandler> handler( host_->CreateResourceHandlerForDownload( request_, - info->GetContext(), - info->GetChildID(), - info->GetRouteID(), - info->GetRequestID(), true, // is_content_initiated DownloadSaveInfo(), DownloadResourceHandler::OnStartedCallback())); diff --git a/content/browser/renderer_host/resource_dispatcher_host_impl.cc b/content/browser/renderer_host/resource_dispatcher_host_impl.cc index 9e2035b..7ed1d12 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_impl.cc +++ b/content/browser/renderer_host/resource_dispatcher_host_impl.cc @@ -544,24 +544,22 @@ net::Error ResourceDispatcherHostImpl::BeginDownload( request_id_--; - // From this point forward, the |DownloadResourceHandler| is responsible for - // |started_callback|. - scoped_ptr<ResourceHandler> handler( - CreateResourceHandlerForDownload(request.get(), context, child_id, - route_id, request_id_, - is_content_initiated, save_info, - started_callback)); - if (!request_context->job_factory()->IsHandledURL(url)) { VLOG(1) << "Download request for unsupported protocol: " << url.possibly_invalid_spec(); - return net::ERR_ACCESS_DENIED; + return CallbackAndReturn(started_callback, net::ERR_ACCESS_DENIED); } ResourceRequestInfoImpl* extra_info = CreateRequestInfo(child_id, route_id, true, context); extra_info->AssociateWithRequest(request.get()); // Request takes ownership. + // From this point forward, the |DownloadResourceHandler| is responsible for + // |started_callback|. + scoped_ptr<ResourceHandler> handler( + CreateResourceHandlerForDownload(request.get(), is_content_initiated, + save_info, started_callback)); + BeginRequestInternal(request.Pass(), handler.Pass()); return net::OK; @@ -588,25 +586,25 @@ void ResourceDispatcherHostImpl::Shutdown() { scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::CreateResourceHandlerForDownload( net::URLRequest* request, - ResourceContext* context, - int child_id, - int route_id, - int request_id, bool is_content_initiated, const DownloadSaveInfo& save_info, const DownloadResourceHandler::OnStartedCallback& started_cb) { scoped_ptr<ResourceHandler> handler( - new DownloadResourceHandler(child_id, route_id, request_id, - request->url(), request, started_cb, - save_info)); + new DownloadResourceHandler(request, started_cb, save_info)); if (delegate_) { + const ResourceRequestInfo* request_info( + ResourceRequestInfo::ForRequest(request)); + ScopedVector<ResourceThrottle> throttles; - delegate_->DownloadStarting(request, context, child_id, route_id, - request_id, is_content_initiated, &throttles); + delegate_->DownloadStarting( + request, request_info->GetContext(), request_info->GetChildID(), + request_info->GetRouteID(), request_info->GetRequestID(), + is_content_initiated, &throttles); if (!throttles.empty()) { handler.reset( - new ThrottlingResourceHandler(handler.Pass(), child_id, request_id, - throttles.Pass())); + new ThrottlingResourceHandler( + handler.Pass(), request_info->GetChildID(), + request_info->GetRequestID(), throttles.Pass())); } } return handler.Pass(); diff --git a/content/browser/renderer_host/resource_dispatcher_host_impl.h b/content/browser/renderer_host/resource_dispatcher_host_impl.h index 372ac7f..9d0a9ff 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_impl.h +++ b/content/browser/renderer_host/resource_dispatcher_host_impl.h @@ -218,12 +218,10 @@ class CONTENT_EXPORT ResourceDispatcherHostImpl return delegate_; } + // Must be called after the ResourceRequestInfo has been created + // and associated with the request. scoped_ptr<ResourceHandler> CreateResourceHandlerForDownload( net::URLRequest* request, - ResourceContext* context, - int child_id, - int route_id, - int request_id, bool is_content_initiated, const DownloadSaveInfo& save_info, const DownloadResourceHandler::OnStartedCallback& started_cb); diff --git a/content/test/mock_download_manager.cc b/content/test/mock_download_manager.cc index d1c3674..dde89db 100644 --- a/content/test/mock_download_manager.cc +++ b/content/test/mock_download_manager.cc @@ -22,4 +22,4 @@ content::DownloadId MockDownloadManager::StartDownload( return MockStartDownload(info.get(), stream.get()); } -} +} // namespace content |