| 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 WEBKIT_PLUGINS_PPAPI_RESOURCE_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_RESOURCE_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_RESOURCE_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_RESOURCE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "ppapi/c/pp_resource.h" | 10 #include "ppapi/c/pp_resource.h" |
| 11 #include "ppapi/shared_impl/resource_object_base.h" |
| 11 #include "webkit/plugins/ppapi/resource_tracker.h" | 12 #include "webkit/plugins/ppapi/resource_tracker.h" |
| 12 | 13 |
| 13 namespace webkit { | 14 namespace webkit { |
| 14 namespace ppapi { | 15 namespace ppapi { |
| 15 | 16 |
| 16 // If you inherit from resource, make sure you add the class name here. | 17 // If you inherit from resource, make sure you add the class name here. |
| 17 #define FOR_ALL_RESOURCES(F) \ | 18 #define FOR_ALL_RESOURCES(F) \ |
| 18 F(MockResource) \ | 19 F(MockResource) \ |
| 19 F(PPB_AudioConfig_Impl) \ | 20 F(PPB_AudioConfig_Impl) \ |
| 20 F(PPB_Audio_Impl) \ | 21 F(PPB_Audio_Impl) \ |
| (...skipping 21 matching lines...) Expand all Loading... |
| 42 F(PPB_VideoDecoder_Impl) \ | 43 F(PPB_VideoDecoder_Impl) \ |
| 43 F(PPB_VideoLayer_Impl) \ | 44 F(PPB_VideoLayer_Impl) \ |
| 44 F(PPB_Widget_Impl) \ | 45 F(PPB_Widget_Impl) \ |
| 45 F(PrivateFontFile) | 46 F(PrivateFontFile) |
| 46 | 47 |
| 47 // Forward declaration of Resource classes. | 48 // Forward declaration of Resource classes. |
| 48 #define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE; | 49 #define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE; |
| 49 FOR_ALL_RESOURCES(DECLARE_RESOURCE_CLASS) | 50 FOR_ALL_RESOURCES(DECLARE_RESOURCE_CLASS) |
| 50 #undef DECLARE_RESOURCE_CLASS | 51 #undef DECLARE_RESOURCE_CLASS |
| 51 | 52 |
| 52 class Resource : public base::RefCountedThreadSafe<Resource> { | 53 class Resource : public base::RefCountedThreadSafe<Resource>, |
| 54 public ::ppapi::shared_impl::ResourceObjectBase { |
| 53 public: | 55 public: |
| 54 explicit Resource(PluginInstance* instance); | 56 explicit Resource(PluginInstance* instance); |
| 55 virtual ~Resource(); | 57 virtual ~Resource(); |
| 56 | 58 |
| 57 // Returns NULL if the resource is invalid or is a different type. | 59 // Returns NULL if the resource is invalid or is a different type. |
| 58 template<typename T> | 60 template<typename T> |
| 59 static scoped_refptr<T> GetAs(PP_Resource res) { | 61 static scoped_refptr<T> GetAs(PP_Resource res) { |
| 60 scoped_refptr<Resource> resource = ResourceTracker::Get()->GetResource(res); | 62 scoped_refptr<Resource> resource = ResourceTracker::Get()->GetResource(res); |
| 61 return resource ? resource->Cast<T>() : NULL; | 63 return resource ? resource->Cast<T>() : NULL; |
| 62 } | 64 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 return As##Type(); \ | 151 return As##Type(); \ |
| 150 } | 152 } |
| 151 | 153 |
| 152 FOR_ALL_RESOURCES(DEFINE_RESOURCE_CAST) | 154 FOR_ALL_RESOURCES(DEFINE_RESOURCE_CAST) |
| 153 #undef DEFINE_RESOURCE_CAST | 155 #undef DEFINE_RESOURCE_CAST |
| 154 | 156 |
| 155 } // namespace ppapi | 157 } // namespace ppapi |
| 156 } // namespace webkit | 158 } // namespace webkit |
| 157 | 159 |
| 158 #endif // WEBKIT_PLUGINS_PPAPI_RESOURCE_H_ | 160 #endif // WEBKIT_PLUGINS_PPAPI_RESOURCE_H_ |
| OLD | NEW |