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

Unified Diff: public/platform/WebPrivatePtr.h

Issue 1249913002: Make ContentDecryptionModuleResult cross-thread destructible. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: use CrossThreadPersistent<> instead Created 5 years, 5 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 | « Source/platform/heap/Handle.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: public/platform/WebPrivatePtr.h
diff --git a/public/platform/WebPrivatePtr.h b/public/platform/WebPrivatePtr.h
index f62961f062b7e81375a0ff153d9aa1659edc8968..b7763cf9ce495a4ecbf0c0bde307bb783af3deda 100644
--- a/public/platform/WebPrivatePtr.h
+++ b/public/platform/WebPrivatePtr.h
@@ -99,6 +99,32 @@ private:
T* m_ptr;
};
+template <typename T>
+struct WebPrivatePtrPersistentIsCrossThreadAccessible {
+private:
+ using YesType = char;
+ struct NoType {
+ char padding[8];
+ };
+
+ template <typename U> static YesType checkMarker(typename U::IsCrossThreadAccessibleMarker*);
+ template <typename U> static NoType checkMarker(...);
+public:
+ static const bool value = sizeof(checkMarker<T>(nullptr)) == sizeof(YesType);
+};
+
+template <typename T, bool = WebPrivatePtrPersistentIsCrossThreadAccessible<T>::value>
+struct WebPrivatePtrPersistentStorageType {
+public:
+ using type = Persistent<T>;
+};
+
+template <typename T>
+struct WebPrivatePtrPersistentStorageType<T, true> {
+public:
+ using type = CrossThreadPersistent<T>;
haraken 2015/07/23 01:41:41 How about making CrossThreadPersistent by default?
+};
+
template<typename T>
class PtrStorageImpl<T, GarbageCollectedLifetime> {
public:
@@ -110,7 +136,7 @@ public:
}
if (!m_handle)
- m_handle = new Persistent<T>();
+ m_handle = new (typename WebPrivatePtrPersistentStorageType<T>::type)();
(*m_handle) = val;
}
@@ -136,7 +162,7 @@ public:
}
private:
- Persistent<T>* m_handle;
+ typename WebPrivatePtrPersistentStorageType<T>::type* m_handle;
};
template<typename T>
« no previous file with comments | « Source/platform/heap/Handle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698