diff options
author | vrk@google.com <vrk@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-19 20:21:12 +0000 |
---|---|---|
committer | vrk@google.com <vrk@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-19 20:21:12 +0000 |
commit | b55a06a9e2604e332fc5b1237924d02cc298dcda (patch) | |
tree | e66daf2d786e7f576fe9e9d5e60f854316dec110 /webkit/glue/media | |
parent | 1cdf4fac8473459e0c6a6860fc482987b79f7b63 (diff) | |
download | chromium_src-b55a06a9e2604e332fc5b1237924d02cc298dcda.zip chromium_src-b55a06a9e2604e332fc5b1237924d02cc298dcda.tar.gz chromium_src-b55a06a9e2604e332fc5b1237924d02cc298dcda.tar.bz2 |
Add NetworkEventCB to media pipeline and remove IsNetworkActive()
Network events and the network status associated with the event (active or
in-) should be coupled together. WebMediaPlayerImpl should not ask the
PipelineImpl for network activity.
BUG=100652
TEST=none
Review URL: http://codereview.chromium.org/8342013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106369 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/media')
-rw-r--r-- | webkit/glue/media/buffered_data_source.cc | 10 | ||||
-rw-r--r-- | webkit/glue/media/buffered_data_source.h | 4 | ||||
-rw-r--r-- | webkit/glue/media/buffered_resource_loader.cc | 35 | ||||
-rw-r--r-- | webkit/glue/media/buffered_resource_loader.h | 12 |
4 files changed, 27 insertions, 34 deletions
diff --git a/webkit/glue/media/buffered_data_source.cc b/webkit/glue/media/buffered_data_source.cc index 407a73a..a3f43cf5 100644 --- a/webkit/glue/media/buffered_data_source.cc +++ b/webkit/glue/media/buffered_data_source.cc @@ -50,7 +50,7 @@ BufferedDataSource::BufferedDataSource( streaming_(false), frame_(frame), loader_(NULL), - network_activity_(false), + is_downloading_data_(false), read_position_(0), read_size_(0), read_buffer_(NULL), @@ -621,7 +621,7 @@ void BufferedDataSource::NetworkEventCallback() { if (loaded_) return; - bool network_activity = loader_->network_activity(); + bool is_downloading_data = loader_->is_downloading_data(); int64 buffered_position = loader_->GetBufferedPosition(); // If we get an unspecified value, return immediately. @@ -640,10 +640,10 @@ void BufferedDataSource::NetworkEventCallback() { if (stop_signal_received_) return; - if (network_activity != network_activity_) { - network_activity_ = network_activity; + if (is_downloading_data != is_downloading_data_) { + is_downloading_data_ = is_downloading_data; if (host()) - host()->SetNetworkActivity(network_activity); + host()->SetNetworkActivity(is_downloading_data); } buffered_bytes_ = buffered_position + 1; diff --git a/webkit/glue/media/buffered_data_source.h b/webkit/glue/media/buffered_data_source.h index b157d5e..7667e4c 100644 --- a/webkit/glue/media/buffered_data_source.h +++ b/webkit/glue/media/buffered_data_source.h @@ -158,8 +158,8 @@ class BufferedDataSource : public WebDataSource { // A resource loader for the media resource. scoped_refptr<BufferedResourceLoader> loader_; - // True if network is active. - bool network_activity_; + // True if |loader| is downloading data. + bool is_downloading_data_; // Callback method from the pipeline for initialization. media::PipelineStatusCB initialize_cb_; diff --git a/webkit/glue/media/buffered_resource_loader.cc b/webkit/glue/media/buffered_resource_loader.cc index d39d54b..457aee2 100644 --- a/webkit/glue/media/buffered_resource_loader.cc +++ b/webkit/glue/media/buffered_resource_loader.cc @@ -295,12 +295,8 @@ void BufferedResourceLoader::Read(int64 position, // Make sure we stop deferring now that there's additional capacity. // // XXX: can we DCHECK(url_loader_.get()) at this point in time? - if (deferred_ && url_loader_.get()) { - deferred_ = false; - - url_loader_->setDefersLoading(deferred_); - NotifyNetworkEvent(); - } + if (deferred_) + SetDeferred(false); DCHECK(!ShouldEnableDefer()) << "Capacity was not adjusted properly to prevent deferring."; @@ -330,7 +326,7 @@ bool BufferedResourceLoader::range_supported() { return range_supported_; } -bool BufferedResourceLoader::network_activity() { +bool BufferedResourceLoader::is_downloading_data() { return !completed_ && !deferred_; } @@ -609,11 +605,17 @@ void BufferedResourceLoader::UpdateDeferBehavior() { if (!url_loader_.get() || !buffer_.get()) return; - if ((deferred_ && ShouldDisableDefer()) || - (!deferred_ && ShouldEnableDefer())) { - bool eventOccurred = ToggleDeferring(); - if (eventOccurred) - NotifyNetworkEvent(); + // If necessary, toggle defer state and continue/pause downloading data + // accordingly. + if (ShouldEnableDefer() || ShouldDisableDefer()) + SetDeferred(!deferred_); +} + +void BufferedResourceLoader::SetDeferred(bool deferred) { + deferred_ = deferred; + if (url_loader_.get()) { + url_loader_->setDefersLoading(deferred); + NotifyNetworkEvent(); } } @@ -668,15 +670,6 @@ bool BufferedResourceLoader::ShouldDisableDefer() { return false; } -bool BufferedResourceLoader::ToggleDeferring() { - deferred_ = !deferred_; - if (url_loader_.get()) { - url_loader_->setDefersLoading(deferred_); - return true; - } - return false; -} - bool BufferedResourceLoader::CanFulfillRead() { // If we are reading too far in the backward direction. if (first_offset_ < 0 && diff --git a/webkit/glue/media/buffered_resource_loader.h b/webkit/glue/media/buffered_resource_loader.h index 1b6d55f..50e2ae8 100644 --- a/webkit/glue/media/buffered_resource_loader.h +++ b/webkit/glue/media/buffered_resource_loader.h @@ -116,8 +116,8 @@ class BufferedResourceLoader // Returns true if the server supports byte range requests. virtual bool range_supported(); - // Returns true if network is currently active. - virtual bool network_activity(); + // Returns true if the resource loader is currently downloading data. + virtual bool is_downloading_data(); // Returns resulting URL. virtual const GURL& url(); @@ -179,10 +179,6 @@ class BufferedResourceLoader // Updates the |buffer_|'s forward and backward capacities. void UpdateBufferWindow(); - // Toggles whether the resource loading is deferred or not. - // Returns true if a network event was fired. - bool ToggleDeferring(); - // Returns true if we should defer resource loading, based // on current buffering scheme. bool ShouldEnableDefer(); @@ -194,6 +190,10 @@ class BufferedResourceLoader // Updates deferring behavior based on current buffering scheme. void UpdateDeferBehavior(); + // Set defer state to |deferred| and cease/continue downloading data + // accordingly. + void SetDeferred(bool deferred); + // Returns true if the current read request can be fulfilled by what is in // the buffer. bool CanFulfillRead(); |