OLD | NEW |
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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, | 258 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, |
259 ERR_REQUEST_RANGE_NOT_SATISFIABLE)); | 259 ERR_REQUEST_RANGE_NOT_SATISFIABLE)); |
260 return; | 260 return; |
261 } | 261 } |
262 | 262 |
263 remaining_bytes_ = byte_range_.last_byte_position() - | 263 remaining_bytes_ = byte_range_.last_byte_position() - |
264 byte_range_.first_byte_position() + 1; | 264 byte_range_.first_byte_position() + 1; |
265 DCHECK_GE(remaining_bytes_, 0); | 265 DCHECK_GE(remaining_bytes_, 0); |
266 | 266 |
267 if (remaining_bytes_ > 0 && byte_range_.first_byte_position() != 0) { | 267 if (remaining_bytes_ > 0 && byte_range_.first_byte_position() != 0) { |
268 int rv = stream_->Seek(FROM_BEGIN, byte_range_.first_byte_position(), | 268 int rv = stream_->Seek(base::File::FROM_BEGIN, |
| 269 byte_range_.first_byte_position(), |
269 base::Bind(&URLRequestFileJob::DidSeek, | 270 base::Bind(&URLRequestFileJob::DidSeek, |
270 weak_ptr_factory_.GetWeakPtr())); | 271 weak_ptr_factory_.GetWeakPtr())); |
271 if (rv != ERR_IO_PENDING) { | 272 if (rv != ERR_IO_PENDING) { |
272 // stream_->Seek() failed, so pass an intentionally erroneous value | 273 // stream_->Seek() failed, so pass an intentionally erroneous value |
273 // into DidSeek(). | 274 // into DidSeek(). |
274 DidSeek(-1); | 275 DidSeek(-1); |
275 } | 276 } |
276 } else { | 277 } else { |
277 // 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() |
278 // 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 Loading... |
306 if (result == 0) { | 307 if (result == 0) { |
307 NotifyDone(URLRequestStatus()); | 308 NotifyDone(URLRequestStatus()); |
308 } else if (result < 0) { | 309 } else if (result < 0) { |
309 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); | 310 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); |
310 } | 311 } |
311 | 312 |
312 NotifyReadComplete(result); | 313 NotifyReadComplete(result); |
313 } | 314 } |
314 | 315 |
315 } // namespace net | 316 } // namespace net |
OLD | NEW |