Chromium Code Reviews| 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()) |