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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 URLRequestFileJob* owner_; | 80 URLRequestFileJob* owner_; |
81 | 81 |
82 base::Lock lock_; | 82 base::Lock lock_; |
83 MessageLoop* owner_loop_; | 83 MessageLoop* owner_loop_; |
84 }; | 84 }; |
85 | 85 |
86 URLRequestFileJob::URLRequestFileJob(URLRequest* request, | 86 URLRequestFileJob::URLRequestFileJob(URLRequest* request, |
87 const FilePath& file_path) | 87 const FilePath& file_path) |
88 : URLRequestJob(request), | 88 : URLRequestJob(request, request->context()->network_delegate()), |
89 file_path_(file_path), | 89 file_path_(file_path), |
90 stream_(NULL), | 90 stream_(NULL), |
91 is_directory_(false), | 91 is_directory_(false), |
92 remaining_bytes_(0) { | 92 remaining_bytes_(0) { |
93 } | 93 } |
94 | 94 |
95 // static | 95 // static |
96 URLRequestJob* URLRequestFileJob::Factory(URLRequest* request, | 96 URLRequestJob* URLRequestFileJob::Factory(URLRequest* request, |
97 const std::string& scheme) { | 97 const std::string& scheme) { |
98 FilePath file_path; | 98 FilePath file_path; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); | 341 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); |
342 } | 342 } |
343 | 343 |
344 remaining_bytes_ -= result; | 344 remaining_bytes_ -= result; |
345 DCHECK_GE(remaining_bytes_, 0); | 345 DCHECK_GE(remaining_bytes_, 0); |
346 | 346 |
347 NotifyReadComplete(result); | 347 NotifyReadComplete(result); |
348 } | 348 } |
349 | 349 |
350 } // namespace net | 350 } // namespace net |
OLD | NEW |