OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_H_ | 5 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_H_ |
6 #define WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_H_ | 6 #define WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
10 #include "ppapi/c/pp_resource.h" | 10 #include "ppapi/c/pp_resource.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 ResourceTracker::Get()->UnrefResource(id); | 96 ResourceTracker::Get()->UnrefResource(id); |
97 } | 97 } |
98 const PP_Resource id; | 98 const PP_Resource id; |
99 }; | 99 }; |
100 | 100 |
101 private: | 101 private: |
102 // Type-specific getters for individual resource types. These will return | 102 // Type-specific getters for individual resource types. These will return |
103 // NULL if the resource does not match the specified type. Used by the Cast() | 103 // NULL if the resource does not match the specified type. Used by the Cast() |
104 // function. | 104 // function. |
105 #define DEFINE_TYPE_GETTER(RESOURCE) \ | 105 #define DEFINE_TYPE_GETTER(RESOURCE) \ |
106 virtual RESOURCE* As##RESOURCE() { return NULL; } | 106 virtual RESOURCE* As##RESOURCE(); |
107 FOR_ALL_RESOURCES(DEFINE_TYPE_GETTER) | 107 FOR_ALL_RESOURCES(DEFINE_TYPE_GETTER) |
108 #undef DEFINE_TYPE_GETTER | 108 #undef DEFINE_TYPE_GETTER |
109 | 109 |
110 // If referenced by a plugin, holds the id of this resource object. Do not | 110 // If referenced by a plugin, holds the id of this resource object. Do not |
111 // access this member directly, because it is possible that the plugin holds | 111 // access this member directly, because it is possible that the plugin holds |
112 // no references to the object, and therefore the resource_id_ is zero. Use | 112 // no references to the object, and therefore the resource_id_ is zero. Use |
113 // either GetReference() to obtain a new resource_id and increase the | 113 // either GetReference() to obtain a new resource_id and increase the |
114 // refcount, or TemporaryReference when you do not want to increase the | 114 // refcount, or TemporaryReference when you do not want to increase the |
115 // refcount. | 115 // refcount. |
116 PP_Resource resource_id_; | 116 PP_Resource resource_id_; |
(...skipping 11 matching lines...) Expand all Loading... |
128 | 128 |
129 // Cast() specializations. | 129 // Cast() specializations. |
130 #define DEFINE_RESOURCE_CAST(Type) \ | 130 #define DEFINE_RESOURCE_CAST(Type) \ |
131 template <> inline Type* Resource::Cast<Type>() { \ | 131 template <> inline Type* Resource::Cast<Type>() { \ |
132 return As##Type(); \ | 132 return As##Type(); \ |
133 } | 133 } |
134 | 134 |
135 FOR_ALL_RESOURCES(DEFINE_RESOURCE_CAST) | 135 FOR_ALL_RESOURCES(DEFINE_RESOURCE_CAST) |
136 #undef DEFINE_RESOURCE_CAST | 136 #undef DEFINE_RESOURCE_CAST |
137 | 137 |
138 #undef FOR_ALL_RESOURCES | |
139 } // namespace pepper | 138 } // namespace pepper |
140 | 139 |
141 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_H_ | 140 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_H_ |
OLD | NEW |