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

Unified Diff: Source/heap/Handle.h

Issue 130493003: Alternative approach to supporting ref counting and garbage collection (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix copyright. Created 6 years, 11 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 | « no previous file | Source/heap/Heap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/heap/Handle.h
diff --git a/Source/heap/Handle.h b/Source/heap/Handle.h
index 8ca68efd6659e0b5cb1843000e0705793977f97d..245128a3ba5456fa4f63a925707270bca0e4eed8 100644
--- a/Source/heap/Handle.h
+++ b/Source/heap/Handle.h
@@ -35,6 +35,9 @@
#include "heap/ThreadState.h"
#include "heap/Visitor.h"
+#include "wtf/Ptr.h"
+#include "wtf/RefCounted.h"
+
namespace WebCore {
template<typename T> class Member;
@@ -159,6 +162,12 @@ private:
template<typename T>
class Persistent : public PersistentBase<ThreadingTrait<T>::Affinity, Persistent<T> > {
public:
+#if ENABLE(OILPAN)
+ typedef Persistent<T> FromRefPtr;
+#else
+ typedef RefPtr<T> FromRefPtr;
+#endif
+
Persistent() : m_raw(0) { }
Persistent(T* raw) : m_raw(raw) { }
@@ -174,6 +183,9 @@ public:
Persistent(const Member<U>& other) : m_raw(other) { }
template<typename U>
+ Persistent(const Ptr<U>& other) : m_raw(other.get()) { }
+
+ template<typename U>
Persistent& operator=(U* other)
{
m_raw = other;
@@ -205,6 +217,7 @@ public:
bool operator!() const { return !m_raw; }
operator T*() const { return m_raw; }
+ operator Ptr<T>() const { return Ptr<T>(m_raw); }
T* operator->() const { return *this; }
@@ -248,6 +261,14 @@ private:
template<typename T>
class Member {
public:
+#if ENABLE(OILPAN)
+ typedef Member<T> FromRefPtr;
+ typedef Member<T> FromOwnPtr;
+#else
+ typedef RefPtr<T> FromRefPtr;
+ typedef OwnPtr<T> FromOwnPtr;
+#endif
+
Member() : m_raw(0) { }
Member(T* raw) : m_raw(raw) { }
@@ -347,6 +368,12 @@ public:
template<typename T>
class WeakMember : public Member<T> {
public:
+#if ENABLE(OILPAN)
+ typedef WeakMember<T> FromPtr;
+#else
+ typedef Ptr<T> FromPtr;
+#endif
+
WeakMember() : Member<T>() { }
WeakMember(T* raw) : Member<T>(raw) { }
@@ -404,6 +431,32 @@ template<typename T, typename U> inline bool operator!=(const Persistent<T>& a,
template<typename T, typename U> inline bool operator==(const Persistent<T>& a, const Persistent<U>& b) { return a.get() == b.get(); }
template<typename T, typename U> inline bool operator!=(const Persistent<T>& a, const Persistent<U>& b) { return a.get() != b.get(); }
+#if ENABLE(OILPAN)
+template<typename T>
+typename Ptr<T>::FromPassRefPtr adoptRefWillBeNoop(T* ptr)
+{
+ return Ptr<T>(ptr);
+}
+
+template<typename T>
+typename Ptr<T>::FromPassOwnPtr adoptPtrWillBeNoop(T* ptr)
+{
+ return Ptr<T>(ptr);
+}
+#else
+template<typename T>
+typename Ptr<T>::FromPassRefPtr adoptRefWillBeNoop(T* ptr)
+{
+ return adoptRef(ptr);
+}
+
+template<typename T>
+typename Ptr<T>::FromPassOwnPtr adoptPtrWillBeNoop(T* ptr)
+{
+ return adoptPtr(ptr);
+}
+#endif
+
} // namespace WebCore
namespace WTF {
« no previous file with comments | « no previous file | Source/heap/Heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698