Avoid deleting print buffer resources before the renderer takes a reference to them
commit1087a3e12e44e2d45f357ae74c11c3fb307efbe1
authorraymes <raymes@chromium.org>
Fri, 22 May 2015 04:34:05 +0000 (21 21:34 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 22 May 2015 04:34:51 +0000 (22 04:34 +0000)
treecc410ff613199896852f4c84fa22ca299c63a81f
parent6262a2f534466059a01244152d2312ae4d216ef7
Avoid deleting print buffer resources before the renderer takes a reference to them

Currently, the plugin returns a PPB_Buffer resource to the renderer in a sync IPC reply which contains the data to print. After it returns the buffer, it calls ResourceTracker::ReleaseSoon to release the buffer on the plugin side. This eventually causes an IPC to be sent to the renderer informing it that the plugin has released its side of the resource. It assumes that by this point the renderer has had a chance to take a reference to the resource (see the old version of PrintPages in ppp_printing_proxy.cc below). However due to the arbitrary order in which sync/async messages can be processed in the renderer side, the release IPC may be received in the renderer before the reply to the sync message, causing the refcount of the buffer resource to drop to 0 and to be released before the renderer has had a chance to add a ref. This seems to have caused crbug.com/488697.

To solve this, in this case we do not send an IPC to release the resource to the renderer and the renderer does not add an extra ref when it receives the resource. Instead, the renderer assumes the plugins ref to the resource and the plugin "abandons" the resource. Abandoning the resource is the same as releasing the resource except that the renderer will never be notified of the release.

BUG=490611

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

Cr-Commit-Position: refs/heads/master@{#331065}
ppapi/proxy/plugin_resource_tracker.cc
ppapi/proxy/plugin_resource_tracker.h
ppapi/proxy/ppp_printing_proxy.cc
ppapi/shared_impl/resource_tracker.cc
ppapi/shared_impl/resource_tracker.h