Chromium Code Reviews| Index: chrome/browser/renderer_host/download_throttling_resource_handler.cc |
| =================================================================== |
| --- chrome/browser/renderer_host/download_throttling_resource_handler.cc (revision 74194) |
| +++ chrome/browser/renderer_host/download_throttling_resource_handler.cc (working copy) |
| @@ -5,8 +5,14 @@ |
| #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" |
| #include "base/logging.h" |
| +#include "chrome/browser/cert_store.h" |
| #include "chrome/browser/renderer_host/download_resource_handler.h" |
| +#include "chrome/browser/renderer_host/render_view_host.h" |
| +#include "chrome/browser/renderer_host/render_view_host_delegate.h" |
| #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| +#include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" |
| +#include "chrome/browser/renderer_host/resource_request_details.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" |
| @@ -36,6 +42,34 @@ |
| DownloadThrottlingResourceHandler::~DownloadThrottlingResourceHandler() { |
| } |
| +ResourceRequestDetails* |
| + DownloadThrottlingResourceHandler::GetResourceRequestDetails() { |
| + int certID = 0; |
| + if (request_->ssl_info().cert) { |
| + ResourceDispatcherHostRequestInfo* info = |
| + ResourceDispatcherHost::InfoForRequest(request_); |
| + |
| + certID = CertStore::GetInstance()->StoreCert(request_->ssl_info().cert, |
|
cbentzel
2011/02/09 12:11:14
I have no idea what's going on here, but it seems
dominich
2011/02/09 22:33:30
Done.
|
| + info->child_id()); |
| + } |
| + |
| + return new ResourceRequestDetails(request_, certID); |
| +} |
| + |
| +template<NotificationType::Type T> |
| +void DownloadThrottlingResourceHandler::NotifyOnUI( |
| + int process_id, int view_id, |
| + ResourceRequestDetails* details) { |
| + RenderViewHost* rvh = RenderViewHost::FromID(process_id, view_id); |
| + if (rvh) { |
| + RenderViewHostDelegate* rvhd = rvh->delegate(); |
| + NotificationService::current()->Notify(T, |
| + Source<RenderViewHostDelegate>(rvhd), |
| + Details<ResourceRequestDetails>(details)); |
| + } |
| + delete details; |
| +} |
| + |
| bool DownloadThrottlingResourceHandler::OnUploadProgress(int request_id, |
| uint64 position, |
| uint64 size) { |
| @@ -60,6 +94,14 @@ |
| bool DownloadThrottlingResourceHandler::OnResponseStarted( |
| int request_id, |
| ResourceResponse* response) { |
| + BrowserThread::PostTask( |
| + BrowserThread::UI, FROM_HERE, |
| + NewRunnableFunction( |
| + &DownloadThrottlingResourceHandler::NotifyOnUI |
| + <NotificationType::DOWNLOAD_STARTED>, |
| + render_process_host_id_, render_view_id_, |
| + GetResourceRequestDetails())); |
| + |
| if (download_handler_.get()) |
| return download_handler_->OnResponseStarted(request_id, response); |
| response_ = response; |
| @@ -141,6 +183,14 @@ |
| } |
| void DownloadThrottlingResourceHandler::CancelDownload() { |
| + BrowserThread::PostTask( |
| + BrowserThread::UI, FROM_HERE, |
| + NewRunnableFunction( |
| + &DownloadThrottlingResourceHandler::NotifyOnUI |
| + <NotificationType::DOWNLOAD_CANCELLED>, |
|
cbentzel
2011/02/09 12:11:14
There are no consumers of DOWNLOAD_CANCELLED right
dominich
2011/02/09 22:33:30
I can. I thought that it would be good to have bot
dominich
2011/02/09 22:33:30
Done.
|
| + render_process_host_id_, render_view_id_, |
| + GetResourceRequestDetails())); |
| + |
| host_->CancelRequest(render_process_host_id_, request_id_, false); |
| } |