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

Unified Diff: third_party/WebKit/Source/platform/heap/Persistent.h

Issue 2371663002: Introduce an injection point to configure the internal pointer of WeakPtr
Patch Set: fix Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/CrossThreadCopier.h ('k') | third_party/WebKit/Source/wtf/WeakPtr.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « third_party/WebKit/Source/platform/CrossThreadCopier.h ('k') | third_party/WebKit/Source/wtf/WeakPtr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698