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

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

Issue 18390: Change URLRequest to use a ref-counted buffer for actual IO.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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_throttling_resource_handler.cc
===================================================================
--- chrome/browser/renderer_host/download_throttling_resource_handler.cc (revision 8565)
+++ chrome/browser/renderer_host/download_throttling_resource_handler.cc (working copy)
@@ -5,6 +5,7 @@
#include "chrome/browser/renderer_host/download_throttling_resource_handler.h"
#include "chrome/browser/renderer_host/download_resource_handler.h"
+#include "net/base/io_buffer.h"
DownloadThrottlingResourceHandler::DownloadThrottlingResourceHandler(
ResourceDispatcherHost* host,
@@ -57,7 +58,7 @@
}
bool DownloadThrottlingResourceHandler::OnWillRead(int request_id,
- char** buf,
+ net::IOBuffer** buf,
int* buf_size,
int min_size) {
if (download_handler_.get())
@@ -68,7 +69,7 @@
DCHECK(!tmp_buffer_.get());
if (min_size < 0)
min_size = 1024;
- tmp_buffer_.reset(new char[min_size]);
+ tmp_buffer_ = new net::IOBuffer(min_size);
*buf = tmp_buffer_.get();
*buf_size = min_size;
return true;
@@ -132,14 +133,14 @@
void DownloadThrottlingResourceHandler::CopyTmpBufferToDownloadHandler() {
// Copy over the tmp buffer.
- char* buffer;
+ net::IOBuffer* buffer;
int buf_size;
if (download_handler_->OnWillRead(request_id_, &buffer, &buf_size,
tmp_buffer_length_)) {
CHECK(buf_size >= tmp_buffer_length_);
- memcpy(buffer, tmp_buffer_.get(), tmp_buffer_length_);
+ memcpy(buffer->data(), tmp_buffer_->data(), tmp_buffer_length_);
download_handler_->OnReadCompleted(request_id_, &tmp_buffer_length_);
}
tmp_buffer_length_ = 0;
- tmp_buffer_.reset();
+ tmp_buffer_ = NULL;
}

Powered by Google App Engine
This is Rietveld 408576698