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

Side by Side Diff: net/url_request/url_request_file_job.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/url_request/url_request_file_job.h ('k') | net/url_request/url_request_http_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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 #if defined(OS_WIN) 121 #if defined(OS_WIN)
122 if (async_resolver_) { 122 if (async_resolver_) {
123 async_resolver_->Cancel(); 123 async_resolver_->Cancel();
124 async_resolver_ = NULL; 124 async_resolver_ = NULL;
125 } 125 }
126 #endif 126 #endif
127 127
128 URLRequestJob::Kill(); 128 URLRequestJob::Kill();
129 } 129 }
130 130
131 bool URLRequestFileJob::ReadRawData( 131 bool URLRequestFileJob::ReadRawData(net::IOBuffer* dest, int dest_size,
132 char* dest, int dest_size, int *bytes_read) { 132 int *bytes_read) {
133 DCHECK_NE(dest_size, 0); 133 DCHECK_NE(dest_size, 0);
134 DCHECK(bytes_read); 134 DCHECK(bytes_read);
135 135
136 int rv = stream_.Read(dest, dest_size, &io_callback_); 136 int rv = stream_.Read(dest->data(), dest_size, &io_callback_);
137 if (rv >= 0) { 137 if (rv >= 0) {
138 // Data is immediately available. 138 // Data is immediately available.
139 *bytes_read = rv; 139 *bytes_read = rv;
140 return true; 140 return true;
141 } 141 }
142 142
143 // Otherwise, a read error occured. We may just need to wait... 143 // Otherwise, a read error occured. We may just need to wait...
144 if (rv == net::ERR_IO_PENDING) { 144 if (rv == net::ERR_IO_PENDING) {
145 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); 145 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0));
146 } else { 146 } else {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 return false; 214 return false;
215 215
216 *location = net::FilePathToFileURL(new_path); 216 *location = net::FilePathToFileURL(new_path);
217 *http_status_code = 301; 217 *http_status_code = 301;
218 return true; 218 return true;
219 #else 219 #else
220 return false; 220 return false;
221 #endif 221 #endif
222 } 222 }
223 223
OLDNEW
« no previous file with comments | « net/url_request/url_request_file_job.h ('k') | net/url_request/url_request_http_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698