Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: ppapi/native_client/src/shared/ppapi_proxy/plugin_resource.h

Issue 10386080: Rename nacl::RefCounted to nacl::RefCountedThreadSafe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: License bump Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_RESOURCE_H_ 5 #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_RESOURCE_H_
6 #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_RESOURCE_H_ 6 #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_RESOURCE_H_
7 7
8 #include "native_client/src/include/nacl_base.h" 8 #include "native_client/src/include/nacl_base.h"
9 #include "native_client/src/include/ref_counted.h" 9 #include "native_client/src/include/ref_counted.h"
10 #include "native_client/src/shared/ppapi_proxy/plugin_resource_tracker.h" 10 #include "native_client/src/shared/ppapi_proxy/plugin_resource_tracker.h"
(...skipping 11 matching lines...) Expand all
22 F(PluginGraphics3D) \ 22 F(PluginGraphics3D) \
23 F(PluginImageData) \ 23 F(PluginImageData) \
24 F(PluginInputEvent) \ 24 F(PluginInputEvent) \
25 F(PluginView) 25 F(PluginView)
26 26
27 // Forward declaration of PluginResource classes. 27 // Forward declaration of PluginResource classes.
28 #define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE; 28 #define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE;
29 FOR_ALL_RESOURCES(DECLARE_RESOURCE_CLASS) 29 FOR_ALL_RESOURCES(DECLARE_RESOURCE_CLASS)
30 #undef DECLARE_RESOURCE_CLASS 30 #undef DECLARE_RESOURCE_CLASS
31 31
32 class PluginResource : public nacl::RefCounted<PluginResource> { 32 class PluginResource : public nacl::RefCountedThreadSafe<PluginResource> {
33 public: 33 public:
34 PluginResource(); 34 PluginResource();
35 virtual ~PluginResource();
36 35
37 // Returns NULL if the resource is invalid or is a different type. 36 // Returns NULL if the resource is invalid or is a different type.
38 template<typename T> 37 template<typename T>
39 static scoped_refptr<T> GetAs(PP_Resource res) { 38 static scoped_refptr<T> GetAs(PP_Resource res) {
40 // See if we have the resource cached. 39 // See if we have the resource cached.
41 scoped_refptr<PluginResource> resource = 40 scoped_refptr<PluginResource> resource =
42 PluginResourceTracker::Get()->GetExistingResource(res); 41 PluginResourceTracker::Get()->GetExistingResource(res);
43 42
44 return resource ? resource->Cast<T>() : NULL; 43 return resource ? resource->Cast<T>() : NULL;
45 } 44 }
(...skipping 16 matching lines...) Expand all
62 // Returns NULL if the resource is invalid or is a different type. 61 // Returns NULL if the resource is invalid or is a different type.
63 template<typename T> 62 template<typename T>
64 static scoped_refptr<T> AdoptAsWithNoBrowserCount(PP_Resource res); 63 static scoped_refptr<T> AdoptAsWithNoBrowserCount(PP_Resource res);
65 64
66 // Cast the resource into a specified type. This will return NULL if the 65 // Cast the resource into a specified type. This will return NULL if the
67 // resource does not match the specified type. Specializations of this 66 // resource does not match the specified type. Specializations of this
68 // template call into As* functions. 67 // template call into As* functions.
69 template <typename T> T* Cast() { return NULL; } 68 template <typename T> T* Cast() { return NULL; }
70 69
71 protected: 70 protected:
71 virtual ~PluginResource();
72
72 virtual bool InitFromBrowserResource(PP_Resource resource) = 0; 73 virtual bool InitFromBrowserResource(PP_Resource resource) = 0;
73 74
74 private: 75 private:
76 friend class nacl::RefCountedThreadSafe<PluginResource>;
77
75 // Type-specific getters for individual resource types. These will return 78 // Type-specific getters for individual resource types. These will return
76 // NULL if the resource does not match the specified type. Used by the Cast() 79 // NULL if the resource does not match the specified type. Used by the Cast()
77 // function. 80 // function.
78 #define DEFINE_TYPE_GETTER(RESOURCE) \ 81 #define DEFINE_TYPE_GETTER(RESOURCE) \
79 virtual RESOURCE* As##RESOURCE() { return NULL; } 82 virtual RESOURCE* As##RESOURCE() { return NULL; }
80 FOR_ALL_RESOURCES(DEFINE_TYPE_GETTER) 83 FOR_ALL_RESOURCES(DEFINE_TYPE_GETTER)
81 #undef DEFINE_TYPE_GETTER 84 #undef DEFINE_TYPE_GETTER
82 85
83 // Call this macro in the derived class declaration to actually implement the 86 // Call this macro in the derived class declaration to actually implement the
84 // type getter. 87 // type getter.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // Adopt the resource with 0 browser-side refcount. 144 // Adopt the resource with 0 browser-side refcount.
142 const size_t browser_refcount = 0; 145 const size_t browser_refcount = 0;
143 return PluginResourceTracker::Get()->AdoptBrowserResource<T>( 146 return PluginResourceTracker::Get()->AdoptBrowserResource<T>(
144 res, browser_refcount); 147 res, browser_refcount);
145 } 148 }
146 149
147 } // namespace ppapi_proxy 150 } // namespace ppapi_proxy
148 151
149 #endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_RESOURCE_H_ 152 #endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_RESOURCE_H_
150 153
OLDNEW
« no previous file with comments | « ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_view.cc ('k') | ppapi/native_client/src/shared/ppapi_proxy/proxy_var.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698