| OLD | NEW |
| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 if (id <= 0 || id >= INTERFACE_ID_COUNT) | 234 if (id <= 0 || id >= INTERFACE_ID_COUNT) |
| 235 return NULL; | 235 return NULL; |
| 236 return id_to_factory_[index]; | 236 return id_to_factory_[index]; |
| 237 } | 237 } |
| 238 | 238 |
| 239 const void* InterfaceList::GetInterfaceForPPB(const std::string& name) const { | 239 const void* InterfaceList::GetInterfaceForPPB(const std::string& name) const { |
| 240 NameToInterfaceInfoMap::const_iterator found = | 240 NameToInterfaceInfoMap::const_iterator found = |
| 241 name_to_browser_info_.find(name); | 241 name_to_browser_info_.find(name); |
| 242 if (found == name_to_browser_info_.end()) | 242 if (found == name_to_browser_info_.end()) |
| 243 return NULL; | 243 return NULL; |
| 244 return found->second.interface; | 244 return found->second.iface; |
| 245 } | 245 } |
| 246 | 246 |
| 247 const void* InterfaceList::GetInterfaceForPPP(const std::string& name) const { | 247 const void* InterfaceList::GetInterfaceForPPP(const std::string& name) const { |
| 248 NameToInterfaceInfoMap::const_iterator found = | 248 NameToInterfaceInfoMap::const_iterator found = |
| 249 name_to_plugin_info_.find(name); | 249 name_to_plugin_info_.find(name); |
| 250 if (found == name_to_plugin_info_.end()) | 250 if (found == name_to_plugin_info_.end()) |
| 251 return NULL; | 251 return NULL; |
| 252 return found->second.interface; | 252 return found->second.iface; |
| 253 } | 253 } |
| 254 | 254 |
| 255 void InterfaceList::AddProxy(InterfaceID id, | 255 void InterfaceList::AddProxy(InterfaceID id, |
| 256 InterfaceProxy::Factory factory) { | 256 InterfaceProxy::Factory factory) { |
| 257 // For interfaces with no corresponding _Proxy objects, the macros will | 257 // For interfaces with no corresponding _Proxy objects, the macros will |
| 258 // generate calls to this function with INTERFACE_ID_NONE. This means we | 258 // generate calls to this function with INTERFACE_ID_NONE. This means we |
| 259 // should just skip adding a factory for these functions. | 259 // should just skip adding a factory for these functions. |
| 260 if (id == INTERFACE_ID_NONE) | 260 if (id == INTERFACE_ID_NONE) |
| 261 return; | 261 return; |
| 262 | 262 |
| 263 // The factory should be an exact dupe of the one we already have if it | 263 // The factory should be an exact dupe of the one we already have if it |
| 264 // has already been registered before. | 264 // has already been registered before. |
| 265 int index = static_cast<int>(id); | 265 int index = static_cast<int>(id); |
| 266 DCHECK(!id_to_factory_[index] || id_to_factory_[index] == factory); | 266 DCHECK(!id_to_factory_[index] || id_to_factory_[index] == factory); |
| 267 | 267 |
| 268 id_to_factory_[index] = factory; | 268 id_to_factory_[index] = factory; |
| 269 } | 269 } |
| 270 | 270 |
| 271 void InterfaceList::AddPPB(const char* name, | 271 void InterfaceList::AddPPB(const char* name, |
| 272 InterfaceID id, | 272 InterfaceID id, |
| 273 const void* interface) { | 273 const void* iface) { |
| 274 DCHECK(name_to_browser_info_.find(name) == name_to_browser_info_.end()); | 274 DCHECK(name_to_browser_info_.find(name) == name_to_browser_info_.end()); |
| 275 name_to_browser_info_[name] = InterfaceInfo(id, interface); | 275 name_to_browser_info_[name] = InterfaceInfo(id, iface); |
| 276 } | 276 } |
| 277 | 277 |
| 278 void InterfaceList::AddPPP(const char* name, | 278 void InterfaceList::AddPPP(const char* name, |
| 279 InterfaceID id, | 279 InterfaceID id, |
| 280 const void* interface) { | 280 const void* iface) { |
| 281 DCHECK(name_to_plugin_info_.find(name) == name_to_plugin_info_.end()); | 281 DCHECK(name_to_plugin_info_.find(name) == name_to_plugin_info_.end()); |
| 282 name_to_plugin_info_[name] = InterfaceInfo(id, interface); | 282 name_to_plugin_info_[name] = InterfaceInfo(id, iface); |
| 283 } | 283 } |
| 284 | 284 |
| 285 void InterfaceList::AddPPB(const InterfaceProxy::Info* info) { | 285 void InterfaceList::AddPPB(const InterfaceProxy::Info* info) { |
| 286 AddProxy(info->id, info->create_proxy); | 286 AddProxy(info->id, info->create_proxy); |
| 287 AddPPB(info->name, info->id, info->interface_ptr); | 287 AddPPB(info->name, info->id, info->interface_ptr); |
| 288 } | 288 } |
| 289 | 289 |
| 290 void InterfaceList::AddPPP(const InterfaceProxy::Info* info) { | 290 void InterfaceList::AddPPP(const InterfaceProxy::Info* info) { |
| 291 AddProxy(info->id, info->create_proxy); | 291 AddProxy(info->id, info->create_proxy); |
| 292 AddPPP(info->name, info->id, info->interface_ptr); | 292 AddPPP(info->name, info->id, info->interface_ptr); |
| 293 } | 293 } |
| 294 | 294 |
| 295 } // namespace proxy | 295 } // namespace proxy |
| 296 } // namespace ppapi | 296 } // namespace ppapi |
| OLD | NEW |