Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Unified Diff: webkit/glue/plugins/pepper_resource_tracker.cc

Issue 2822031: File API boilerplate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/plugins/pepper_resource_tracker.h ('k') | webkit/glue/plugins/pepper_var.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « webkit/glue/plugins/pepper_resource_tracker.h ('k') | webkit/glue/plugins/pepper_var.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698