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

Side by Side Diff: chrome/browser/renderer_host/download_throttling_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: Now with conflicts resolved 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" 5 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/cert_store.h"
cbentzel 2011/02/10 14:44:34 A bunch of these includes are not needed: cert_st
dominich 2011/02/10 18:46:22 Done.
8 #include "chrome/browser/renderer_host/download_resource_handler.h" 9 #include "chrome/browser/renderer_host/download_resource_handler.h"
10 #include "chrome/browser/renderer_host/render_view_host.h"
11 #include "chrome/browser/renderer_host/render_view_host_delegate.h"
9 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" 12 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
13 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
14 #include "chrome/browser/renderer_host/resource_request_details.h"
15 #include "chrome/common/notification_service.h"
10 #include "chrome/common/resource_response.h" 16 #include "chrome/common/resource_response.h"
11 #include "net/base/io_buffer.h" 17 #include "net/base/io_buffer.h"
12 #include "net/base/mime_sniffer.h" 18 #include "net/base/mime_sniffer.h"
13 19
20 namespace {
21
22 void NotifyOnUI(NotificationType::Type notification_type,
23 int process_id, int view_id) {
24 RenderViewHost* rvh = RenderViewHost::FromID(process_id, view_id);
cbentzel 2011/02/10 14:44:34 You should probably DCHECK that this is called on
cbentzel 2011/02/10 14:44:34 Do you want to DCHECK that the notification_type i
dominich 2011/02/10 18:46:22 Done.
dominich 2011/02/10 18:46:22 I can, but given this is local to the file and is
25 if (rvh) {
cbentzel 2011/02/10 14:44:34 You can also do if (!rvh) return; to minimize
26 RenderViewHostDelegate* rvhd = rvh->delegate();
27 NotificationService::current()->Notify(notification_type,
28 Source<RenderViewHostDelegate>(rvhd),
cbentzel 2011/02/10 14:44:34 This certainly simplifies things for prerender, bu
Randy Smith (Not in Mondays) 2011/02/10 16:57:10 I would agree with this comment, and unless it rea
dominich 2011/02/10 18:46:22 Done.
29 NotificationService::NoDetails());
30 }
31 }
32
33 }
cbentzel 2011/02/10 14:44:34 Nit: add // namespace to make it clear what this b
34
14 DownloadThrottlingResourceHandler::DownloadThrottlingResourceHandler( 35 DownloadThrottlingResourceHandler::DownloadThrottlingResourceHandler(
15 ResourceDispatcherHost* host, 36 ResourceDispatcherHost* host,
16 net::URLRequest* request, 37 net::URLRequest* request,
17 const GURL& url, 38 const GURL& url,
18 int render_process_host_id, 39 int render_process_host_id,
19 int render_view_id, 40 int render_view_id,
20 int request_id, 41 int request_id,
21 bool in_complete) 42 bool in_complete)
22 : host_(host), 43 : host_(host),
23 request_(request), 44 request_(request),
(...skipping 29 matching lines...) Expand all
53 return download_handler_->OnRequestRedirected( 74 return download_handler_->OnRequestRedirected(
54 request_id, url, response, defer); 75 request_id, url, response, defer);
55 } 76 }
56 url_ = url; 77 url_ = url;
57 return true; 78 return true;
58 } 79 }
59 80
60 bool DownloadThrottlingResourceHandler::OnResponseStarted( 81 bool DownloadThrottlingResourceHandler::OnResponseStarted(
61 int request_id, 82 int request_id,
62 ResourceResponse* response) { 83 ResourceResponse* response) {
84 BrowserThread::PostTask(
cbentzel 2011/02/10 14:44:34 I thought this was going to move into DownloadReso
Randy Smith (Not in Mondays) 2011/02/10 16:57:10 We never get to DownloadResourceHandler, so he can
85 BrowserThread::UI, FROM_HERE,
86 NewRunnableFunction(&NotifyOnUI, NotificationType::DOWNLOAD_INITIATED,
87 render_process_host_id_, render_view_id_));
88
63 if (download_handler_.get()) 89 if (download_handler_.get())
64 return download_handler_->OnResponseStarted(request_id, response); 90 return download_handler_->OnResponseStarted(request_id, response);
65 response_ = response; 91 response_ = response;
66 return true; 92 return true;
67 } 93 }
68 94
69 bool DownloadThrottlingResourceHandler::OnWillStart(int request_id, 95 bool DownloadThrottlingResourceHandler::OnWillStart(int request_id,
70 const GURL& url, 96 const GURL& url,
71 bool* defer) { 97 bool* defer) {
72 if (download_handler_.get()) 98 if (download_handler_.get())
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 int buf_size; 202 int buf_size;
177 if (download_handler_->OnWillRead(request_id_, &buffer, &buf_size, 203 if (download_handler_->OnWillRead(request_id_, &buffer, &buf_size,
178 tmp_buffer_length_)) { 204 tmp_buffer_length_)) {
179 CHECK(buf_size >= tmp_buffer_length_); 205 CHECK(buf_size >= tmp_buffer_length_);
180 memcpy(buffer->data(), tmp_buffer_->data(), tmp_buffer_length_); 206 memcpy(buffer->data(), tmp_buffer_->data(), tmp_buffer_length_);
181 download_handler_->OnReadCompleted(request_id_, &tmp_buffer_length_); 207 download_handler_->OnReadCompleted(request_id_, &tmp_buffer_length_);
182 } 208 }
183 tmp_buffer_length_ = 0; 209 tmp_buffer_length_ = 0;
184 tmp_buffer_ = NULL; 210 tmp_buffer_ = NULL;
185 } 211 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698