Chromium Code Reviews| 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 |
| 11 #include "base/atomic_sequence_num.h" | |
| 11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/containers/scoped_ptr_hash_map.h" | |
| 12 #include "ppapi/proxy/interface_proxy.h" | 14 #include "ppapi/proxy/interface_proxy.h" |
| 13 #include "ppapi/proxy/ppapi_proxy_export.h" | 15 #include "ppapi/proxy/ppapi_proxy_export.h" |
| 14 #include "ppapi/shared_impl/ppapi_permissions.h" | 16 #include "ppapi/shared_impl/ppapi_permissions.h" |
| 15 | 17 |
| 16 namespace ppapi { | 18 namespace ppapi { |
| 17 namespace proxy { | 19 namespace proxy { |
| 18 | 20 |
| 19 class PPAPI_PROXY_EXPORT InterfaceList { | 21 class PPAPI_PROXY_EXPORT InterfaceList { |
| 20 public: | 22 public: |
| 21 InterfaceList(); | 23 InterfaceList(); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 43 // or NULL if it's not supported. | 45 // or NULL if it's not supported. |
| 44 const void* GetInterfaceForPPB(const std::string& name); | 46 const void* GetInterfaceForPPB(const std::string& name); |
| 45 const void* GetInterfaceForPPP(const std::string& name) const; | 47 const void* GetInterfaceForPPP(const std::string& name) const; |
| 46 | 48 |
| 47 private: | 49 private: |
| 48 friend class InterfaceListTest; | 50 friend class InterfaceListTest; |
| 49 | 51 |
| 50 struct InterfaceInfo { | 52 struct InterfaceInfo { |
| 51 InterfaceInfo() | 53 InterfaceInfo() |
| 52 : iface(NULL), | 54 : iface(NULL), |
| 53 required_permission(PERMISSION_NONE), | 55 required_permission(PERMISSION_NONE) { |
| 54 interface_logged(false) { | |
| 55 } | 56 } |
| 56 InterfaceInfo(const void* in_interface, Permission in_perm) | 57 InterfaceInfo(const void* in_interface, Permission in_perm) |
| 57 : iface(in_interface), | 58 : iface(in_interface), |
| 58 required_permission(in_perm), | 59 required_permission(in_perm) { |
| 59 interface_logged(false) { | |
| 60 } | 60 } |
| 61 | 61 |
| 62 const void* iface; | 62 const void* iface; |
| 63 | 63 |
| 64 // Permission required to return non-null for this interface. This will | 64 // Permission required to return non-null for this interface. This will |
| 65 // be checked with the value set via SetProcessGlobalPermissionBits when | 65 // be checked with the value set via SetProcessGlobalPermissionBits when |
| 66 // an interface is requested. | 66 // an interface is requested. |
| 67 Permission required_permission; | 67 Permission required_permission; |
| 68 | 68 |
| 69 // Interface usage is logged just once per-interface-per-plugin-process. | 69 // Count how many times the interface has been requested. This helps us |
| 70 bool interface_logged; | 70 // only log the first time the interface is requested (or in the unlikely |
| 71 // event that the count rolls over). | |
| 72 base::AtomicSequenceNumber interface_request_count_; | |
|
teravest
2014/09/12 19:08:27
Since we don't really need a sequence number, I wo
dmichael (off chromium)
2014/09/12 20:44:00
done with a lock-per-interface. Contention should
| |
| 73 private: | |
| 74 DISALLOW_COPY_AND_ASSIGN(InterfaceInfo); | |
| 71 }; | 75 }; |
| 72 | 76 |
| 73 typedef std::map<std::string, InterfaceInfo> NameToInterfaceInfoMap; | 77 typedef base::ScopedPtrHashMap<std::string, InterfaceInfo> |
| 78 NameToInterfaceInfoMap; | |
|
dmichael (off chromium)
2014/09/12 18:12:07
changed because AtomicSequenceNumber is not copyab
| |
| 74 | 79 |
| 75 void AddProxy(ApiID id, InterfaceProxy::Factory factory); | 80 void AddProxy(ApiID id, InterfaceProxy::Factory factory); |
| 76 | 81 |
| 77 // Permissions is the type of permission required to access the corresponding | 82 // Permissions is the type of permission required to access the corresponding |
| 78 // interface. Currently this must be just one unique permission (rather than | 83 // interface. Currently this must be just one unique permission (rather than |
| 79 // a bitfield). | 84 // a bitfield). |
| 80 void AddPPB(const char* name, const void* iface, Permission permission); | 85 void AddPPB(const char* name, const void* iface, Permission permission); |
| 81 void AddPPP(const char* name, const void* iface); | 86 void AddPPP(const char* name, const void* iface); |
| 82 | 87 |
| 83 // Hash the interface name for UMA logging. | 88 // Hash the interface name for UMA logging. |
| 84 static int HashInterfaceName(const std::string& name); | 89 static int HashInterfaceName(const std::string& name); |
| 85 | 90 |
| 86 PpapiPermissions permissions_; | 91 PpapiPermissions permissions_; |
| 87 | 92 |
| 88 NameToInterfaceInfoMap name_to_browser_info_; | 93 NameToInterfaceInfoMap name_to_browser_info_; |
| 89 NameToInterfaceInfoMap name_to_plugin_info_; | 94 NameToInterfaceInfoMap name_to_plugin_info_; |
| 90 | 95 |
| 91 InterfaceProxy::Factory id_to_factory_[API_ID_COUNT]; | 96 InterfaceProxy::Factory id_to_factory_[API_ID_COUNT]; |
| 92 | 97 |
| 93 DISALLOW_COPY_AND_ASSIGN(InterfaceList); | 98 DISALLOW_COPY_AND_ASSIGN(InterfaceList); |
| 94 }; | 99 }; |
| 95 | 100 |
| 96 } // namespace proxy | 101 } // namespace proxy |
| 97 } // namespace ppapi | 102 } // namespace ppapi |
| 98 | 103 |
| 99 #endif // PPAPI_PROXY_INTERFACE_LIST_H_ | 104 #endif // PPAPI_PROXY_INTERFACE_LIST_H_ |
| 100 | 105 |
| OLD | NEW |