summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host/download_resource_handler.cc
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-24 02:39:54 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-24 02:39:54 +0000
commite993abfe81feaa374d476828a44942d296bdcc78 (patch)
tree201fffef0ba93ce41afaf2bd6e61e05b61c04028 /chrome/browser/renderer_host/download_resource_handler.cc
parent0afe80d755b899c188313629ea3f45f0fe5be981 (diff)
downloadchromium_src-e993abfe81feaa374d476828a44942d296bdcc78.zip
chromium_src-e993abfe81feaa374d476828a44942d296bdcc78.tar.gz
chromium_src-e993abfe81feaa374d476828a44942d296bdcc78.tar.bz2
revert r8603
Review URL: http://codereview.chromium.org/18576 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8605 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host/download_resource_handler.cc')
-rw-r--r--chrome/browser/renderer_host/download_resource_handler.cc20
1 files changed, 9 insertions, 11 deletions
diff --git a/chrome/browser/renderer_host/download_resource_handler.cc b/chrome/browser/renderer_host/download_resource_handler.cc
index 01704e7..13e7457 100644
--- a/chrome/browser/renderer_host/download_resource_handler.cc
+++ b/chrome/browser/renderer_host/download_resource_handler.cc
@@ -7,7 +7,6 @@
#include "chrome/browser/download/download_file.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
-#include "net/base/io_buffer.h"
DownloadResourceHandler::DownloadResourceHandler(ResourceDispatcherHost* rdh,
int render_process_host_id,
@@ -21,6 +20,7 @@ DownloadResourceHandler::DownloadResourceHandler(ResourceDispatcherHost* rdh,
global_id_(ResourceDispatcherHost::GlobalRequestID(render_process_host_id,
request_id)),
render_view_id_(render_view_id),
+ read_buffer_(NULL),
url_(UTF8ToWide(url)),
content_length_(0),
download_manager_(manager),
@@ -72,14 +72,15 @@ bool DownloadResourceHandler::OnResponseStarted(int request_id,
// Create a new buffer, which will be handed to the download thread for file
// writing and deletion.
-bool DownloadResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf,
- int* buf_size, int min_size) {
+bool DownloadResourceHandler::OnWillRead(int request_id,
+ char** buf, int* buf_size,
+ int min_size) {
DCHECK(buf && buf_size);
if (!read_buffer_) {
*buf_size = min_size < 0 ? kReadBufSize : min_size;
- read_buffer_ = new net::IOBuffer(*buf_size);
+ read_buffer_ = new char[*buf_size];
}
- *buf = read_buffer_.get();
+ *buf = read_buffer_;
return true;
}
@@ -90,11 +91,7 @@ bool DownloadResourceHandler::OnReadCompleted(int request_id, int* bytes_read) {
DCHECK(read_buffer_);
AutoLock auto_lock(buffer_->lock);
bool need_update = buffer_->contents.empty();
-
- // We are passing ownership of this buffer to the download file manager.
- net::IOBuffer* buffer = NULL;
- read_buffer_.swap(&buffer);
- buffer_->contents.push_back(std::make_pair(buffer, *bytes_read));
+ buffer_->contents.push_back(std::make_pair(read_buffer_, *bytes_read));
if (need_update) {
download_manager_->file_loop()->PostTask(FROM_HERE,
NewRunnableMethod(download_manager_,
@@ -102,6 +99,7 @@ bool DownloadResourceHandler::OnReadCompleted(int request_id, int* bytes_read) {
download_id_,
buffer_));
}
+ read_buffer_ = NULL;
// We schedule a pause outside of the read loop if there is too much file
// writing work to do.
@@ -119,7 +117,7 @@ bool DownloadResourceHandler::OnResponseCompleted(
&DownloadFileManager::DownloadFinished,
download_id_,
buffer_));
- read_buffer_ = NULL;
+ delete [] read_buffer_;
// 'buffer_' is deleted by the DownloadFileManager.
buffer_ = NULL;