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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 190 } |
191 } | 191 } |
192 } | 192 } |
193 } | 193 } |
194 | 194 |
195 URLRequestFileJob::~URLRequestFileJob() { | 195 URLRequestFileJob::~URLRequestFileJob() { |
196 } | 196 } |
197 | 197 |
198 void URLRequestFileJob::FetchMetaInfo(const base::FilePath& file_path, | 198 void URLRequestFileJob::FetchMetaInfo(const base::FilePath& file_path, |
199 FileMetaInfo* meta_info) { | 199 FileMetaInfo* meta_info) { |
200 base::PlatformFileInfo platform_info; | 200 base::File::Info file_info; |
201 meta_info->file_exists = base::GetFileInfo(file_path, &platform_info); | 201 meta_info->file_exists = base::GetFileInfo(file_path, &file_info); |
202 if (meta_info->file_exists) { | 202 if (meta_info->file_exists) { |
203 meta_info->file_size = platform_info.size; | 203 meta_info->file_size = file_info.size; |
204 meta_info->is_directory = platform_info.is_directory; | 204 meta_info->is_directory = file_info.is_directory; |
205 } | 205 } |
206 // On Windows GetMimeTypeFromFile() goes to the registry. Thus it should be | 206 // On Windows GetMimeTypeFromFile() goes to the registry. Thus it should be |
207 // done in WorkerPool. | 207 // done in WorkerPool. |
208 meta_info->mime_type_result = GetMimeTypeFromFile(file_path, | 208 meta_info->mime_type_result = GetMimeTypeFromFile(file_path, |
209 &meta_info->mime_type); | 209 &meta_info->mime_type); |
210 } | 210 } |
211 | 211 |
212 void URLRequestFileJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) { | 212 void URLRequestFileJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) { |
213 meta_info_ = *meta_info; | 213 meta_info_ = *meta_info; |
214 | 214 |
(...skipping 77 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 |