OLD | NEW |
1 // Copyright (c) 2011 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 // |
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 URLRequestFileJob* owner_; | 79 URLRequestFileJob* owner_; |
80 | 80 |
81 base::Lock lock_; | 81 base::Lock lock_; |
82 MessageLoop* owner_loop_; | 82 MessageLoop* owner_loop_; |
83 }; | 83 }; |
84 | 84 |
85 URLRequestFileJob::URLRequestFileJob(URLRequest* request, | 85 URLRequestFileJob::URLRequestFileJob(URLRequest* request, |
86 const FilePath& file_path) | 86 const FilePath& file_path) |
87 : URLRequestJob(request), | 87 : URLRequestJob(request), |
88 file_path_(file_path), | 88 file_path_(file_path), |
| 89 stream_(NULL), |
89 is_directory_(false), | 90 is_directory_(false), |
90 remaining_bytes_(0) { | 91 remaining_bytes_(0) { |
91 } | 92 } |
92 | 93 |
93 // static | 94 // static |
94 URLRequestJob* URLRequestFileJob::Factory(URLRequest* request, | 95 URLRequestJob* URLRequestFileJob::Factory(URLRequest* request, |
95 const std::string& scheme) { | 96 const std::string& scheme) { |
96 | 97 |
97 FilePath file_path; | 98 FilePath file_path; |
98 const bool is_file = FileURLToFilePath(request->url(), &file_path); | 99 const bool is_file = FileURLToFilePath(request->url(), &file_path); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); | 356 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); |
356 } | 357 } |
357 | 358 |
358 remaining_bytes_ -= result; | 359 remaining_bytes_ -= result; |
359 DCHECK_GE(remaining_bytes_, 0); | 360 DCHECK_GE(remaining_bytes_, 0); |
360 | 361 |
361 NotifyReadComplete(result); | 362 NotifyReadComplete(result); |
362 } | 363 } |
363 | 364 |
364 } // namespace net | 365 } // namespace net |
OLD | NEW |