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

Side by Side Diff: third_party/WebKit/Source/platform/heap/Handle.h

Issue 1923183002: Add support for IsGarbageCollectedType<void> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: auto-Rebase Created 4 years, 7 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) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 } 1152 }
1153 1153
1154 template<typename T> inline T* getPtr(const blink::Persistent<T>& p) 1154 template<typename T> inline T* getPtr(const blink::Persistent<T>& p)
1155 { 1155 {
1156 return p.get(); 1156 return p.get();
1157 } 1157 }
1158 1158
1159 // For wtf/Functional.h 1159 // For wtf/Functional.h
1160 template<typename T, bool isGarbageCollected> struct PointerParamStorageTraits; 1160 template<typename T, bool isGarbageCollected> struct PointerParamStorageTraits;
1161 1161
1162 // The condition of 'T must be fully defined' (except for void) is checked in
1163 // blink::IsGarbageCollectedType<T>::value.
1162 template<typename T> 1164 template<typename T>
1163 struct PointerParamStorageTraits<T*, false> { 1165 struct PointerParamStorageTraits<T*, false> {
1164 STATIC_ONLY(PointerParamStorageTraits); 1166 STATIC_ONLY(PointerParamStorageTraits);
1165 static_assert(sizeof(T), "T must be fully defined");
1166 using StorageType = T*; 1167 using StorageType = T*;
1167 1168
1168 static StorageType wrap(T* value) { return value; } 1169 static StorageType wrap(T* value) { return value; }
1169 static T* unwrap(const StorageType& value) { return value; } 1170 static T* unwrap(const StorageType& value) { return value; }
1170 }; 1171 };
1171 1172
1172 template<typename T> 1173 template<typename T>
1173 struct PointerParamStorageTraits<T*, true> { 1174 struct PointerParamStorageTraits<T*, true> {
1174 STATIC_ONLY(PointerParamStorageTraits); 1175 STATIC_ONLY(PointerParamStorageTraits);
1175 static_assert(sizeof(T), "T must be fully defined");
1176 using StorageType = blink::CrossThreadPersistent<T>; 1176 using StorageType = blink::CrossThreadPersistent<T>;
1177 1177
1178 static StorageType wrap(T* value) { return value; } 1178 static StorageType wrap(T* value) { return value; }
1179 static T* unwrap(const StorageType& value) { return value.get(); } 1179 static T* unwrap(const StorageType& value) { return value.get(); }
1180 }; 1180 };
1181 1181
1182 template<typename T> 1182 template<typename T>
1183 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, blink::IsGa rbageCollectedType<T>::value> { 1183 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, blink::IsGa rbageCollectedType<T>::value> {
1184 STATIC_ONLY(ParamStorageTraits); 1184 STATIC_ONLY(ParamStorageTraits);
1185 static_assert(sizeof(T), "T must be fully defined");
1186 }; 1185 };
1187 1186
1188 template<typename T> 1187 template<typename T>
1189 struct ParamStorageTraits<blink::WeakPersistentThisPointer<T>> { 1188 struct ParamStorageTraits<blink::WeakPersistentThisPointer<T>> {
1190 STATIC_ONLY(ParamStorageTraits); 1189 STATIC_ONLY(ParamStorageTraits);
1191 static_assert(sizeof(T), "T must be fully defined"); 1190 static_assert(sizeof(T), "T must be fully defined");
1192 using StorageType = blink::WeakPersistent<T>; 1191 using StorageType = blink::WeakPersistent<T>;
1193 1192
1194 static StorageType wrap(const blink::WeakPersistentThisPointer<T>& value) { return value.value(); } 1193 static StorageType wrap(const blink::WeakPersistentThisPointer<T>& value) { return value.value(); }
1195 1194
(...skipping 17 matching lines...) Expand all
1213 // into it. 1212 // into it.
1214 // 1213 //
1215 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty pe like 1214 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty pe like
1216 // CrossThreadWeakPersistent<>. 1215 // CrossThreadWeakPersistent<>.
1217 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR eference<T>::create(value.get())); } 1216 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR eference<T>::create(value.get())); }
1218 }; 1217 };
1219 1218
1220 } // namespace WTF 1219 } // namespace WTF
1221 1220
1222 #endif 1221 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/GarbageCollected.h ('k') | third_party/WebKit/Source/wtf/Functional.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698