summaryrefslogtreecommitdiffstats
path: root/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-10 17:36:28 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-10 17:36:28 +0000
commita4e154afb5ee82d26fc13da06f34afc2fe124e30 (patch)
treede16701a4ecc351b62deaf7060a71222bb8cb6b8 /webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
parentcc6db92524420397e246af1ed1b07258ded14e30 (diff)
downloadchromium_src-a4e154afb5ee82d26fc13da06f34afc2fe124e30.zip
chromium_src-a4e154afb5ee82d26fc13da06f34afc2fe124e30.tar.gz
chromium_src-a4e154afb5ee82d26fc13da06f34afc2fe124e30.tar.bz2
Always run Flush completion callbacks in Graphics2D.
This fixes a leak because the completion callbacks were not getting run on resource destruction. This leaves the calling code waiting for the callbacks with leaked data associated with the callback. This patch just always runs the callbacks with PP_ERROR_ABORTED. I tweaked the callback code to use the (newer than the original code) "run and clear" completion callback macro which also cleans up the code a little. BUG=106402 Review URL: http://codereview.chromium.org/8801027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113954 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins/ppapi/ppb_graphics_2d_impl.cc')
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc23
1 files changed, 13 insertions, 10 deletions
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index a6c12a8..a209e1f 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -161,6 +161,9 @@ PPB_Graphics2D_Impl::PPB_Graphics2D_Impl(PP_Instance instance)
}
PPB_Graphics2D_Impl::~PPB_Graphics2D_Impl() {
+ // LastPluginRefWasDeleted should have aborted all pending callbacks.
+ DCHECK(painted_flush_callback_.is_null());
+ DCHECK(unpainted_flush_callback_.is_null());
}
// static
@@ -194,8 +197,14 @@ PPB_Graphics2D_Impl::AsPPB_Graphics2D_API() {
return this;
}
-PPB_Graphics2D_Impl* PPB_Graphics2D_Impl::AsPPB_Graphics2D_Impl() {
- return this;
+void PPB_Graphics2D_Impl::LastPluginRefWasDeleted() {
+ Resource::LastPluginRefWasDeleted();
+
+ // Abort any pending callbacks.
+ if (!unpainted_flush_callback_.is_null())
+ unpainted_flush_callback_.Execute(PP_ERROR_ABORTED);
+ if (!painted_flush_callback_.is_null())
+ painted_flush_callback_.Execute(PP_ERROR_ABORTED);
}
PP_Bool PPB_Graphics2D_Impl::Describe(PP_Size* size,
@@ -540,14 +549,8 @@ void PPB_Graphics2D_Impl::ViewInitiatedPaint() {
void PPB_Graphics2D_Impl::ViewFlushedPaint() {
// Notify any "painted" callback. See |unpainted_flush_callback_| in the
// header for more.
- if (!painted_flush_callback_.is_null()) {
- // We must clear this variable before issuing the callback. It will be
- // common for the plugin to issue another invalidate in response to a flush
- // callback, and we don't want to think that a callback is already pending.
- FlushCallbackData callback;
- std::swap(callback, painted_flush_callback_);
- callback.Execute(PP_OK);
- }
+ if (!painted_flush_callback_.is_null())
+ painted_flush_callback_.Execute(PP_OK);
}
void PPB_Graphics2D_Impl::ExecutePaintImageData(PPB_ImageData_Impl* image,