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

Side by Side Diff: ppapi/proxy/interface_list.cc

Issue 8359010: Convert the Flash interfaces to no longer use GetInfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comment Created 9 years, 2 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/interface_list.h ('k') | ppapi/proxy/ppb_flash_clipboard_proxy.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 #include "ppapi/proxy/interface_list.h" 5 #include "ppapi/proxy/interface_list.h"
6 6
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "ppapi/c/dev/ppb_buffer_dev.h" 8 #include "ppapi/c/dev/ppb_buffer_dev.h"
9 #include "ppapi/c/dev/ppb_char_set_dev.h" 9 #include "ppapi/c/dev/ppb_char_set_dev.h"
10 #include "ppapi/c/dev/ppb_console_dev.h" 10 #include "ppapi/c/dev/ppb_console_dev.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 #include "ppapi/shared_impl/opengles2_impl.h" 96 #include "ppapi/shared_impl/opengles2_impl.h"
97 #include "ppapi/thunk/thunk.h" 97 #include "ppapi/thunk/thunk.h"
98 98
99 // Helper to get the proxy name PPB_Foo_Proxy given the API name PPB_Foo. 99 // Helper to get the proxy name PPB_Foo_Proxy given the API name PPB_Foo.
100 #define PROXY_CLASS_NAME(api_name) api_name##_Proxy 100 #define PROXY_CLASS_NAME(api_name) api_name##_Proxy
101 101
102 // Helper to get the interface ID PPB_Foo_Proxy::kApiID given the API 102 // Helper to get the interface ID PPB_Foo_Proxy::kApiID given the API
103 // name PPB_Foo. 103 // name PPB_Foo.
104 #define PROXY_API_ID(api_name) PROXY_CLASS_NAME(api_name)::kApiID 104 #define PROXY_API_ID(api_name) PROXY_CLASS_NAME(api_name)::kApiID
105 105
106 // Helper to get the name of the factory function CreatePPB_Foo_Proxy given 106 // Helper to get the name of the templatized factory function.
107 // the API name PPB_Foo. 107 #define PROXY_FACTORY_NAME(api_name) ProxyFactory<PROXY_CLASS_NAME(api_name)>
108 #define PROXY_FACTORY_NAME(api_name) Create##api_name##_Proxy
109 108
110 // Helper to get the name of the thunk GetPPB_Foo_1_0_Thunk given the interface 109 // Helper to get the name of the thunk GetPPB_Foo_1_0_Thunk given the interface
111 // struct name PPB_Foo_1_0. 110 // struct name PPB_Foo_1_0.
112 #define INTERFACE_THUNK_NAME(iface_struct) thunk::Get##iface_struct##_Thunk 111 #define INTERFACE_THUNK_NAME(iface_struct) thunk::Get##iface_struct##_Thunk
113 112
114 namespace ppapi { 113 namespace ppapi {
115 namespace proxy { 114 namespace proxy {
116 115
117 namespace { 116 namespace {
118 117
119 // The interface list has interfaces with no ID listed as "NoAPIName" which 118 // The interface list has interfaces with no ID listed as "NoAPIName" which
120 // means there's no corresponding _Proxy object. Our macros expand this to 119 // means there's no corresponding _Proxy object. Our macros expand this to
121 // NoAPIName_Proxy, and then they look for kApiID inside it. 120 // NoAPIName_Proxy, and then they look for kApiID inside it.
122 // 121 //
123 // This dummy class provides the correct definition for that interface ID, 122 // This dummy class provides the correct definition for that interface ID,
124 // which is "NONE". 123 // which is "NONE".
125 class NoAPIName_Proxy { 124 class NoAPIName_Proxy {
126 public: 125 public:
127 static const ApiID kApiID = API_ID_NONE; 126 static const ApiID kApiID = API_ID_NONE;
128 }; 127 };
129 128
130 // Define factory functions for each interface type. These are of the form: 129 template<typename ProxyClass>
131 // InterfaceProxy* CreatePPB_URLLoader_Proxy(... 130 InterfaceProxy* ProxyFactory(Dispatcher* dispatcher) {
132 #define PROXIED_API(api_name) \ 131 return new ProxyClass(dispatcher);
133 InterfaceProxy* PROXY_FACTORY_NAME(api_name)(Dispatcher* dispatcher) { \ 132 }
134 return new PROXY_CLASS_NAME(api_name)(dispatcher); \
135 }
136 #include "ppapi/thunk/interfaces_ppb_public_stable.h"
137 #include "ppapi/thunk/interfaces_ppb_public_dev.h"
138 #include "ppapi/thunk/interfaces_ppb_private.h"
139 #undef PROXIED_API
140 133
141 } // namespace 134 } // namespace
142 135
143 InterfaceList::InterfaceList() { 136 InterfaceList::InterfaceList() {
144 memset(id_to_factory_, 0, sizeof(id_to_factory_)); 137 memset(id_to_factory_, 0, sizeof(id_to_factory_));
145 138
146 // Register the API factories for each of the API types. This calls AddProxy 139 // Register the API factories for each of the API types. This calls AddProxy
147 // for each InterfaceProxy type we support. 140 // for each InterfaceProxy type we support.
148 #define PROXIED_API(api_name) \ 141 #define PROXIED_API(api_name) \
149 AddProxy(PROXY_API_ID(api_name), &PROXY_FACTORY_NAME(api_name)); 142 AddProxy(PROXY_API_ID(api_name), &PROXY_FACTORY_NAME(api_name));
(...skipping 17 matching lines...) Expand all
167 // proxy and the impl and there's no obvious message routing. 160 // proxy and the impl and there's no obvious message routing.
168 AddProxy(API_ID_RESOURCE_CREATION, &ResourceCreationProxy::Create); 161 AddProxy(API_ID_RESOURCE_CREATION, &ResourceCreationProxy::Create);
169 AddProxy(API_ID_PPP_CLASS, &PPP_Class_Proxy::Create); 162 AddProxy(API_ID_PPP_CLASS, &PPP_Class_Proxy::Create);
170 AddPPB(PPB_CORE_INTERFACE, API_ID_PPB_CORE, 163 AddPPB(PPB_CORE_INTERFACE, API_ID_PPB_CORE,
171 PPB_Core_Proxy::GetPPB_Core_Interface()); 164 PPB_Core_Proxy::GetPPB_Core_Interface());
172 AddPPB(PPB_OPENGLES2_INTERFACE, API_ID_NONE, 165 AddPPB(PPB_OPENGLES2_INTERFACE, API_ID_NONE,
173 OpenGLES2Impl::GetInterface()); 166 OpenGLES2Impl::GetInterface());
174 AddPPB(PPB_VAR_INTERFACE, API_ID_NONE, 167 AddPPB(PPB_VAR_INTERFACE, API_ID_NONE,
175 GetPPB_Var_Interface()); 168 GetPPB_Var_Interface());
176 169
170 AddFlashInterfaces();
171
177 // PPB (browser) interfaces. 172 // PPB (browser) interfaces.
178 AddPPB(PPB_FileChooser_Proxy::GetTrustedInfo()); 173 AddPPB(PPB_FileChooser_Proxy::GetTrustedInfo());
179 AddPPB(PPB_Flash_Clipboard_Proxy::GetInfo());
180 AddPPB(PPB_Flash_File_FileRef_Proxy::GetInfo());
181 AddPPB(PPB_Flash_File_ModuleLocal_Proxy::GetInfo());
182 AddPPB(PPB_Flash_Menu_Proxy::GetInfo());
183 AddPPB(PPB_Flash_Proxy::GetInfo());
184 AddPPB(PPB_Flash_TCPSocket_Proxy::GetInfo());
185 AddPPB(PPB_Flash_UDPSocket_Proxy::GetInfo());
186 AddPPB(PPB_Instance_Proxy::GetInfoPrivate()); 174 AddPPB(PPB_Instance_Proxy::GetInfoPrivate());
187 AddPPB(PPB_PDF_Proxy::GetInfo()); 175 AddPPB(PPB_PDF_Proxy::GetInfo());
188 AddPPB(PPB_Testing_Proxy::GetInfo()); 176 AddPPB(PPB_Testing_Proxy::GetInfo());
189 AddPPB(PPB_URLLoader_Proxy::GetTrustedInfo()); 177 AddPPB(PPB_URLLoader_Proxy::GetTrustedInfo());
190 AddPPB(PPB_Var_Deprecated_Proxy::GetInfo()); 178 AddPPB(PPB_Var_Deprecated_Proxy::GetInfo());
191 179
192 #ifdef ENABLE_FLAPPER_HACKS
193 AddPPB(PPB_Flash_NetConnector_Proxy::GetInfo());
194 #endif
195
196 // PPP (plugin) interfaces. 180 // PPP (plugin) interfaces.
197 AddPPP(PPP_Graphics3D_Proxy::GetInfo()); 181 AddPPP(PPP_Graphics3D_Proxy::GetInfo());
198 AddPPP(PPP_InputEvent_Proxy::GetInfo()); 182 AddPPP(PPP_InputEvent_Proxy::GetInfo());
199 AddPPP(PPP_Instance_Private_Proxy::GetInfo()); 183 AddPPP(PPP_Instance_Private_Proxy::GetInfo());
200 AddPPP(PPP_Instance_Proxy::GetInfo1_0()); 184 AddPPP(PPP_Instance_Proxy::GetInfo1_0());
201 AddPPP(PPP_Messaging_Proxy::GetInfo()); 185 AddPPP(PPP_Messaging_Proxy::GetInfo());
202 AddPPP(PPP_MouseLock_Proxy::GetInfo()); 186 AddPPP(PPP_MouseLock_Proxy::GetInfo());
203 AddPPP(PPP_VideoCapture_Proxy::GetInfo()); 187 AddPPP(PPP_VideoCapture_Proxy::GetInfo());
204 AddPPP(PPP_VideoDecoder_Proxy::GetInfo()); 188 AddPPP(PPP_VideoDecoder_Proxy::GetInfo());
205 } 189 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } 229 }
246 230
247 const void* InterfaceList::GetInterfaceForPPP(const std::string& name) const { 231 const void* InterfaceList::GetInterfaceForPPP(const std::string& name) const {
248 NameToInterfaceInfoMap::const_iterator found = 232 NameToInterfaceInfoMap::const_iterator found =
249 name_to_plugin_info_.find(name); 233 name_to_plugin_info_.find(name);
250 if (found == name_to_plugin_info_.end()) 234 if (found == name_to_plugin_info_.end())
251 return NULL; 235 return NULL;
252 return found->second.iface; 236 return found->second.iface;
253 } 237 }
254 238
239 void InterfaceList::AddFlashInterfaces() {
240 AddProxy(API_ID_PPB_FLASH_CLIPBOARD,
241 &ProxyFactory<PPB_Flash_Clipboard_Proxy>);
242 AddPPB(PPB_FLASH_CLIPBOARD_INTERFACE, API_ID_PPB_FLASH_CLIPBOARD,
243 PPB_Flash_Clipboard_Proxy::GetInterface());
244
245 AddProxy(API_ID_PPB_FLASH_FILE_MODULELOCAL,
246 &ProxyFactory<PPB_Flash_File_ModuleLocal_Proxy>);
247 AddPPB(PPB_FLASH_FILE_MODULELOCAL_INTERFACE,
248 API_ID_PPB_FLASH_FILE_MODULELOCAL,
249 PPB_Flash_File_ModuleLocal_Proxy::GetInterface());
250
251 AddProxy(API_ID_PPB_FLASH_FILE_FILEREF,
252 &ProxyFactory<PPB_Flash_File_FileRef_Proxy>);
253 AddPPB(PPB_FLASH_FILE_FILEREF_INTERFACE, API_ID_PPB_FLASH_FILE_FILEREF,
254 PPB_Flash_File_FileRef_Proxy::GetInterface());
255
256 AddProxy(API_ID_PPB_FLASH_MENU, &ProxyFactory<PPB_Flash_Menu_Proxy>);
257 AddPPB(PPB_FLASH_MENU_INTERFACE, API_ID_PPB_FLASH_MENU,
258 thunk::GetPPB_Flash_Menu_Thunk());
259
260 AddProxy(API_ID_PPB_FLASH, &ProxyFactory<PPB_Flash_Proxy>);
261 AddPPB(PPB_FLASH_INTERFACE, API_ID_PPB_FLASH,
262 PPB_Flash_Proxy::GetInterface());
263
264 AddProxy(API_ID_PPB_FLASH_TCPSOCKET,
265 &ProxyFactory<PPB_Flash_TCPSocket_Proxy>);
266 AddPPB(PPB_FLASH_TCPSOCKET_INTERFACE, API_ID_PPB_FLASH_TCPSOCKET,
267 thunk::GetPPB_Flash_TCPSocket_Thunk());
268
269 AddProxy(API_ID_PPB_FLASH_UDPSOCKET,
270 &ProxyFactory<PPB_Flash_UDPSocket_Proxy>);
271 AddPPB(PPB_FLASH_UDPSOCKET_INTERFACE, API_ID_PPB_FLASH_UDPSOCKET,
272 thunk::GetPPB_Flash_UDPSocket_Thunk());
273
274 #ifdef ENABLE_FLAPPER_HACKS
275 AddProxy(API_ID_PPB_FLASH_NETCONNECTOR,
276 &ProxyFactory<PPB_Flash_NetConnector_Proxy>);
277 AddPPB(PPB_FLASH_NETCONNECTOR_INTERFACE, API_ID_PPB_FLASH_NETCONNECTOR,
278 thunk::GetPPB_Flash_NetConnector_Thunk());
279 #endif
280 }
281
255 void InterfaceList::AddProxy(ApiID id, 282 void InterfaceList::AddProxy(ApiID id,
256 InterfaceProxy::Factory factory) { 283 InterfaceProxy::Factory factory) {
257 // For interfaces with no corresponding _Proxy objects, the macros will 284 // For interfaces with no corresponding _Proxy objects, the macros will
258 // generate calls to this function with API_ID_NONE. This means we 285 // generate calls to this function with API_ID_NONE. This means we
259 // should just skip adding a factory for these functions. 286 // should just skip adding a factory for these functions.
260 if (id == API_ID_NONE) 287 if (id == API_ID_NONE)
261 return; 288 return;
262 289
263 // The factory should be an exact dupe of the one we already have if it 290 // The factory should be an exact dupe of the one we already have if it
264 // has already been registered before. 291 // has already been registered before.
(...skipping 22 matching lines...) Expand all
287 AddPPB(info->name, info->id, info->interface_ptr); 314 AddPPB(info->name, info->id, info->interface_ptr);
288 } 315 }
289 316
290 void InterfaceList::AddPPP(const InterfaceProxy::Info* info) { 317 void InterfaceList::AddPPP(const InterfaceProxy::Info* info) {
291 AddProxy(info->id, info->create_proxy); 318 AddProxy(info->id, info->create_proxy);
292 AddPPP(info->name, info->id, info->interface_ptr); 319 AddPPP(info->name, info->id, info->interface_ptr);
293 } 320 }
294 321
295 } // namespace proxy 322 } // namespace proxy
296 } // namespace ppapi 323 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/interface_list.h ('k') | ppapi/proxy/ppb_flash_clipboard_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698