| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 // FileDirJob where it is resolved as invalid. | 222 // FileDirJob where it is resolved as invalid. |
| 223 if (!meta_info_.file_exists) { | 223 if (!meta_info_.file_exists) { |
| 224 DidOpen(ERR_FILE_NOT_FOUND); | 224 DidOpen(ERR_FILE_NOT_FOUND); |
| 225 return; | 225 return; |
| 226 } | 226 } |
| 227 if (meta_info_.is_directory) { | 227 if (meta_info_.is_directory) { |
| 228 DidOpen(OK); | 228 DidOpen(OK); |
| 229 return; | 229 return; |
| 230 } | 230 } |
| 231 | 231 |
| 232 int flags = base::PLATFORM_FILE_OPEN | | 232 int flags = base::File::FLAG_OPEN | |
| 233 base::PLATFORM_FILE_READ | | 233 base::File::FLAG_READ | |
| 234 base::PLATFORM_FILE_ASYNC; | 234 base::File::FLAG_ASYNC; |
| 235 int rv = stream_->Open(file_path_, flags, | 235 int rv = stream_->Open(file_path_, flags, |
| 236 base::Bind(&URLRequestFileJob::DidOpen, | 236 base::Bind(&URLRequestFileJob::DidOpen, |
| 237 weak_ptr_factory_.GetWeakPtr())); | 237 weak_ptr_factory_.GetWeakPtr())); |
| 238 if (rv != ERR_IO_PENDING) | 238 if (rv != ERR_IO_PENDING) |
| 239 DidOpen(rv); | 239 DidOpen(rv); |
| 240 } | 240 } |
| 241 | 241 |
| 242 void URLRequestFileJob::DidOpen(int result) { | 242 void URLRequestFileJob::DidOpen(int result) { |
| 243 if (result != OK) { | 243 if (result != OK) { |
| 244 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); | 244 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); | 292 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); |
| 293 } | 293 } |
| 294 | 294 |
| 295 remaining_bytes_ -= result; | 295 remaining_bytes_ -= result; |
| 296 DCHECK_GE(remaining_bytes_, 0); | 296 DCHECK_GE(remaining_bytes_, 0); |
| 297 | 297 |
| 298 NotifyReadComplete(result); | 298 NotifyReadComplete(result); |
| 299 } | 299 } |
| 300 | 300 |
| 301 } // namespace net | 301 } // namespace net |
| OLD | NEW |