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

Unified Diff: ppapi/proxy/interface_list.h

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/nacl_irt/plugin_main.cc ('k') | ppapi/proxy/interface_list.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/interface_list.h
diff --git a/ppapi/proxy/interface_list.h b/ppapi/proxy/interface_list.h
index a2b4569c8f1b3b3693af6f85b068e82095a334c4..dc109e5c5afd45ca1395ff1dec3d658684e12bbf 100644
--- a/ppapi/proxy/interface_list.h
+++ b/ppapi/proxy/interface_list.h
@@ -9,6 +9,8 @@
#include <string>
#include "base/basictypes.h"
+#include "base/containers/scoped_ptr_hash_map.h"
+#include "base/synchronization/lock.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
@@ -47,30 +49,39 @@ class PPAPI_PROXY_EXPORT InterfaceList {
private:
friend class InterfaceListTest;
- struct InterfaceInfo {
- InterfaceInfo()
- : iface(NULL),
- required_permission(PERMISSION_NONE),
- interface_logged(false) {
- }
+ class InterfaceInfo {
+ public:
InterfaceInfo(const void* in_interface, Permission in_perm)
- : iface(in_interface),
- required_permission(in_perm),
- interface_logged(false) {
+ : iface_(in_interface),
+ required_permission_(in_perm),
+ sent_to_uma_(false) {
}
- const void* iface;
+ const void* iface() { return iface_; }
// Permission required to return non-null for this interface. This will
// be checked with the value set via SetProcessGlobalPermissionBits when
// an interface is requested.
- Permission required_permission;
+ Permission required_permission() { return required_permission_; };
+
+ // Call this any time the interface is requested. It will log a UMA count
+ // only the first time. This is safe to call from any thread, regardless of
+ // whether the proxy lock is held.
+ void LogWithUmaOnce(IPC::Sender* sender, const std::string& name);
+ private:
+ DISALLOW_COPY_AND_ASSIGN(InterfaceInfo);
+
+ const void* const iface_;
+ const Permission required_permission_;
- // Interface usage is logged just once per-interface-per-plugin-process.
- bool interface_logged;
+ bool sent_to_uma_;
+ base::Lock sent_to_uma_lock_;
};
+ // Give friendship for HashInterfaceName.
+ friend class InterfaceInfo;
- typedef std::map<std::string, InterfaceInfo> NameToInterfaceInfoMap;
+ typedef base::ScopedPtrHashMap<std::string, InterfaceInfo>
+ NameToInterfaceInfoMap;
void AddProxy(ApiID id, InterfaceProxy::Factory factory);
« no previous file with comments | « ppapi/nacl_irt/plugin_main.cc ('k') | ppapi/proxy/interface_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698