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

Unified Diff: third_party/WebKit/Source/platform/CrossThreadCopier.h

Issue 1701013003: CrossThreadCopier: Consider arithmetic and enum types as safe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | third_party/WebKit/Source/platform/CrossThreadCopier.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/CrossThreadCopier.h
diff --git a/third_party/WebKit/Source/platform/CrossThreadCopier.h b/third_party/WebKit/Source/platform/CrossThreadCopier.h
index 7cdb70caef1ce7d992145ede57ff7b7a1dc28b95..5124406c6ef6a81bf39f32d45d5033cbc122a8e2 100644
--- a/third_party/WebKit/Source/platform/CrossThreadCopier.h
+++ b/third_party/WebKit/Source/platform/CrossThreadCopier.h
@@ -63,18 +63,18 @@ struct CrossThreadCopierPassThrough {
}
};
-template <bool isConvertibleToInteger, bool isThreadSafeRefCounted, bool isGarbageCollected, typename T>
+template <typename T, bool isArithmeticOrEnum, bool isThreadSafeRefCounted, bool isGarbageCollected>
struct CrossThreadCopierBase;
-// Integers get passed through without any changes.
-template <typename T>
-struct CrossThreadCopierBase<true, false, false, T> : public CrossThreadCopierPassThrough<T> {
+// Arithmetic values (integers or floats) and enums can be safely copied.
+template <typename T, bool isThreadSafeRefCounted, bool isGarbageCollected>
+struct CrossThreadCopierBase<T, true, isThreadSafeRefCounted, isGarbageCollected> : public CrossThreadCopierPassThrough<T> {
STATIC_ONLY(CrossThreadCopierBase);
};
-// Custom copy methods.
-template <typename T>
-struct CrossThreadCopierBase<false, true, false, T> {
+// Custom copy method for ThreadSafeRefCounted.
+template <typename T, bool isGarbageCollected>
+struct CrossThreadCopierBase<T, false, true, isGarbageCollected> {
STATIC_ONLY(CrossThreadCopierBase);
typedef typename WTF::RemoveTemplate<T, RefPtr>::Type TypeWithoutRefPtr;
typedef typename WTF::RemoveTemplate<TypeWithoutRefPtr, PassRefPtr>::Type TypeWithoutPassRefPtr;
@@ -93,8 +93,9 @@ struct CrossThreadCopierBase<false, true, false, T> {
}
};
+// A pointer to GarbageCollected.
template <typename T>
-struct CrossThreadCopierBase<false, false, true, T> {
+struct CrossThreadCopierBase<T, false, false, true> {
STATIC_ONLY(CrossThreadCopierBase);
typedef typename std::remove_pointer<T>::type TypeWithoutPointer;
typedef RawPtr<TypeWithoutPointer> Type;
@@ -105,12 +106,13 @@ struct CrossThreadCopierBase<false, false, true, T> {
};
template <typename T>
-struct CrossThreadCopier : public CrossThreadCopierBase<std::is_convertible<T, int>::value,
+struct CrossThreadCopier : public CrossThreadCopierBase<
+ T,
+ std::is_arithmetic<T>::value || std::is_enum<T>::value,
WTF::IsSubclassOfTemplate<typename WTF::RemoveTemplate<T, RefPtr>::Type, ThreadSafeRefCounted>::value
|| WTF::IsSubclassOfTemplate<typename std::remove_pointer<T>::type, ThreadSafeRefCounted>::value
|| WTF::IsSubclassOfTemplate<typename WTF::RemoveTemplate<T, PassRefPtr>::Type, ThreadSafeRefCounted>::value,
- WTF::IsSubclassOfTemplate<typename std::remove_pointer<T>::type, GarbageCollected>::value,
- T> {
+ WTF::IsSubclassOfTemplate<typename std::remove_pointer<T>::type, GarbageCollected>::value> {
STATIC_ONLY(CrossThreadCopier);
};
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/CrossThreadCopier.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698