Chromium Code Reviews| Index: ppapi/proxy/interface_list.cc |
| diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc |
| index 79789d70ace37d9fc95b62b3a6bb4790289e589b..6c202fa3ea67de54219073ab3ed23773082f285e 100644 |
| --- a/ppapi/proxy/interface_list.cc |
| +++ b/ppapi/proxy/interface_list.cc |
| @@ -4,6 +4,7 @@ |
| #include "ppapi/proxy/interface_list.h" |
| +#include "base/hash.h" |
| #include "base/lazy_instance.h" |
| #include "base/memory/singleton.h" |
| #include "ppapi/c/dev/ppb_alarms_dev.h" |
| @@ -104,6 +105,8 @@ |
| #include "ppapi/c/trusted/ppb_file_chooser_trusted.h" |
| #include "ppapi/c/trusted/ppb_url_loader_trusted.h" |
| #include "ppapi/proxy/interface_proxy.h" |
| +#include "ppapi/proxy/plugin_globals.h" |
| +#include "ppapi/proxy/ppapi_messages.h" |
| #include "ppapi/proxy/ppb_audio_proxy.h" |
| #include "ppapi/proxy/ppb_broker_proxy.h" |
| #include "ppapi/proxy/ppb_buffer_proxy.h" |
| @@ -315,15 +318,26 @@ InterfaceProxy::Factory InterfaceList::GetFactoryForID(ApiID id) const { |
| return id_to_factory_[index]; |
| } |
| -const void* InterfaceList::GetInterfaceForPPB(const std::string& name) const { |
| - NameToInterfaceInfoMap::const_iterator found = |
| +const void* InterfaceList::GetInterfaceForPPB(const std::string& name) { |
| + NameToInterfaceInfoMap::iterator found = |
| name_to_browser_info_.find(name); |
| if (found == name_to_browser_info_.end()) |
| return NULL; |
| if (g_process_global_permissions.Get().HasPermission( |
| - found->second.required_permission)) |
| + found->second.required_permission)) { |
| + // Only log interface use once per plugin. |
| + if (!found->second.interface_logged) { |
| + uint32 data = base::Hash(name.c_str(), name.size()); |
| + // Strip off the signed bit because UMA doesn't support negative values, |
| + // but takes a signed int as input. |
| + int hash = static_cast<int>(data & 0x7fffffff); |
|
Alexei Svitkine (slow)
2014/02/04 18:30:43
Is base::Hash() guaranteed to never change impleme
|
| + PluginGlobals::Get()->GetBrowserSender()->Send( |
| + new PpapiHostMsg_LogInterfaceUsage(hash)); |
| + found->second.interface_logged = true; |
| + } |
| return found->second.iface; |
| + } |
| return NULL; |
| } |