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

Unified Diff: media/blink/multibuffer_data_source.cc

Issue 2357773003: Fix a timing bug in multibuffer. (Closed)
Patch Set: comments addressed Created 4 years, 3 months 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 | « media/blink/multibuffer_data_source.h ('k') | 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 a343fee303aef91f428fcad47dcf86f04ba6b61a..1390c69c36e78319d6f4063678258090b72bc099 100644
--- a/media/blink/multibuffer_data_source.cc
+++ b/media/blink/multibuffer_data_source.cc
@@ -416,7 +416,7 @@ void MultibufferDataSource::ReadTask() {
} else {
reader_->Wait(1, base::Bind(&MultibufferDataSource::ReadTask,
weak_factory_.GetWeakPtr()));
- UpdateLoadingState(false);
+ UpdateLoadingState_Locked(false);
}
}
@@ -507,7 +507,7 @@ void MultibufferDataSource::StartCallback() {
// Even if data is cached, say that we're loading at this point for
// compatibility.
- UpdateLoadingState(true);
+ UpdateLoadingState_Locked(true);
}
void MultibufferDataSource::ProgressCallback(int64_t begin, int64_t end) {
@@ -517,25 +517,29 @@ void MultibufferDataSource::ProgressCallback(int64_t begin, int64_t end) {
if (assume_fully_buffered())
return;
+ base::AutoLock auto_lock(lock_);
+
if (end > begin) {
// TODO(scherkus): we shouldn't have to lock to signal host(), see
// http://crbug.com/113712 for details.
- base::AutoLock auto_lock(lock_);
if (stop_signal_received_)
return;
host_->AddBufferedByteRange(begin, end);
}
- UpdateLoadingState(false);
+ UpdateLoadingState_Locked(false);
}
-void MultibufferDataSource::UpdateLoadingState(bool force_loading) {
+void MultibufferDataSource::UpdateLoadingState_Locked(bool force_loading) {
DVLOG(1) << __func__;
+ lock_.AssertAcquired();
if (assume_fully_buffered())
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;
« no previous file with comments | « media/blink/multibuffer_data_source.h ('k') | media/blink/multibuffer_data_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698