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

Side by Side Diff: net/url_request/url_request_file_job.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/mock_file_stream.cc ('k') | webkit/blob/blob_url_request_job.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // For loading files, we make use of overlapped i/o to ensure that reading from 5 // For loading files, we make use of overlapped i/o to ensure that reading from
6 // the filesystem (e.g., a network filesystem) does not block the calling 6 // the filesystem (e.g., a network filesystem) does not block the calling
7 // thread. An alternative approach would be to use a background thread or pool 7 // thread. An alternative approach would be to use a background thread or pool
8 // of threads, but it seems better to leverage the operating system's ability 8 // of threads, but it seems better to leverage the operating system's ability
9 // to do background file reads for us. 9 // to do background file reads for us.
10 // 10 //
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 if (remaining_bytes_ < dest_size) 180 if (remaining_bytes_ < dest_size)
181 dest_size = static_cast<int>(remaining_bytes_); 181 dest_size = static_cast<int>(remaining_bytes_);
182 182
183 // If we should copy zero bytes because |remaining_bytes_| is zero, short 183 // If we should copy zero bytes because |remaining_bytes_| is zero, short
184 // circuit here. 184 // circuit here.
185 if (!dest_size) { 185 if (!dest_size) {
186 *bytes_read = 0; 186 *bytes_read = 0;
187 return true; 187 return true;
188 } 188 }
189 189
190 int rv = stream_.Read(dest->data(), dest_size, 190 int rv = stream_.Read(dest, dest_size,
191 base::Bind(&URLRequestFileJob::DidRead, 191 base::Bind(&URLRequestFileJob::DidRead,
192 base::Unretained(this))); 192 base::Unretained(this)));
193 if (rv >= 0) { 193 if (rv >= 0) {
194 // Data is immediately available. 194 // Data is immediately available.
195 *bytes_read = rv; 195 *bytes_read = rv;
196 remaining_bytes_ -= rv; 196 remaining_bytes_ -= rv;
197 DCHECK_GE(remaining_bytes_, 0); 197 DCHECK_GE(remaining_bytes_, 0);
198 return true; 198 return true;
199 } 199 }
200 200
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); 359 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result));
360 } 360 }
361 361
362 remaining_bytes_ -= result; 362 remaining_bytes_ -= result;
363 DCHECK_GE(remaining_bytes_, 0); 363 DCHECK_GE(remaining_bytes_, 0);
364 364
365 NotifyReadComplete(result); 365 NotifyReadComplete(result);
366 } 366 }
367 367
368 } // namespace net 368 } // namespace net
OLDNEW
« no previous file with comments | « net/base/mock_file_stream.cc ('k') | webkit/blob/blob_url_request_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698