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 ef9e225487f968feccbfee012e6aecc444760374..5280743816436cbe2545e399bf706477d9487048 100644 |
--- a/content/browser/renderer_host/resource_dispatcher_host.cc |
+++ b/content/browser/renderer_host/resource_dispatcher_host.cc |
@@ -301,6 +301,24 @@ void OnSwapOutACKHelper(int render_process_id, int render_view_id) { |
rvh->OnSwapOutACK(); |
} |
+void CallbackOnUIThread( |
+ const DownloadResourceHandler::OnStartedCallback& started_cb, |
+ net::Error net_error) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ |
+ started_cb.Run(content::DownloadId::Invalid(), net_error); |
+} |
+ |
+net::Error CallbackAndReturn( |
+ const DownloadResourceHandler::OnStartedCallback& started_cb, |
+ net::Error net_error) { |
+ BrowserThread::PostTask( |
cbentzel
2012/03/08 17:58:48
Skip this if started_cb.is_null()?
ahendrickson
2012/03/08 21:33:07
Done.
|
+ BrowserThread::UI, FROM_HERE, |
+ base::Bind(&CallbackOnUIThread, started_cb, net_error)); |
Randy Smith (Not in Mondays)
2012/03/07 21:16:57
Can you just bind started_cb to content::DownloadI
ahendrickson
2012/03/08 21:33:07
Done.
|
+ |
+ return net_error; |
+} |
+ |
} // namespace |
ResourceDispatcherHost* ResourceDispatcherHost::Get() { |
@@ -916,7 +934,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(); |
const net::URLRequestContext* request_context = context->GetRequestContext(); |
@@ -941,7 +959,7 @@ 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_--; |
@@ -954,7 +972,7 @@ net::Error ResourceDispatcherHost::BeginDownload( |
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_cb, net::ERR_ACCESS_DENIED); |
Randy Smith (Not in Mondays)
2012/03/07 21:16:57
Since you've already created the resource handler
ahendrickson
2012/03/08 21:33:07
Done.
|
} |
ResourceDispatcherHostRequestInfo* extra_info = |