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

Unified Diff: Source/WebCore/platform/CrossThreadCopier.cpp

Issue 7946013: Merge 94986 - Make the ThreadSafeRefCounted support in CrossThreadCopier work for T*. (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/874/
Patch Set: Created 9 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 | « Source/WebCore/platform/CrossThreadCopier.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/platform/CrossThreadCopier.cpp
===================================================================
--- Source/WebCore/platform/CrossThreadCopier.cpp (revision 95461)
+++ Source/WebCore/platform/CrossThreadCopier.cpp (working copy)
@@ -39,6 +39,8 @@
#include "ResourceResponse.h"
#include "SerializedScriptValue.h"
+#include <wtf/Assertions.h>
+
namespace WebCore {
CrossThreadCopierBase<false, false, KURL>::Type CrossThreadCopierBase<false, false, KURL>::copy(const KURL& url)
@@ -66,4 +68,68 @@
return response.copyData();
}
+// Test CrossThreadCopier using COMPILE_ASSERT.
+
+// Verify that ThreadSafeRefCounted objects get handled correctly.
+class CopierThreadSafeRefCountedTest : public ThreadSafeRefCounted<CopierThreadSafeRefCountedTest> {
+};
+
+COMPILE_ASSERT((WTF::IsSameType<
+ PassRefPtr<CopierThreadSafeRefCountedTest>,
+ CrossThreadCopier<PassRefPtr<CopierThreadSafeRefCountedTest> >::Type
+ >::value),
+ PassRefPtrTest);
+COMPILE_ASSERT((WTF::IsSameType<
+ PassRefPtr<CopierThreadSafeRefCountedTest>,
+ CrossThreadCopier<RefPtr<CopierThreadSafeRefCountedTest> >::Type
+ >::value),
+ RefPtrTest);
+COMPILE_ASSERT((WTF::IsSameType<
+ PassRefPtr<CopierThreadSafeRefCountedTest>,
+ CrossThreadCopier<CopierThreadSafeRefCountedTest*>::Type
+ >::value),
+ RawPointerTest);
+
+
+// Add a generic specialization which will let's us verify that no other template matches.
+template<typename T> struct CrossThreadCopierBase<false, false, T> {
+ typedef int Type;
+};
+
+// Verify that RefCounted objects only match our generic template which exposes Type as int.
+class CopierRefCountedTest : public RefCounted<CopierRefCountedTest> {
+};
+
+COMPILE_ASSERT((WTF::IsSameType<
+ int,
+ CrossThreadCopier<PassRefPtr<CopierRefCountedTest> >::Type
+ >::value),
+ PassRefPtrRefCountedTest);
+
+COMPILE_ASSERT((WTF::IsSameType<
+ int,
+ CrossThreadCopier<RefPtr<CopierRefCountedTest> >::Type
+ >::value),
+ RefPtrRefCountedTest);
+
+COMPILE_ASSERT((WTF::IsSameType<
+ int,
+ CrossThreadCopier<CopierRefCountedTest*>::Type
+ >::value),
+ RawPointerRefCountedTest);
+
+// Verify that PassOwnPtr gets passed through.
+COMPILE_ASSERT((WTF::IsSameType<
+ PassOwnPtr<float>,
+ CrossThreadCopier<PassOwnPtr<float> >::Type
+ >::value),
+ PassOwnPtrTest);
+
+// Verify that PassOwnPtr does not get passed through.
+COMPILE_ASSERT((WTF::IsSameType<
+ int,
+ CrossThreadCopier<OwnPtr<float> >::Type
+ >::value),
+ OwnPtrTest);
+
} // namespace WebCore
« no previous file with comments | « Source/WebCore/platform/CrossThreadCopier.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698