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> |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 // (This function would make more conceptual sense on PluginResource but we | 201 // (This function would make more conceptual sense on PluginResource but we |
202 // need to call this function from general code that doesn't know how to | 202 // need to call this function from general code that doesn't know how to |
203 // distinguish the classes.) | 203 // distinguish the classes.) |
204 virtual void OnReplyReceived(const proxy::ResourceMessageReplyParams& params, | 204 virtual void OnReplyReceived(const proxy::ResourceMessageReplyParams& params, |
205 const IPC::Message& msg); | 205 const IPC::Message& msg); |
206 | 206 |
207 protected: | 207 protected: |
208 // Logs a message to the console from this resource. | 208 // Logs a message to the console from this resource. |
209 void Log(PP_LogLevel level, const std::string& message); | 209 void Log(PP_LogLevel level, const std::string& message); |
210 | 210 |
| 211 // Removes the resource from the ResourceTracker's tables. This normally |
| 212 // happens as part of Resource destruction, but if a subclass destructor |
| 213 // has a risk of re-entering destruction via the ResourceTracker, it can |
| 214 // call this explicitly to get rid of the table entry before continuing |
| 215 // with the destruction. If the resource is not in the ResourceTracker's |
| 216 // tables, silently does nothing. See http://crbug.com/159429. |
| 217 void RemoveFromResourceTracker(); |
| 218 |
211 // Notifications for subclasses. | 219 // Notifications for subclasses. |
212 virtual void LastPluginRefWasDeleted() {} | 220 virtual void LastPluginRefWasDeleted() {} |
213 virtual void InstanceWasDeleted() {} | 221 virtual void InstanceWasDeleted() {} |
214 | 222 |
215 private: | 223 private: |
216 // See the getters above. | 224 // See the getters above. |
217 PP_Resource pp_resource_; | 225 PP_Resource pp_resource_; |
218 HostResource host_resource_; | 226 HostResource host_resource_; |
219 | 227 |
220 DISALLOW_IMPLICIT_CONSTRUCTORS(Resource); | 228 DISALLOW_IMPLICIT_CONSTRUCTORS(Resource); |
221 }; | 229 }; |
222 | 230 |
223 // Template-based dynamic casting. These specializations forward to the | 231 // Template-based dynamic casting. These specializations forward to the |
224 // AsXXX virtual functions to return whether the given type is supported. | 232 // AsXXX virtual functions to return whether the given type is supported. |
225 #define DEFINE_RESOURCE_CAST(RESOURCE) \ | 233 #define DEFINE_RESOURCE_CAST(RESOURCE) \ |
226 template<> inline thunk::RESOURCE* Resource::GetAs() { \ | 234 template<> inline thunk::RESOURCE* Resource::GetAs() { \ |
227 return As##RESOURCE(); \ | 235 return As##RESOURCE(); \ |
228 } | 236 } |
229 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_RESOURCE_CAST) | 237 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_RESOURCE_CAST) |
230 #undef DEFINE_RESOURCE_CAST | 238 #undef DEFINE_RESOURCE_CAST |
231 | 239 |
232 } // namespace ppapi | 240 } // namespace ppapi |
233 | 241 |
234 #endif // PPAPI_SHARED_IMPL_RESOURCE_H_ | 242 #endif // PPAPI_SHARED_IMPL_RESOURCE_H_ |
OLD | NEW |