| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 !network_delegate->CanAccessFile(*request, file_path)) { | 74 !network_delegate->CanAccessFile(*request, file_path)) { |
| 75 return new URLRequestErrorJob(request, network_delegate, ERR_ACCESS_DENIED); | 75 return new URLRequestErrorJob(request, network_delegate, ERR_ACCESS_DENIED); |
| 76 } | 76 } |
| 77 // We need to decide whether to create URLRequestFileJob for file access or | 77 // We need to decide whether to create URLRequestFileJob for file access or |
| 78 // URLRequestFileDirJob for directory access. To avoid accessing the | 78 // URLRequestFileDirJob for directory access. To avoid accessing the |
| 79 // filesystem, we only look at the path string here. | 79 // filesystem, we only look at the path string here. |
| 80 // The code in the URLRequestFileJob::Start() method discovers that a path, | 80 // The code in the URLRequestFileJob::Start() method discovers that a path, |
| 81 // which doesn't end with a slash, should really be treated as a directory, | 81 // which doesn't end with a slash, should really be treated as a directory, |
| 82 // and it then redirects to the URLRequestFileDirJob. | 82 // and it then redirects to the URLRequestFileDirJob. |
| 83 if (is_file && | 83 if (is_file && |
| 84 file_util::EndsWithSeparator(file_path) && | 84 file_path.EndsWithSeparator() && |
| 85 file_path.IsAbsolute()) | 85 file_path.IsAbsolute()) |
| 86 return new URLRequestFileDirJob(request, network_delegate, file_path); | 86 return new URLRequestFileDirJob(request, network_delegate, file_path); |
| 87 | 87 |
| 88 // Use a regular file request job for all non-directories (including invalid | 88 // Use a regular file request job for all non-directories (including invalid |
| 89 // file names). | 89 // file names). |
| 90 return new URLRequestFileJob(request, network_delegate, file_path); | 90 return new URLRequestFileJob(request, network_delegate, file_path); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void URLRequestFileJob::Start() { | 93 void URLRequestFileJob::Start() { |
| 94 FileMetaInfo* meta_info = new FileMetaInfo(); | 94 FileMetaInfo* meta_info = new FileMetaInfo(); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); | 318 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); |
| 319 } | 319 } |
| 320 | 320 |
| 321 remaining_bytes_ -= result; | 321 remaining_bytes_ -= result; |
| 322 DCHECK_GE(remaining_bytes_, 0); | 322 DCHECK_GE(remaining_bytes_, 0); |
| 323 | 323 |
| 324 NotifyReadComplete(result); | 324 NotifyReadComplete(result); |
| 325 } | 325 } |
| 326 | 326 |
| 327 } // namespace net | 327 } // namespace net |
| OLD | NEW |