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