summaryrefslogtreecommitdiffstats
path: root/webkit/media
diff options
context:
space:
mode:
authorsievers@chromium.org <sievers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-26 20:56:35 +0000
committersievers@chromium.org <sievers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-26 20:56:35 +0000
commitd92b01b07c815bf1a5744f7e903a045faf9b3e2a (patch)
tree47576c84255a23adb6f2bae38339864c3e898cfe /webkit/media
parente453a61a478c6e79ba67fee94fbfb2650361286d (diff)
downloadchromium_src-d92b01b07c815bf1a5744f7e903a045faf9b3e2a.zip
chromium_src-d92b01b07c815bf1a5744f7e903a045faf9b3e2a.tar.gz
chromium_src-d92b01b07c815bf1a5744f7e903a045faf9b3e2a.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 NOTRY=True Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=190599 Review URL: https://chromiumcodereview.appspot.com/12895002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190760 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/media')
-rw-r--r--webkit/media/android/stream_texture_factory_android.h23
-rw-r--r--webkit/media/android/webmediaplayer_android.cc5
-rw-r--r--webkit/media/android/webmediaplayer_android.h5
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 6fc3591..ba83a44 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"
namespace webkit_media {
@@ -13,19 +14,29 @@ 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.
virtual void SetClient(cc::VideoFrameProvider::Client* client) = 0;
+
+ 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 774ab07..2cf9297 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::SetVideoFrameProviderClient(
}
scoped_refptr<media::VideoFrame> 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());
}
return current_frame_;
diff --git a/webkit/media/android/webmediaplayer_android.h b/webkit/media/android/webmediaplayer_android.h
index 432d2c2..b5ad22e 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 WebLayerImpl;
@@ -23,8 +24,6 @@ class WebLayerImpl;
namespace webkit_media {
-class StreamTextureFactory;
-class StreamTextureProxy;
class WebMediaPlayerManagerAndroid;
// An abstract class that serves as the common base class for implementing
@@ -247,7 +246,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_;