Chromium Code Reviews| 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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 510 UpdateLoadingState(true); | 510 UpdateLoadingState(true); |
| 511 } | 511 } |
| 512 | 512 |
| 513 void MultibufferDataSource::ProgressCallback(int64_t begin, int64_t end) { | 513 void MultibufferDataSource::ProgressCallback(int64_t begin, int64_t end) { |
| 514 DVLOG(1) << __func__ << "(" << begin << ", " << end << ")"; | 514 DVLOG(1) << __func__ << "(" << begin << ", " << end << ")"; |
| 515 DCHECK(render_task_runner_->BelongsToCurrentThread()); | 515 DCHECK(render_task_runner_->BelongsToCurrentThread()); |
| 516 | 516 |
| 517 if (assume_fully_buffered()) | 517 if (assume_fully_buffered()) |
| 518 return; | 518 return; |
| 519 | 519 |
| 520 base::AutoLock auto_lock(lock_); | |
| 521 | |
| 520 if (end > begin) { | 522 if (end > begin) { |
| 521 // TODO(scherkus): we shouldn't have to lock to signal host(), see | 523 // TODO(scherkus): we shouldn't have to lock to signal host(), see |
| 522 // http://crbug.com/113712 for details. | 524 // http://crbug.com/113712 for details. |
| 523 base::AutoLock auto_lock(lock_); | |
| 524 if (stop_signal_received_) | 525 if (stop_signal_received_) |
| 525 return; | 526 return; |
| 526 | 527 |
| 527 host_->AddBufferedByteRange(begin, end); | 528 host_->AddBufferedByteRange(begin, end); |
| 528 } | 529 } |
| 529 | 530 |
| 530 UpdateLoadingState(false); | 531 UpdateLoadingState(false); |
| 531 } | 532 } |
| 532 | 533 |
| 533 void MultibufferDataSource::UpdateLoadingState(bool force_loading) { | 534 void MultibufferDataSource::UpdateLoadingState(bool force_loading) { |
|
sandersd (OOO until July 31)
2016/09/21 01:13:39
Nit: Add _Locked suffix?
hubbe
2016/09/21 04:19:22
Done
| |
| 534 DVLOG(1) << __func__; | 535 DVLOG(1) << __func__; |
| 536 lock_.AssertAcquired(); | |
| 535 if (assume_fully_buffered()) | 537 if (assume_fully_buffered()) |
| 536 return; | 538 return; |
| 537 // Update loading state. | 539 // Update loading state. |
| 538 bool is_loading = !!reader_ && reader_->IsLoading(); | 540 bool is_loading = !!reader_ && reader_->IsLoading(); |
| 541 if (read_op_) | |
| 542 is_loading = true; | |
|
sandersd (OOO until July 31)
2016/09/21 01:13:39
This means nothing to me, but I'll believe you.
hubbe
2016/09/21 04:19:22
Well, basically we can't destroy reader_ if there
| |
| 539 if (force_loading || is_loading != loading_) { | 543 if (force_loading || is_loading != loading_) { |
| 540 loading_ = is_loading || force_loading; | 544 loading_ = is_loading || force_loading; |
| 541 | 545 |
| 542 if (!loading_ && cancel_on_defer_) { | 546 if (!loading_ && cancel_on_defer_) { |
| 543 reader_.reset(nullptr); | 547 reader_.reset(nullptr); |
| 544 } | 548 } |
| 545 | 549 |
| 546 // Callback could kill us, be sure to call it last. | 550 // Callback could kill us, be sure to call it last. |
| 547 downloading_cb_.Run(loading_); | 551 downloading_cb_.Run(loading_); |
| 548 } | 552 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 597 reader_->SetPinRange(back_buffer, kMaxBufferPreload + kPreloadHighExtra); | 601 reader_->SetPinRange(back_buffer, kMaxBufferPreload + kPreloadHighExtra); |
| 598 | 602 |
| 599 if (preload_ == METADATA) { | 603 if (preload_ == METADATA) { |
| 600 reader_->SetPreload(0, 0); | 604 reader_->SetPreload(0, 0); |
| 601 } else { | 605 } else { |
| 602 reader_->SetPreload(preload_high, preload); | 606 reader_->SetPreload(preload_high, preload); |
| 603 } | 607 } |
| 604 } | 608 } |
| 605 | 609 |
| 606 } // namespace media | 610 } // namespace media |
| OLD | NEW |