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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/interface_list.h ('k') | ppapi/proxy/interface_list_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ppapi/proxy/interface_list.h" 5 #include "ppapi/proxy/interface_list.h"
6 6
7 #include "base/hash.h"
7 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
8 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
9 #include "ppapi/c/dev/ppb_alarms_dev.h" 10 #include "ppapi/c/dev/ppb_alarms_dev.h"
10 #include "ppapi/c/dev/ppb_audio_input_dev.h" 11 #include "ppapi/c/dev/ppb_audio_input_dev.h"
11 #include "ppapi/c/dev/ppb_buffer_dev.h" 12 #include "ppapi/c/dev/ppb_buffer_dev.h"
12 #include "ppapi/c/dev/ppb_char_set_dev.h" 13 #include "ppapi/c/dev/ppb_char_set_dev.h"
13 #include "ppapi/c/dev/ppb_crypto_dev.h" 14 #include "ppapi/c/dev/ppb_crypto_dev.h"
14 #include "ppapi/c/dev/ppb_cursor_control_dev.h" 15 #include "ppapi/c/dev/ppb_cursor_control_dev.h"
15 #include "ppapi/c/dev/ppb_device_ref_dev.h" 16 #include "ppapi/c/dev/ppb_device_ref_dev.h"
16 #include "ppapi/c/dev/ppb_font_dev.h" 17 #include "ppapi/c/dev/ppb_font_dev.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 #include "ppapi/c/private/ppb_video_destination_private.h" 98 #include "ppapi/c/private/ppb_video_destination_private.h"
98 #include "ppapi/c/private/ppb_video_source_private.h" 99 #include "ppapi/c/private/ppb_video_source_private.h"
99 #include "ppapi/c/private/ppb_x509_certificate_private.h" 100 #include "ppapi/c/private/ppb_x509_certificate_private.h"
100 #include "ppapi/c/private/ppp_content_decryptor_private.h" 101 #include "ppapi/c/private/ppp_content_decryptor_private.h"
101 #include "ppapi/c/trusted/ppb_broker_trusted.h" 102 #include "ppapi/c/trusted/ppb_broker_trusted.h"
102 #include "ppapi/c/trusted/ppb_browser_font_trusted.h" 103 #include "ppapi/c/trusted/ppb_browser_font_trusted.h"
103 #include "ppapi/c/trusted/ppb_char_set_trusted.h" 104 #include "ppapi/c/trusted/ppb_char_set_trusted.h"
104 #include "ppapi/c/trusted/ppb_file_chooser_trusted.h" 105 #include "ppapi/c/trusted/ppb_file_chooser_trusted.h"
105 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" 106 #include "ppapi/c/trusted/ppb_url_loader_trusted.h"
106 #include "ppapi/proxy/interface_proxy.h" 107 #include "ppapi/proxy/interface_proxy.h"
108 #include "ppapi/proxy/plugin_globals.h"
109 #include "ppapi/proxy/ppapi_messages.h"
107 #include "ppapi/proxy/ppb_audio_proxy.h" 110 #include "ppapi/proxy/ppb_audio_proxy.h"
108 #include "ppapi/proxy/ppb_broker_proxy.h" 111 #include "ppapi/proxy/ppb_broker_proxy.h"
109 #include "ppapi/proxy/ppb_buffer_proxy.h" 112 #include "ppapi/proxy/ppb_buffer_proxy.h"
110 #include "ppapi/proxy/ppb_core_proxy.h" 113 #include "ppapi/proxy/ppb_core_proxy.h"
111 #include "ppapi/proxy/ppb_flash_message_loop_proxy.h" 114 #include "ppapi/proxy/ppb_flash_message_loop_proxy.h"
112 #include "ppapi/proxy/ppb_graphics_3d_proxy.h" 115 #include "ppapi/proxy/ppb_graphics_3d_proxy.h"
113 #include "ppapi/proxy/ppb_image_data_proxy.h" 116 #include "ppapi/proxy/ppb_image_data_proxy.h"
114 #include "ppapi/proxy/ppb_instance_proxy.h" 117 #include "ppapi/proxy/ppb_instance_proxy.h"
115 #include "ppapi/proxy/ppb_message_loop_proxy.h" 118 #include "ppapi/proxy/ppb_message_loop_proxy.h"
116 #include "ppapi/proxy/ppb_testing_proxy.h" 119 #include "ppapi/proxy/ppb_testing_proxy.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 311 }
309 312
310 InterfaceProxy::Factory InterfaceList::GetFactoryForID(ApiID id) const { 313 InterfaceProxy::Factory InterfaceList::GetFactoryForID(ApiID id) const {
311 int index = static_cast<int>(id); 314 int index = static_cast<int>(id);
312 COMPILE_ASSERT(API_ID_NONE == 0, none_must_be_zero); 315 COMPILE_ASSERT(API_ID_NONE == 0, none_must_be_zero);
313 if (id <= 0 || id >= API_ID_COUNT) 316 if (id <= 0 || id >= API_ID_COUNT)
314 return NULL; 317 return NULL;
315 return id_to_factory_[index]; 318 return id_to_factory_[index];
316 } 319 }
317 320
318 const void* InterfaceList::GetInterfaceForPPB(const std::string& name) const { 321 const void* InterfaceList::GetInterfaceForPPB(const std::string& name) {
319 NameToInterfaceInfoMap::const_iterator found = 322 NameToInterfaceInfoMap::iterator found =
320 name_to_browser_info_.find(name); 323 name_to_browser_info_.find(name);
321 if (found == name_to_browser_info_.end()) 324 if (found == name_to_browser_info_.end())
322 return NULL; 325 return NULL;
323 326
324 if (g_process_global_permissions.Get().HasPermission( 327 if (g_process_global_permissions.Get().HasPermission(
325 found->second.required_permission)) 328 found->second.required_permission)) {
329 // Only log interface use once per plugin.
330 if (!found->second.interface_logged) {
331 PluginGlobals::Get()->GetBrowserSender()->Send(
332 new PpapiHostMsg_LogInterfaceUsage(HashInterfaceName(name)));
333 found->second.interface_logged = true;
334 }
326 return found->second.iface; 335 return found->second.iface;
336 }
327 return NULL; 337 return NULL;
328 } 338 }
329 339
330 const void* InterfaceList::GetInterfaceForPPP(const std::string& name) const { 340 const void* InterfaceList::GetInterfaceForPPP(const std::string& name) const {
331 NameToInterfaceInfoMap::const_iterator found = 341 NameToInterfaceInfoMap::const_iterator found =
332 name_to_plugin_info_.find(name); 342 name_to_plugin_info_.find(name);
333 if (found == name_to_plugin_info_.end()) 343 if (found == name_to_plugin_info_.end())
334 return NULL; 344 return NULL;
335 return found->second.iface; 345 return found->second.iface;
336 } 346 }
(...skipping 20 matching lines...) Expand all
357 DCHECK(name_to_browser_info_.find(name) == name_to_browser_info_.end()); 367 DCHECK(name_to_browser_info_.find(name) == name_to_browser_info_.end());
358 name_to_browser_info_[name] = InterfaceInfo(iface, perm); 368 name_to_browser_info_[name] = InterfaceInfo(iface, perm);
359 } 369 }
360 370
361 void InterfaceList::AddPPP(const char* name, 371 void InterfaceList::AddPPP(const char* name,
362 const void* iface) { 372 const void* iface) {
363 DCHECK(name_to_plugin_info_.find(name) == name_to_plugin_info_.end()); 373 DCHECK(name_to_plugin_info_.find(name) == name_to_plugin_info_.end());
364 name_to_plugin_info_[name] = InterfaceInfo(iface, PERMISSION_NONE); 374 name_to_plugin_info_[name] = InterfaceInfo(iface, PERMISSION_NONE);
365 } 375 }
366 376
377 // static
378 int InterfaceList::HashInterfaceName(const std::string& name) {
379 uint32 data = base::Hash(name.c_str(), name.size());
380 // Strip off the signed bit because UMA doesn't support negative values,
381 // but takes a signed int as input.
382 return static_cast<int>(data & 0x7fffffff);
383 }
384
367 } // namespace proxy 385 } // namespace proxy
368 } // namespace ppapi 386 } // namespace ppapi
OLDNEW
« 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