diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-09 23:14:13 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-09 23:14:13 +0000 |
commit | 2bbd2c670008e30aaaef6c3c25ae37e0c17f8c3f (patch) | |
tree | 79595eeb026dd29841a7380fd7753f992c2e466b /ppapi/shared_impl/var.h | |
parent | 32131b9030d8313f7adc9b765f706ffbee7ca709 (diff) | |
download | chromium_src-2bbd2c670008e30aaaef6c3c25ae37e0c17f8c3f.zip chromium_src-2bbd2c670008e30aaaef6c3c25ae37e0c17f8c3f.tar.gz chromium_src-2bbd2c670008e30aaaef6c3c25ae37e0c17f8c3f.tar.bz2 |
Unify var tracking between webkit and the proxy.
This replaces the var tracking in the proxy with the var tracking in the
shared_impl that's used by the implementation. It adds a new ProxyObjectVar
to be the proxied plugin analog of NPObjectVar in the impl. This new object
just keeps track of the host data.
The tricky part is to make the var tracker able to do all the crazy messaging.
This adds some virtual functions to the shared var tracker that we override
in the plugin in PluginVarTracker.
This removes the calls to the GetLiveObjectsForInstance in the var deprecated
test. It turns out this function really can't be implemented properly in the
proxy, and I don't know why it even worked before. A Release() call posts a
non-nestable task so the object isn't released until later. So to implement
the proxy for GetLiveObjectsForInstance we would also need to post a
non-nestable task. But when the test runs we're getting called from within
the plugin, so blocking on a non-nestable task deadlocks. So I just gave up
and deleted the parts of the test that uses it.
TEST=included
BUG=none
Review URL: http://codereview.chromium.org/7578001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96094 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/shared_impl/var.h')
-rw-r--r-- | ppapi/shared_impl/var.h | 43 |
1 files changed, 11 insertions, 32 deletions
diff --git a/ppapi/shared_impl/var.h b/ppapi/shared_impl/var.h index e03e286..1ff42dd 100644 --- a/ppapi/shared_impl/var.h +++ b/ppapi/shared_impl/var.h @@ -10,12 +10,12 @@ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" #include "ppapi/c/pp_module.h" - -struct PP_Var; +#include "ppapi/c/pp_var.h" namespace ppapi { class NPObjectVar; +class ProxyObjectVar; class StringVar; // Var ------------------------------------------------------------------------- @@ -30,43 +30,17 @@ class Var : public base::RefCounted<Var> { // Returns a string representing the given var for logging purposes. static std::string PPVarToLogString(PP_Var var); - // Provides access to the manual refcounting of a PP_Var from the plugin's - // perspective. This is different than the AddRef/Release on this scoped - // object. This uses the ResourceTracker, which keeps a separate "plugin - // refcount" that prevents the plugin from messing up our refcounting or - // freeing something out from under us. - // - // You should not generally need to use these functions. However, if you - // call a plugin function that returns a var, it will transfer a ref to us - // (the caller) which in the case of a string or object var will need to - // be released. - // - // Example, assuming we're expecting the plugin to return a string: - // PP_Var rv = some_ppp_interface->DoSomething(a, b, c); - // - // // Get the string value. This will take a reference to the object which - // // will prevent it from being deleted out from under us when we call - // // PluginReleasePPVar(). - // scoped_refptr<StringVar> string(StringVar::FromPPVar(rv)); - // - // // Release the reference the plugin gave us when returning the value. - // // This is legal to do for all types of vars. - // Var::PluginReleasePPVar(rv); - // - // // Use the string. - // if (!string) - // return false; // It didn't return a proper string. - // UseTheString(string->value()); - static void PluginAddRefPPVar(PP_Var var); - static void PluginReleasePPVar(PP_Var var); - virtual StringVar* AsStringVar(); virtual NPObjectVar* AsNPObjectVar(); + virtual ProxyObjectVar* AsProxyObjectVar(); // Creates a PP_Var corresponding to this object. The return value will have // one reference addrefed on behalf of the caller. virtual PP_Var GetPPVar() = 0; + // Returns the type of this var. + virtual PP_VarType GetType() const = 0; + // Returns the ID corresponing to the string or object if it exists already, // or 0 if an ID hasn't been generated for this object (the plugin is holding // no refs). @@ -89,6 +63,10 @@ class Var : public base::RefCounted<Var> { // caller. int32 GetOrCreateVarID(); + // Sets the internal object ID. This assumes that the ID hasn't been set + // before. This is used in cases where the ID is generated externally. + void AssignVarID(int32 id); + private: PP_Module pp_module_; @@ -120,6 +98,7 @@ class StringVar : public Var { // Var override. virtual StringVar* AsStringVar() OVERRIDE; virtual PP_Var GetPPVar() OVERRIDE; + virtual PP_VarType GetType() const OVERRIDE; // Helper function to create a PP_Var of type string that contains a copy of // the given string. The input data must be valid UTF-8 encoded text, if it |