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

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

Issue 7189045: Make o.o.p. proxy handle PPP_Instance versions 0.4 and 0.5. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make HostDispatcher remember plugin IFs by name, not ID Created 9 years, 6 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 #include "ppapi/proxy/dispatcher.h" 5 #include "ppapi/proxy/dispatcher.h"
6 6
7 #include <string.h> // For memset. 7 #include <string.h> // For memset.
8 8
9 #include <map> 9 #include <map>
10 10
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 typedef std::map<std::string, const InterfaceProxy::Info*> NameToInfo; 98 typedef std::map<std::string, const InterfaceProxy::Info*> NameToInfo;
99 NameToInfo name_to_plugin_info_; 99 NameToInfo name_to_plugin_info_;
100 NameToInfo name_to_browser_info_; 100 NameToInfo name_to_browser_info_;
101 101
102 // Note that there can be multiple interface names mapping to the same ID. 102 // Note that there can be multiple interface names mapping to the same ID.
103 // In this case, the ID will map to one of them. This is temporary while 103 // In this case, the ID will map to one of them. This is temporary while
104 // we're converting to the thunk system, when that is complete, we need to 104 // we're converting to the thunk system, when that is complete, we need to
105 // have a better way of handling multiple interface implemented by one 105 // have a better way of handling multiple interface implemented by one
106 // proxy object. 106 // proxy object.
107 const InterfaceProxy::Info* id_to_plugin_info_[INTERFACE_ID_COUNT];
108 const InterfaceProxy::Info* id_to_browser_info_[INTERFACE_ID_COUNT]; 107 const InterfaceProxy::Info* id_to_browser_info_[INTERFACE_ID_COUNT];
109 }; 108 };
110 109
111 InterfaceList::InterfaceList() { 110 InterfaceList::InterfaceList() {
112 memset(id_to_plugin_info_, 0, sizeof(id_to_plugin_info_));
113 memset(id_to_browser_info_, 0, sizeof(id_to_browser_info_)); 111 memset(id_to_browser_info_, 0, sizeof(id_to_browser_info_));
114 112
115 // PPB (browser) interfaces. 113 // PPB (browser) interfaces.
116 AddPPB(PPB_AudioConfig_Proxy::GetInfo()); 114 AddPPB(PPB_AudioConfig_Proxy::GetInfo());
117 AddPPB(PPB_Audio_Proxy::GetInfo()); 115 AddPPB(PPB_Audio_Proxy::GetInfo());
118 AddPPB(PPB_Broker_Proxy::GetInfo()); 116 AddPPB(PPB_Broker_Proxy::GetInfo());
119 AddPPB(PPB_Buffer_Proxy::GetInfo()); 117 AddPPB(PPB_Buffer_Proxy::GetInfo());
120 AddPPB(PPB_CharSet_Proxy::GetInfo()); 118 AddPPB(PPB_CharSet_Proxy::GetInfo());
121 AddPPB(PPB_Console_Proxy::GetInfo()); 119 AddPPB(PPB_Console_Proxy::GetInfo());
122 AddPPB(PPB_Context3D_Proxy::GetInfo()); 120 AddPPB(PPB_Context3D_Proxy::GetInfo());
(...skipping 28 matching lines...) Expand all
151 AddPPB(PPB_Var_Deprecated_Proxy::GetInfo()); 149 AddPPB(PPB_Var_Deprecated_Proxy::GetInfo());
152 AddPPB(PPB_Var_Proxy::GetInfo()); 150 AddPPB(PPB_Var_Proxy::GetInfo());
153 151
154 #ifdef ENABLE_FLAPPER_HACKS 152 #ifdef ENABLE_FLAPPER_HACKS
155 AddPPB(PPB_Flash_NetConnector_Proxy::GetInfo()); 153 AddPPB(PPB_Flash_NetConnector_Proxy::GetInfo());
156 #endif 154 #endif
157 155
158 // PPP (plugin) interfaces. 156 // PPP (plugin) interfaces.
159 AddPPP(PPP_Graphics3D_Proxy::GetInfo()); 157 AddPPP(PPP_Graphics3D_Proxy::GetInfo());
160 AddPPP(PPP_Instance_Private_Proxy::GetInfo()); 158 AddPPP(PPP_Instance_Private_Proxy::GetInfo());
161 AddPPP(PPP_Instance_Proxy::GetInfo()); 159 AddPPP(PPP_Instance_Proxy::GetInfo0_4());
160 AddPPP(PPP_Instance_Proxy::GetInfo0_5());
162 } 161 }
163 162
164 void InterfaceList::AddPPP(const InterfaceProxy::Info* info) { 163 void InterfaceList::AddPPP(const InterfaceProxy::Info* info) {
165 DCHECK(name_to_plugin_info_.find(info->name) == 164 DCHECK(name_to_plugin_info_.find(info->name) ==
166 name_to_plugin_info_.end()); 165 name_to_plugin_info_.end());
167 DCHECK(info->id >= INTERFACE_ID_NONE && info->id < INTERFACE_ID_COUNT); 166 DCHECK(info->id >= INTERFACE_ID_NONE && info->id < INTERFACE_ID_COUNT);
168 DCHECK(info->id == INTERFACE_ID_NONE || id_to_plugin_info_[info->id] == NULL);
169 167
170 name_to_plugin_info_[info->name] = info; 168 name_to_plugin_info_[info->name] = info;
171 if (info->id != INTERFACE_ID_NONE)
172 id_to_plugin_info_[info->id] = info;
173 } 169 }
174 170
175 void InterfaceList::AddPPB(const InterfaceProxy::Info* info) { 171 void InterfaceList::AddPPB(const InterfaceProxy::Info* info) {
176 DCHECK(name_to_browser_info_.find(info->name) == 172 DCHECK(name_to_browser_info_.find(info->name) ==
177 name_to_browser_info_.end()); 173 name_to_browser_info_.end());
178 DCHECK(info->id >= INTERFACE_ID_NONE && info->id < INTERFACE_ID_COUNT); 174 DCHECK(info->id >= INTERFACE_ID_NONE && info->id < INTERFACE_ID_COUNT);
179 DCHECK(info->id == INTERFACE_ID_NONE || 175 DCHECK(info->id == INTERFACE_ID_NONE ||
180 id_to_browser_info_[info->id] == NULL); 176 id_to_browser_info_[info->id] == NULL);
181 177
182 name_to_browser_info_[std::string(info->name)] = info; 178 name_to_browser_info_[std::string(info->name)] = info;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 const InterfaceProxy::Info* Dispatcher::GetPPPInterfaceInfo( 235 const InterfaceProxy::Info* Dispatcher::GetPPPInterfaceInfo(
240 const std::string& name) { 236 const std::string& name) {
241 const InterfaceList* list = InterfaceList::GetInstance(); 237 const InterfaceList* list = InterfaceList::GetInstance();
242 InterfaceList::NameToInfo::const_iterator found = 238 InterfaceList::NameToInfo::const_iterator found =
243 list->name_to_plugin_info_.find(name); 239 list->name_to_plugin_info_.find(name);
244 if (found == list->name_to_plugin_info_.end()) 240 if (found == list->name_to_plugin_info_.end())
245 return NULL; 241 return NULL;
246 return found->second; 242 return found->second;
247 } 243 }
248 244
249 // static
250 const InterfaceProxy::Info* Dispatcher::GetPPPInterfaceInfo(InterfaceID id) {
251 if (id <= 0 || id >= INTERFACE_ID_COUNT)
252 return NULL;
253 const InterfaceList* list = InterfaceList::GetInstance();
254 return list->id_to_plugin_info_[id];
255 }
256
257 void Dispatcher::SetSerializationRules( 245 void Dispatcher::SetSerializationRules(
258 VarSerializationRules* var_serialization_rules) { 246 VarSerializationRules* var_serialization_rules) {
259 serialization_rules_.reset(var_serialization_rules); 247 serialization_rules_.reset(var_serialization_rules);
260 } 248 }
261 249
262 const void* Dispatcher::GetLocalInterface(const char* interface_name) { 250 const void* Dispatcher::GetLocalInterface(const char* interface_name) {
263 return local_get_interface_(interface_name); 251 return local_get_interface_(interface_name);
264 } 252 }
265 253
266 base::MessageLoopProxy* Dispatcher::GetIPCMessageLoop() { 254 base::MessageLoopProxy* Dispatcher::GetIPCMessageLoop() {
267 return delegate()->GetIPCMessageLoop(); 255 return delegate()->GetIPCMessageLoop();
268 } 256 }
269 257
270 void Dispatcher::AddIOThreadMessageFilter( 258 void Dispatcher::AddIOThreadMessageFilter(
271 IPC::ChannelProxy::MessageFilter* filter) { 259 IPC::ChannelProxy::MessageFilter* filter) {
272 channel()->AddFilter(filter); 260 channel()->AddFilter(filter);
273 } 261 }
274 262
275 } // namespace proxy 263 } // namespace proxy
276 } // namespace pp 264 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698