OLD | NEW |
---|---|
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 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
984 ASSERT(!m_keepAlive || m_keepAlive->get() == self); | 984 ASSERT(!m_keepAlive || m_keepAlive->get() == self); |
985 if (!m_keepAlive) | 985 if (!m_keepAlive) |
986 m_keepAlive = adoptPtr(new Persistent<Self>); | 986 m_keepAlive = adoptPtr(new Persistent<Self>); |
987 *m_keepAlive = self; | 987 *m_keepAlive = self; |
988 } | 988 } |
989 | 989 |
990 GC_PLUGIN_IGNORE("420515") | 990 GC_PLUGIN_IGNORE("420515") |
991 OwnPtr<Persistent<Self>> m_keepAlive; | 991 OwnPtr<Persistent<Self>> m_keepAlive; |
992 }; | 992 }; |
993 | 993 |
994 template<typename T> | |
995 class AllowCrossThreadWeakPersistent { | |
996 STACK_ALLOCATED(); | |
997 public: | |
998 explicit AllowCrossThreadWeakPersistent(T* value) : m_value(value) { } | |
999 CrossThreadWeakPersistent<T> value() const { return m_value; } | |
haraken
2015/09/03 23:39:33
Just to confirm: All call sites of value() are wri
sof
2015/09/04 05:21:04
No, doing so would require teaching wtf/Functional
haraken
2015/09/04 05:23:38
Makes sense.
sof
2015/09/04 06:50:20
Added a comment + TODO next to the relevant unwrap
| |
1000 private: | |
1001 CrossThreadWeakPersistent<T> m_value; | |
1002 }; | |
1003 | |
994 } // namespace blink | 1004 } // namespace blink |
995 | 1005 |
996 namespace WTF { | 1006 namespace WTF { |
997 | 1007 |
998 template <typename T> struct VectorTraits<blink::Member<T>> : VectorTraitsBase<b link::Member<T>> { | 1008 template <typename T> struct VectorTraits<blink::Member<T>> : VectorTraitsBase<b link::Member<T>> { |
999 static const bool needsDestruction = false; | 1009 static const bool needsDestruction = false; |
1000 static const bool canInitializeWithMemset = true; | 1010 static const bool canInitializeWithMemset = true; |
1001 static const bool canClearUnusedSlotsWithMemset = true; | 1011 static const bool canClearUnusedSlotsWithMemset = true; |
1002 static const bool canMoveWithMemcpy = true; | 1012 static const bool canMoveWithMemcpy = true; |
1003 }; | 1013 }; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1175 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, blink::IsGa rbageCollectedType<T>::value> { | 1185 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, blink::IsGa rbageCollectedType<T>::value> { |
1176 static_assert(sizeof(T), "T must be fully defined"); | 1186 static_assert(sizeof(T), "T must be fully defined"); |
1177 }; | 1187 }; |
1178 | 1188 |
1179 template<typename T> | 1189 template<typename T> |
1180 struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin k::IsGarbageCollectedType<T>::value> { | 1190 struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin k::IsGarbageCollectedType<T>::value> { |
1181 static_assert(sizeof(T), "T must be fully defined"); | 1191 static_assert(sizeof(T), "T must be fully defined"); |
1182 }; | 1192 }; |
1183 | 1193 |
1184 template<typename T> | 1194 template<typename T> |
1195 struct ParamStorageTraits<blink::AllowCrossThreadWeakPersistent<T>> { | |
1196 static_assert(sizeof(T), "T must be fully defined"); | |
1197 using StorageType = blink::CrossThreadWeakPersistent<T>; | |
1198 | |
1199 static StorageType wrap(const blink::AllowCrossThreadWeakPersistent<T>& valu e) { return value.value(); } | |
1200 static T* unwrap(const StorageType& value) { return value.get(); } | |
1201 }; | |
1202 | |
1203 template<typename T> | |
1185 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; | 1204 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; |
1186 | 1205 |
1187 } // namespace WTF | 1206 } // namespace WTF |
1188 | 1207 |
1189 #endif | 1208 #endif |
OLD | NEW |