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

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: lockless approach 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
Index: ppapi/proxy/interface_list.h
diff --git a/ppapi/proxy/interface_list.h b/ppapi/proxy/interface_list.h
index a2b4569c8f1b3b3693af6f85b068e82095a334c4..16c6c4d18b1558b4c9e62335ca44085b13a99b06 100644
--- a/ppapi/proxy/interface_list.h
+++ b/ppapi/proxy/interface_list.h
@@ -8,7 +8,9 @@
#include <map>
#include <string>
+#include "base/atomic_sequence_num.h"
#include "base/basictypes.h"
+#include "base/containers/scoped_ptr_hash_map.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
@@ -50,13 +52,11 @@ class PPAPI_PROXY_EXPORT InterfaceList {
struct InterfaceInfo {
InterfaceInfo()
: iface(NULL),
- required_permission(PERMISSION_NONE),
- interface_logged(false) {
+ required_permission(PERMISSION_NONE) {
}
InterfaceInfo(const void* in_interface, Permission in_perm)
: iface(in_interface),
- required_permission(in_perm),
- interface_logged(false) {
+ required_permission(in_perm) {
}
const void* iface;
@@ -66,11 +66,16 @@ class PPAPI_PROXY_EXPORT InterfaceList {
// an interface is requested.
Permission required_permission;
- // Interface usage is logged just once per-interface-per-plugin-process.
- bool interface_logged;
+ // Count how many times the interface has been requested. This helps us
+ // only log the first time the interface is requested (or in the unlikely
+ // event that the count rolls over).
+ base::AtomicSequenceNumber interface_request_count_;
teravest 2014/09/12 19:08:27 Since we don't really need a sequence number, I wo
dmichael (off chromium) 2014/09/12 20:44:00 done with a lock-per-interface. Contention should
+ private:
+ DISALLOW_COPY_AND_ASSIGN(InterfaceInfo);
};
- typedef std::map<std::string, InterfaceInfo> NameToInterfaceInfoMap;
+ typedef base::ScopedPtrHashMap<std::string, InterfaceInfo>
+ NameToInterfaceInfoMap;
dmichael (off chromium) 2014/09/12 18:12:07 changed because AtomicSequenceNumber is not copyab
void AddProxy(ApiID id, InterfaceProxy::Factory factory);

Powered by Google App Engine
This is Rietveld 408576698