Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Unified Diff: webkit/plugins/ppapi/ppapi_webplugin_impl.cc

Issue 9403039: PPAPI: Really force-free NPObjects on Instance destruction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/plugins/ppapi/ppapi_webplugin_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppapi_webplugin_impl.cc
diff --git a/webkit/plugins/ppapi/ppapi_webplugin_impl.cc b/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
index c505741daed6c492a81066dc64932ef34ce2941a..fb0166217f54a830cb8e15b846286d0fc8b7e641 100644
--- a/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
+++ b/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
@@ -8,7 +8,8 @@
#include "base/message_loop.h"
#include "googleurl/src/gurl.h"
-#include "ppapi/c/pp_var.h"
+#include "ppapi/shared_impl/ppapi_globals.h"
+#include "ppapi/shared_impl/var_tracker.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
@@ -51,7 +52,8 @@ WebPluginImpl::WebPluginImpl(
const WebPluginParams& params,
const base::WeakPtr<PluginDelegate>& plugin_delegate)
: init_data_(new InitData()),
- full_frame_(params.loadManually) {
+ full_frame_(params.loadManually),
+ instance_object_(PP_MakeUndefined()) {
DCHECK(plugin_module);
init_data_->module = plugin_module;
init_data_->delegate = plugin_delegate;
@@ -91,6 +93,8 @@ bool WebPluginImpl::initialize(WebPluginContainer* container) {
void WebPluginImpl::destroy() {
if (instance_) {
+ ::ppapi::PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(instance_object_);
+ instance_object_ = PP_MakeUndefined();
instance_->Delete();
instance_ = NULL;
}
@@ -99,17 +103,16 @@ void WebPluginImpl::destroy() {
}
NPObject* WebPluginImpl::scriptableObject() {
- // Call through the plugin to get its instance object. Note that we "leak" a
- // reference here. But we want to keep the instance object alive so long as
- // the instance is alive, so it's okay. It will get cleaned up when all
- // NPObjectVars are "force freed" at instance shutdown.
- scoped_refptr<NPObjectVar> object(
- NPObjectVar::FromPPVar(instance_->GetInstanceObject()));
+ // Call through the plugin to get its instance object. The plugin should pass
+ // us a reference which we release in destroy().
+ if (instance_object_.type == PP_VARTYPE_UNDEFINED)
+ instance_object_ = instance_->GetInstanceObject();
// GetInstanceObject talked to the plugin which may have removed the instance
// from the DOM, in which case instance_ would be NULL now.
if (!instance_)
return NULL;
+ scoped_refptr<NPObjectVar> object(NPObjectVar::FromPPVar(instance_object_));
// If there's an InstanceObject, tell the Instance's MessageChannel to pass
// any non-postMessage calls to it.
if (object) {
« no previous file with comments | « webkit/plugins/ppapi/ppapi_webplugin_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698