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

Side by Side Diff: net/url_request/url_request_file_job.cc

Issue 1148383003: Only support seeking file streams from the beginning of the file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Win DBG build by Pass()-ing file out of CreateForAsyncHandle. Created 5 years, 6 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
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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, 259 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED,
260 ERR_REQUEST_RANGE_NOT_SATISFIABLE)); 260 ERR_REQUEST_RANGE_NOT_SATISFIABLE));
261 return; 261 return;
262 } 262 }
263 263
264 remaining_bytes_ = byte_range_.last_byte_position() - 264 remaining_bytes_ = byte_range_.last_byte_position() -
265 byte_range_.first_byte_position() + 1; 265 byte_range_.first_byte_position() + 1;
266 DCHECK_GE(remaining_bytes_, 0); 266 DCHECK_GE(remaining_bytes_, 0);
267 267
268 if (remaining_bytes_ > 0 && byte_range_.first_byte_position() != 0) { 268 if (remaining_bytes_ > 0 && byte_range_.first_byte_position() != 0) {
269 int rv = stream_->Seek(base::File::FROM_BEGIN, 269 int rv = stream_->Seek(byte_range_.first_byte_position(),
270 byte_range_.first_byte_position(),
271 base::Bind(&URLRequestFileJob::DidSeek, 270 base::Bind(&URLRequestFileJob::DidSeek,
272 weak_ptr_factory_.GetWeakPtr())); 271 weak_ptr_factory_.GetWeakPtr()));
273 if (rv != ERR_IO_PENDING) { 272 if (rv != ERR_IO_PENDING) {
274 // stream_->Seek() failed, so pass an intentionally erroneous value 273 // stream_->Seek() failed, so pass an intentionally erroneous value
275 // into DidSeek(). 274 // into DidSeek().
276 DidSeek(-1); 275 DidSeek(-1);
277 } 276 }
278 } else { 277 } else {
279 // We didn't need to call stream_->Seek() at all, so we pass to DidSeek() 278 // We didn't need to call stream_->Seek() at all, so we pass to DidSeek()
280 // the value that would mean seek success. This way we skip the code 279 // the value that would mean seek success. This way we skip the code
(...skipping 27 matching lines...) Expand all
308 if (result == 0) { 307 if (result == 0) {
309 NotifyDone(URLRequestStatus()); 308 NotifyDone(URLRequestStatus());
310 } else if (result < 0) { 309 } else if (result < 0) {
311 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); 310 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result));
312 } 311 }
313 312
314 NotifyReadComplete(result); 313 NotifyReadComplete(result);
315 } 314 }
316 315
317 } // namespace net 316 } // namespace net
OLDNEW
« no previous file with comments | « net/base/upload_file_element_reader.cc ('k') | storage/browser/fileapi/local_file_stream_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698