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

Side by Side Diff: ppapi/proxy/plugin_resource.h

Issue 7608033: Move the refcounting from the proxy/impl resource object to the shared resource object base class. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 4 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
« no previous file with comments | « no previous file | ppapi/shared_impl/audio_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 "base/memory/ref_counted.h"
10 #include "ppapi/c/pp_instance.h" 9 #include "ppapi/c/pp_instance.h"
11 #include "ppapi/proxy/host_resource.h" 10 #include "ppapi/proxy/host_resource.h"
12 #include "ppapi/proxy/plugin_dispatcher.h" 11 #include "ppapi/proxy/plugin_dispatcher.h"
13 #include "ppapi/proxy/plugin_resource_tracker.h" 12 #include "ppapi/proxy/plugin_resource_tracker.h"
14 #include "ppapi/shared_impl/resource_object_base.h" 13 #include "ppapi/shared_impl/resource_object_base.h"
15 14
16 // If you inherit from resource, make sure you add the class name here. 15 // If you inherit from resource, make sure you add the class name here.
17 #define FOR_ALL_PLUGIN_RESOURCES(F) \ 16 #define FOR_ALL_PLUGIN_RESOURCES(F) \
18 F(Audio) \ 17 F(Audio) \
19 F(AudioConfig) \ 18 F(AudioConfig) \
(...skipping 19 matching lines...) Expand all
39 F(VideoDecoder) 38 F(VideoDecoder)
40 39
41 namespace pp { 40 namespace pp {
42 namespace proxy { 41 namespace proxy {
43 42
44 // Forward declaration of Resource classes. 43 // Forward declaration of Resource classes.
45 #define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE; 44 #define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE;
46 FOR_ALL_PLUGIN_RESOURCES(DECLARE_RESOURCE_CLASS) 45 FOR_ALL_PLUGIN_RESOURCES(DECLARE_RESOURCE_CLASS)
47 #undef DECLARE_RESOURCE_CLASS 46 #undef DECLARE_RESOURCE_CLASS
48 47
49 class PluginResource : public ::ppapi::ResourceObjectBase, 48 class PluginResource : public ::ppapi::ResourceObjectBase {
50 public base::RefCounted<PluginResource> {
51 public: 49 public:
52 PluginResource(const HostResource& resource); 50 PluginResource(const HostResource& resource);
53 virtual ~PluginResource(); 51 virtual ~PluginResource();
54 52
55 // Returns NULL if the resource is invalid or is a different type. 53 // Returns NULL if the resource is invalid or is a different type.
56 template<typename T> static T* GetAs(PP_Resource res) { 54 template<typename T> static T* GetAs(PP_Resource res) {
57 PluginResource* resource = 55 PluginResource* resource =
58 PluginResourceTracker::GetInstance()->GetResourceObject(res); 56 PluginResourceTracker::GetInstance()->GetResourceObject(res);
59 return resource ? resource->Cast<T>() : NULL; 57 return resource ? resource->Cast<T>() : NULL;
60 } 58 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 template <> inline Type* PluginResource::Cast<Type>() { \ 91 template <> inline Type* PluginResource::Cast<Type>() { \
94 return As##Type(); \ 92 return As##Type(); \
95 } 93 }
96 FOR_ALL_PLUGIN_RESOURCES(DEFINE_RESOURCE_CAST) 94 FOR_ALL_PLUGIN_RESOURCES(DEFINE_RESOURCE_CAST)
97 #undef DEFINE_RESOURCE_CAST 95 #undef DEFINE_RESOURCE_CAST
98 96
99 } // namespace proxy 97 } // namespace proxy
100 } // namespace pp 98 } // namespace pp
101 99
102 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_H_ 100 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_H_
OLDNEW
« no previous file with comments | « no previous file | ppapi/shared_impl/audio_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698