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 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1189 private: | 1189 private: |
1190 | 1190 |
1191 #define DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(type) \ | 1191 #define DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(type) \ |
1192 type::~type() { } | 1192 type::~type() { } |
1193 | 1193 |
1194 #define DEFINE_STATIC_REF_WILL_BE_PERSISTENT(type, name, arguments) \ | 1194 #define DEFINE_STATIC_REF_WILL_BE_PERSISTENT(type, name, arguments) \ |
1195 DEFINE_STATIC_REF(type, name, arguments) | 1195 DEFINE_STATIC_REF(type, name, arguments) |
1196 | 1196 |
1197 #endif // ENABLE(OILPAN) | 1197 #endif // ENABLE(OILPAN) |
1198 | 1198 |
1199 template<typename T, bool = IsGarbageCollectedType<T>::value> | |
1200 class PointerFieldStorageTrait { | |
haraken
2016/01/13 07:41:56
RawPtrOrMemberTrait ?
sof
2016/01/13 09:41:17
Done, little confusion about what it offers with s
| |
1201 public: | |
1202 using Type = RawPtr<T>; | |
haraken
2016/01/13 07:41:56
4 indentation
sof
2016/01/13 09:41:17
Done.
| |
1203 }; | |
1204 | |
1205 template<typename T> | |
1206 class PointerFieldStorageTrait<T, true> { | |
1207 public: | |
1208 using Type = Member<T>; | |
1209 }; | |
1210 | |
1199 // Abstraction for injecting calls to an object's 'dispose()' method | 1211 // Abstraction for injecting calls to an object's 'dispose()' method |
1200 // on leaving a stack scope, ensuring earlier release of resources | 1212 // on leaving a stack scope, ensuring earlier release of resources |
1201 // than waiting until the object is eventually GCed. | 1213 // than waiting until the object is eventually GCed. |
1202 template<typename T, void (T::*Disposer)() = (&T::dispose)> | 1214 template<typename T, void (T::*Disposer)() = (&T::dispose)> |
1203 class ScopedDisposal { | 1215 class ScopedDisposal { |
1204 STACK_ALLOCATED(); | 1216 STACK_ALLOCATED(); |
1205 public: | 1217 public: |
1206 ScopedDisposal(T* object) | 1218 ScopedDisposal(T* object) |
1207 : m_object(object) | 1219 : m_object(object) |
1208 { | 1220 { |
1209 } | 1221 } |
1210 | 1222 |
1211 ~ScopedDisposal() | 1223 ~ScopedDisposal() |
1212 { | 1224 { |
1213 if (m_object) | 1225 if (m_object) |
1214 (m_object->*Disposer)(); | 1226 (m_object->*Disposer)(); |
1215 } | 1227 } |
1216 | 1228 |
1217 void clear() { m_object.clear(); } | 1229 void clear() { m_object.clear(); } |
1218 | 1230 |
1219 private: | 1231 private: |
1220 template<typename U, bool = IsGarbageCollectedType<U>::value> | |
1221 class PointerFieldStorageTrait { | |
1222 public: | |
1223 using Type = RawPtr<U>; | |
1224 }; | |
1225 | |
1226 template<typename U> | |
1227 class PointerFieldStorageTrait<U, true> { | |
1228 public: | |
1229 using Type = Member<U>; | |
1230 }; | |
1231 | |
1232 typename PointerFieldStorageTrait<T>::Type m_object; | 1232 typename PointerFieldStorageTrait<T>::Type m_object; |
1233 }; | 1233 }; |
1234 | 1234 |
1235 // SelfKeepAlive<Object> is the idiom to use for objects that have to keep | 1235 // SelfKeepAlive<Object> is the idiom to use for objects that have to keep |
1236 // themselves temporarily alive and cannot rely on there being some | 1236 // themselves temporarily alive and cannot rely on there being some |
1237 // external reference in that interval: | 1237 // external reference in that interval: |
1238 // | 1238 // |
1239 // class Opener { | 1239 // class Opener { |
1240 // public: | 1240 // public: |
1241 // ... | 1241 // ... |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1589 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR eference<T>::create(value.get())); } | 1589 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR eference<T>::create(value.get())); } |
1590 }; | 1590 }; |
1591 | 1591 |
1592 // Adoption is not needed nor wanted for RefCountedGarbageCollected<>-derived ty pes. | 1592 // Adoption is not needed nor wanted for RefCountedGarbageCollected<>-derived ty pes. |
1593 template<typename T> | 1593 template<typename T> |
1594 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; | 1594 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; |
1595 | 1595 |
1596 } // namespace WTF | 1596 } // namespace WTF |
1597 | 1597 |
1598 #endif | 1598 #endif |
OLD | NEW |