OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PPAPI_SHARED_IMPL_SCOPED_PP_VAR_H_ | 5 #ifndef PPAPI_SHARED_IMPL_SCOPED_PP_VAR_H_ |
6 #define PPAPI_SHARED_IMPL_SCOPED_PP_VAR_H_ | 6 #define PPAPI_SHARED_IMPL_SCOPED_PP_VAR_H_ |
7 | 7 |
8 #include "ppapi/c/pp_var.h" | 8 #include "ppapi/c/pp_var.h" |
9 #include "ppapi/shared_impl/ppapi_shared_export.h" | 9 #include "ppapi/shared_impl/ppapi_shared_export.h" |
10 | 10 |
11 namespace ppapi { | 11 namespace ppapi { |
12 | 12 |
13 class PPAPI_SHARED_EXPORT ScopedPPVar { | 13 class PPAPI_SHARED_EXPORT ScopedPPVar { |
14 public: | 14 public: |
15 struct PassRef {}; | 15 struct PassRef {}; |
16 | 16 |
17 ScopedPPVar(); | 17 ScopedPPVar(); |
18 | 18 |
19 // Takes one reference to the given resource. | 19 // Takes one reference to the given var. |
20 explicit ScopedPPVar(const PP_Var& v); | 20 explicit ScopedPPVar(const PP_Var& v); |
21 | 21 |
22 // Assumes responsibility for one ref that the var already has. | 22 // Assumes responsibility for one ref that the var already has. |
23 ScopedPPVar(const PassRef&, const PP_Var& v); | 23 ScopedPPVar(const PassRef&, const PP_Var& v); |
24 | 24 |
25 // Implicit copy constructor allowed. | 25 // Implicit copy constructor allowed. |
26 ScopedPPVar(const ScopedPPVar& other); | 26 ScopedPPVar(const ScopedPPVar& other); |
27 | 27 |
28 ~ScopedPPVar(); | 28 ~ScopedPPVar(); |
29 | 29 |
30 ScopedPPVar& operator=(const PP_Var& r); | 30 ScopedPPVar& operator=(const PP_Var& r); |
31 ScopedPPVar& operator=(const ScopedPPVar& other) { | 31 ScopedPPVar& operator=(const ScopedPPVar& other) { |
32 return operator=(other.var_); | 32 return operator=(other.var_); |
33 } | 33 } |
34 | 34 |
35 const PP_Var& get() const { return var_; } | 35 const PP_Var& get() const { return var_; } |
36 | 36 |
37 // Returns the PP_Var, passing the reference to the caller. This class | 37 // Returns the PP_Var, passing the reference to the caller. This class |
38 // will no longer hold the var. | 38 // will no longer hold the var. |
39 PP_Var Release(); | 39 PP_Var Release(); |
40 | 40 |
41 private: | 41 private: |
42 PP_Var var_; | 42 PP_Var var_; |
43 }; | 43 }; |
44 | 44 |
45 } // namespace ppapi | 45 } // namespace ppapi |
46 | 46 |
47 #endif // PPAPI_SHARED_IMPL_SCOPED_PP_VAR_H_ | 47 #endif // PPAPI_SHARED_IMPL_SCOPED_PP_VAR_H_ |
OLD | NEW |