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/logging.h" | 8 #include "base/logging.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 class FileIO; | 22 class FileIO; |
23 class FileRef; | 23 class FileRef; |
24 class Font; | 24 class Font; |
25 class ImageData; | 25 class ImageData; |
26 class PluginModule; | 26 class PluginModule; |
27 class PrivateFontFile; | 27 class PrivateFontFile; |
28 class Scrollbar; | 28 class Scrollbar; |
29 class URLLoader; | 29 class URLLoader; |
30 class URLRequestInfo; | 30 class URLRequestInfo; |
31 class URLResponseInfo; | 31 class URLResponseInfo; |
| 32 class VideoDecoder; |
32 class Widget; | 33 class Widget; |
33 | 34 |
34 class Resource : public base::RefCountedThreadSafe<Resource> { | 35 class Resource : public base::RefCountedThreadSafe<Resource> { |
35 public: | 36 public: |
36 explicit Resource(PluginModule* module) : resource_id_(0), module_(module) {} | 37 explicit Resource(PluginModule* module) : resource_id_(0), module_(module) {} |
37 virtual ~Resource() {} | 38 virtual ~Resource() {} |
38 | 39 |
39 // Returns NULL if the resource is invalid or is a different type. | 40 // Returns NULL if the resource is invalid or is a different type. |
40 template<typename T> | 41 template<typename T> |
41 static scoped_refptr<T> GetAs(PP_Resource res) { | 42 static scoped_refptr<T> GetAs(PP_Resource res) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 virtual FileChooser* AsFileChooser() { return NULL; } | 84 virtual FileChooser* AsFileChooser() { return NULL; } |
84 virtual FileIO* AsFileIO() { return NULL; } | 85 virtual FileIO* AsFileIO() { return NULL; } |
85 virtual FileRef* AsFileRef() { return NULL; } | 86 virtual FileRef* AsFileRef() { return NULL; } |
86 virtual Font* AsFont() { return NULL; } | 87 virtual Font* AsFont() { return NULL; } |
87 virtual ImageData* AsImageData() { return NULL; } | 88 virtual ImageData* AsImageData() { return NULL; } |
88 virtual PrivateFontFile* AsPrivateFontFile() { return NULL; } | 89 virtual PrivateFontFile* AsPrivateFontFile() { return NULL; } |
89 virtual Scrollbar* AsScrollbar() { return NULL; } | 90 virtual Scrollbar* AsScrollbar() { return NULL; } |
90 virtual URLLoader* AsURLLoader() { return NULL; } | 91 virtual URLLoader* AsURLLoader() { return NULL; } |
91 virtual URLRequestInfo* AsURLRequestInfo() { return NULL; } | 92 virtual URLRequestInfo* AsURLRequestInfo() { return NULL; } |
92 virtual URLResponseInfo* AsURLResponseInfo() { return NULL; } | 93 virtual URLResponseInfo* AsURLResponseInfo() { return NULL; } |
| 94 virtual VideoDecoder* AsVideoDecoder() { return NULL; } |
93 virtual Widget* AsWidget() { return NULL; } | 95 virtual Widget* AsWidget() { return NULL; } |
94 | 96 |
95 private: | 97 private: |
96 // If referenced by a plugin, holds the id of this resource object. Do not | 98 // If referenced by a plugin, holds the id of this resource object. Do not |
97 // access this member directly, because it is possible that the plugin holds | 99 // access this member directly, because it is possible that the plugin holds |
98 // no references to the object, and therefore the resource_id_ is zero. Use | 100 // no references to the object, and therefore the resource_id_ is zero. Use |
99 // either GetReference() to obtain a new resource_id and increase the | 101 // either GetReference() to obtain a new resource_id and increase the |
100 // refcount, or TemporaryReference when you do not want to increase the | 102 // refcount, or TemporaryReference when you do not want to increase the |
101 // refcount. | 103 // refcount. |
102 PP_Resource resource_id_; | 104 PP_Resource resource_id_; |
(...skipping 26 matching lines...) Expand all Loading... |
129 DEFINE_RESOURCE_CAST(FileChooser) | 131 DEFINE_RESOURCE_CAST(FileChooser) |
130 DEFINE_RESOURCE_CAST(FileIO) | 132 DEFINE_RESOURCE_CAST(FileIO) |
131 DEFINE_RESOURCE_CAST(FileRef) | 133 DEFINE_RESOURCE_CAST(FileRef) |
132 DEFINE_RESOURCE_CAST(Font) | 134 DEFINE_RESOURCE_CAST(Font) |
133 DEFINE_RESOURCE_CAST(ImageData) | 135 DEFINE_RESOURCE_CAST(ImageData) |
134 DEFINE_RESOURCE_CAST(PrivateFontFile) | 136 DEFINE_RESOURCE_CAST(PrivateFontFile) |
135 DEFINE_RESOURCE_CAST(Scrollbar) | 137 DEFINE_RESOURCE_CAST(Scrollbar) |
136 DEFINE_RESOURCE_CAST(URLLoader) | 138 DEFINE_RESOURCE_CAST(URLLoader) |
137 DEFINE_RESOURCE_CAST(URLRequestInfo) | 139 DEFINE_RESOURCE_CAST(URLRequestInfo) |
138 DEFINE_RESOURCE_CAST(URLResponseInfo) | 140 DEFINE_RESOURCE_CAST(URLResponseInfo) |
| 141 DEFINE_RESOURCE_CAST(VideoDecoder) |
139 DEFINE_RESOURCE_CAST(Widget) | 142 DEFINE_RESOURCE_CAST(Widget) |
140 | 143 |
141 #undef DEFINE_RESOURCE_CAST | 144 #undef DEFINE_RESOURCE_CAST |
142 } // namespace pepper | 145 } // namespace pepper |
143 | 146 |
144 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_H_ | 147 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_H_ |
OLD | NEW |