Skip to content

Commit

Permalink
PPAPI: Always inform RenderViewImpl of instance deletion
Browse files Browse the repository at this point in the history
BUG=343576

Review URL: https://codereview.chromium.org/167393002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251810 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
dmichael@chromium.org committed Feb 18, 2014
1 parent a6b0a33 commit ee400fb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 22 additions & 2 deletions content/renderer/pepper/pepper_plugin_instance_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,26 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl(

if (render_frame) { // NULL in tests
render_frame->render_view()->PepperInstanceCreated(this);
// Bind a callback now so that we can inform the RenderViewImpl when we are
// destroyed. This works around a temporary problem stemming from work to
// move parts of RenderViewImpl in to RenderFrameImpl (see
// crbug.com/245126). If destruction happens in this order:
// 1) RenderFrameImpl
// 2) PepperPluginInstanceImpl
// 3) RenderViewImpl
// Then after 1), the PepperPluginInstanceImpl doesn't have any way to talk
// to the RenderViewImpl. But when the instance is destroyed, it still
// needs to inform the RenderViewImpl that it has gone away, otherwise
// between (2) and (3), the RenderViewImpl will still have the dead
// instance in its active set, and so might make calls on the deleted
// instance. See crbug.com/343576 for more information. Once the plugin
// calls move entirely from RenderViewImpl in to RenderFrameImpl, this
// can be a little bit simplified by instead making a direct call on
// RenderFrameImpl in the destructor (but only if render_frame_ is valid).
instance_deleted_callback_ =
base::Bind(&RenderViewImpl::PepperInstanceDeleted,
render_frame->render_view()->AsWeakPtr(),
base::Unretained(this));
view_data_.is_page_visible = !render_frame_->GetRenderWidget()->is_hidden();

// Set the initial focus.
Expand Down Expand Up @@ -584,8 +604,8 @@ PepperPluginInstanceImpl::~PepperPluginInstanceImpl() {
if (TrackedCallback::IsPending(lock_mouse_callback_))
lock_mouse_callback_->Abort();

if (render_frame_ && render_frame_->render_view())
render_frame_->render_view()->PepperInstanceDeleted(this);
if (!instance_deleted_callback_.is_null())
instance_deleted_callback_.Run();

if (!module_->IsProxied() && render_frame_) {
PepperBrowserConnection* browser_connection =
Expand Down
2 changes: 2 additions & 0 deletions content/renderer/pepper/pepper_plugin_instance_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <string>
#include <vector>

#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
Expand Down Expand Up @@ -664,6 +665,7 @@ class CONTENT_EXPORT PepperPluginInstanceImpl
const ppapi::URLResponseInfoData& data);

RenderFrameImpl* render_frame_;
base::Closure instance_deleted_callback_;
scoped_refptr<PluginModule> module_;
scoped_ptr<ppapi::PPP_Instance_Combined> instance_interface_;
// If this is the NaCl plugin, we create a new module when we switch to the
Expand Down

0 comments on commit ee400fb

Please sign in to comment.