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