summaryrefslogtreecommitdiffstats
path: root/webkit/media
diff options
context:
space:
mode:
authorddorwin@chromium.org <ddorwin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-07 19:20:06 +0000
committerddorwin@chromium.org <ddorwin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-07 19:20:06 +0000
commit795cd7dc24861699050010c94446e1234ec82dbe (patch)
tree0b33ebc978c413291673e0f2a67ce401848f5ac6 /webkit/media
parent9f4f1d916f20689a5d8121f3a784c4f98e43176e (diff)
downloadchromium_src-795cd7dc24861699050010c94446e1234ec82dbe.zip
chromium_src-795cd7dc24861699050010c94446e1234ec82dbe.tar.gz
chromium_src-795cd7dc24861699050010c94446e1234ec82dbe.tar.bz2
Properly manage lifetime of Helper Plugin in ProxyDecryptor.
BUG=173755 TEST=Forced failure and saw no assert Review URL: https://chromiumcodereview.appspot.com/12114056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181347 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/media')
-rw-r--r--webkit/media/crypto/proxy_decryptor.cc26
-rw-r--r--webkit/media/crypto/proxy_decryptor.h1
2 files changed, 24 insertions, 3 deletions
diff --git a/webkit/media/crypto/proxy_decryptor.cc b/webkit/media/crypto/proxy_decryptor.cc
index 4ab9dce..60a354a 100644
--- a/webkit/media/crypto/proxy_decryptor.cc
+++ b/webkit/media/crypto/proxy_decryptor.cc
@@ -22,7 +22,10 @@
namespace webkit_media {
-static scoped_refptr<webkit::ppapi::PluginInstance> CreatePluginInstance(
+// Returns the PluginInstance associated with the Helper Plugin.
+// If a non-NULL pointer is returned, the caller must call closeHelperPlugin()
+// when the Helper Plugin is no longer needed.
+static scoped_refptr<webkit::ppapi::PluginInstance> CreateHelperPlugin(
const std::string& plugin_type,
WebKit::WebMediaPlayerClient* web_media_player_client,
WebKit::WebFrame* web_frame) {
@@ -41,6 +44,11 @@ static scoped_refptr<webkit::ppapi::PluginInstance> CreatePluginInstance(
return ppapi_plugin->instance();
}
+static void DestroyHelperPlugin(
+ WebKit::WebMediaPlayerClient* web_media_player_client) {
+ web_media_player_client->closeHelperPlugin();
+}
+
ProxyDecryptor::ProxyDecryptor(
WebKit::WebMediaPlayerClient* web_media_player_client,
WebKit::WebFrame* web_frame,
@@ -50,6 +58,7 @@ ProxyDecryptor::ProxyDecryptor(
const media::NeedKeyCB& need_key_cb)
: web_media_player_client_(web_media_player_client),
web_frame_(web_frame),
+ did_create_helper_plugin_(false),
key_added_cb_(key_added_cb),
key_error_cb_(key_error_cb),
key_message_cb_(key_message_cb),
@@ -58,6 +67,16 @@ ProxyDecryptor::ProxyDecryptor(
}
ProxyDecryptor::~ProxyDecryptor() {
+ // Destroy the decryptor explicitly before destroying the plugin.
+ {
+ base::AutoLock auto_lock(lock_);
+ decryptor_.reset();
+ }
+
+ if (did_create_helper_plugin_)
+ DestroyHelperPlugin(web_media_player_client_);
+
+ web_media_player_client_ = NULL; // We should be done using it now.
}
// TODO(xhwang): Support multiple decryptor notification request (e.g. from
@@ -144,8 +163,9 @@ scoped_ptr<media::Decryptor> ProxyDecryptor::CreatePpapiDecryptor(
std::string plugin_type = GetPluginType(key_system);
DCHECK(!plugin_type.empty());
const scoped_refptr<webkit::ppapi::PluginInstance>& plugin_instance =
- CreatePluginInstance(plugin_type, web_media_player_client_, web_frame_);
- if (!plugin_instance) {
+ CreateHelperPlugin(plugin_type, web_media_player_client_, web_frame_);
+ did_create_helper_plugin_ = plugin_instance != NULL;
+ if (!did_create_helper_plugin_) {
DVLOG(1) << "ProxyDecryptor: plugin instance creation failed.";
return scoped_ptr<media::Decryptor>();
}
diff --git a/webkit/media/crypto/proxy_decryptor.h b/webkit/media/crypto/proxy_decryptor.h
index 40a9af5..8327fee 100644
--- a/webkit/media/crypto/proxy_decryptor.h
+++ b/webkit/media/crypto/proxy_decryptor.h
@@ -73,6 +73,7 @@ class ProxyDecryptor {
// Needed to create the PpapiDecryptor.
WebKit::WebMediaPlayerClient* web_media_player_client_;
WebKit::WebFrame* web_frame_;
+ bool did_create_helper_plugin_;
// Callbacks for firing key events.
media::KeyAddedCB key_added_cb_;