| 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 int64_t available = reader_->Available(); | 391 int64_t available = reader_->Available(); |
| 392 if (available < 0) { | 392 if (available < 0) { |
| 393 // A failure has occured. | 393 // A failure has occured. |
| 394 ReadOperation::Run(std::move(read_op_), kReadError); | 394 ReadOperation::Run(std::move(read_op_), kReadError); |
| 395 return; | 395 return; |
| 396 } | 396 } |
| 397 if (available) { | 397 if (available) { |
| 398 bytes_read = | 398 bytes_read = |
| 399 static_cast<int>(std::min<int64_t>(available, read_op_->size())); | 399 static_cast<int>(std::min<int64_t>(available, read_op_->size())); |
| 400 bytes_read = reader_->TryRead(read_op_->data(), bytes_read); | 400 bytes_read = reader_->TryRead(read_op_->data(), bytes_read); |
| 401 |
| 402 if (bytes_read == 0 && total_bytes_ == kPositionNotSpecified) { |
| 403 // We've reached the end of the file and we didn't know the total size |
| 404 // before. Update the total size so Read()s past the end of the file will |
| 405 // fail like they would if we had known the file size at the beginning. |
| 406 total_bytes_ = reader_->Tell(); |
| 407 if (total_bytes_ != kPositionNotSpecified) |
| 408 host_->SetTotalBytes(total_bytes_); |
| 409 } |
| 410 |
| 401 ReadOperation::Run(std::move(read_op_), bytes_read); | 411 ReadOperation::Run(std::move(read_op_), bytes_read); |
| 402 } else { | 412 } else { |
| 403 reader_->Wait(1, base::Bind(&MultibufferDataSource::ReadTask, | 413 reader_->Wait(1, base::Bind(&MultibufferDataSource::ReadTask, |
| 404 weak_factory_.GetWeakPtr())); | 414 weak_factory_.GetWeakPtr())); |
| 405 UpdateLoadingState(false); | 415 UpdateLoadingState(false); |
| 406 } | 416 } |
| 407 } | 417 } |
| 408 | 418 |
| 409 void MultibufferDataSource::StopInternal_Locked() { | 419 void MultibufferDataSource::StopInternal_Locked() { |
| 410 lock_.AssertAcquired(); | 420 lock_.AssertAcquired(); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 reader_->SetMaxBuffer(back_buffer, preload + kPreloadHighExtra); | 584 reader_->SetMaxBuffer(back_buffer, preload + kPreloadHighExtra); |
| 575 | 585 |
| 576 if (preload_ == METADATA) { | 586 if (preload_ == METADATA) { |
| 577 reader_->SetPreload(0, 0); | 587 reader_->SetPreload(0, 0); |
| 578 } else { | 588 } else { |
| 579 reader_->SetPreload(preload + kPreloadHighExtra, preload); | 589 reader_->SetPreload(preload + kPreloadHighExtra, preload); |
| 580 } | 590 } |
| 581 } | 591 } |
| 582 | 592 |
| 583 } // namespace media | 593 } // namespace media |
| OLD | NEW |