summaryrefslogtreecommitdiffstats
path: root/ppapi/shared_impl/scoped_pp_var.h
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-19 17:36:08 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-19 17:36:08 +0000
commit7657b68535868ea5bb3fd81d1b9428691739a232 (patch)
tree11fbdc38bb33482450480370e215fcf05788490d /ppapi/shared_impl/scoped_pp_var.h
parent28e9584fb55f83343eb50caa7e826dc721dd0f70 (diff)
downloadchromium_src-7657b68535868ea5bb3fd81d1b9428691739a232.zip
chromium_src-7657b68535868ea5bb3fd81d1b9428691739a232.tar.gz
chromium_src-7657b68535868ea5bb3fd81d1b9428691739a232.tar.bz2
Add a ScopedPPVar class for helping to track a reference to a base PP_Var.
This will be used in unit tests and (possibly in the future) son proxy implementation code. This is basically copied from ScopedPPResource. TEST=none BUG=none Review URL: https://chromiumcodereview.appspot.com/10562033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142982 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/shared_impl/scoped_pp_var.h')
-rw-r--r--ppapi/shared_impl/scoped_pp_var.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/ppapi/shared_impl/scoped_pp_var.h b/ppapi/shared_impl/scoped_pp_var.h
new file mode 100644
index 0000000..8079a91
--- /dev/null
+++ b/ppapi/shared_impl/scoped_pp_var.h
@@ -0,0 +1,47 @@
+// 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.
+
+#ifndef PPAPI_SHARED_IMPL_SCOPED_PP_VAR_H_
+#define PPAPI_SHARED_IMPL_SCOPED_PP_VAR_H_
+
+#include "ppapi/c/pp_var.h"
+#include "ppapi/shared_impl/ppapi_shared_export.h"
+
+namespace ppapi {
+
+class PPAPI_SHARED_EXPORT ScopedPPVar {
+ public:
+ struct PassRef {};
+
+ ScopedPPVar();
+
+ // Takes one reference to the given resource.
+ explicit ScopedPPVar(const PP_Var& v);
+
+ // Assumes responsibility for one ref that the var already has.
+ ScopedPPVar(const PassRef&, const PP_Var& v);
+
+ // Implicit copy constructor allowed.
+ ScopedPPVar(const ScopedPPVar& other);
+
+ ~ScopedPPVar();
+
+ ScopedPPVar& operator=(const PP_Var& r);
+ ScopedPPVar& operator=(const ScopedPPVar& other) {
+ return operator=(other.var_);
+ }
+
+ const PP_Var& get() const { return var_; }
+
+ // Returns the PP_Var, passing the reference to the caller. This class
+ // will no longer hold the var.
+ PP_Var Release();
+
+ private:
+ PP_Var var_;
+};
+
+} // namespace ppapi
+
+#endif // PPAPI_SHARED_IMPL_SCOPED_PP_VAR_H_