diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 20:40:39 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 20:40:39 +0000 |
commit | f24448db9f893c5dde10ed1ae4cead436e18f64f (patch) | |
tree | c224a27ed5949a761ed2f62b75cedae0fa2014e2 /ppapi/proxy/plugin_var_tracker.cc | |
parent | e9319bf33e2b7e6bdd2fa005b212f2fcf0896883 (diff) | |
download | chromium_src-f24448db9f893c5dde10ed1ae4cead436e18f64f.zip chromium_src-f24448db9f893c5dde10ed1ae4cead436e18f64f.tar.gz chromium_src-f24448db9f893c5dde10ed1ae4cead436e18f64f.tar.bz2 |
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
Diffstat (limited to 'ppapi/proxy/plugin_var_tracker.cc')
-rw-r--r-- | ppapi/proxy/plugin_var_tracker.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/ppapi/proxy/plugin_var_tracker.cc b/ppapi/proxy/plugin_var_tracker.cc index 42370be..c079716 100644 --- a/ppapi/proxy/plugin_var_tracker.cc +++ b/ppapi/proxy/plugin_var_tracker.cc @@ -15,6 +15,9 @@ namespace proxy { namespace { +// When non-NULL, this object overrides the VarTrackerSingleton. +PluginVarTracker* var_tracker_override = NULL; + class RefCountedString : public base::RefCounted<RefCountedString> { public: RefCountedString() { @@ -64,7 +67,15 @@ PluginVarTracker::PluginVarTracker() : last_plugin_object_id_(0) { PluginVarTracker::~PluginVarTracker() { } +// static +void PluginVarTracker::SetInstanceForTest(PluginVarTracker* tracker) { + var_tracker_override = tracker; +} + +// static PluginVarTracker* PluginVarTracker::GetInstance() { + if (var_tracker_override) + return var_tracker_override; return Singleton<PluginVarTracker>::get(); } @@ -221,6 +232,24 @@ PP_Var PluginVarTracker::GetHostObject(const PP_Var& plugin_object) const { return ret; } +void PluginVarTracker::ReleaseHostObject(Sender* sender, + const PP_Var& host_object) { + // Convert the host object to a normal var valid in the plugin. + DCHECK(host_object.type == PP_VARTYPE_OBJECT); + HostVarToPluginVarMap::iterator found = host_var_to_plugin_var_.find( + HostVar(sender, host_object.value.as_id)); + if (found == host_var_to_plugin_var_.end()) { + NOTREACHED(); + return; + } + + // Now just release the object like normal. + PP_Var plugin_object; + plugin_object.type = PP_VARTYPE_OBJECT; + plugin_object.value.as_id = found->second; + Release(plugin_object); +} + int PluginVarTracker::GetRefCountForObject(const PP_Var& plugin_object) { PluginVarInfoMap::iterator found = plugin_var_info_.find( plugin_object.value.as_id); |