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

Unified Diff: ppapi/shared_impl/scoped_pp_var.cc

Issue 10560030: Add resource message call and reply infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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/shared_impl/scoped_pp_var.cc
diff --git a/ppapi/shared_impl/scoped_pp_var.cc b/ppapi/shared_impl/scoped_pp_var.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a91dbe6e488bdc5b7e83bf30988e1d98f503710a
--- /dev/null
+++ b/ppapi/shared_impl/scoped_pp_var.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2012 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/shared_impl/scoped_pp_var.h"
+
+#include "ppapi/shared_impl/ppapi_globals.h"
+#include "ppapi/shared_impl/var_tracker.h"
+
+namespace ppapi {
+
+namespace {
+
+void CallAddRef(const PP_Var& v) {
+ PpapiGlobals::Get()->GetVarTracker()->AddRefVar(v);
+}
+
+void CallRelease(const PP_Var& v) {
+ PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(v);
+}
+
+} // namespace
+
+ScopedPPVar::ScopedPPVar() : var_(PP_MakeUndefined()) {
+}
+
+ScopedPPVar::ScopedPPVar(const PP_Var& v) : var_(v) {
+ CallAddRef(var_);
+}
+
+ScopedPPVar::ScopedPPVar(const PassRef&, const PP_Var& v) : var_(v) {
+}
bbudge 2012/06/19 20:40:31 I don't see how the input var loses its ref. Am I
+
+ScopedPPVar::ScopedPPVar(const ScopedPPVar& other)
+ : var_(other.var_) {
+ CallAddRef(var_);
+}
+
+ScopedPPVar::~ScopedPPVar() {
+ CallRelease(var_);
+}
+
+ScopedPPVar& ScopedPPVar::operator=(const PP_Var& v) {
+ CallAddRef(v);
+ CallRelease(var_);
+ var_ = v;
+ return *this;
+}
+
+} // namespace ppapi
« ppapi/proxy/resource_message_params.cc ('K') | « ppapi/shared_impl/scoped_pp_var.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698