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