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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 // We don't support multiple range requests in one single URL request, | 177 // We don't support multiple range requests in one single URL request, |
178 // because we need to do multipart encoding here. | 178 // because we need to do multipart encoding here. |
179 // TODO(hclam): decide whether we want to support multiple range | 179 // TODO(hclam): decide whether we want to support multiple range |
180 // requests. | 180 // requests. |
181 range_parse_result_ = net::ERR_REQUEST_RANGE_NOT_SATISFIABLE; | 181 range_parse_result_ = net::ERR_REQUEST_RANGE_NOT_SATISFIABLE; |
182 } | 182 } |
183 } | 183 } |
184 } | 184 } |
185 } | 185 } |
186 | 186 |
187 void URLRequestFileJob::OnSeekComplete(int64 result) { | 187 void URLRequestFileJob::OnSeekComplete(int64_t result) {} |
188 } | |
189 | 188 |
190 void URLRequestFileJob::OnReadComplete(IOBuffer* buf, int result) { | 189 void URLRequestFileJob::OnReadComplete(IOBuffer* buf, int result) { |
191 } | 190 } |
192 | 191 |
193 URLRequestFileJob::~URLRequestFileJob() { | 192 URLRequestFileJob::~URLRequestFileJob() { |
194 } | 193 } |
195 | 194 |
196 void URLRequestFileJob::FetchMetaInfo(const base::FilePath& file_path, | 195 void URLRequestFileJob::FetchMetaInfo(const base::FilePath& file_path, |
197 FileMetaInfo* meta_info) { | 196 FileMetaInfo* meta_info) { |
198 base::File::Info file_info; | 197 base::File::Info file_info; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 DidSeek(-1); | 268 DidSeek(-1); |
270 } | 269 } |
271 } else { | 270 } else { |
272 // We didn't need to call stream_->Seek() at all, so we pass to DidSeek() | 271 // We didn't need to call stream_->Seek() at all, so we pass to DidSeek() |
273 // the value that would mean seek success. This way we skip the code | 272 // the value that would mean seek success. This way we skip the code |
274 // handling seek failure. | 273 // handling seek failure. |
275 DidSeek(byte_range_.first_byte_position()); | 274 DidSeek(byte_range_.first_byte_position()); |
276 } | 275 } |
277 } | 276 } |
278 | 277 |
279 void URLRequestFileJob::DidSeek(int64 result) { | 278 void URLRequestFileJob::DidSeek(int64_t result) { |
280 OnSeekComplete(result); | 279 OnSeekComplete(result); |
281 if (result != byte_range_.first_byte_position()) { | 280 if (result != byte_range_.first_byte_position()) { |
282 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, | 281 NotifyStartError(URLRequestStatus(URLRequestStatus::FAILED, |
283 ERR_REQUEST_RANGE_NOT_SATISFIABLE)); | 282 ERR_REQUEST_RANGE_NOT_SATISFIABLE)); |
284 return; | 283 return; |
285 } | 284 } |
286 | 285 |
287 set_expected_content_size(remaining_bytes_); | 286 set_expected_content_size(remaining_bytes_); |
288 NotifyHeadersComplete(); | 287 NotifyHeadersComplete(); |
289 } | 288 } |
290 | 289 |
291 void URLRequestFileJob::DidRead(scoped_refptr<IOBuffer> buf, int result) { | 290 void URLRequestFileJob::DidRead(scoped_refptr<IOBuffer> buf, int result) { |
292 if (result >= 0) { | 291 if (result >= 0) { |
293 remaining_bytes_ -= result; | 292 remaining_bytes_ -= result; |
294 DCHECK_GE(remaining_bytes_, 0); | 293 DCHECK_GE(remaining_bytes_, 0); |
295 } | 294 } |
296 | 295 |
297 OnReadComplete(buf.get(), result); | 296 OnReadComplete(buf.get(), result); |
298 buf = NULL; | 297 buf = NULL; |
299 | 298 |
300 ReadRawDataComplete(result); | 299 ReadRawDataComplete(result); |
301 } | 300 } |
302 | 301 |
303 } // namespace net | 302 } // namespace net |
OLD | NEW |