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

Unified Diff: ppapi/cpp/dev/var_resource_dev.cc

Issue 52233002: [PPAPI] Added VarResource_Dev class. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix Windows compile. Created 7 years, 1 month 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
« no previous file with comments | « ppapi/cpp/dev/var_resource_dev.h ('k') | ppapi/cpp/file_system.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/dev/var_resource_dev.cc
diff --git a/ppapi/cpp/dev/var_resource_dev.cc b/ppapi/cpp/dev/var_resource_dev.cc
new file mode 100644
index 0000000000000000000000000000000000000000..69fb15b0898b8d662e867f6a259b4723b9db017e
--- /dev/null
+++ b/ppapi/cpp/dev/var_resource_dev.cc
@@ -0,0 +1,70 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/cpp/dev/var_resource_dev.h"
+
+#include "ppapi/c/dev/ppb_var_resource_dev.h"
+#include "ppapi/cpp/logging.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_VarResource_Dev_0_1>() {
+ return PPB_VAR_RESOURCE_DEV_INTERFACE_0_1;
+}
+
+} // namespace
+
+VarResource_Dev::VarResource_Dev(const pp::Resource& resource) : Var(Null()) {
+ if (!has_interface<PPB_VarResource_Dev_0_1>()) {
+ PP_NOTREACHED();
+ return;
+ }
+
+ // Note: Var(Null()) sets is_managed_ to true, so |var_| will be properly
+ // released upon destruction.
+ var_ = get_interface<PPB_VarResource_Dev_0_1>()->VarFromResource(
+ resource.pp_resource());
+}
+
+VarResource_Dev::VarResource_Dev(const Var& var) : Var(var) {
+ if (!var.is_resource()) {
+ PP_NOTREACHED();
+
+ // This takes care of releasing the reference that this object holds.
+ Var::operator=(Var(Null()));
+ }
+}
+
+VarResource_Dev::VarResource_Dev(const VarResource_Dev& other) : Var(other) {}
+
+VarResource_Dev::~VarResource_Dev() {}
+
+VarResource_Dev& VarResource_Dev::operator=(const VarResource_Dev& other) {
+ Var::operator=(other);
+ return *this;
+}
+
+Var& VarResource_Dev::operator=(const Var& other) {
+ if (other.is_resource()) {
+ Var::operator=(other);
+ } else {
+ PP_NOTREACHED();
+ Var::operator=(Var(Null()));
+ }
+ return *this;
+}
+
+pp::Resource VarResource_Dev::AsResource() {
+ if (!has_interface<PPB_VarResource_Dev_0_1>())
+ return pp::Resource();
+
+ return pp::Resource(
+ pp::PASS_REF,
+ get_interface<PPB_VarResource_Dev_0_1>()->VarToResource(var_));
+}
+
+} // namespace pp
« no previous file with comments | « ppapi/cpp/dev/var_resource_dev.h ('k') | ppapi/cpp/file_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698