Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Unified Diff: media/blink/multibuffer_data_source.cc

Issue 2481673004: media: Make sure we transition back to a non-loading state (Closed)
Patch Set: merged Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/blink/multibuffer_data_source_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/multibuffer_data_source.cc
diff --git a/media/blink/multibuffer_data_source.cc b/media/blink/multibuffer_data_source.cc
index a0e16e6138528bb2531889f20ebe92b077fea7af..249e4b1d7d8ad5cd3b281cfcdfcb1202446f72fc 100644
--- a/media/blink/multibuffer_data_source.cc
+++ b/media/blink/multibuffer_data_source.cc
@@ -424,8 +424,8 @@ void MultibufferDataSource::ReadTask() {
} else {
reader_->Wait(1, base::Bind(&MultibufferDataSource::ReadTask,
weak_factory_.GetWeakPtr()));
- UpdateLoadingState_Locked(false);
}
+ UpdateLoadingState_Locked(false);
}
void MultibufferDataSource::StopInternal_Locked() {
@@ -546,15 +546,21 @@ void MultibufferDataSource::UpdateLoadingState_Locked(bool force_loading) {
return;
// Update loading state.
bool is_loading = !!reader_ && reader_->IsLoading();
- if (read_op_)
- is_loading = true;
if (force_loading || is_loading != loading_) {
- loading_ = is_loading || force_loading;
-
- if (!loading_ && cancel_on_defer_) {
+ bool loading = is_loading || force_loading;
+
+ if (!loading && cancel_on_defer_) {
+ if (read_op_) {
+ // We can't destroy the reader if a read operation is pending.
+ // UpdateLoadingState_Locked will be called again when the read
+ // operation is done.
+ return;
+ }
reader_.reset(nullptr);
}
+ loading_ = loading;
+
// Callback could kill us, be sure to call it last.
downloading_cb_.Run(loading_);
}
« no previous file with comments | « no previous file | media/blink/multibuffer_data_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698