summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-15 17:18:05 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-15 17:18:05 +0000
commit9670691da1ff13fc4c0cd69fab4369b448f9019a (patch)
tree2317e355463e2215a0247f142f39d3c3abeb096b /webkit/glue
parent7fd25315869cf0520d9dd813d407c58ff5c5508a (diff)
downloadchromium_src-9670691da1ff13fc4c0cd69fab4369b448f9019a.zip
chromium_src-9670691da1ff13fc4c0cd69fab4369b448f9019a.tar.gz
chromium_src-9670691da1ff13fc4c0cd69fab4369b448f9019a.tar.bz2
Removed the bool parameter from PipelineCallback and cleaned up WebMediaPlayerImpl::Proxy.
This forces clients to check Pipeline::GetError() instead of using a simple true/false check for success. Also the bool parameter wasn't being used for Seek() and Stop() callbacks, further hinting at its removal. BUG=16009 TEST=media_unittests pass, layout tests pass Review URL: http://codereview.chromium.org/149584 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20738 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/webmediaplayer_impl.cc125
-rw-r--r--webkit/glue/webmediaplayer_impl.h54
2 files changed, 73 insertions, 106 deletions
diff --git a/webkit/glue/webmediaplayer_impl.cc b/webkit/glue/webmediaplayer_impl.cc
index 3bd5138..051e7d4 100644
--- a/webkit/glue/webmediaplayer_impl.cc
+++ b/webkit/glue/webmediaplayer_impl.cc
@@ -56,58 +56,6 @@ void WebMediaPlayerImpl::Proxy::Repaint() {
}
}
-void WebMediaPlayerImpl::Proxy::TimeChanged() {
- render_loop_->PostTask(FROM_HERE,
- NewRunnableMethod(this, &WebMediaPlayerImpl::Proxy::TimeChangedTask));
-}
-
-void WebMediaPlayerImpl::Proxy::NetworkStateChanged(
- WebKit::WebMediaPlayer::NetworkState state) {
- render_loop_->PostTask(FROM_HERE,
- NewRunnableMethod(this,
- &WebMediaPlayerImpl::Proxy::NetworkStateChangedTask,
- state));
-}
-
-void WebMediaPlayerImpl::Proxy::ReadyStateChanged(
- WebKit::WebMediaPlayer::ReadyState state) {
- render_loop_->PostTask(FROM_HERE,
- NewRunnableMethod(this,
- &WebMediaPlayerImpl::Proxy::ReadyStateChangedTask,
- state));
-}
-
-void WebMediaPlayerImpl::Proxy::RepaintTask() {
- DCHECK(MessageLoop::current() == render_loop_);
- {
- AutoLock auto_lock(lock_);
- --outstanding_repaints_;
- DCHECK_GE(outstanding_repaints_, 0);
- }
- if (webmediaplayer_)
- webmediaplayer_->Repaint();
-}
-
-void WebMediaPlayerImpl::Proxy::TimeChangedTask() {
- DCHECK(MessageLoop::current() == render_loop_);
- if (webmediaplayer_)
- webmediaplayer_->TimeChanged();
-}
-
-void WebMediaPlayerImpl::Proxy::NetworkStateChangedTask(
- WebKit::WebMediaPlayer::NetworkState state) {
- DCHECK(MessageLoop::current() == render_loop_);
- if (webmediaplayer_)
- webmediaplayer_->SetNetworkState(state);
-}
-
-void WebMediaPlayerImpl::Proxy::ReadyStateChangedTask(
- WebKit::WebMediaPlayer::ReadyState state) {
- DCHECK(MessageLoop::current() == render_loop_);
- if (webmediaplayer_)
- webmediaplayer_->SetReadyState(state);
-}
-
void WebMediaPlayerImpl::Proxy::SetVideoRenderer(
VideoRendererImpl* video_renderer) {
video_renderer_ = video_renderer;
@@ -134,27 +82,40 @@ void WebMediaPlayerImpl::Proxy::Detach() {
video_renderer_ = NULL;
}
-void WebMediaPlayerImpl::Proxy::PipelineInitializationCallback(bool success) {
- if (success) {
- // Since we have initialized the pipeline, say we have everything.
- // TODO(hclam): change this to report the correct status. Should also post
- // a task to call to |webmediaplayer_|.
- ReadyStateChanged(WebKit::WebMediaPlayer::HaveMetadata);
- ReadyStateChanged(WebKit::WebMediaPlayer::HaveEnoughData);
- NetworkStateChanged(WebKit::WebMediaPlayer::Loaded);
- } else {
- // TODO(hclam): should use pipeline_->GetError() to determine the state
- // properly and reports error using MediaError.
- // WebKit uses FormatError to indicate an error for bogus URL or bad file.
- // Since we are at the initialization stage we can safely treat every error
- // as format error. Should post a task to call to |webmediaplayer_|.
- NetworkStateChanged(WebKit::WebMediaPlayer::FormatError);
+void WebMediaPlayerImpl::Proxy::PipelineInitializationCallback() {
+ render_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
+ &WebMediaPlayerImpl::Proxy::PipelineInitializationTask));
+}
+
+void WebMediaPlayerImpl::Proxy::PipelineSeekCallback() {
+ render_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
+ &WebMediaPlayerImpl::Proxy::PipelineSeekTask));
+}
+
+void WebMediaPlayerImpl::Proxy::RepaintTask() {
+ DCHECK(MessageLoop::current() == render_loop_);
+ {
+ AutoLock auto_lock(lock_);
+ --outstanding_repaints_;
+ DCHECK_GE(outstanding_repaints_, 0);
+ }
+ if (webmediaplayer_) {
+ webmediaplayer_->Repaint();
}
}
-void WebMediaPlayerImpl::Proxy::PipelineSeekCallback(bool success) {
- if (success)
- TimeChanged();
+void WebMediaPlayerImpl::Proxy::PipelineInitializationTask() {
+ DCHECK(MessageLoop::current() == render_loop_);
+ if (webmediaplayer_) {
+ webmediaplayer_->OnPipelineInitialize();
+ }
+}
+
+void WebMediaPlayerImpl::Proxy::PipelineSeekTask() {
+ DCHECK(MessageLoop::current() == render_loop_);
+ if (webmediaplayer_) {
+ webmediaplayer_->OnPipelineSeek();
+ }
}
/////////////////////////////////////////////////////////////////////////////
@@ -393,9 +354,29 @@ void WebMediaPlayerImpl::Repaint() {
GetClient()->repaint();
}
-void WebMediaPlayerImpl::TimeChanged() {
+void WebMediaPlayerImpl::OnPipelineInitialize() {
+ DCHECK(MessageLoop::current() == main_loop_);
+ if (pipeline_->GetError() == media::PIPELINE_OK) {
+ // Since we have initialized the pipeline, say we have everything.
+ // TODO(hclam): change this to report the correct status.
+ SetReadyState(WebKit::WebMediaPlayer::HaveMetadata);
+ SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData);
+ SetNetworkState(WebKit::WebMediaPlayer::Loaded);
+ } else {
+ // TODO(hclam): should use pipeline_->GetError() to determine the state
+ // properly and reports error using MediaError.
+ // WebKit uses FormatError to indicate an error for bogus URL or bad file.
+ // Since we are at the initialization stage we can safely treat every error
+ // as format error. Should post a task to call to |webmediaplayer_|.
+ SetNetworkState(WebKit::WebMediaPlayer::FormatError);
+ }
+}
+
+void WebMediaPlayerImpl::OnPipelineSeek() {
DCHECK(MessageLoop::current() == main_loop_);
- GetClient()->timeChanged();
+ if (pipeline_->GetError() == media::PIPELINE_OK) {
+ GetClient()->timeChanged();
+ }
}
void WebMediaPlayerImpl::SetNetworkState(
diff --git a/webkit/glue/webmediaplayer_impl.h b/webkit/glue/webmediaplayer_impl.h
index c13d30f..9e9522e 100644
--- a/webkit/glue/webmediaplayer_impl.h
+++ b/webkit/glue/webmediaplayer_impl.h
@@ -93,46 +93,29 @@ class WebMediaPlayerImpl : public WebKit::WebMediaPlayer,
WebMediaPlayerImpl* webmediaplayer);
virtual ~Proxy();
- // Fire a repaint event to WebKit.
+ // Public methods called from the video renderer.
void Repaint();
+ void SetVideoRenderer(VideoRendererImpl* video_renderer);
- // Report to WebKit that time has changed.
- void TimeChanged();
-
- // Report to WebKit that network state has changed.
- void NetworkStateChanged(WebKit::WebMediaPlayer::NetworkState state);
+ // Public methods called from WebMediaPlayerImpl.
+ void Paint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect);
+ void SetSize(const gfx::Rect& rect);
+ void Detach();
- // Report the WebKit that ready state has changed.
- void ReadyStateChanged(WebKit::WebMediaPlayer::ReadyState state);
-
- // Public methods to be called from video renderer.
- void SetVideoRenderer(VideoRendererImpl* video_renderer);
+ // Public methods called from the pipeline via callback issued by
+ // WebMediaPlayerImpl.
+ void PipelineInitializationCallback();
+ void PipelineSeekCallback();
private:
- friend class WebMediaPlayerImpl;
-
// Invoke |webmediaplayer_| to perform a repaint.
void RepaintTask();
- // Invoke |webmediaplayer_| to notify a time change event.
- void TimeChangedTask();
-
- // Saves the internal network state and notify WebKit to pick up the change.
- void NetworkStateChangedTask(WebKit::WebMediaPlayer::NetworkState state);
+ // Notify |webmediaplayer_| that initialization has finished.
+ void PipelineInitializationTask();
- // Saves the internal ready state and notify WebKit to pick the change.
- void ReadyStateChangedTask(WebKit::WebMediaPlayer::ReadyState state);
-
- void Paint(skia::PlatformCanvas* canvas, const gfx::Rect& dest_rect);
-
- void SetSize(const gfx::Rect& rect);
-
- // Detach from |webmediaplayer_|.
- void Detach();
-
- void PipelineInitializationCallback(bool success);
-
- void PipelineSeekCallback(bool success);
+ // Notify |webmediaplayer_| that a seek has finished.
+ void PipelineSeekTask();
// The render message loop where WebKit lives.
MessageLoop* render_loop_;
@@ -224,13 +207,16 @@ class WebMediaPlayerImpl : public WebKit::WebMediaPlayer,
void Repaint();
- void TimeChanged();
+ void OnPipelineInitialize();
- void SetNetworkState(WebKit::WebMediaPlayer::NetworkState state);
+ void OnPipelineSeek();
+ private:
+ // Helpers that set the network/ready state and notifies the client if
+ // they've changed.
+ void SetNetworkState(WebKit::WebMediaPlayer::NetworkState state);
void SetReadyState(WebKit::WebMediaPlayer::ReadyState state);
- private:
// Destroy resources held.
void Destroy();