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

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: '' 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/download/download_util.h"
8 #include "chrome/browser/renderer_host/download_resource_handler.h" 9 #include "chrome/browser/renderer_host/download_resource_handler.h"
9 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" 10 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
10 #include "chrome/common/resource_response.h" 11 #include "chrome/common/resource_response.h"
11 #include "net/base/io_buffer.h" 12 #include "net/base/io_buffer.h"
12 #include "net/base/mime_sniffer.h" 13 #include "net/base/mime_sniffer.h"
13 14
14 DownloadThrottlingResourceHandler::DownloadThrottlingResourceHandler( 15 DownloadThrottlingResourceHandler::DownloadThrottlingResourceHandler(
15 ResourceDispatcherHost* host, 16 ResourceDispatcherHost* host,
16 net::URLRequest* request, 17 net::URLRequest* request,
17 const GURL& url, 18 const GURL& url,
18 int render_process_host_id, 19 int render_process_host_id,
19 int render_view_id, 20 int render_view_id,
20 int request_id, 21 int request_id,
21 bool in_complete) 22 bool in_complete)
22 : host_(host), 23 : host_(host),
23 request_(request), 24 request_(request),
24 url_(url), 25 url_(url),
25 render_process_host_id_(render_process_host_id), 26 render_process_host_id_(render_process_host_id),
26 render_view_id_(render_view_id), 27 render_view_id_(render_view_id),
27 request_id_(request_id), 28 request_id_(request_id),
28 tmp_buffer_length_(0), 29 tmp_buffer_length_(0),
29 ignore_on_read_complete_(in_complete) { 30 ignore_on_read_complete_(in_complete) {
30 // Pause the request. 31 // Pause the request.
31 host_->PauseRequest(render_process_host_id_, request_id_, true); 32 host_->PauseRequest(render_process_host_id_, request_id_, true);
32 host_->download_request_limiter()->CanDownloadOnIOThread( 33 host_->download_request_limiter()->CanDownloadOnIOThread(
33 render_process_host_id_, render_view_id, this); 34 render_process_host_id_, render_view_id, this);
34 } 35
36 BrowserThread::PostTask(
37 BrowserThread::UI, FROM_HERE,
38 NewRunnableFunction(&download_util::NotifyDownloadInitiated,
39 render_process_host_id_, render_view_id_));
40 }
35 41
36 DownloadThrottlingResourceHandler::~DownloadThrottlingResourceHandler() { 42 DownloadThrottlingResourceHandler::~DownloadThrottlingResourceHandler() {
37 } 43 }
38 44
39 bool DownloadThrottlingResourceHandler::OnUploadProgress(int request_id, 45 bool DownloadThrottlingResourceHandler::OnUploadProgress(int request_id,
40 uint64 position, 46 uint64 position,
41 uint64 size) { 47 uint64 size) {
42 if (download_handler_.get()) 48 if (download_handler_.get())
43 return download_handler_->OnUploadProgress(request_id, position, size); 49 return download_handler_->OnUploadProgress(request_id, position, size);
44 return true; 50 return true;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 int buf_size; 182 int buf_size;
177 if (download_handler_->OnWillRead(request_id_, &buffer, &buf_size, 183 if (download_handler_->OnWillRead(request_id_, &buffer, &buf_size,
178 tmp_buffer_length_)) { 184 tmp_buffer_length_)) {
179 CHECK(buf_size >= tmp_buffer_length_); 185 CHECK(buf_size >= tmp_buffer_length_);
180 memcpy(buffer->data(), tmp_buffer_->data(), tmp_buffer_length_); 186 memcpy(buffer->data(), tmp_buffer_->data(), tmp_buffer_length_);
181 download_handler_->OnReadCompleted(request_id_, &tmp_buffer_length_); 187 download_handler_->OnReadCompleted(request_id_, &tmp_buffer_length_);
182 } 188 }
183 tmp_buffer_length_ = 0; 189 tmp_buffer_length_ = 0;
184 tmp_buffer_ = NULL; 190 tmp_buffer_ = NULL;
185 } 191 }
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_final_status.h ('k') | chrome/browser/renderer_host/resource_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698