Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Unified Diff: ppapi/proxy/interface_list.cc

Issue 141523010: Pepper: Log in UMA when an interface is used. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased again Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/proxy/interface_list.h ('k') | ppapi/proxy/interface_list_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/interface_list.cc
diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc
index 79789d70ace37d9fc95b62b3a6bb4790289e589b..9e33c7208be50815f990fef61348d4e371ee438a 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,22 @@ 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) {
+ PluginGlobals::Get()->GetBrowserSender()->Send(
+ new PpapiHostMsg_LogInterfaceUsage(HashInterfaceName(name)));
+ found->second.interface_logged = true;
+ }
return found->second.iface;
+ }
return NULL;
}
@@ -364,5 +374,13 @@ void InterfaceList::AddPPP(const char* name,
name_to_plugin_info_[name] = InterfaceInfo(iface, PERMISSION_NONE);
}
+// static
+int InterfaceList::HashInterfaceName(const std::string& name) {
+ 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.
+ return static_cast<int>(data & 0x7fffffff);
+}
+
} // namespace proxy
} // namespace ppapi
« no previous file with comments | « ppapi/proxy/interface_list.h ('k') | ppapi/proxy/interface_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698