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

Unified Diff: media/base/download_rate_monitor.cc

Issue 9269027: Revert 118546 because it caused PrerenderHTML5VideoNetwork to timeout on windows and linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 11 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/base/download_rate_monitor.h ('k') | media/base/download_rate_monitor_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/download_rate_monitor.cc
===================================================================
--- media/base/download_rate_monitor.cc (revision 118589)
+++ media/base/download_rate_monitor.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -91,6 +91,8 @@
if (stopped_)
return;
+ is_downloading_data_ = true;
+
// Check monotonically nondecreasing constraint.
base::Time previous_time;
if (!current_sample_.is_null())
@@ -118,11 +120,12 @@
}
void DownloadRateMonitor::SetNetworkActivity(bool is_downloading_data) {
- // Record when download defers for the first time.
- if (!is_downloading_data && !has_deferred_) {
- has_deferred_ = true;
- NotifyCanPlayThroughIfNeeded();
- }
+ if (is_downloading_data == is_downloading_data_)
+ return;
+ // Invalidate the current sample if downloading is going from start to stopped
+ // or vice versa.
+ current_sample_.Reset();
+ is_downloading_data_ = is_downloading_data;
}
void DownloadRateMonitor::Stop() {
@@ -136,13 +139,13 @@
has_notified_can_play_through_ = false;
current_sample_.Reset();
sample_window_.clear();
+ is_downloading_data_ = false;
total_bytes_ = -1;
buffered_bytes_ = 0;
local_source_ = false;
bitrate_ = 0;
stopped_ = true;
streaming_ = false;
- has_deferred_ = false;
}
DownloadRateMonitor::~DownloadRateMonitor() { }
@@ -207,9 +210,8 @@
if (local_source_ || streaming_)
return true;
- // If all bytes are buffered or if enough bytes were buffered such that
- // downloading has deferred, fire CanPlayThrough.
- if (buffered_bytes_ == total_bytes_ || has_deferred_)
+ // If all bytes are buffered, fire CanPlayThrough.
+ if (buffered_bytes_ == total_bytes_)
return true;
// If bitrate is unknown, optimistically fire CanPlayThrough immediately.
@@ -226,9 +228,12 @@
if (download_rate > 0)
return download_rate >= bytes_needed_per_second;
- // With very fast connections, we may want to fire CanPlayThrough before
- // waiting for the sample window size to reach |kNumberOfSamples|. Check for
- // this scenario.
+ // If download rate is unknown, it may be because the media is being
+ // downloaded so fast that it cannot collect an adequate number of samples
+ // before the download gets deferred.
+ //
+ // To catch this case, we also look at how much data is being downloaded
+ // immediately after the download begins.
if (sample_window_.size() < kNumberOfSamples) {
int64 bytes_downloaded_since_start =
bytes_downloaded_in_window() + current_sample_.bytes_downloaded();
« no previous file with comments | « media/base/download_rate_monitor.h ('k') | media/base/download_rate_monitor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698