OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/blink/multibuffer_data_source.h" | 5 #include "media/blink/multibuffer_data_source.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 int64_t available = reader_->Available(); | 396 int64_t available = reader_->Available(); |
397 if (available < 0) { | 397 if (available < 0) { |
398 // A failure has occured. | 398 // A failure has occured. |
399 ReadOperation::Run(std::move(read_op_), kReadError); | 399 ReadOperation::Run(std::move(read_op_), kReadError); |
400 return; | 400 return; |
401 } | 401 } |
402 if (available) { | 402 if (available) { |
403 bytes_read = | 403 bytes_read = |
404 static_cast<int>(std::min<int64_t>(available, read_op_->size())); | 404 static_cast<int>(std::min<int64_t>(available, read_op_->size())); |
405 bytes_read = reader_->TryRead(read_op_->data(), bytes_read); | 405 bytes_read = reader_->TryRead(read_op_->data(), bytes_read); |
406 | 406 url_data_->AddBytesRead(bytes_read); |
407 if (bytes_read == 0 && total_bytes_ == kPositionNotSpecified) { | 407 if (bytes_read == 0 && total_bytes_ == kPositionNotSpecified) { |
408 // We've reached the end of the file and we didn't know the total size | 408 // We've reached the end of the file and we didn't know the total size |
409 // before. Update the total size so Read()s past the end of the file will | 409 // before. Update the total size so Read()s past the end of the file will |
410 // fail like they would if we had known the file size at the beginning. | 410 // fail like they would if we had known the file size at the beginning. |
411 total_bytes_ = reader_->Tell(); | 411 total_bytes_ = reader_->Tell(); |
412 if (total_bytes_ != kPositionNotSpecified) | 412 if (total_bytes_ != kPositionNotSpecified) |
413 host_->SetTotalBytes(total_bytes_); | 413 host_->SetTotalBytes(total_bytes_); |
414 } | 414 } |
415 | 415 |
416 ReadOperation::Run(std::move(read_op_), bytes_read); | 416 ReadOperation::Run(std::move(read_op_), bytes_read); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 reader_->SetPinRange(pin_backward, pin_forward); | 614 reader_->SetPinRange(pin_backward, pin_forward); |
615 | 615 |
616 if (preload_ == METADATA) { | 616 if (preload_ == METADATA) { |
617 reader_->SetPreload(0, 0); | 617 reader_->SetPreload(0, 0); |
618 } else { | 618 } else { |
619 reader_->SetPreload(preload_high, preload); | 619 reader_->SetPreload(preload_high, preload); |
620 } | 620 } |
621 } | 621 } |
622 | 622 |
623 } // namespace media | 623 } // namespace media |
OLD | NEW |