Index: third_party/WebKit/Source/platform/heap/Persistent.h |
diff --git a/third_party/WebKit/Source/platform/heap/Persistent.h b/third_party/WebKit/Source/platform/heap/Persistent.h |
index baf4856b2492d239263ed0dbd995095c747ce6fc..81d7620bd558814d9a69a59da6cf7a26d058a101 100644 |
--- a/third_party/WebKit/Source/platform/heap/Persistent.h |
+++ b/third_party/WebKit/Source/platform/heap/Persistent.h |
@@ -6,11 +6,13 @@ |
#define Persistent_h |
#include "platform/heap/Heap.h" |
+#include "platform/heap/InlinedGlobalMarkingVisitor.h" |
#include "platform/heap/Member.h" |
#include "platform/heap/PersistentNode.h" |
#include "platform/heap/Visitor.h" |
#include "wtf/Allocator.h" |
#include "wtf/Atomics.h" |
+#include "wtf/WeakPtr.h" |
namespace blink { |
@@ -728,6 +730,71 @@ template<typename T, typename U> inline bool operator!=(const Member<T>& a, cons |
template<typename T, typename U> inline bool operator==(const Persistent<T>& a, const Member<U>& b) { return a.get() == b.get(); } |
template<typename T, typename U> inline bool operator!=(const Persistent<T>& a, const Member<U>& b) { return a.get() != b.get(); } |
+struct RevocableWeakPersistentTraits { |
+ template <typename T> |
+ struct PointerHolder { |
+ protected: |
+ PointerHolder(T* ptr) |
+ : m_ptr(ptr) |
+ { |
+ } |
+ void reset() { m_ptr = nullptr; } |
+ T* get() const { return m_ptr.get(); } |
+ private: |
+ WeakPersistent<T> m_ptr; |
+ }; |
+}; |
+struct RevocableCrossThreadWeakPersistentTraits { |
+ template <typename T> |
+ struct PointerHolder { |
+ protected: |
+ PointerHolder(T* ptr) |
+ : m_ptr(ptr) |
+ { |
+ } |
+ void reset() { m_ptr = nullptr; } |
+ T* get() const { return m_ptr.get(); } |
+ private: |
+ CrossThreadWeakPersistent<T> m_ptr; |
+ }; |
+}; |
+struct RevocableWeakMemberTraits { |
+ template <typename T> |
+ struct PointerHolder { |
+ DISALLOW_NEW(); |
+ |
+ protected: |
+ PointerHolder(T* ptr) |
+ : m_ptr(ptr) |
+ { |
+ } |
+ void reset() { m_ptr = nullptr; } |
+ T* get() const { return m_ptr.get(); } |
+ public: |
+ DEFINE_INLINE_TRACE() |
+ { |
+ visitor->trace(m_ptr); |
+ } |
+ |
+ private: |
+ WeakMember<T> m_ptr; |
+ }; |
+}; |
+ |
+template <typename T> |
+using RevocableWeakPersistent = WTF::WeakPtr<T, RevocableWeakPersistentTraits>; |
+template <typename T> |
+using RevocableCrossThreadWeakPersistent = WTF::WeakPtr<T, RevocableCrossThreadWeakPersistentTraits>; |
+template <typename T> |
+using RevocableWeakMember = WTF::WeakPtr<T, RevocableWeakMemberTraits>; |
+ |
+template <typename T> |
+using RevocableWeakPersistentFactory = WTF::WeakPtrFactory<T, RevocableWeakPersistentTraits>; |
+template <typename T> |
+using RevocableCrossThreadWeakPersistentFactory = WTF::WeakPtrFactory<T, RevocableCrossThreadWeakPersistentTraits>; |
+template <typename T> |
+using RevocableWeakMemberFactory = WTF::WeakPtrFactory<T, RevocableWeakMemberTraits>; |
+ |
} // namespace blink |
namespace WTF { |
@@ -775,6 +842,6 @@ struct BindUnwrapTraits<blink::CrossThreadWeakPersistent<T>> { |
} |
}; |
-} |
+} // namespace base |
#endif // Persistent_h |