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

Unified Diff: ppapi/shared_impl/scoped_pp_var.h

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.h
diff --git a/ppapi/shared_impl/scoped_pp_var.h b/ppapi/shared_impl/scoped_pp_var.h
new file mode 100644
index 0000000000000000000000000000000000000000..d0d3408f622222bed085b2a2e20d2594d8977ee7
--- /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_

Powered by Google App Engine
This is Rietveld 408576698