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

Unified Diff: Source/wtf/RefCounted.h

Issue 16042013: [oilpan] Resurrect a loop-back persistent handle in RefCountedHeapAllocated (Closed) Base URL: svn://svn.chromium.org/blink/branches/oilpan
Patch Set: Created 7 years, 7 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 | « Source/heap/Heap.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/RefCounted.h
diff --git a/Source/wtf/RefCounted.h b/Source/wtf/RefCounted.h
index 0504b9ed2818d7ad9fd164fd9c5a256ab6036c9e..129bcaee48f893c8370aea75424c93de1fe5fca0 100644
--- a/Source/wtf/RefCounted.h
+++ b/Source/wtf/RefCounted.h
@@ -43,23 +43,7 @@ class RefCountedBase {
public:
void ref()
{
-#if CHECK_REF_COUNTED_LIFECYCLE
- // Start thread verification as soon as the ref count gets to 2. This
- // heuristic reflects the fact that items are often created on one thread
- // and then given to another thread to be used.
- // FIXME: Make this restriction tigher. Especially as we move to more
- // common methods for sharing items across threads like CrossThreadCopier.h
- // We should be able to add a "detachFromThread" method to make this explicit.
- if (m_refCount == 1)
- m_verifier.setShared(true);
- // If this assert fires, it either indicates a thread safety issue or
- // that the verification needs to change. See ThreadRestrictionVerifier for
- // the different modes.
- ASSERT(m_verifier.isSafeToUse());
- ASSERT(!m_deletionHasBegun);
- ASSERT(!m_adoptionIsRequired);
-#endif
- ++m_refCount;
+ refBase();
}
bool hasOneRef() const
@@ -135,6 +119,27 @@ protected:
#endif
}
+ void refBase()
+ {
+#if CHECK_REF_COUNTED_LIFECYCLE
Mads Ager (chromium) 2013/05/29 12:31:06 When we get into the situation that we have an obj
haraken 2013/05/29 13:37:05 Disabled the check to make the test case workable.
+ // Start thread verification as soon as the ref count gets to 2. This
+ // heuristic reflects the fact that items are often created on one thread
+ // and then given to another thread to be used.
+ // FIXME: Make this restriction tigher. Especially as we move to more
+ // common methods for sharing items across threads like CrossThreadCopier.h
+ // We should be able to add a "detachFromThread" method to make this explicit.
+ if (m_refCount == 1)
+ m_verifier.setShared(true);
+ // If this assert fires, it either indicates a thread safety issue or
+ // that the verification needs to change. See ThreadRestrictionVerifier for
+ // the different modes.
+ ASSERT(m_verifier.isSafeToUse());
+ ASSERT(!m_deletionHasBegun);
+ ASSERT(!m_adoptionIsRequired);
+#endif
+ ++m_refCount;
+ }
+
// Returns whether the pointer should be freed or not.
bool derefBase()
{
@@ -196,6 +201,11 @@ inline void adopted(RefCountedBase* object)
template<typename T> class RefCounted : public RefCountedBase {
WTF_MAKE_NONCOPYABLE(RefCounted); WTF_MAKE_FAST_ALLOCATED;
public:
+ void ref()
+ {
+ refBase();
+ }
+
void deref()
{
if (derefBase())
@@ -213,6 +223,11 @@ template<typename T> class RefCountedCustomAllocated : public RefCountedBase {
WTF_MAKE_NONCOPYABLE(RefCountedCustomAllocated);
public:
+ void ref()
+ {
+ refBase();
+ }
+
void deref()
{
if (derefBase())
« no previous file with comments | « Source/heap/Heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698