Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Unified Diff: ppapi/cpp/var.cc

Issue 148213016: [PPAPI] Moving pp::VarResource_Dev API into pp::Var (now stable). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove HTML note about dev interfaces. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/cpp/var.cc
diff --git a/ppapi/cpp/var.cc b/ppapi/cpp/var.cc
index 1108e05ef46488ced290cef1d8f6ee7ae366fcf2..23c7b48d7c73f5cdcca539a74d0ffb72a23db58a 100644
--- a/ppapi/cpp/var.cc
+++ b/ppapi/cpp/var.cc
@@ -25,6 +25,9 @@ namespace pp {
namespace {
+template <> const char* interface_name<PPB_Var_1_2>() {
+ return PPB_VAR_INTERFACE_1_2;
+}
template <> const char* interface_name<PPB_Var_1_1>() {
return PPB_VAR_INTERFACE_1_1;
}
@@ -101,6 +104,19 @@ Var::Var(const std::string& utf8_str) {
is_managed_ = true;
}
+Var::Var(const pp::Resource& resource) {
+ if (!has_interface<PPB_Var_1_2>()) {
+ PP_NOTREACHED();
+ return;
+ }
+
+ var_ = get_interface<PPB_Var_1_2>()->VarFromResource(
+ resource.pp_resource());
+ // Set |is_managed_| to true, so |var_| will be properly released upon
+ // destruction.
+ is_managed_ = true;
+}
+
Var::Var(const PP_Var& var) {
var_ = var;
@@ -219,6 +235,15 @@ std::string Var::AsString() const {
return std::string(str, len);
}
+pp::Resource Var::AsResource() const {
yzshen1 2014/02/06 18:02:58 Maybe we should follow AsString to assert that it
Matt Giuca 2014/02/07 03:11:22 Done.
+ if (!has_interface<PPB_Var_1_2>())
+ return pp::Resource();
+
+ return pp::Resource(
+ pp::PASS_REF,
+ get_interface<PPB_Var_1_2>()->VarToResource(var_));
+}
+
std::string Var::DebugString() const {
char buf[256];
if (is_undefined()) {

Powered by Google App Engine
This is Rietveld 408576698