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

Unified Diff: third_party/WebKit/Source/wtf/text/StringImpl.h

Issue 2624443003: Enable ThreadRestrictionVerifier for StringImpl (Closed)
Patch Set: Get rid of vestigial debugging code Created 3 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
Index: third_party/WebKit/Source/wtf/text/StringImpl.h
diff --git a/third_party/WebKit/Source/wtf/text/StringImpl.h b/third_party/WebKit/Source/wtf/text/StringImpl.h
index 6288b563810dad392f1dfec34c1316107237f0a1..c25ddf1c3b77800c90727714625d8a87fe934c80 100644
--- a/third_party/WebKit/Source/wtf/text/StringImpl.h
+++ b/third_party/WebKit/Source/wtf/text/StringImpl.h
@@ -35,6 +35,10 @@
#include <limits.h>
#include <string.h>
+#if DCHECK_IS_ON()
+#include "wtf/ThreadRestrictionVerifier.h"
+#endif
+
#if OS(MACOSX)
typedef const struct __CFString* CFStringRef;
#endif
@@ -297,11 +301,25 @@ class WTF_EXPORT StringImpl {
return hashSlowCase();
}
- ALWAYS_INLINE bool hasOneRef() const { return m_refCount == 1; }
+ ALWAYS_INLINE bool hasOneRef() const {
+#if DCHECK_IS_ON()
+ DCHECK(isStatic() || m_verifier.isSafeToUse()) << asciiForDebugging();
+#endif
+ return m_refCount == 1;
+ }
- ALWAYS_INLINE void ref() { ++m_refCount; }
+ ALWAYS_INLINE void ref() {
+#if DCHECK_IS_ON()
+ DCHECK(isStatic() || m_verifier.onRef(m_refCount)) << asciiForDebugging();
+#endif
+ ++m_refCount;
+ }
ALWAYS_INLINE void deref() {
+#if DCHECK_IS_ON()
+ DCHECK(isStatic() || m_verifier.onDeref(m_refCount))
+ << asciiForDebugging() << " " << currentThread();
+#endif
if (!--m_refCount)
destroyIfNotStatic();
}
@@ -490,6 +508,10 @@ class WTF_EXPORT StringImpl {
void destroyIfNotStatic();
void updateContainsOnlyASCII() const;
+#if DCHECK_IS_ON()
+ std::string asciiForDebugging() const;
+#endif
+
#ifdef STRING_STATS
static StringStats m_stringStats;
#endif
@@ -513,6 +535,10 @@ class WTF_EXPORT StringImpl {
unsigned m_isAtomic : 1;
const unsigned m_is8Bit : 1;
const unsigned m_isStatic : 1;
+
+#if DCHECK_IS_ON()
+ mutable ThreadRestrictionVerifier m_verifier;
+#endif
};
template <>

Powered by Google App Engine
This is Rietveld 408576698