diff options
author | neb@chromium.org <neb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-14 23:28:21 +0000 |
---|---|---|
committer | neb@chromium.org <neb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-14 23:28:21 +0000 |
commit | 72a66643059314b3564ead689ddac3a466c3dada (patch) | |
tree | 2f191fd4322a4a297beccdfdc790817951799440 /webkit/glue | |
parent | e7635e69babeafa99a6e3efa8c50f04302fd9935 (diff) | |
download | chromium_src-72a66643059314b3564ead689ddac3a466c3dada.zip chromium_src-72a66643059314b3564ead689ddac3a466c3dada.tar.gz chromium_src-72a66643059314b3564ead689ddac3a466c3dada.tar.bz2 |
Made deriving from Pepper Resource class easier.
BUG=none
TEST=ppapi_tests
Review URL: http://codereview.chromium.org/3732002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62673 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/plugins/pepper_resource.h | 107 |
1 files changed, 38 insertions, 69 deletions
diff --git a/webkit/glue/plugins/pepper_resource.h b/webkit/glue/plugins/pepper_resource.h index cab6f32..e920ab1 100644 --- a/webkit/glue/plugins/pepper_resource.h +++ b/webkit/glue/plugins/pepper_resource.h @@ -12,29 +12,36 @@ namespace pepper { -class Buffer; -class Audio; -class AudioConfig; -class DirectoryReader; -class FileChooser; -class FileIO; -class FileRef; -class Font; -class Graphics2D; -class Graphics3D; -class ImageData; -class ObjectVar; -class PluginModule; -class PrivateFontFile; -class Scrollbar; -class StringVar; -class Transport; -class URLLoader; -class URLRequestInfo; -class URLResponseInfo; -class Var; -class VideoDecoder; -class Widget; +// If you inherit from resource, make sure you add the class name here. +#define FOR_ALL_RESOURCES(F) \ + F(Audio) \ + F(Buffer) \ + F(AudioConfig) \ + F(DirectoryReader) \ + F(FileChooser) \ + F(FileIO) \ + F(FileRef) \ + F(Font) \ + F(Graphics2D) \ + F(Graphics3D) \ + F(ImageData) \ + F(ObjectVar) \ + F(PluginModule) \ + F(PrivateFontFile) \ + F(Scrollbar) \ + F(StringVar) \ + F(Transport) \ + F(URLLoader) \ + F(URLRequestInfo) \ + F(URLResponseInfo) \ + F(Var) \ + F(VideoDecoder) \ + F(Widget) + +// Forward declaration of Resource classes. +#define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE; +FOR_ALL_RESOURCES(DECLARE_RESOURCE_CLASS) +#undef DECLARE_RESOURCE_CLASS class Resource : public base::RefCountedThreadSafe<Resource> { public: @@ -80,28 +87,11 @@ class Resource : public base::RefCountedThreadSafe<Resource> { // Type-specific getters for individual resource types. These will return // NULL if the resource does not match the specified type. Used by the Cast() // function. - virtual Audio* AsAudio() { return NULL; } - virtual AudioConfig* AsAudioConfig() { return NULL; } - virtual Buffer* AsBuffer() { return NULL; } - virtual DirectoryReader* AsDirectoryReader() { return NULL; } - virtual FileChooser* AsFileChooser() { return NULL; } - virtual FileIO* AsFileIO() { return NULL; } - virtual FileRef* AsFileRef() { return NULL; } - virtual Font* AsFont() { return NULL; } - virtual Graphics2D* AsGraphics2D() { return NULL; } - virtual Graphics3D* AsGraphics3D() { return NULL; } - virtual ImageData* AsImageData() { return NULL; } - virtual ObjectVar* AsObjectVar() { return NULL; } - virtual PrivateFontFile* AsPrivateFontFile() { return NULL; } - virtual Scrollbar* AsScrollbar() { return NULL; } - virtual StringVar* AsStringVar() { return NULL; } - virtual Transport* AsTransport() { return NULL; } - virtual URLLoader* AsURLLoader() { return NULL; } - virtual URLRequestInfo* AsURLRequestInfo() { return NULL; } - virtual URLResponseInfo* AsURLResponseInfo() { return NULL; } - virtual Var* AsVar() { return NULL; } - virtual VideoDecoder* AsVideoDecoder() { return NULL; } - virtual Widget* AsWidget() { return NULL; } + #define DEFINE_TYPE_GETTER(RESOURCE) \ + virtual RESOURCE* As##RESOURCE() { return NULL; } + FOR_ALL_RESOURCES(DEFINE_TYPE_GETTER) + #undef DEFINE_TYPE_GETTER + private: // If referenced by a plugin, holds the id of this resource object. Do not @@ -128,31 +118,10 @@ class Resource : public base::RefCountedThreadSafe<Resource> { template <> inline Type* Resource::Cast<Type>() { \ return As##Type(); \ } - -DEFINE_RESOURCE_CAST(Audio) -DEFINE_RESOURCE_CAST(AudioConfig) -DEFINE_RESOURCE_CAST(Buffer) -DEFINE_RESOURCE_CAST(DirectoryReader) -DEFINE_RESOURCE_CAST(FileChooser) -DEFINE_RESOURCE_CAST(FileIO) -DEFINE_RESOURCE_CAST(FileRef) -DEFINE_RESOURCE_CAST(Font) -DEFINE_RESOURCE_CAST(Graphics2D) -DEFINE_RESOURCE_CAST(Graphics3D) -DEFINE_RESOURCE_CAST(ImageData) -DEFINE_RESOURCE_CAST(ObjectVar) -DEFINE_RESOURCE_CAST(PrivateFontFile) -DEFINE_RESOURCE_CAST(Scrollbar) -DEFINE_RESOURCE_CAST(StringVar); -DEFINE_RESOURCE_CAST(Transport) -DEFINE_RESOURCE_CAST(URLLoader) -DEFINE_RESOURCE_CAST(URLRequestInfo) -DEFINE_RESOURCE_CAST(URLResponseInfo) -DEFINE_RESOURCE_CAST(Var) -DEFINE_RESOURCE_CAST(VideoDecoder) -DEFINE_RESOURCE_CAST(Widget) - +FOR_ALL_RESOURCES(DEFINE_RESOURCE_CAST) #undef DEFINE_RESOURCE_CAST + +#undef FOR_ALL_RESOURCES } // namespace pepper #endif // WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_H_ |