diff options
author | sievers@chromium.org <sievers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-26 08:36:59 +0000 |
---|---|---|
committer | sievers@chromium.org <sievers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-26 08:36:59 +0000 |
commit | 7cd8fa922be4cc295ec31d109f81bd6552129ad0 (patch) | |
tree | c90318b29850718f3e94f1bd94d93c2665da8ecf /webkit/media | |
parent | 9f3b46d0a7413e88907ee8d89de0a6a648548fda (diff) | |
download | chromium_src-7cd8fa922be4cc295ec31d109f81bd6552129ad0.zip chromium_src-7cd8fa922be4cc295ec31d109f81bd6552129ad0.tar.gz chromium_src-7cd8fa922be4cc295ec31d109f81bd6552129ad0.tar.bz2 |
Android: Delete StreamTextureProxy on impl thread.
StreamTextureHost has a backpointer (listener_) to StreamTextureProxyImpl,
so both need to be deleted in a thread-safe fashion.
BUG=167586
Review URL: https://chromiumcodereview.appspot.com/12895002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190599 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/media')
-rw-r--r-- | webkit/media/android/stream_texture_factory_android.h | 23 | ||||
-rw-r--r-- | webkit/media/android/webmediaplayer_android.cc | 5 | ||||
-rw-r--r-- | webkit/media/android/webmediaplayer_android.h | 5 |
3 files changed, 21 insertions, 12 deletions
diff --git a/webkit/media/android/stream_texture_factory_android.h b/webkit/media/android/stream_texture_factory_android.h index dffcb8b..7a149bc 100644 --- a/webkit/media/android/stream_texture_factory_android.h +++ b/webkit/media/android/stream_texture_factory_android.h @@ -5,6 +5,7 @@ #ifndef WEBKIT_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_ANDROID_H_ #define WEBKIT_MEDIA_ANDROID_STREAM_TEXTURE_FACTORY_ANDROID_H_ +#include "base/memory/scoped_ptr.h" #include "cc/layers/video_frame_provider.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebVideoFrame.h" @@ -18,13 +19,11 @@ namespace webkit_media { // when a new video frame is available. class StreamTextureProxy { public: - virtual ~StreamTextureProxy() {} - - // Initialize the the stream_id, texture width and height. This should - // be called on the compositor thread. - virtual bool Initialize(int stream_id, int width, int height) = 0; + // Initialize and bind to the current thread, which becomes the thread that + // a connected client will receive callbacks on. + virtual void BindToCurrentThread(int stream_id, int width, int height) = 0; - virtual bool IsInitialized() = 0; + virtual bool IsBoundToThread() = 0; // Setting the target for callback when a frame is available. This function // could be called on both the main thread and the compositor thread. @@ -33,8 +32,20 @@ class StreamTextureProxy { #else virtual void SetClient(cc::VideoFrameProvider::Client* client) = 0; #endif + + struct Deleter { + inline void operator()(StreamTextureProxy* ptr) const { ptr->Release(); } + }; + + protected: + virtual ~StreamTextureProxy() {} + + // Causes this instance to be deleted on the thread it is bound to. + virtual void Release() = 0; }; +typedef scoped_ptr<StreamTextureProxy, StreamTextureProxy::Deleter> + ScopedStreamTextureProxy; // Factory class for managing the stream texture. class StreamTextureFactory { diff --git a/webkit/media/android/webmediaplayer_android.cc b/webkit/media/android/webmediaplayer_android.cc index 15dd860..4f096c4 100644 --- a/webkit/media/android/webmediaplayer_android.cc +++ b/webkit/media/android/webmediaplayer_android.cc @@ -13,7 +13,6 @@ #include "net/base/mime_util.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerClient.h" #include "webkit/compositor_bindings/web_layer_impl.h" -#include "webkit/media/android/stream_texture_factory_android.h" #include "webkit/media/android/webmediaplayer_manager_android.h" #include "webkit/media/media_switches.h" #include "webkit/media/webmediaplayer_util.h" @@ -450,10 +449,10 @@ void WebMediaPlayerAndroid::ReallocateVideoFrame() { #ifndef REMOVE_WEBVIDEOFRAME WebVideoFrame* WebMediaPlayerAndroid::getCurrentFrame() { - if (stream_texture_proxy_ && !stream_texture_proxy_->IsInitialized() && + if (stream_texture_proxy_ && !stream_texture_proxy_->IsBoundToThread() && stream_id_ && !needs_external_surface_) { gfx::Size natural_size = current_frame_->natural_size(); - stream_texture_proxy_->Initialize( + stream_texture_proxy_->BindToCurrentThread( stream_id_, natural_size.width(), natural_size.height()); } diff --git a/webkit/media/android/webmediaplayer_android.h b/webkit/media/android/webmediaplayer_android.h index fb5fae1..8deb2fe 100644 --- a/webkit/media/android/webmediaplayer_android.h +++ b/webkit/media/android/webmediaplayer_android.h @@ -16,6 +16,7 @@ #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h" +#include "webkit/media/android/stream_texture_factory_android.h" namespace WebKit { class WebVideoFrame; @@ -27,8 +28,6 @@ class WebLayerImpl; namespace webkit_media { -class StreamTextureFactory; -class StreamTextureProxy; class WebMediaPlayerManagerAndroid; class WebVideoFrameImpl; @@ -265,7 +264,7 @@ class WebMediaPlayerAndroid // Object for calling back the compositor thread to repaint the video when a // frame available. It should be initialized on the compositor thread. - scoped_ptr<StreamTextureProxy> stream_texture_proxy_; + ScopedStreamTextureProxy stream_texture_proxy_; // Whether media player needs external surface. bool needs_external_surface_; |