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 | 9 |
10 /// @file | 10 /// @file |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 /// Note that the reference count on the resource is unchanged and the caller | 49 /// Note that the reference count on the resource is unchanged and the caller |
50 /// needs to release the resource. | 50 /// needs to release the resource. |
51 /// | 51 /// |
52 /// @return The detached <code>PP_Resource</code>. | 52 /// @return The detached <code>PP_Resource</code>. |
53 PP_Resource detach(); | 53 PP_Resource detach(); |
54 | 54 |
55 protected: | 55 protected: |
56 /// A constructor used when a <code>PP_Resource</code> is provided as a | 56 /// A constructor used when a <code>PP_Resource</code> is provided as a |
57 /// return value whose reference count we need to increment. | 57 /// return value whose reference count we need to increment. |
58 /// | 58 /// |
59 /// @param[in] resource A <code>PP_Resource</code>. | 59 /// @param[in] resource A <code>PP_Resource</code> corresponding to a |
| 60 /// resource. |
60 explicit Resource(PP_Resource resource); | 61 explicit Resource(PP_Resource resource); |
61 | 62 |
62 /// PassRefFromConstructor is called by derived class' constructors to | 63 /// PassRefFromConstructor is called by derived class' constructors to |
63 /// initialize this <code>Resource</code> with a <code>PP_Resource</code> | 64 /// initialize this <code>Resource</code> with a <code>PP_Resource</code> |
64 /// that has already had its reference count incremented by | 65 /// that has already had its reference count incremented by |
65 /// <code>Core::AddRefResource</code>. It also assumes this object has no | 66 /// <code>Core::AddRefResource</code>. It also assumes this object has no |
66 /// current resource. | 67 /// current resource. |
67 /// | 68 /// |
68 /// The intended usage of this function that the derived class constructor | 69 /// The intended usage of this function that the derived class constructor |
69 /// will call the default <code>Resource</code> constructor, then make a call | 70 /// will call the default <code>Resource</code> constructor, then make a call |
70 /// to create a resource. It then wants to assign the new resource (which, | 71 /// to create a resource. It then wants to assign the new resource (which, |
71 /// since it was returned by the browser, already had its reference count | 72 /// since it was returned by the browser, already had its reference count |
72 /// increased). | 73 /// increased). |
73 /// | 74 /// |
74 /// @param[in] resource A PP_Resource. | 75 /// @param[in] resource A <code>PP_Resource</code> corresponding to a |
| 76 /// resource. |
75 void PassRefFromConstructor(PP_Resource resource); | 77 void PassRefFromConstructor(PP_Resource resource); |
76 | 78 |
77 private: | 79 private: |
78 PP_Resource pp_resource_; | 80 PP_Resource pp_resource_; |
79 }; | 81 }; |
80 | 82 |
81 } // namespace pp | 83 } // namespace pp |
82 | 84 |
83 inline bool operator==(const pp::Resource& lhs, const pp::Resource& rhs) { | 85 inline bool operator==(const pp::Resource& lhs, const pp::Resource& rhs) { |
84 return lhs.pp_resource() == rhs.pp_resource(); | 86 return lhs.pp_resource() == rhs.pp_resource(); |
85 } | 87 } |
86 | 88 |
87 #endif // PPAPI_CPP_RESOURCE_H_ | 89 #endif // PPAPI_CPP_RESOURCE_H_ |
OLD | NEW |