OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 |
(...skipping 23 matching lines...) Expand all Loading... |
34 // This check just allows us to return NULL for interfaces you "shouldn't" be | 34 // This check just allows us to return NULL for interfaces you "shouldn't" be |
35 // using to keep honest plugins honest. | 35 // using to keep honest plugins honest. |
36 static void SetProcessGlobalPermissions(const PpapiPermissions& permissions); | 36 static void SetProcessGlobalPermissions(const PpapiPermissions& permissions); |
37 | 37 |
38 // Looks up the factory function for the given ID. Returns NULL if not | 38 // Looks up the factory function for the given ID. Returns NULL if not |
39 // supported. | 39 // supported. |
40 InterfaceProxy::Factory GetFactoryForID(ApiID id) const; | 40 InterfaceProxy::Factory GetFactoryForID(ApiID id) const; |
41 | 41 |
42 // Returns the interface pointer for the given browser or plugin interface, | 42 // Returns the interface pointer for the given browser or plugin interface, |
43 // or NULL if it's not supported. | 43 // or NULL if it's not supported. |
44 const void* GetInterfaceForPPB(const std::string& name) const; | 44 const void* GetInterfaceForPPB(const std::string& name); |
45 const void* GetInterfaceForPPP(const std::string& name) const; | 45 const void* GetInterfaceForPPP(const std::string& name) const; |
46 | 46 |
47 private: | 47 private: |
48 friend class InterfaceListTest; | 48 friend class InterfaceListTest; |
49 | 49 |
50 struct InterfaceInfo { | 50 struct InterfaceInfo { |
51 InterfaceInfo() | 51 InterfaceInfo() |
52 : iface(NULL), | 52 : iface(NULL), |
53 required_permission(PERMISSION_NONE) { | 53 required_permission(PERMISSION_NONE), |
| 54 interface_logged(false) { |
54 } | 55 } |
55 InterfaceInfo(const void* in_interface, Permission in_perm) | 56 InterfaceInfo(const void* in_interface, Permission in_perm) |
56 : iface(in_interface), | 57 : iface(in_interface), |
57 required_permission(in_perm) { | 58 required_permission(in_perm), |
| 59 interface_logged(false) { |
58 } | 60 } |
59 | 61 |
60 const void* iface; | 62 const void* iface; |
61 | 63 |
62 // Permission required to return non-null for this interface. This will | 64 // Permission required to return non-null for this interface. This will |
63 // be checked with the value set via SetProcessGlobalPermissionBits when | 65 // be checked with the value set via SetProcessGlobalPermissionBits when |
64 // an interface is requested. | 66 // an interface is requested. |
65 Permission required_permission; | 67 Permission required_permission; |
| 68 |
| 69 // Interface usage is logged just once per-interface-per-plugin-process. |
| 70 bool interface_logged; |
66 }; | 71 }; |
67 | 72 |
68 typedef std::map<std::string, InterfaceInfo> NameToInterfaceInfoMap; | 73 typedef std::map<std::string, InterfaceInfo> NameToInterfaceInfoMap; |
69 | 74 |
70 void AddProxy(ApiID id, InterfaceProxy::Factory factory); | 75 void AddProxy(ApiID id, InterfaceProxy::Factory factory); |
71 | 76 |
72 // Permissions is the type of permission required to access the corresponding | 77 // Permissions is the type of permission required to access the corresponding |
73 // interface. Currently this must be just one unique permission (rather than | 78 // interface. Currently this must be just one unique permission (rather than |
74 // a bitfield). | 79 // a bitfield). |
75 void AddPPB(const char* name, const void* iface, Permission permission); | 80 void AddPPB(const char* name, const void* iface, Permission permission); |
76 void AddPPP(const char* name, const void* iface); | 81 void AddPPP(const char* name, const void* iface); |
77 | 82 |
| 83 // Hash the interface name for UMA logging. |
| 84 static int HashInterfaceName(const std::string& name); |
| 85 |
78 PpapiPermissions permissions_; | 86 PpapiPermissions permissions_; |
79 | 87 |
80 NameToInterfaceInfoMap name_to_browser_info_; | 88 NameToInterfaceInfoMap name_to_browser_info_; |
81 NameToInterfaceInfoMap name_to_plugin_info_; | 89 NameToInterfaceInfoMap name_to_plugin_info_; |
82 | 90 |
83 InterfaceProxy::Factory id_to_factory_[API_ID_COUNT]; | 91 InterfaceProxy::Factory id_to_factory_[API_ID_COUNT]; |
84 | 92 |
85 DISALLOW_COPY_AND_ASSIGN(InterfaceList); | 93 DISALLOW_COPY_AND_ASSIGN(InterfaceList); |
86 }; | 94 }; |
87 | 95 |
88 } // namespace proxy | 96 } // namespace proxy |
89 } // namespace ppapi | 97 } // namespace ppapi |
90 | 98 |
91 #endif // PPAPI_PROXY_INTERFACE_LIST_H_ | 99 #endif // PPAPI_PROXY_INTERFACE_LIST_H_ |
92 | 100 |
OLD | NEW |