OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_GLUE_PLUGINS_PEPPER_RESOURCE_H_ | 5 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_H_ |
6 #define WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_H_ | 6 #define WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
10 #include "third_party/ppapi/c/pp_resource.h" | 10 #include "third_party/ppapi/c/pp_resource.h" |
11 #include "webkit/glue/plugins/pepper_resource_tracker.h" | 11 #include "webkit/glue/plugins/pepper_resource_tracker.h" |
12 | 12 |
13 namespace pepper { | 13 namespace pepper { |
14 | 14 |
15 class Buffer; | 15 class Buffer; |
16 class DeviceContext2D; | 16 class DeviceContext2D; |
17 class DirectoryReader; | 17 class DirectoryReader; |
18 class FileChooser; | 18 class FileChooser; |
19 class FileIO; | 19 class FileIO; |
20 class FileRef; | 20 class FileRef; |
| 21 class Font; |
21 class ImageData; | 22 class ImageData; |
22 class PluginModule; | 23 class PluginModule; |
23 class Scrollbar; | 24 class Scrollbar; |
24 class URLLoader; | 25 class URLLoader; |
25 class URLRequestInfo; | 26 class URLRequestInfo; |
26 class URLResponseInfo; | 27 class URLResponseInfo; |
27 class Widget; | 28 class Widget; |
28 | 29 |
29 class Resource : public base::RefCountedThreadSafe<Resource> { | 30 class Resource : public base::RefCountedThreadSafe<Resource> { |
30 public: | 31 public: |
(...skipping 19 matching lines...) Expand all Loading... |
50 private: | 51 private: |
51 // Type-specific getters for individual resource types. These will return | 52 // Type-specific getters for individual resource types. These will return |
52 // NULL if the resource does not match the specified type. Used by the Cast() | 53 // NULL if the resource does not match the specified type. Used by the Cast() |
53 // function. | 54 // function. |
54 virtual Buffer* AsBuffer() { return NULL; } | 55 virtual Buffer* AsBuffer() { return NULL; } |
55 virtual DeviceContext2D* AsDeviceContext2D() { return NULL; } | 56 virtual DeviceContext2D* AsDeviceContext2D() { return NULL; } |
56 virtual DirectoryReader* AsDirectoryReader() { return NULL; } | 57 virtual DirectoryReader* AsDirectoryReader() { return NULL; } |
57 virtual FileChooser* AsFileChooser() { return NULL; } | 58 virtual FileChooser* AsFileChooser() { return NULL; } |
58 virtual FileIO* AsFileIO() { return NULL; } | 59 virtual FileIO* AsFileIO() { return NULL; } |
59 virtual FileRef* AsFileRef() { return NULL; } | 60 virtual FileRef* AsFileRef() { return NULL; } |
| 61 virtual Font* AsFont() { return NULL; } |
60 virtual ImageData* AsImageData() { return NULL; } | 62 virtual ImageData* AsImageData() { return NULL; } |
61 virtual Scrollbar* AsScrollbar() { return NULL; } | 63 virtual Scrollbar* AsScrollbar() { return NULL; } |
62 virtual URLLoader* AsURLLoader() { return NULL; } | 64 virtual URLLoader* AsURLLoader() { return NULL; } |
63 virtual URLRequestInfo* AsURLRequestInfo() { return NULL; } | 65 virtual URLRequestInfo* AsURLRequestInfo() { return NULL; } |
64 virtual URLResponseInfo* AsURLResponseInfo() { return NULL; } | 66 virtual URLResponseInfo* AsURLResponseInfo() { return NULL; } |
65 virtual Widget* AsWidget() { return NULL; } | 67 virtual Widget* AsWidget() { return NULL; } |
66 | 68 |
67 PluginModule* module_; // Non-owning pointer to our module. | 69 PluginModule* module_; // Non-owning pointer to our module. |
68 | 70 |
69 DISALLOW_COPY_AND_ASSIGN(Resource); | 71 DISALLOW_COPY_AND_ASSIGN(Resource); |
70 }; | 72 }; |
71 | 73 |
72 // Cast() specializations. | 74 // Cast() specializations. |
73 #define DEFINE_RESOURCE_CAST(Type) \ | 75 #define DEFINE_RESOURCE_CAST(Type) \ |
74 template <> inline Type* Resource::Cast<Type>() { \ | 76 template <> inline Type* Resource::Cast<Type>() { \ |
75 return As##Type(); \ | 77 return As##Type(); \ |
76 } | 78 } |
77 | 79 |
78 DEFINE_RESOURCE_CAST(Buffer) | 80 DEFINE_RESOURCE_CAST(Buffer) |
79 DEFINE_RESOURCE_CAST(DeviceContext2D) | 81 DEFINE_RESOURCE_CAST(DeviceContext2D) |
80 DEFINE_RESOURCE_CAST(DirectoryReader) | 82 DEFINE_RESOURCE_CAST(DirectoryReader) |
81 DEFINE_RESOURCE_CAST(FileChooser) | 83 DEFINE_RESOURCE_CAST(FileChooser) |
82 DEFINE_RESOURCE_CAST(FileIO) | 84 DEFINE_RESOURCE_CAST(FileIO) |
83 DEFINE_RESOURCE_CAST(FileRef) | 85 DEFINE_RESOURCE_CAST(FileRef) |
| 86 DEFINE_RESOURCE_CAST(Font) |
84 DEFINE_RESOURCE_CAST(ImageData) | 87 DEFINE_RESOURCE_CAST(ImageData) |
85 DEFINE_RESOURCE_CAST(Scrollbar) | 88 DEFINE_RESOURCE_CAST(Scrollbar) |
86 DEFINE_RESOURCE_CAST(URLLoader) | 89 DEFINE_RESOURCE_CAST(URLLoader) |
87 DEFINE_RESOURCE_CAST(URLRequestInfo) | 90 DEFINE_RESOURCE_CAST(URLRequestInfo) |
88 DEFINE_RESOURCE_CAST(URLResponseInfo) | 91 DEFINE_RESOURCE_CAST(URLResponseInfo) |
89 DEFINE_RESOURCE_CAST(Widget) | 92 DEFINE_RESOURCE_CAST(Widget) |
90 | 93 |
91 #undef DEFINE_RESOURCE_CAST | 94 #undef DEFINE_RESOURCE_CAST |
92 } // namespace pepper | 95 } // namespace pepper |
93 | 96 |
94 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_H_ | 97 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_H_ |
OLD | NEW |