Index: webkit/glue/plugins/pepper_resource_tracker.cc |
=================================================================== |
--- webkit/glue/plugins/pepper_resource_tracker.cc (revision 50938) |
+++ webkit/glue/plugins/pepper_resource_tracker.cc (working copy) |
@@ -10,6 +10,10 @@ |
#include "third_party/ppapi/c/pp_resource.h" |
#include "webkit/glue/plugins/pepper_buffer.h" |
#include "webkit/glue/plugins/pepper_device_context_2d.h" |
+#include "webkit/glue/plugins/pepper_directory_reader.h" |
+#include "webkit/glue/plugins/pepper_file_chooser.h" |
+#include "webkit/glue/plugins/pepper_file_io.h" |
+#include "webkit/glue/plugins/pepper_file_ref.h" |
#include "webkit/glue/plugins/pepper_image_data.h" |
#include "webkit/glue/plugins/pepper_resource.h" |
#include "webkit/glue/plugins/pepper_url_loader.h" |
@@ -53,52 +57,24 @@ |
live_resources_.erase(found); |
} |
-scoped_refptr<DeviceContext2D> ResourceTracker::GetAsDeviceContext2D( |
- PP_Resource res) const { |
- scoped_refptr<Resource> resource = GetResource(res); |
- if (!resource.get()) |
- return scoped_refptr<DeviceContext2D>(); |
- return scoped_refptr<DeviceContext2D>(resource->AsDeviceContext2D()); |
-} |
+#define GET_AS_TYPE_IMPL(Type) \ |
+ scoped_refptr<Type> ResourceTracker::GetAs##Type( \ |
+ PP_Resource res) const { \ |
+ scoped_refptr<Resource> resource = GetResource(res); \ |
+ if (!resource.get()) \ |
+ return scoped_refptr<Type>(); \ |
+ return scoped_refptr<Type>(resource->As##Type()); \ |
+ } |
-scoped_refptr<ImageData> ResourceTracker::GetAsImageData( |
- PP_Resource res) const { |
- scoped_refptr<Resource> resource = GetResource(res); |
- if (!resource.get()) |
- return scoped_refptr<ImageData>(); |
- return scoped_refptr<ImageData>(resource->AsImageData()); |
-} |
+GET_AS_TYPE_IMPL(Buffer) |
+GET_AS_TYPE_IMPL(DeviceContext2D) |
+GET_AS_TYPE_IMPL(DirectoryReader) |
+GET_AS_TYPE_IMPL(FileChooser) |
+GET_AS_TYPE_IMPL(FileIO) |
+GET_AS_TYPE_IMPL(FileRef) |
+GET_AS_TYPE_IMPL(ImageData) |
+GET_AS_TYPE_IMPL(URLLoader) |
+GET_AS_TYPE_IMPL(URLRequestInfo) |
+GET_AS_TYPE_IMPL(URLResponseInfo) |
-scoped_refptr<URLLoader> ResourceTracker::GetAsURLLoader( |
- PP_Resource res) const { |
- scoped_refptr<Resource> resource = GetResource(res); |
- if (!resource.get()) |
- return scoped_refptr<URLLoader>(); |
- return scoped_refptr<URLLoader>(resource->AsURLLoader()); |
-} |
- |
-scoped_refptr<URLRequestInfo> ResourceTracker::GetAsURLRequestInfo( |
- PP_Resource res) const { |
- scoped_refptr<Resource> resource = GetResource(res); |
- if (!resource.get()) |
- return scoped_refptr<URLRequestInfo>(); |
- return scoped_refptr<URLRequestInfo>(resource->AsURLRequestInfo()); |
-} |
- |
-scoped_refptr<URLResponseInfo> ResourceTracker::GetAsURLResponseInfo( |
- PP_Resource res) const { |
- scoped_refptr<Resource> resource = GetResource(res); |
- if (!resource.get()) |
- return scoped_refptr<URLResponseInfo>(); |
- return scoped_refptr<URLResponseInfo>(resource->AsURLResponseInfo()); |
-} |
- |
-scoped_refptr<Buffer> ResourceTracker::GetAsBuffer( |
- PP_Resource res) const { |
- scoped_refptr<Resource> resource = GetResource(res); |
- if (!resource.get()) |
- return scoped_refptr<Buffer>(); |
- return scoped_refptr<Buffer>(resource->AsBuffer()); |
-} |
- |
} // namespace pepper |