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

Unified Diff: content/renderer/media/buffered_data_source.cc

Issue 302553006: Suppress pause and buffer for local resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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 | « content/renderer/media/buffered_data_source.h ('k') | content/renderer/media/webmediaplayer_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/buffered_data_source.cc
diff --git a/content/renderer/media/buffered_data_source.cc b/content/renderer/media/buffered_data_source.cc
index d0461785f5e5b6e9b79eccee19f4e752da684b31..118167489f553331a25d276350c2331ae1968808 100644
--- a/content/renderer/media/buffered_data_source.cc
+++ b/content/renderer/media/buffered_data_source.cc
@@ -201,12 +201,13 @@ void BufferedDataSource::MediaPlaybackRateChanged(float playback_rate) {
void BufferedDataSource::MediaIsPlaying() {
DCHECK(render_loop_->BelongsToCurrentThread());
media_has_played_ = true;
- UpdateDeferStrategy(false);
+ // is_local_resource does not matter while playing, so send false.
+ UpdateDeferStrategy(false, false);
}
-void BufferedDataSource::MediaIsPaused() {
+void BufferedDataSource::MediaIsPaused(bool is_local_resource) {
DCHECK(render_loop_->BelongsToCurrentThread());
- UpdateDeferStrategy(true);
+ UpdateDeferStrategy(true, is_local_resource);
}
/////////////////////////////////////////////////////////////////////////////
@@ -513,7 +514,8 @@ void BufferedDataSource::ProgressCallback(int64 position) {
host_->AddBufferedByteRange(loader_->first_byte_position(), position);
}
-void BufferedDataSource::UpdateDeferStrategy(bool paused) {
+void BufferedDataSource::UpdateDeferStrategy(bool paused,
+ bool is_local_resource) {
// 200 responses end up not being reused to satisfy future range requests,
// and we don't want to get too far ahead of the read-head (and thus require
// a restart), so keep to the thresholds.
@@ -525,8 +527,13 @@ void BufferedDataSource::UpdateDeferStrategy(bool paused) {
// If the playback has started (at which point the preload value is ignored)
// and we're paused, then try to load as much as possible (the loader will
// fall back to kCapacityDefer if it knows the current response won't be
- // useful from the cache in the future).
+ // useful from the cache in the future) for external resources. Loading data
+ // in buffer is not necessary while the player is paused.
AmoghBihani 2014/05/27 14:17:30 Oh I am sorry, I will change this statement to "Lo
if (media_has_played_ && paused) {
+ if (is_local_resource) {
+ loader_->UpdateDeferStrategy(BufferedResourceLoader::kReadThenDefer);
+ return;
+ }
loader_->UpdateDeferStrategy(BufferedResourceLoader::kNeverDefer);
return;
}
« no previous file with comments | « content/renderer/media/buffered_data_source.h ('k') | content/renderer/media/webmediaplayer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698