From f24448db9f893c5dde10ed1ae4cead436e18f64f Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" Date: Thu, 27 Jan 2011 20:40:39 +0000 Subject: Refactor PPAPI proxy resource handling to maintain which host they came from, and to map back to that host when calling functions on them. Adds a mapping between resources generated by the hosts to a new list inside the plugin so there can't be overlaps. This means there are now two meanings for a PP_Resource, one in the plugin process and one in the host process. This is potentially very confusing. I introduced a new object called a HostResource that always represents a "host" PP_Resource to try to prevent errors. In the plugin side of the proxy, it only deals with PP_Resources valid in the plugin, and SerializedResources valid in the host. It also encapsulates the associated instance, which simplifies some code. Each PluginResource object maintains its SerializedResource which the proxy uses to send to the host for requests. This requires getting the PluginResource object in more proxy calls. This fixes a bug in var sending introduced in my previous patch. The var releasing from EndSendPassRef used the host var rather than the plugin var. I had to add more plumbing to get the dispatcher at this location and convert to a plugin var. I removed the separate file for ImageData and put it in ppb_image_data_proxy like for the other resource types. TEST=some unit tests included BUG=none Review URL: http://codereview.chromium.org/6334016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72879 0039d316-1c4b-4281-b951-d872f2087c98 --- ppapi/proxy/plugin_var_tracker.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'ppapi/proxy/plugin_var_tracker.h') diff --git a/ppapi/proxy/plugin_var_tracker.h b/ppapi/proxy/plugin_var_tracker.h index 02e83d5..21cd4594 100644 --- a/ppapi/proxy/plugin_var_tracker.h +++ b/ppapi/proxy/plugin_var_tracker.h @@ -44,6 +44,11 @@ class PluginVarTracker { // Dispatcher in this class, which makes it easy to unit test. typedef IPC::Channel::Sender Sender; + // Called by tests that want to specify a specific VarTracker. This allows + // them to use a unique one each time and avoids singletons sticking around + // across tests. + static void SetInstanceForTest(PluginVarTracker* tracker); + // Returns the global var tracker for the plugin object. static PluginVarTracker* GetInstance(); @@ -75,6 +80,10 @@ class PluginVarTracker { // should be a VARTYPE_OBJECT PP_Var GetHostObject(const PP_Var& plugin_object) const; + // Like Release() but the var is identified by its host object ID (as + // returned by GetHostObject). + void ReleaseHostObject(Sender* sender, const PP_Var& host_object); + // Retrieves the internal reference counts for testing. Returns 0 if we // know about the object but the corresponding value is 0, or -1 if the // given object ID isn't in our map. @@ -83,7 +92,7 @@ class PluginVarTracker { private: friend struct DefaultSingletonTraits; - friend class PluginVarTrackerTest; + friend class PluginProxyTest; // Represents a var as received from the host. struct HostVar { -- cgit v1.1