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 #include "webkit/blob/blob_url_request_job.h" | 5 #include "webkit/blob/blob_url_request_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_util_proxy.h" | 9 #include "base/file_util_proxy.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 int bytes_read = read_buf_->BytesConsumed(); | 407 int bytes_read = read_buf_->BytesConsumed(); |
408 read_buf_ = NULL; | 408 read_buf_ = NULL; |
409 return bytes_read; | 409 return bytes_read; |
410 } | 410 } |
411 | 411 |
412 int BlobURLRequestJob::ComputeBytesToRead() const { | 412 int BlobURLRequestJob::ComputeBytesToRead() const { |
413 int64 current_item_remaining_bytes = | 413 int64 current_item_remaining_bytes = |
414 item_length_list_[current_item_index_] - current_item_offset_; | 414 item_length_list_[current_item_index_] - current_item_offset_; |
415 int64 remaining_bytes = std::min(current_item_remaining_bytes, | 415 int64 remaining_bytes = std::min(current_item_remaining_bytes, |
416 remaining_bytes_); | 416 remaining_bytes_); |
417 return std::min(read_buf_->BytesRemaining(), | 417 |
418 static_cast<int>(remaining_bytes)); | 418 return static_cast<int>(std::min( |
| 419 static_cast<int64>(read_buf_->BytesRemaining()), |
| 420 remaining_bytes)); |
419 } | 421 } |
420 | 422 |
421 bool BlobURLRequestJob::ReadLoop(int* bytes_read) { | 423 bool BlobURLRequestJob::ReadLoop(int* bytes_read) { |
422 // Read until we encounter an error or could not get the data immediately. | 424 // Read until we encounter an error or could not get the data immediately. |
423 while (remaining_bytes_ > 0 && read_buf_->BytesRemaining() > 0) { | 425 while (remaining_bytes_ > 0 && read_buf_->BytesRemaining() > 0) { |
424 if (!ReadItem()) | 426 if (!ReadItem()) |
425 return false; | 427 return false; |
426 } | 428 } |
427 | 429 |
428 *bytes_read = BytesReadCompleted(); | 430 *bytes_read = BytesReadCompleted(); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 file_thread_proxy_, | 533 file_thread_proxy_, |
532 item.file_path, | 534 item.file_path, |
533 item.offset, | 535 item.offset, |
534 item.expected_modification_time); | 536 item.expected_modification_time); |
535 } | 537 } |
536 DCHECK(index_to_reader_[index]); | 538 DCHECK(index_to_reader_[index]); |
537 return index_to_reader_[index]; | 539 return index_to_reader_[index]; |
538 } | 540 } |
539 | 541 |
540 } // namespace webkit_blob | 542 } // namespace webkit_blob |
OLD | NEW |