summaryrefslogtreecommitdiffstats
path: root/webkit/media
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-21 02:58:18 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-21 02:58:18 +0000
commit21e3afccb6c9a1cb33b7159d1c17cf346a8fdf46 (patch)
tree89e4993199c8cbeecff14c6270ea1d241c022e82 /webkit/media
parent88e81a8e2768184d451df062f33cd6ca19f6f718 (diff)
downloadchromium_src-21e3afccb6c9a1cb33b7159d1c17cf346a8fdf46.zip
chromium_src-21e3afccb6c9a1cb33b7159d1c17cf346a8fdf46.tar.gz
chromium_src-21e3afccb6c9a1cb33b7159d1c17cf346a8fdf46.tar.bz2
Revert 118546 because it caused PrerenderHTML5VideoNetwork to timeout on windows and linux
""" Fire canplaythrough as soon as download defers to fix autoplay Reenables delayed firing of canplaythrough for media elements, and fixes the bug that had been introduced where a video with autoplay=true sometimes never starts. With this change, a video with autoplay=true should always (though not necessarily immediately) start playback on its own. BUG=106480,73609 TEST=media_unitests, manually checking video files in various conditions Review URL: https://chromiumcodereview.appspot.com/9113023 TBR=vrk@google.com Review URL: https://chromiumcodereview.appspot.com/9269027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118590 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/media')
-rw-r--r--webkit/media/buffered_data_source.cc19
-rw-r--r--webkit/media/buffered_data_source_unittest.cc38
-rw-r--r--webkit/media/webmediaplayer_impl.cc13
3 files changed, 28 insertions, 42 deletions
diff --git a/webkit/media/buffered_data_source.cc b/webkit/media/buffered_data_source.cc
index 1b9eecf..8537073 100644
--- a/webkit/media/buffered_data_source.cc
+++ b/webkit/media/buffered_data_source.cc
@@ -552,10 +552,11 @@ void BufferedDataSource::ReadCallback(int error) {
// before. Update the total size so Read()s past the end of the file will
// fail like they would if we had known the file size at the beginning.
total_bytes_ = loader_->instance_size();
- if (total_bytes_ != kPositionNotSpecified)
- buffered_bytes_ = total_bytes_;
- UpdateHostState_Locked();
+ if (host() && total_bytes_ != kPositionNotSpecified) {
+ host()->SetTotalBytes(total_bytes_);
+ host()->SetBufferedBytes(total_bytes_);
+ }
}
DoneRead_Locked(error);
}
@@ -588,10 +589,15 @@ void BufferedDataSource::NetworkEventCallback() {
if (stop_signal_received_)
return;
- is_downloading_data_ = is_downloading_data;
- buffered_bytes_ = buffered_position + 1;
+ if (is_downloading_data != is_downloading_data_) {
+ is_downloading_data_ = is_downloading_data;
+ if (host())
+ host()->SetNetworkActivity(is_downloading_data);
+ }
- UpdateHostState_Locked();
+ buffered_bytes_ = buffered_position + 1;
+ if (host())
+ host()->SetBufferedBytes(buffered_bytes_);
}
void BufferedDataSource::UpdateHostState_Locked() {
@@ -603,7 +609,6 @@ void BufferedDataSource::UpdateHostState_Locked() {
if (total_bytes_ != kPositionNotSpecified)
host()->SetTotalBytes(total_bytes_);
- host()->SetNetworkActivity(is_downloading_data_);
host()->SetBufferedBytes(buffered_bytes_);
}
diff --git a/webkit/media/buffered_data_source_unittest.cc b/webkit/media/buffered_data_source_unittest.cc
index d371a8a..6680633 100644
--- a/webkit/media/buffered_data_source_unittest.cc
+++ b/webkit/media/buffered_data_source_unittest.cc
@@ -16,8 +16,8 @@
using ::testing::_;
using ::testing::Assign;
-using ::testing::AtLeast;
using ::testing::Invoke;
+using ::testing::StrictMock;
using ::testing::NiceMock;
using WebKit::WebFrame;
@@ -83,6 +83,7 @@ class BufferedDataSourceTest : public testing::Test {
data_source_ = new MockBufferedDataSource(message_loop_,
view_->mainFrame());
+ data_source_->set_host(&host_);
}
virtual ~BufferedDataSourceTest() {
@@ -90,13 +91,6 @@ class BufferedDataSourceTest : public testing::Test {
}
void Initialize(media::PipelineStatus expected) {
- Initialize(expected, true);
- }
-
- void Initialize(media::PipelineStatus expected, bool set_host) {
- if (set_host)
- data_source_->set_host(&host_);
-
ExpectCreateResourceLoader();
data_source_->Initialize(response_generator_.gurl(),
media::NewExpectedStatusCB(expected));
@@ -107,10 +101,8 @@ class BufferedDataSourceTest : public testing::Test {
void InitializeWith206Response() {
Initialize(media::PIPELINE_OK);
- EXPECT_CALL(host_, SetTotalBytes(response_generator_.content_length()))
- .Times(AtLeast(1));
- EXPECT_CALL(host_, SetBufferedBytes(0))
- .Times(AtLeast(1));
+ EXPECT_CALL(host_, SetTotalBytes(response_generator_.content_length()));
+ EXPECT_CALL(host_, SetBufferedBytes(0));
Respond(response_generator_.Generate206(0));
}
@@ -184,7 +176,7 @@ class BufferedDataSourceTest : public testing::Test {
MockWebFrameClient client_;
WebView* view_;
- NiceMock<media::MockDataSourceHost> host_;
+ StrictMock<media::MockDataSourceHost> host_;
MessageLoop* message_loop_;
private:
@@ -447,10 +439,8 @@ TEST_F(BufferedDataSourceTest, Read) {
ReadAt(0);
// When the read completes we'll update our network status.
- EXPECT_CALL(host_, SetBufferedBytes(kDataSize))
- .Times(AtLeast(1));
- EXPECT_CALL(host_, SetNetworkActivity(true))
- .Times(AtLeast(1));
+ EXPECT_CALL(host_, SetBufferedBytes(kDataSize));
+ EXPECT_CALL(host_, SetNetworkActivity(true));
EXPECT_CALL(*this, ReadCallback(kDataSize));
FinishRead();
@@ -462,18 +452,4 @@ TEST_F(BufferedDataSourceTest, Read) {
Stop();
}
-// Make sure information regarding loaded data propogates to the host even if it
-// gets initialized before the host is set.
-TEST_F(BufferedDataSourceTest, HostSetAfterResponse) {
- Initialize(media::PIPELINE_OK, false);
- Respond(response_generator_.Generate206(0));
-
- EXPECT_CALL(host_, SetNetworkActivity(_));
- EXPECT_CALL(host_, SetTotalBytes(_));
- EXPECT_CALL(host_, SetBufferedBytes(_));
- data_source_->set_host(&host_);
-
- Stop();
-}
-
} // namespace webkit_media
diff --git a/webkit/media/webmediaplayer_impl.cc b/webkit/media/webmediaplayer_impl.cc
index 1432dba..011e630 100644
--- a/webkit/media/webmediaplayer_impl.cc
+++ b/webkit/media/webmediaplayer_impl.cc
@@ -701,7 +701,10 @@ void WebMediaPlayerImpl::OnPipelineInitialize(PipelineStatus status) {
SetNetworkState(WebKit::WebMediaPlayer::Loaded);
SetReadyState(WebKit::WebMediaPlayer::HaveMetadata);
- SetReadyState(WebKit::WebMediaPlayer::HaveFutureData);
+ // Fire canplaythrough immediately after playback begins because of
+ // crbug.com/106480.
+ // TODO(vrk): set ready state to HaveFutureData when bug above is fixed.
+ SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData);
} else {
// TODO(hclam): should use |status| to determine the state
// properly and reports error using MediaError.
@@ -787,11 +790,13 @@ void WebMediaPlayerImpl::OnNetworkEvent(NetworkEvent type) {
SetNetworkState(WebKit::WebMediaPlayer::Loading);
break;
case media::DOWNLOAD_PAUSED:
- if (!pipeline_->IsLocalSource())
- SetNetworkState(WebKit::WebMediaPlayer::Idle);
+ SetNetworkState(WebKit::WebMediaPlayer::Idle);
break;
case media::CAN_PLAY_THROUGH:
- SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData);
+ // Temporarily disable delayed firing of CAN_PLAY_THROUGH due to
+ // crbug.com/106480.
+ // TODO(vrk): uncomment code below when bug above is fixed.
+ // SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData);
break;
default:
NOTREACHED();