OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SHARED_IMPL_RESOURCE_H_ | 5 #ifndef PPAPI_SHARED_IMPL_RESOURCE_H_ |
6 #define PPAPI_SHARED_IMPL_RESOURCE_H_ | 6 #define PPAPI_SHARED_IMPL_RESOURCE_H_ |
7 | 7 |
8 #include <stddef.h> // For NULL. | 8 #include <stddef.h> // For NULL. |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 FOR_ALL_PPAPI_RESOURCE_APIS(DECLARE_RESOURCE_CLASS) | 111 FOR_ALL_PPAPI_RESOURCE_APIS(DECLARE_RESOURCE_CLASS) |
112 #undef DECLARE_RESOURCE_CLASS | 112 #undef DECLARE_RESOURCE_CLASS |
113 } // namespace thunk | 113 } // namespace thunk |
114 | 114 |
115 // Resources have slightly different registration behaviors when the're an | 115 // Resources have slightly different registration behaviors when the're an |
116 // in-process ("impl") resource in the host (renderer) process, or when they're | 116 // in-process ("impl") resource in the host (renderer) process, or when they're |
117 // a proxied resource in the plugin process. This enum differentiates those | 117 // a proxied resource in the plugin process. This enum differentiates those |
118 // cases. | 118 // cases. |
119 enum ResourceObjectType { OBJECT_IS_IMPL, OBJECT_IS_PROXY }; | 119 enum ResourceObjectType { OBJECT_IS_IMPL, OBJECT_IS_PROXY }; |
120 | 120 |
121 class PPAPI_SHARED_EXPORT Resource : public base::RefCounted<Resource> { | 121 // TODO(mgiuca): Avoid using UnsafeRefCounted. http://crbug.com/469952. |
| 122 class PPAPI_SHARED_EXPORT Resource : public base::UnsafeRefCounted<Resource> { |
122 public: | 123 public: |
123 // Constructor for impl and non-proxied, instance-only objects. | 124 // Constructor for impl and non-proxied, instance-only objects. |
124 // | 125 // |
125 // For constructing "impl" (non-proxied) objects, this just takes the | 126 // For constructing "impl" (non-proxied) objects, this just takes the |
126 // associated instance, and generates a new resource ID. The host resource | 127 // associated instance, and generates a new resource ID. The host resource |
127 // will be the same as the newly-generated resource ID. For all objects in | 128 // will be the same as the newly-generated resource ID. For all objects in |
128 // the renderer (host) process, you'll use this constructor and call it with | 129 // the renderer (host) process, you'll use this constructor and call it with |
129 // OBJECT_IS_IMPL. | 130 // OBJECT_IS_IMPL. |
130 // | 131 // |
131 // For proxied objects, this will create an "instance-only" object which | 132 // For proxied objects, this will create an "instance-only" object which |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 template <> \ | 253 template <> \ |
253 inline thunk::RESOURCE* Resource::GetAs() { \ | 254 inline thunk::RESOURCE* Resource::GetAs() { \ |
254 return As##RESOURCE(); \ | 255 return As##RESOURCE(); \ |
255 } | 256 } |
256 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_RESOURCE_CAST) | 257 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_RESOURCE_CAST) |
257 #undef DEFINE_RESOURCE_CAST | 258 #undef DEFINE_RESOURCE_CAST |
258 | 259 |
259 } // namespace ppapi | 260 } // namespace ppapi |
260 | 261 |
261 #endif // PPAPI_SHARED_IMPL_RESOURCE_H_ | 262 #endif // PPAPI_SHARED_IMPL_RESOURCE_H_ |
OLD | NEW |