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

Side by Side Diff: third_party/WebKit/Source/platform/CrossThreadCopier.cpp

Issue 1477213003: More switching to standard type traits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Excluded WTF::IsSubclass from the patch Created 4 years, 12 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 { 62 {
63 return response.copyData(); 63 return response.copyData();
64 } 64 }
65 65
66 // Test CrossThreadCopier using static_assert. 66 // Test CrossThreadCopier using static_assert.
67 67
68 // Verify that ThreadSafeRefCounted objects get handled correctly. 68 // Verify that ThreadSafeRefCounted objects get handled correctly.
69 class CopierThreadSafeRefCountedTest : public ThreadSafeRefCounted<CopierThreadS afeRefCountedTest> { 69 class CopierThreadSafeRefCountedTest : public ThreadSafeRefCounted<CopierThreadS afeRefCountedTest> {
70 }; 70 };
71 71
72 static_assert((WTF::IsSameType< 72 static_assert((std::is_same<
73 PassRefPtr<CopierThreadSafeRefCountedTest>, 73 PassRefPtr<CopierThreadSafeRefCountedTest>,
74 CrossThreadCopier<PassRefPtr<CopierThreadSafeRefCountedTest>>::Type 74 CrossThreadCopier<PassRefPtr<CopierThreadSafeRefCountedTest>>::Type
75 >::value), 75 >::value),
76 "PassRefPtr test"); 76 "PassRefPtr test");
77 static_assert((WTF::IsSameType< 77 static_assert((std::is_same<
78 PassRefPtr<CopierThreadSafeRefCountedTest>, 78 PassRefPtr<CopierThreadSafeRefCountedTest>,
79 CrossThreadCopier<RefPtr<CopierThreadSafeRefCountedTest>>::Type 79 CrossThreadCopier<RefPtr<CopierThreadSafeRefCountedTest>>::Type
80 >::value), 80 >::value),
81 "RefPtr test"); 81 "RefPtr test");
82 static_assert((WTF::IsSameType< 82 static_assert((std::is_same<
83 PassRefPtr<CopierThreadSafeRefCountedTest>, 83 PassRefPtr<CopierThreadSafeRefCountedTest>,
84 CrossThreadCopier<CopierThreadSafeRefCountedTest*>::Type 84 CrossThreadCopier<CopierThreadSafeRefCountedTest*>::Type
85 >::value), 85 >::value),
86 "RawPointer test"); 86 "RawPointer test");
87 87
88 88
89 // Add a generic specialization which will let's us verify that no other templat e matches. 89 // Add a generic specialization which will let's us verify that no other templat e matches.
90 template<typename T> struct CrossThreadCopierBase<false, false, false, T> { 90 template<typename T> struct CrossThreadCopierBase<false, false, false, T> {
91 typedef int Type; 91 typedef int Type;
92 }; 92 };
93 93
94 // Verify that RefCounted objects only match our generic template which exposes Type as int. 94 // Verify that RefCounted objects only match our generic template which exposes Type as int.
95 class CopierRefCountedTest : public RefCounted<CopierRefCountedTest> { 95 class CopierRefCountedTest : public RefCounted<CopierRefCountedTest> {
96 }; 96 };
97 97
98 static_assert((WTF::IsSameType< 98 static_assert((std::is_same<
99 int, 99 int,
100 CrossThreadCopier<PassRefPtr<CopierRefCountedTest>>::Type 100 CrossThreadCopier<PassRefPtr<CopierRefCountedTest>>::Type
101 >::value), 101 >::value),
102 "PassRefPtr<RefCountedTest> test"); 102 "PassRefPtr<RefCountedTest> test");
103 103
104 static_assert((WTF::IsSameType< 104 static_assert((std::is_same<
105 int, 105 int,
106 CrossThreadCopier<RefPtr<CopierRefCountedTest>>::Type 106 CrossThreadCopier<RefPtr<CopierRefCountedTest>>::Type
107 >::value), 107 >::value),
108 "RefPtr<RefCounted> test"); 108 "RefPtr<RefCounted> test");
109 109
110 static_assert((WTF::IsSameType< 110 static_assert((std::is_same<
111 int, 111 int,
112 CrossThreadCopier<CopierRefCountedTest*>::Type 112 CrossThreadCopier<CopierRefCountedTest*>::Type
113 >::value), 113 >::value),
114 "Raw pointer RefCounted test"); 114 "Raw pointer RefCounted test");
115 115
116 // Verify that PassOwnPtr gets passed through. 116 // Verify that PassOwnPtr gets passed through.
117 static_assert((WTF::IsSameType< 117 static_assert((std::is_same<
118 PassOwnPtr<float>, 118 PassOwnPtr<float>,
119 CrossThreadCopier<PassOwnPtr<float>>::Type 119 CrossThreadCopier<PassOwnPtr<float>>::Type
120 >::value), 120 >::value),
121 "PassOwnPtr test"); 121 "PassOwnPtr test");
122 122
123 // Verify that PassOwnPtr does not get passed through. 123 // Verify that PassOwnPtr does not get passed through.
124 static_assert((WTF::IsSameType< 124 static_assert((std::is_same<
125 int, 125 int,
126 CrossThreadCopier<OwnPtr<float>>::Type 126 CrossThreadCopier<OwnPtr<float>>::Type
127 >::value), 127 >::value),
128 "OwnPtr test"); 128 "OwnPtr test");
129 129
130 } // namespace blink 130 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/CrossThreadCopier.h ('k') | third_party/WebKit/Source/platform/TraceEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698