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

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

Issue 7587011: Remove the old type system for proxied resources. These were no longer being used. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: New one 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 | « ppapi/proxy/mock_resource.cc ('k') | ppapi/proxy/plugin_resource.cc » ('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 "ppapi/c/pp_instance.h" 9 #include "ppapi/c/pp_instance.h"
10 #include "ppapi/proxy/host_resource.h" 10 #include "ppapi/proxy/host_resource.h"
11 #include "ppapi/proxy/plugin_dispatcher.h" 11 #include "ppapi/proxy/plugin_dispatcher.h"
12 #include "ppapi/proxy/plugin_resource_tracker.h" 12 #include "ppapi/proxy/plugin_resource_tracker.h"
13 #include "ppapi/shared_impl/resource_object_base.h" 13 #include "ppapi/shared_impl/resource_object_base.h"
14 14
15 // If you inherit from resource, make sure you add the class name here.
16 #define FOR_ALL_PLUGIN_RESOURCES(F) \
17 F(Audio) \
18 F(AudioConfig) \
19 F(Broker) \
20 F(Buffer) \
21 F(Context3D) \
22 F(FileChooser) \
23 F(FileRef) \
24 F(FileSystem) \
25 F(FlashMenu) \
26 F(FlashNetConnector) \
27 F(Font) \
28 F(Graphics2D) \
29 F(Graphics3D) \
30 F(ImageData) \
31 F(MockResource) \
32 F(PrivateFontFile) \
33 F(Surface3D) \
34 F(URLLoader) \
35 F(URLRequestInfo) \
36 F(URLResponseInfo) \
37 F(VideoCapture) \
38 F(VideoDecoder)
39
40 namespace pp { 15 namespace pp {
41 namespace proxy { 16 namespace proxy {
42 17
43 // Forward declaration of Resource classes.
44 #define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE;
45 FOR_ALL_PLUGIN_RESOURCES(DECLARE_RESOURCE_CLASS)
46 #undef DECLARE_RESOURCE_CLASS
47
48 class PluginResource : public ::ppapi::ResourceObjectBase { 18 class PluginResource : public ::ppapi::ResourceObjectBase {
49 public: 19 public:
50 PluginResource(const HostResource& resource); 20 PluginResource(const HostResource& resource);
51 virtual ~PluginResource(); 21 virtual ~PluginResource();
52 22
53 // Returns NULL if the resource is invalid or is a different type.
54 template<typename T> static T* GetAs(PP_Resource res) {
55 PluginResource* resource =
56 PluginResourceTracker::GetInstance()->GetResourceObject(res);
57 return resource ? resource->Cast<T>() : NULL;
58 }
59
60 template <typename T> T* Cast() { return NULL; }
61
62 PP_Instance instance() const { return host_resource_.instance(); } 23 PP_Instance instance() const { return host_resource_.instance(); }
63 24
64 // Returns the host resource ID for sending to the host process. 25 // Returns the host resource ID for sending to the host process.
65 const HostResource& host_resource() const { 26 const HostResource& host_resource() const {
66 return host_resource_; 27 return host_resource_;
67 } 28 }
68 29
69 PluginDispatcher* GetDispatcher(); 30 PluginDispatcher* GetDispatcher();
70 31
71 private: 32 private:
72 // Type-specific getters for individual resource types. These will return
73 // NULL if the resource does not match the specified type. Used by the Cast()
74 // function.
75 #define DEFINE_TYPE_GETTER(RESOURCE) \
76 virtual RESOURCE* As##RESOURCE();
77 FOR_ALL_PLUGIN_RESOURCES(DEFINE_TYPE_GETTER)
78 #undef DEFINE_TYPE_GETTER
79
80 // The resource ID in the host that this object corresponds to. Inside the 33 // The resource ID in the host that this object corresponds to. Inside the
81 // plugin we'll remap the resource IDs so we can have many host processes 34 // plugin we'll remap the resource IDs so we can have many host processes
82 // each independently generating resources (which may conflict) but the IDs 35 // each independently generating resources (which may conflict) but the IDs
83 // in the plugin will all be unique. 36 // in the plugin will all be unique.
84 HostResource host_resource_; 37 HostResource host_resource_;
85 38
86 DISALLOW_COPY_AND_ASSIGN(PluginResource); 39 DISALLOW_COPY_AND_ASSIGN(PluginResource);
87 }; 40 };
88 41
89 // Cast() specializations.
90 #define DEFINE_RESOURCE_CAST(Type) \
91 template <> inline Type* PluginResource::Cast<Type>() { \
92 return As##Type(); \
93 }
94 FOR_ALL_PLUGIN_RESOURCES(DEFINE_RESOURCE_CAST)
95 #undef DEFINE_RESOURCE_CAST
96
97 } // namespace proxy 42 } // namespace proxy
98 } // namespace pp 43 } // namespace pp
99 44
100 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_H_ 45 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/mock_resource.cc ('k') | ppapi/proxy/plugin_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698