Index: content/browser/renderer_host/resource_dispatcher_host.cc |
diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc |
index 0f26b2c13a2e41d627faa06be4666a27475df179..ec1bd75a6c91e6c52fff510a5386c4c15a948b67 100644 |
--- a/content/browser/renderer_host/resource_dispatcher_host.cc |
+++ b/content/browser/renderer_host/resource_dispatcher_host.cc |
@@ -304,6 +304,19 @@ void OnSwapOutACKHelper(int render_process_id, int render_view_id) { |
rvh->OnSwapOutACK(); |
} |
+net::Error CallbackAndReturn( |
+ const DownloadResourceHandler::OnStartedCallback& started_cb, |
+ net::Error net_error) { |
+ DCHECK(!started_cb.is_null()); |
Randy Smith (Not in Mondays)
2012/03/09 19:14:02
Why the DCHECK? This may be a result of my not ye
ahendrickson
2012/03/09 20:50:08
Removed.
|
+ if (started_cb.is_null()) |
+ return net_error; |
+ BrowserThread::PostTask( |
+ BrowserThread::UI, FROM_HERE, |
+ base::Bind(started_cb, content::DownloadId::Invalid(), net_error)); |
+ |
+ return net_error; |
+} |
+ |
} // namespace |
ResourceDispatcherHost* ResourceDispatcherHost::Get() { |
@@ -924,7 +937,7 @@ net::Error ResourceDispatcherHost::BeginDownload( |
int route_id, |
content::ResourceContext* context) { |
if (is_shutdown_) |
- return net::ERR_INSUFFICIENT_RESOURCES; |
+ return CallbackAndReturn(started_cb, net::ERR_INSUFFICIENT_RESOURCES); |
const GURL& url = request->original_url(); |
#if defined(OS_CHROMEOS) |
@@ -953,11 +966,13 @@ net::Error ResourceDispatcherHost::BeginDownload( |
CanRequestURL(child_id, url)) { |
VLOG(1) << "Denied unauthorized download request for " |
<< url.possibly_invalid_spec(); |
- return net::ERR_ACCESS_DENIED; |
+ return CallbackAndReturn(started_cb, net::ERR_ACCESS_DENIED); |
} |
request_id_--; |
+ // From this point forward, the |DownloadResourceHandler| is responsible for |
+ // |started_cb|. |
scoped_refptr<ResourceHandler> handler( |
CreateResourceHandlerForDownload(request.get(), context, child_id, |
route_id, request_id_, save_info, |