| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // |
| 11 // Since overlapped reads require a 'static' buffer for the duration of the | 11 // Since overlapped reads require a 'static' buffer for the duration of the |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 return false; | 256 return false; |
| 257 | 257 |
| 258 *location = FilePathToFileURL(new_path); | 258 *location = FilePathToFileURL(new_path); |
| 259 *http_status_code = 301; | 259 *http_status_code = 301; |
| 260 return true; | 260 return true; |
| 261 #else | 261 #else |
| 262 return false; | 262 return false; |
| 263 #endif | 263 #endif |
| 264 } | 264 } |
| 265 | 265 |
| 266 bool URLRequestFileJob::GetContentEncodings( | 266 Filter* URLRequestFileJob::SetupFilter() const { |
| 267 std::vector<Filter::FilterType>* encoding_types) { | |
| 268 DCHECK(encoding_types->empty()); | |
| 269 | |
| 270 // Bug 9936 - .svgz files needs to be decompressed. | 267 // Bug 9936 - .svgz files needs to be decompressed. |
| 271 if (LowerCaseEqualsASCII(file_path_.Extension(), ".svgz")) | 268 return LowerCaseEqualsASCII(file_path_.Extension(), ".svgz") |
| 272 encoding_types->push_back(Filter::FILTER_TYPE_GZIP); | 269 ? Filter::GZipFactory() : NULL; |
| 273 | |
| 274 return !encoding_types->empty(); | |
| 275 } | 270 } |
| 276 | 271 |
| 277 bool URLRequestFileJob::GetMimeType(std::string* mime_type) const { | 272 bool URLRequestFileJob::GetMimeType(std::string* mime_type) const { |
| 278 // URL requests should not block on the disk! On Windows this goes to the | 273 // URL requests should not block on the disk! On Windows this goes to the |
| 279 // registry. | 274 // registry. |
| 280 // http://code.google.com/p/chromium/issues/detail?id=59849 | 275 // http://code.google.com/p/chromium/issues/detail?id=59849 |
| 281 base::ThreadRestrictions::ScopedAllowIO allow_io; | 276 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 282 DCHECK(request_); | 277 DCHECK(request_); |
| 283 return GetMimeTypeFromFile(file_path_, mime_type); | 278 return GetMimeTypeFromFile(file_path_, mime_type); |
| 284 } | 279 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); | 377 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); |
| 383 } | 378 } |
| 384 | 379 |
| 385 remaining_bytes_ -= result; | 380 remaining_bytes_ -= result; |
| 386 DCHECK_GE(remaining_bytes_, 0); | 381 DCHECK_GE(remaining_bytes_, 0); |
| 387 | 382 |
| 388 NotifyReadComplete(result); | 383 NotifyReadComplete(result); |
| 389 } | 384 } |
| 390 | 385 |
| 391 } // namespace net | 386 } // namespace net |
| OLD | NEW |