Chromium Code Reviews| Index: chrome/browser/renderer_host/download_throttling_resource_handler.cc |
| =================================================================== |
| --- chrome/browser/renderer_host/download_throttling_resource_handler.cc (revision 74377) |
| +++ chrome/browser/renderer_host/download_throttling_resource_handler.cc (working copy) |
| @@ -6,11 +6,27 @@ |
| #include "base/logging.h" |
| #include "chrome/browser/renderer_host/download_resource_handler.h" |
| +#include "chrome/browser/renderer_host/render_view_host.h" |
| #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| +#include "chrome/common/notification_service.h" |
| #include "chrome/common/resource_response.h" |
| #include "net/base/io_buffer.h" |
| #include "net/base/mime_sniffer.h" |
| +namespace { |
| +void NotifyOnUI(NotificationType::Type notification_type, |
| + int process_id, int view_id) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + RenderViewHost* rvh = RenderViewHost::FromID(process_id, view_id); |
| + if (!rvh) |
| + return; |
| + |
| + NotificationService::current()->Notify(notification_type, |
| + Source<RenderViewHost>(rvh), |
| + NotificationService::NoDetails()); |
| +} |
| +} // namespace |
|
Randy Smith (Not in Mondays)
2011/02/13 03:08:36
Is dislike duplicating this code; is there anywher
dominich
2011/02/14 16:07:12
I do want to keep it generic as I can see this bei
|
| + |
| DownloadThrottlingResourceHandler::DownloadThrottlingResourceHandler( |
| ResourceDispatcherHost* host, |
| net::URLRequest* request, |
| @@ -31,7 +47,11 @@ |
| host_->PauseRequest(render_process_host_id_, request_id_, true); |
| host_->download_request_limiter()->CanDownloadOnIOThread( |
| render_process_host_id_, render_view_id, this); |
| - } |
| + BrowserThread::PostTask( |
| + BrowserThread::UI, FROM_HERE, |
| + NewRunnableFunction(&NotifyOnUI, NotificationType::DOWNLOAD_INITIATED, |
| + render_process_host_id_, render_view_id_)); |
| +} |
| DownloadThrottlingResourceHandler::~DownloadThrottlingResourceHandler() { |
| } |