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

Unified Diff: Source/platform/heap/Heap.h

Issue 489353003: ThreadSafeRefCountedGarbageCollected should use makeKeepAlive (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/Heap.h
diff --git a/Source/platform/heap/Heap.h b/Source/platform/heap/Heap.h
index 4ca6be0d7cd9684881a627f047b520b0488278e5..ce62e641c5d3cb0de41b2ebd2b034db60fd0ec80 100644
--- a/Source/platform/heap/Heap.h
+++ b/Source/platform/heap/Heap.h
@@ -671,7 +671,7 @@ class ThreadSafeRefCountedGarbageCollected : public GarbageCollectedFinalized<T>
public:
ThreadSafeRefCountedGarbageCollected()
{
- m_keepAlive = adoptPtr(new CrossThreadPersistent<T>(static_cast<T*>(this)));
+ makeKeepAlive();
}
// Override ref to deal with a case where a reference count goes up
@@ -683,8 +683,7 @@ public:
{
MutexLocker lock(m_mutex);
if (UNLIKELY(!refCount())) {
- ASSERT(!m_keepAlive);
- m_keepAlive = adoptPtr(new CrossThreadPersistent<T>(static_cast<T*>(this)));
+ makeKeepAlive();
}
WTF::ThreadSafeRefCountedBase::ref();
}
@@ -706,6 +705,12 @@ protected:
~ThreadSafeRefCountedGarbageCollected() { }
private:
+ void makeKeepAlive()
+ {
+ ASSERT(!m_keepAlive);
+ m_keepAlive = adoptPtr(new CrossThreadPersistent<T>(static_cast<T*>(this)));
+ }
+
OwnPtr<CrossThreadPersistent<T> > m_keepAlive;
mutable Mutex m_mutex;
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698