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 #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 Loading... | |
| 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 Loading... | |
| 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 uint32 data = base::Hash(name.c_str(), name.size()); | |
| 332 // Strip off the signed bit because UMA doesn't support negative values, | |
| 333 // but takes a signed int as input. | |
| 334 int hash = static_cast<int>(data & 0x7fffffff); | |
|
Alexei Svitkine (slow)
2014/02/04 18:30:43
Is base::Hash() guaranteed to never change impleme
| |
| 335 PluginGlobals::Get()->GetBrowserSender()->Send( | |
| 336 new PpapiHostMsg_LogInterfaceUsage(hash)); | |
| 337 found->second.interface_logged = true; | |
| 338 } | |
| 326 return found->second.iface; | 339 return found->second.iface; |
| 340 } | |
| 327 return NULL; | 341 return NULL; |
| 328 } | 342 } |
| 329 | 343 |
| 330 const void* InterfaceList::GetInterfaceForPPP(const std::string& name) const { | 344 const void* InterfaceList::GetInterfaceForPPP(const std::string& name) const { |
| 331 NameToInterfaceInfoMap::const_iterator found = | 345 NameToInterfaceInfoMap::const_iterator found = |
| 332 name_to_plugin_info_.find(name); | 346 name_to_plugin_info_.find(name); |
| 333 if (found == name_to_plugin_info_.end()) | 347 if (found == name_to_plugin_info_.end()) |
| 334 return NULL; | 348 return NULL; |
| 335 return found->second.iface; | 349 return found->second.iface; |
| 336 } | 350 } |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 359 } | 373 } |
| 360 | 374 |
| 361 void InterfaceList::AddPPP(const char* name, | 375 void InterfaceList::AddPPP(const char* name, |
| 362 const void* iface) { | 376 const void* iface) { |
| 363 DCHECK(name_to_plugin_info_.find(name) == name_to_plugin_info_.end()); | 377 DCHECK(name_to_plugin_info_.find(name) == name_to_plugin_info_.end()); |
| 364 name_to_plugin_info_[name] = InterfaceInfo(iface, PERMISSION_NONE); | 378 name_to_plugin_info_[name] = InterfaceInfo(iface, PERMISSION_NONE); |
| 365 } | 379 } |
| 366 | 380 |
| 367 } // namespace proxy | 381 } // namespace proxy |
| 368 } // namespace ppapi | 382 } // namespace ppapi |
| OLD | NEW |