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

Unified Diff: content/browser/renderer_host/redirect_to_file_resource_handler.cc

Issue 9402014: net: FileStream::Read/Write() to take IOBuffer* instead of char* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix redirect_to_file_resource_handler.cc Created 8 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
« no previous file with comments | « no previous file | net/base/file_stream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/redirect_to_file_resource_handler.cc
diff --git a/content/browser/renderer_host/redirect_to_file_resource_handler.cc b/content/browser/renderer_host/redirect_to_file_resource_handler.cc
index 8ebba69a259a904d9adbd1c44fc59e235b088735..c28c1bcc346d43da300976d249f0680c6083048d 100644
--- a/content/browser/renderer_host/redirect_to_file_resource_handler.cc
+++ b/content/browser/renderer_host/redirect_to_file_resource_handler.cc
@@ -211,9 +211,20 @@ bool RedirectToFileResourceHandler::WriteMore() {
if (write_callback_pending_)
return true;
DCHECK(write_cursor_ < buf_->offset());
+
+ // Create a temporary drainable buffer that can be passed to
+ // Write(). Temporarily reset the buf_ offset to 0 so that the
+ // drainable buffer can point to the the beginning of the buf_.
+ int offset = buf_->offset();
+ buf_->set_offset(0);
+ scoped_refptr<net::DrainableIOBuffer>
+ drainable = new net::DrainableIOBuffer(buf_, offset);
+ drainable->DidConsume(write_cursor_);
+ buf_->set_offset(offset);
+
int rv = file_stream_->Write(
- buf_->StartOfBuffer() + write_cursor_,
- buf_->offset() - write_cursor_,
+ drainable,
+ drainable->BytesRemaining(),
base::Bind(&RedirectToFileResourceHandler::DidWriteToFile,
base::Unretained(this)));
if (rv == net::ERR_IO_PENDING) {
« no previous file with comments | « no previous file | net/base/file_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698