From 424bf6b47ba02d4000ea75ff1cb1a0bc4f9e118c Mon Sep 17 00:00:00 2001 From: "mgiuca@chromium.org" Date: Thu, 12 Sep 2013 11:11:20 +0000 Subject: [PPAPI] Added PP_VARTYPE_RESOURCE as a PP_VarType enum value. This type is not yet useful. There is currently no way to generate one of these. If the plugin manually builds one and sends it in a message, it will currently check-fail, crashing the plugin. BUG=177017 Review URL: https://chromiumcodereview.appspot.com/18599005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222759 0039d316-1c4b-4281-b951-d872f2087c98 --- ppapi/shared_impl/resource_var.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'ppapi/shared_impl/resource_var.cc') diff --git a/ppapi/shared_impl/resource_var.cc b/ppapi/shared_impl/resource_var.cc index 61709119..7936e70 100644 --- a/ppapi/shared_impl/resource_var.cc +++ b/ppapi/shared_impl/resource_var.cc @@ -4,6 +4,9 @@ #include "ppapi/shared_impl/resource_var.h" +#include "ppapi/shared_impl/ppapi_globals.h" +#include "ppapi/shared_impl/var_tracker.h" + namespace ppapi { ResourceVar::ResourceVar() : pp_resource_(0) {} @@ -21,16 +24,18 @@ ResourceVar* ResourceVar::AsResourceVar() { } PP_VarType ResourceVar::GetType() const { - // TODO(mgiuca): Return PP_VARTYPE_RESOURCE, once that is a valid enum value. - NOTREACHED(); - return PP_VARTYPE_UNDEFINED; + return PP_VARTYPE_RESOURCE; } // static ResourceVar* ResourceVar::FromPPVar(PP_Var var) { - // TODO(mgiuca): Implement this function, once PP_VARTYPE_RESOURCE is - // introduced. - return NULL; + if (var.type != PP_VARTYPE_RESOURCE) + return NULL; + scoped_refptr var_object( + PpapiGlobals::Get()->GetVarTracker()->GetVar(var)); + if (!var_object.get()) + return NULL; + return var_object->AsResourceVar(); } } // namespace ppapi -- cgit v1.1