OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_CPP_RESOURCE_H_ | 5 #ifndef PPAPI_CPP_RESOURCE_H_ |
6 #define PPAPI_CPP_RESOURCE_H_ | 6 #define PPAPI_CPP_RESOURCE_H_ |
7 | 7 |
8 #include "ppapi/c/pp_resource.h" | 8 #include "ppapi/c/pp_resource.h" |
9 #include "ppapi/cpp/instance_handle.h" | 9 #include "ppapi/cpp/instance_handle.h" |
10 #include "ppapi/cpp/pass_ref.h" | 10 #include "ppapi/cpp/pass_ref.h" |
11 | 11 |
12 /// @file | 12 /// @file |
13 /// This file defines a <code>Resource</code> type representing data associated | 13 /// This file defines a <code>Resource</code> type representing data associated |
14 /// with the module. | 14 /// with the module. |
15 namespace pp { | 15 namespace pp { |
16 | 16 |
| 17 class VarResource_Dev; |
| 18 |
17 /// A reference counted module resource. | 19 /// A reference counted module resource. |
18 class Resource { | 20 class Resource { |
19 public: | 21 public: |
20 /// The default constructor. | 22 /// The default constructor. |
21 Resource(); | 23 Resource(); |
22 | 24 |
23 /// A constructor for copying a resource. | 25 /// A constructor for copying a resource. |
24 /// | 26 /// |
25 /// @param[in] other A <code>Resource</code>. | 27 /// @param[in] other A <code>Resource</code>. |
26 Resource(const Resource& other); | 28 Resource(const Resource& other); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 /// The intended usage of this function that the derived class constructor | 76 /// The intended usage of this function that the derived class constructor |
75 /// will call the default <code>Resource</code> constructor, then make a call | 77 /// will call the default <code>Resource</code> constructor, then make a call |
76 /// to create a resource. It then wants to assign the new resource (which, | 78 /// to create a resource. It then wants to assign the new resource (which, |
77 /// since it was returned by the browser, already had its reference count | 79 /// since it was returned by the browser, already had its reference count |
78 /// increased). | 80 /// increased). |
79 /// | 81 /// |
80 /// @param[in] resource A <code>PP_Resource</code> corresponding to a | 82 /// @param[in] resource A <code>PP_Resource</code> corresponding to a |
81 /// resource. | 83 /// resource. |
82 void PassRefFromConstructor(PP_Resource resource); | 84 void PassRefFromConstructor(PP_Resource resource); |
83 | 85 |
| 86 /// Sets this resource to null. This releases ownership of the resource. |
| 87 void Clear(); |
| 88 |
84 private: | 89 private: |
| 90 friend class VarResource_Dev; |
| 91 |
85 PP_Resource pp_resource_; | 92 PP_Resource pp_resource_; |
86 }; | 93 }; |
87 | 94 |
88 } // namespace pp | 95 } // namespace pp |
89 | 96 |
90 inline bool operator==(const pp::Resource& lhs, const pp::Resource& rhs) { | 97 inline bool operator==(const pp::Resource& lhs, const pp::Resource& rhs) { |
91 return lhs.pp_resource() == rhs.pp_resource(); | 98 return lhs.pp_resource() == rhs.pp_resource(); |
92 } | 99 } |
93 | 100 |
94 inline bool operator!=(const pp::Resource& lhs, const pp::Resource& rhs) { | 101 inline bool operator!=(const pp::Resource& lhs, const pp::Resource& rhs) { |
95 return !(lhs == rhs); | 102 return !(lhs == rhs); |
96 } | 103 } |
97 | 104 |
98 #endif // PPAPI_CPP_RESOURCE_H_ | 105 #endif // PPAPI_CPP_RESOURCE_H_ |
OLD | NEW |