Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9413)

Unified Diff: chrome/browser/renderer_host/download_resource_handler.cc

Issue 6459005: Cancel prerender when we discover a download starting from a page we are prer... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Moved notification to ctor and added notification for manual downloads Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/renderer_host/download_resource_handler.cc
===================================================================
--- chrome/browser/renderer_host/download_resource_handler.cc (revision 74377)
+++ chrome/browser/renderer_host/download_resource_handler.cc (working copy)
@@ -15,13 +15,29 @@
#include "chrome/browser/download/download_file_manager.h"
#include "chrome/browser/history/download_create_info.h"
#include "chrome/browser/renderer_host/global_request_id.h"
+#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
+#include "chrome/common/notification_service.h"
#include "chrome/common/resource_response.h"
#include "net/base/io_buffer.h"
#include "net/http/http_response_headers.h"
#include "net/url_request/url_request_context.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
+
DownloadResourceHandler::DownloadResourceHandler(
ResourceDispatcherHost* rdh,
int render_process_host_id,
@@ -46,6 +62,10 @@
rdh_(rdh),
is_paused_(false),
url_check_pending_(false) {
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ NewRunnableFunction(&NotifyOnUI, NotificationType::DOWNLOAD_INITIATED,
+ render_process_host_id, render_view_id_));
Randy Smith (Not in Mondays) 2011/02/13 03:08:36 I'd rather not notify from the DownloadResourceHan
dominich 2011/02/14 16:07:12 I was considering download_util::DownloadUrl as an
Randy Smith (Not in Mondays) 2011/02/14 19:20:51 Neither one's particularly future-proof, I'm afrai
}
bool DownloadResourceHandler::OnUploadProgress(int request_id,

Powered by Google App Engine
This is Rietveld 408576698