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

Side by Side Diff: ppapi/shared_impl/scoped_pp_var.h

Issue 10562033: Add a ScopedPPVar class for helping to track a reference to a base PP_Var. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/ppapi_shared.gypi ('k') | ppapi/shared_impl/scoped_pp_var.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef PPAPI_SHARED_IMPL_SCOPED_PP_VAR_H_
6 #define PPAPI_SHARED_IMPL_SCOPED_PP_VAR_H_
7
8 #include "ppapi/c/pp_var.h"
9 #include "ppapi/shared_impl/ppapi_shared_export.h"
10
11 namespace ppapi {
12
13 class PPAPI_SHARED_EXPORT ScopedPPVar {
14 public:
15 struct PassRef {};
16
17 ScopedPPVar();
18
19 // Takes one reference to the given resource.
20 ScopedPPVar(const PP_Var& v);
dmichael (off chromium) 2012/06/18 20:09:16 probably should be explicit?
21
22 // Assumes responsibility for one ref that the var already has.
23 ScopedPPVar(const PassRef&, const PP_Var& v);
24
25 // Implicit copy constructor allowed.
26 ScopedPPVar(const ScopedPPVar& other);
27
28 ~ScopedPPVar();
29
30 ScopedPPVar& operator=(const PP_Var& r);
31 ScopedPPVar& operator=(const ScopedPPVar& other) {
32 return operator=(other.var_);
33 }
34
35 const PP_Var& get() const { return var_; }
36 operator PP_Var() const { return var_; }
dmichael (off chromium) 2012/06/18 20:09:16 This might be dangerous. Should we force people to
37
38 // Returns the PP_Var, passing the reference to the caller. This class
39 // will no longer hold the var.
40 PP_Var Release();
41
42 private:
43 PP_Var var_;
44 };
45
46 } // namespace ppapi
47
48 #endif // PPAPI_SHARED_IMPL_SCOPED_PP_VAR_H_
OLDNEW
« no previous file with comments | « ppapi/ppapi_shared.gypi ('k') | ppapi/shared_impl/scoped_pp_var.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698