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 PPAPI_PROXY_PLUGIN_RESOURCE_H_ | 5 #ifndef PPAPI_PROXY_PLUGIN_RESOURCE_H_ |
6 #define PPAPI_PROXY_PLUGIN_RESOURCE_H_ | 6 #define PPAPI_PROXY_PLUGIN_RESOURCE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "ppapi/proxy/plugin_dispatcher.h" | 9 #include "ppapi/proxy/plugin_dispatcher.h" |
10 #include "ppapi/proxy/plugin_resource_tracker.h" | 10 #include "ppapi/proxy/plugin_resource_tracker.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 return resource ? resource->Cast<T>() : NULL; | 43 return resource ? resource->Cast<T>() : NULL; |
44 } | 44 } |
45 | 45 |
46 template <typename T> T* Cast() { return NULL; } | 46 template <typename T> T* Cast() { return NULL; } |
47 | 47 |
48 private: | 48 private: |
49 // Type-specific getters for individual resource types. These will return | 49 // Type-specific getters for individual resource types. These will return |
50 // NULL if the resource does not match the specified type. Used by the Cast() | 50 // NULL if the resource does not match the specified type. Used by the Cast() |
51 // function. | 51 // function. |
52 #define DEFINE_TYPE_GETTER(RESOURCE) \ | 52 #define DEFINE_TYPE_GETTER(RESOURCE) \ |
53 virtual RESOURCE* As##RESOURCE() { return NULL; } | 53 virtual RESOURCE* As##RESOURCE(); |
54 FOR_ALL_RESOURCES(DEFINE_TYPE_GETTER) | 54 FOR_ALL_RESOURCES(DEFINE_TYPE_GETTER) |
55 #undef DEFINE_TYPE_GETTER | 55 #undef DEFINE_TYPE_GETTER |
56 | 56 |
57 DISALLOW_COPY_AND_ASSIGN(PluginResource); | 57 DISALLOW_COPY_AND_ASSIGN(PluginResource); |
58 }; | 58 }; |
59 | 59 |
60 // Cast() specializations. | 60 // Cast() specializations. |
61 #define DEFINE_RESOURCE_CAST(Type) \ | 61 #define DEFINE_RESOURCE_CAST(Type) \ |
62 template <> inline Type* PluginResource::Cast<Type>() { \ | 62 template <> inline Type* PluginResource::Cast<Type>() { \ |
63 return As##Type(); \ | 63 return As##Type(); \ |
64 } | 64 } |
65 FOR_ALL_RESOURCES(DEFINE_RESOURCE_CAST) | 65 FOR_ALL_RESOURCES(DEFINE_RESOURCE_CAST) |
66 #undef DEFINE_RESOURCE_CAST | 66 #undef DEFINE_RESOURCE_CAST |
67 | 67 |
68 } // namespace proxy | 68 } // namespace proxy |
69 } // namespace pp | 69 } // namespace pp |
70 | 70 |
71 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_H_ | 71 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_H_ |
OLD | NEW |