| OLD | NEW |
| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 // We may have been orphaned... | 170 // We may have been orphaned... |
| 171 if (!request_) | 171 if (!request_) |
| 172 return; | 172 return; |
| 173 | 173 |
| 174 is_directory_ = file_info.is_directory; | 174 is_directory_ = file_info.is_directory; |
| 175 | 175 |
| 176 int rv = net::OK; | 176 int rv = net::OK; |
| 177 if (!exists) { | 177 if (!exists) { |
| 178 rv = net::ERR_FILE_NOT_FOUND; | 178 rv = net::ERR_FILE_NOT_FOUND; |
| 179 } else if (!is_directory_) { | 179 } else if (!is_directory_) { |
| 180 rv = stream_.Open(file_path_, true); | 180 int flags = base::PLATFORM_FILE_OPEN | |
| 181 base::PLATFORM_FILE_READ | |
| 182 base::PLATFORM_FILE_ASYNC; |
| 183 rv = stream_.Open(file_path_, flags); |
| 181 } | 184 } |
| 182 | 185 |
| 183 if (rv == net::OK) { | 186 if (rv == net::OK) { |
| 184 set_expected_content_size(file_info.size); | 187 set_expected_content_size(file_info.size); |
| 185 NotifyHeadersComplete(); | 188 NotifyHeadersComplete(); |
| 186 } else { | 189 } else { |
| 187 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); | 190 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); |
| 188 } | 191 } |
| 189 } | 192 } |
| 190 | 193 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 return false; | 236 return false; |
| 234 | 237 |
| 235 *location = net::FilePathToFileURL(new_path); | 238 *location = net::FilePathToFileURL(new_path); |
| 236 *http_status_code = 301; | 239 *http_status_code = 301; |
| 237 return true; | 240 return true; |
| 238 #else | 241 #else |
| 239 return false; | 242 return false; |
| 240 #endif | 243 #endif |
| 241 } | 244 } |
| 242 | 245 |
| OLD | NEW |