| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef PPAPI_PROXY_INTERFACE_LIST_H_ | |
| 6 #define PPAPI_PROXY_INTERFACE_LIST_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "ppapi/proxy/interface_proxy.h" | |
| 13 | |
| 14 namespace ppapi { | |
| 15 namespace proxy { | |
| 16 | |
| 17 class InterfaceList { | |
| 18 public: | |
| 19 InterfaceList(); | |
| 20 ~InterfaceList(); | |
| 21 | |
| 22 static InterfaceList* GetInstance(); | |
| 23 | |
| 24 // Looks up the ID for the given interface name. Returns INTERFACE_ID_NONE if | |
| 25 // the interface string is not found. | |
| 26 InterfaceID GetIDForPPBInterface(const std::string& name) const; | |
| 27 InterfaceID GetIDForPPPInterface(const std::string& name) const; | |
| 28 | |
| 29 // Looks up the factory function for the given ID. Returns NULL if not | |
| 30 // supported. | |
| 31 InterfaceProxy::Factory GetFactoryForID(InterfaceID id) const; | |
| 32 | |
| 33 // Returns the interface pointer for the given browser or plugin interface, | |
| 34 // or NULL if it's not supported. | |
| 35 const void* GetInterfaceForPPB(const std::string& name) const; | |
| 36 const void* GetInterfaceForPPP(const std::string& name) const; | |
| 37 | |
| 38 private: | |
| 39 struct InterfaceInfo { | |
| 40 InterfaceInfo() | |
| 41 : id(INTERFACE_ID_NONE), | |
| 42 interface(NULL) { | |
| 43 } | |
| 44 InterfaceInfo(InterfaceID in_id, const void* in_interface) | |
| 45 : id(in_id), | |
| 46 interface(in_interface) { | |
| 47 } | |
| 48 | |
| 49 InterfaceID id; | |
| 50 const void* interface; | |
| 51 }; | |
| 52 | |
| 53 typedef std::map<std::string, InterfaceInfo> NameToInterfaceInfoMap; | |
| 54 | |
| 55 void AddProxy(InterfaceID id, InterfaceProxy::Factory factory); | |
| 56 | |
| 57 void AddPPB(const char* name, InterfaceID id, const void* interface); | |
| 58 void AddPPP(const char* name, InterfaceID id, const void* interface); | |
| 59 | |
| 60 // Old-style add functions. These should be removed when the rest of the | |
| 61 // proxies are converted over to using the new system. | |
| 62 void AddPPB(const InterfaceProxy::Info* info); | |
| 63 void AddPPP(const InterfaceProxy::Info* info); | |
| 64 | |
| 65 NameToInterfaceInfoMap name_to_browser_info_; | |
| 66 NameToInterfaceInfoMap name_to_plugin_info_; | |
| 67 | |
| 68 InterfaceProxy::Factory id_to_factory_[INTERFACE_ID_COUNT]; | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(InterfaceList); | |
| 71 }; | |
| 72 | |
| 73 } // namespace proxy | |
| 74 } // namespace ppapi | |
| 75 | |
| 76 #endif // PPAPI_PROXY_INTERFACE_LIST_H_ | |
| 77 | |
| OLD | NEW |