Index: ppapi/shared_impl/ppb_var_shared.cc |
diff --git a/ppapi/shared_impl/ppb_var_shared.cc b/ppapi/shared_impl/ppb_var_shared.cc |
index 702a89a684853fbd73f9b5d86a0847e96da7eee1..1ed4c7b7f04f3795ebcaebd1b9f006f362ead0dd 100644 |
--- a/ppapi/shared_impl/ppb_var_shared.cc |
+++ b/ppapi/shared_impl/ppb_var_shared.cc |
@@ -11,6 +11,8 @@ |
#include "ppapi/c/pp_var.h" |
#include "ppapi/shared_impl/ppapi_globals.h" |
#include "ppapi/shared_impl/proxy_lock.h" |
+#include "ppapi/shared_impl/resource_tracker.h" |
+#include "ppapi/shared_impl/resource_var.h" |
#include "ppapi/shared_impl/var.h" |
#include "ppapi/shared_impl/var_tracker.h" |
@@ -53,10 +55,34 @@ const char* VarToUtf8(PP_Var var, uint32_t* len) { |
return NULL; |
} |
+PP_Resource VarToResource(struct PP_Var var) { |
+ ProxyAutoLock lock; |
+ ResourceVar* resource = ResourceVar::FromPPVar(var); |
+ if (!resource) |
+ return 0; |
+ PP_Resource pp_resource = resource->GetPPResource(); |
+ PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(pp_resource); |
+ return pp_resource; |
+} |
+ |
+struct PP_Var VarFromResource(PP_Resource resource) { |
yzshen1
2014/02/06 18:02:58
struct is not necessary
Matt Giuca
2014/02/07 03:11:22
Done.
|
+ ProxyAutoLock lock; |
+ return PpapiGlobals::Get()->GetVarTracker()->MakeResourcePPVar(resource); |
+} |
+ |
const PPB_Var var_interface = { |
&AddRefVar, |
&ReleaseVar, |
&VarFromUtf8, |
+ &VarToUtf8, |
+ &VarToResource, |
+ &VarFromResource |
+}; |
+ |
+const PPB_Var_1_1 var_interface1_1 = { |
+ &AddRefVar, |
+ &ReleaseVar, |
+ &VarFromUtf8, |
&VarToUtf8 |
}; |
@@ -110,11 +136,16 @@ const PPB_VarArrayBuffer_1_0 var_arraybuffer_interface = { |
} // namespace |
// static |
-const PPB_Var_1_1* PPB_Var_Shared::GetVarInterface1_1() { |
+const PPB_Var_1_2* PPB_Var_Shared::GetVarInterface1_2() { |
return &var_interface; |
} |
// static |
+const PPB_Var_1_1* PPB_Var_Shared::GetVarInterface1_1() { |
+ return &var_interface1_1; |
+} |
+ |
+// static |
const PPB_Var_1_0* PPB_Var_Shared::GetVarInterface1_0() { |
return &var_interface1_0; |
} |