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_RESOURCE_H_ | 5 #ifndef PPAPI_SHARED_IMPL_RESOURCE_H_ |
6 #define PPAPI_SHARED_IMPL_RESOURCE_H_ | 6 #define PPAPI_SHARED_IMPL_RESOURCE_H_ |
7 | 7 |
8 #include <stddef.h> // For NULL. | 8 #include <stddef.h> // For NULL. |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "ppapi/c/pp_instance.h" | 14 #include "ppapi/c/pp_instance.h" |
15 #include "ppapi/c/pp_resource.h" | 15 #include "ppapi/c/pp_resource.h" |
16 #include "ppapi/c/dev/ppb_console_dev.h" | 16 #include "ppapi/c/ppb_console.h" |
17 #include "ppapi/shared_impl/host_resource.h" | 17 #include "ppapi/shared_impl/host_resource.h" |
18 | 18 |
19 // All resource types should be added here. This implements our hand-rolled | 19 // All resource types should be added here. This implements our hand-rolled |
20 // RTTI system since we don't compile with "real" RTTI. | 20 // RTTI system since we don't compile with "real" RTTI. |
21 #define FOR_ALL_PPAPI_RESOURCE_APIS(F) \ | 21 #define FOR_ALL_PPAPI_RESOURCE_APIS(F) \ |
22 F(PPB_Audio_API) \ | 22 F(PPB_Audio_API) \ |
23 F(PPB_AudioConfig_API) \ | 23 F(PPB_AudioConfig_API) \ |
24 F(PPB_AudioInput_API) \ | 24 F(PPB_AudioInput_API) \ |
25 F(PPB_AudioTrusted_API) \ | 25 F(PPB_AudioTrusted_API) \ |
26 F(PPB_Broker_API) \ | 26 F(PPB_Broker_API) \ |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 // override this function). | 196 // override this function). |
197 // | 197 // |
198 // (This function would make more conceptual sense on PluginResource but we | 198 // (This function would make more conceptual sense on PluginResource but we |
199 // need to call this function from general code that doesn't know how to | 199 // need to call this function from general code that doesn't know how to |
200 // distinguish the classes.) | 200 // distinguish the classes.) |
201 virtual void OnReplyReceived(const proxy::ResourceMessageReplyParams& params, | 201 virtual void OnReplyReceived(const proxy::ResourceMessageReplyParams& params, |
202 const IPC::Message& msg); | 202 const IPC::Message& msg); |
203 | 203 |
204 protected: | 204 protected: |
205 // Logs a message to the console from this resource. | 205 // Logs a message to the console from this resource. |
206 void Log(PP_LogLevel_Dev level, const std::string& message); | 206 void Log(PP_LogLevel level, const std::string& message); |
207 | 207 |
208 // Notifications for subclasses. | 208 // Notifications for subclasses. |
209 virtual void LastPluginRefWasDeleted() {} | 209 virtual void LastPluginRefWasDeleted() {} |
210 virtual void InstanceWasDeleted() {} | 210 virtual void InstanceWasDeleted() {} |
211 | 211 |
212 private: | 212 private: |
213 // See the getters above. | 213 // See the getters above. |
214 PP_Resource pp_resource_; | 214 PP_Resource pp_resource_; |
215 HostResource host_resource_; | 215 HostResource host_resource_; |
216 | 216 |
217 DISALLOW_IMPLICIT_CONSTRUCTORS(Resource); | 217 DISALLOW_IMPLICIT_CONSTRUCTORS(Resource); |
218 }; | 218 }; |
219 | 219 |
220 // Template-based dynamic casting. These specializations forward to the | 220 // Template-based dynamic casting. These specializations forward to the |
221 // AsXXX virtual functions to return whether the given type is supported. | 221 // AsXXX virtual functions to return whether the given type is supported. |
222 #define DEFINE_RESOURCE_CAST(RESOURCE) \ | 222 #define DEFINE_RESOURCE_CAST(RESOURCE) \ |
223 template<> inline thunk::RESOURCE* Resource::GetAs() { \ | 223 template<> inline thunk::RESOURCE* Resource::GetAs() { \ |
224 return As##RESOURCE(); \ | 224 return As##RESOURCE(); \ |
225 } | 225 } |
226 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_RESOURCE_CAST) | 226 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_RESOURCE_CAST) |
227 #undef DEFINE_RESOURCE_CAST | 227 #undef DEFINE_RESOURCE_CAST |
228 | 228 |
229 } // namespace ppapi | 229 } // namespace ppapi |
230 | 230 |
231 #endif // PPAPI_SHARED_IMPL_RESOURCE_H_ | 231 #endif // PPAPI_SHARED_IMPL_RESOURCE_H_ |
OLD | NEW |