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

Unified Diff: media/blink/multibuffer_data_source.cc

Issue 2445993003: Make sure we get at least one progress callback (Closed)
Patch Set: fix tests Created 4 years, 2 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 ce450c96bce12b6c93e885e4fb8a49b5d938396e..f054dac827f89d67b5a8eef41c53e9be7493b1d6 100644
--- a/media/blink/multibuffer_data_source.cc
+++ b/media/blink/multibuffer_data_source.cc
@@ -177,6 +177,14 @@ void MultibufferDataSource::Initialize(const InitializeCB& init_cb) {
render_task_runner_->PostTask(
FROM_HERE,
base::Bind(&MultibufferDataSource::StartCallback, weak_ptr_));
+
+ // When the entire file is already in the cache, we won't get any more
+ // progress callbacks, which breaks some expectations. Post a task to
+ // make sure that the client gets at least one call each for the progress
+ // and loading callbacks.
+ render_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&MultibufferDataSource::UpdateProgress,
+ weak_factory_.GetWeakPtr()));
} else {
reader_->Wait(1,
base::Bind(&MultibufferDataSource::StartCallback, weak_ptr_));
@@ -505,14 +513,6 @@ void MultibufferDataSource::StartCallback() {
render_task_runner_->PostTask(
FROM_HERE, base::Bind(base::ResetAndReturn(&init_cb_), success));
- // When we tell our clients that we're loading below, it's possible that
- // the entire file is already cashed. If that's true, then we won't get
- // any progress callbacks later, so we'll never tell the client that we
- // stopped loading. Post a task to make sure that we check the loading
- // state at least once.
- render_task_runner_->PostTask(
- FROM_HERE, base::Bind(&MultibufferDataSource::UpdateLoadingState,
- weak_factory_.GetWeakPtr()));
// Even if data is cached, say that we're loading at this point for
// compatibility.
UpdateLoadingState_Locked(true);
@@ -560,10 +560,13 @@ void MultibufferDataSource::UpdateLoadingState_Locked(bool force_loading) {
}
}
-void MultibufferDataSource::UpdateLoadingState() {
+void MultibufferDataSource::UpdateProgress() {
DCHECK(render_task_runner_->BelongsToCurrentThread());
- base::AutoLock auto_lock(lock_);
- UpdateLoadingState_Locked(false);
+ if (reader_) {
+ uint64_t available = reader_->Available();
+ uint64_t pos = reader_->Tell();
+ ProgressCallback(pos, pos + available);
+ }
}
void MultibufferDataSource::UpdateBufferSizes() {
« 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