| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // We don't support multiple range requests in one single URL request, | 171 // We don't support multiple range requests in one single URL request, |
| 172 // because we need to do multipart encoding here. | 172 // because we need to do multipart encoding here. |
| 173 // TODO(hclam): decide whether we want to support multiple range | 173 // TODO(hclam): decide whether we want to support multiple range |
| 174 // requests. | 174 // requests. |
| 175 range_parse_result_ = ERR_REQUEST_RANGE_NOT_SATISFIABLE; | 175 range_parse_result_ = ERR_REQUEST_RANGE_NOT_SATISFIABLE; |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| 181 bool URLRequestFileJob::OnFetchMetaInfo(const FileMetaInfo& meta_info) { |
| 182 return true; |
| 183 } |
| 184 |
| 181 void URLRequestFileJob::OnOpenComplete(int result) {} | 185 void URLRequestFileJob::OnOpenComplete(int result) {} |
| 182 | 186 |
| 183 void URLRequestFileJob::OnSeekComplete(int64_t result) {} | 187 void URLRequestFileJob::OnSeekComplete(int64_t result) {} |
| 184 | 188 |
| 185 void URLRequestFileJob::OnReadComplete(IOBuffer* buf, int result) { | 189 void URLRequestFileJob::OnReadComplete(IOBuffer* buf, int result) { |
| 186 } | 190 } |
| 187 | 191 |
| 188 URLRequestFileJob::~URLRequestFileJob() { | 192 URLRequestFileJob::~URLRequestFileJob() { |
| 189 } | 193 } |
| 190 | 194 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 201 base::File::Info file_info; | 205 base::File::Info file_info; |
| 202 meta_info->file_exists = base::GetFileInfo(file_path, &file_info); | 206 meta_info->file_exists = base::GetFileInfo(file_path, &file_info); |
| 203 if (meta_info->file_exists) { | 207 if (meta_info->file_exists) { |
| 204 meta_info->file_size = file_info.size; | 208 meta_info->file_size = file_info.size; |
| 205 meta_info->is_directory = file_info.is_directory; | 209 meta_info->is_directory = file_info.is_directory; |
| 206 } | 210 } |
| 207 // On Windows GetMimeTypeFromFile() goes to the registry. Thus it should be | 211 // On Windows GetMimeTypeFromFile() goes to the registry. Thus it should be |
| 208 // done in WorkerPool. | 212 // done in WorkerPool. |
| 209 meta_info->mime_type_result = GetMimeTypeFromFile(file_path, | 213 meta_info->mime_type_result = GetMimeTypeFromFile(file_path, |
| 210 &meta_info->mime_type); | 214 &meta_info->mime_type); |
| 215 meta_info->absolute_path = base::MakeAbsoluteFilePath(file_path); |
| 211 } | 216 } |
| 212 | 217 |
| 213 void URLRequestFileJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) { | 218 void URLRequestFileJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) { |
| 219 if (!OnFetchMetaInfo(*meta_info)) |
| 220 return; |
| 221 |
| 214 meta_info_ = *meta_info; | 222 meta_info_ = *meta_info; |
| 215 | 223 |
| 216 // We use URLRequestFileJob to handle files as well as directories without | 224 // We use URLRequestFileJob to handle files as well as directories without |
| 217 // trailing slash. | 225 // trailing slash. |
| 218 // If a directory does not exist, we return ERR_FILE_NOT_FOUND. Otherwise, | 226 // If a directory does not exist, we return ERR_FILE_NOT_FOUND. Otherwise, |
| 219 // we will append trailing slash and redirect to FileDirJob. | 227 // we will append trailing slash and redirect to FileDirJob. |
| 220 // A special case is "\" on Windows. We should resolve as invalid. | 228 // A special case is "\" on Windows. We should resolve as invalid. |
| 221 // However, Windows resolves "\" to "C:\", thus reports it as existent. | 229 // However, Windows resolves "\" to "C:\", thus reports it as existent. |
| 222 // So what happens is we append it with trailing slash and redirect it to | 230 // So what happens is we append it with trailing slash and redirect it to |
| 223 // FileDirJob where it is resolved as invalid. | 231 // FileDirJob where it is resolved as invalid. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 DCHECK_GE(remaining_bytes_, 0); | 299 DCHECK_GE(remaining_bytes_, 0); |
| 292 } | 300 } |
| 293 | 301 |
| 294 OnReadComplete(buf.get(), result); | 302 OnReadComplete(buf.get(), result); |
| 295 buf = NULL; | 303 buf = NULL; |
| 296 | 304 |
| 297 ReadRawDataComplete(result); | 305 ReadRawDataComplete(result); |
| 298 } | 306 } |
| 299 | 307 |
| 300 } // namespace net | 308 } // namespace net |
| OLD | NEW |