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

Unified Diff: ppapi/proxy/interface_list.cc

Issue 568793002: PPAPI: Fix GetBrowserInterface race conditions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 6 years, 3 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/plugin_dispatcher.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 3e9003fd8d4fe78cfd85e9cbca52f25f75e8ab63..f2ed19a61b27a6bb46767291c9c5d3b7ce3ad5be 100644
--- a/ppapi/proxy/interface_list.cc
+++ b/ppapi/proxy/interface_list.cc
@@ -320,6 +320,8 @@ InterfaceList::~InterfaceList() {
// static
InterfaceList* InterfaceList::GetInstance() {
+ // CAUTION: This function is called without the ProxyLock to avoid excessive
+ // excessive locking from C++ wrappers. (See also GetBrowserInterface.)
return Singleton<InterfaceList>::get();
}
@@ -338,20 +340,19 @@ InterfaceProxy::Factory InterfaceList::GetFactoryForID(ApiID id) const {
}
const void* InterfaceList::GetInterfaceForPPB(const std::string& name) {
+ // CAUTION: This function is called without the ProxyLock to avoid excessive
+ // excessive locking from C++ wrappers. (See also GetBrowserInterface.)
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;
+ found->second->LogWithUmaOnce(
+ PluginGlobals::Get()->GetBrowserSender(), name);
+ return found->second->iface();
}
return NULL;
}
@@ -361,7 +362,20 @@ const void* InterfaceList::GetInterfaceForPPP(const std::string& name) const {
name_to_plugin_info_.find(name);
if (found == name_to_plugin_info_.end())
return NULL;
- return found->second.iface;
+ return found->second->iface();
+}
+
+void InterfaceList::InterfaceInfo::LogWithUmaOnce(
+ IPC::Sender* sender, const std::string& name) {
+ {
+ base::AutoLock acquire(sent_to_uma_lock_);
+ if (sent_to_uma_)
+ return;
+ sent_to_uma_ = true;
+ }
+ int hash = InterfaceList::HashInterfaceName(name);
+ PluginGlobals::Get()->GetBrowserSender()->Send(
+ new PpapiHostMsg_LogInterfaceUsage(hash));
}
void InterfaceList::AddProxy(ApiID id,
@@ -384,16 +398,18 @@ void InterfaceList::AddPPB(const char* name,
const void* iface,
Permission perm) {
DCHECK(name_to_browser_info_.find(name) == name_to_browser_info_.end());
- name_to_browser_info_[name] = InterfaceInfo(iface, perm);
+ name_to_browser_info_.add(
+ name, scoped_ptr<InterfaceInfo>(new InterfaceInfo(iface, perm)));
}
void InterfaceList::AddPPP(const char* name,
const void* iface) {
DCHECK(name_to_plugin_info_.find(name) == name_to_plugin_info_.end());
- name_to_plugin_info_[name] = InterfaceInfo(iface, PERMISSION_NONE);
+ name_to_plugin_info_.add(
+ name,
+ scoped_ptr<InterfaceInfo>(new 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,
« no previous file with comments | « ppapi/proxy/interface_list.h ('k') | ppapi/proxy/plugin_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698