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

Unified Diff: media/blink/multibuffer_data_source.cc

Issue 2495633002: media: Make sure we transition back to a non-loading state (Closed)
Patch Set: 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 1390c69c36e78319d6f4063678258090b72bc099..78c65025e2a25e3236c1ee6ae0ebe0545331bc70 100644
--- a/media/blink/multibuffer_data_source.cc
+++ b/media/blink/multibuffer_data_source.cc
@@ -416,8 +416,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() {
@@ -538,15 +538,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