diff options
author | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-05 16:44:24 +0000 |
---|---|---|
committer | fischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-05 16:44:24 +0000 |
commit | b517bce9d75f702c7dcffe4cdf91620ee066f818 (patch) | |
tree | 1bbcab0fefedcbede04789c32a7cbd9076e64f16 | |
parent | bb5ceb93a5ec91b4bde5fd2340b4e74691720354 (diff) | |
download | chromium_src-b517bce9d75f702c7dcffe4cdf91620ee066f818.zip chromium_src-b517bce9d75f702c7dcffe4cdf91620ee066f818.tar.gz chromium_src-b517bce9d75f702c7dcffe4cdf91620ee066f818.tar.bz2 |
Stop dropping buffering updates on the floor for small media resources.
Before, BufferedDataSource would fail to report buffering bytes earlier than the
current seek target. This is wrong because BufferedResourceLoader has a
kForwardWaitThreshold buffer and if the seek is within that range, it'll just
keep feeding bytes to BDS until the seek target is reached. Account for this.
BUG=130843
Review URL: https://chromiumcodereview.appspot.com/10503004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140536 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/media/buffered_data_source.cc | 13 | ||||
-rw-r--r-- | webkit/media/buffered_resource_loader.cc | 4 | ||||
-rw-r--r-- | webkit/media/buffered_resource_loader.h | 7 |
3 files changed, 17 insertions, 7 deletions
diff --git a/webkit/media/buffered_data_source.cc b/webkit/media/buffered_data_source.cc index 0aec84a..9e87ca0 100644 --- a/webkit/media/buffered_data_source.cc +++ b/webkit/media/buffered_data_source.cc @@ -526,7 +526,8 @@ void BufferedDataSource::ReadCallback( if (host() && total_bytes_ != kPositionNotSpecified) { host()->SetTotalBytes(total_bytes_); - host()->AddBufferedByteRange(last_read_start_, total_bytes_); + host()->AddBufferedByteRange(loader_->first_byte_position(), + total_bytes_); } } DoneRead_Locked(bytes_read); @@ -566,8 +567,9 @@ void BufferedDataSource::NetworkEventCallback() { host()->SetNetworkActivity(is_downloading_data); } - if (host() && current_buffered_position > last_read_start_) - host()->AddBufferedByteRange(last_read_start_, current_buffered_position); + int64 start = loader_->first_byte_position(); + if (host() && current_buffered_position > start) + host()->AddBufferedByteRange(start, current_buffered_position); } void BufferedDataSource::UpdateHostState_Locked() { @@ -579,8 +581,9 @@ void BufferedDataSource::UpdateHostState_Locked() { if (total_bytes_ != kPositionNotSpecified) host()->SetTotalBytes(total_bytes_); - if (buffered_bytes_ > last_read_start_) - host()->AddBufferedByteRange(last_read_start_, buffered_bytes_); + int64 start = loader_->first_byte_position(); + if (buffered_bytes_ > start) + host()->AddBufferedByteRange(start, buffered_bytes_); } } // namespace webkit_media diff --git a/webkit/media/buffered_resource_loader.cc b/webkit/media/buffered_resource_loader.cc index cfeda51..c552cba 100644 --- a/webkit/media/buffered_resource_loader.cc +++ b/webkit/media/buffered_resource_loader.cc @@ -716,6 +716,10 @@ void BufferedResourceLoader::ReadInternal() { DoneRead(kOk, read); } +int64 BufferedResourceLoader::first_byte_position() const { + return first_byte_position_; +} + // static bool BufferedResourceLoader::ParseContentRange( const std::string& content_range_str, int64* first_byte_position, diff --git a/webkit/media/buffered_resource_loader.h b/webkit/media/buffered_resource_loader.h index 3277941..83a2f5d 100644 --- a/webkit/media/buffered_resource_loader.h +++ b/webkit/media/buffered_resource_loader.h @@ -183,6 +183,9 @@ class BufferedResourceLoader : public WebKit::WebURLLoaderClient { // accordingly. void SetBitrate(int bitrate); + // Return the |first_byte_position| passed into the ctor. + int64 first_byte_position() const; + // Parse a Content-Range header into its component pieces and return true if // each of the expected elements was found & parsed correctly. // |*instance_size| may be set to kPositionNotSpecified if the range ends in @@ -281,8 +284,8 @@ class BufferedResourceLoader : public WebKit::WebURLLoaderClient { size_t saved_forward_capacity_; GURL url_; - int64 first_byte_position_; - int64 last_byte_position_; + const int64 first_byte_position_; + const int64 last_byte_position_; bool single_origin_; // Closure that listens to network events. |