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

Unified Diff: third_party/WebKit/Source/wtf/WeakPtr.h

Issue 2031463002: Add WTF::WeakPtr::operator*() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/WeakPtr.h
diff --git a/third_party/WebKit/Source/wtf/WeakPtr.h b/third_party/WebKit/Source/wtf/WeakPtr.h
index e04fd5a5fe151f2fe3f4560f237d4547bf731752..73d53655f42a98af2c862760e3c9132f0f5ae770 100644
--- a/third_party/WebKit/Source/wtf/WeakPtr.h
+++ b/third_party/WebKit/Source/wtf/WeakPtr.h
@@ -44,20 +44,24 @@ public:
T* get() const
{
- ASSERT(m_boundThread == currentThread());
+#if DCHECK_IS_ON()
+ DCHECK(m_boundThread == currentThread());
+#endif
return m_ptr;
}
void clear()
{
- ASSERT(m_boundThread == currentThread());
+#if DCHECK_IS_ON()
+ DCHECK(m_boundThread == currentThread());
+#endif
m_ptr = 0;
}
void bindTo(T* ptr)
{
- ASSERT(!m_ptr);
-#if ENABLE(ASSERT)
+ DCHECK(!m_ptr);
+#if DCHECK_IS_ON()
m_boundThread = currentThread();
#endif
m_ptr = ptr;
@@ -68,14 +72,14 @@ private:
explicit WeakReference(T* ptr)
: m_ptr(ptr)
-#if ENABLE(ASSERT)
+#if DCHECK_IS_ON()
, m_boundThread(currentThread())
#endif
{
}
T* m_ptr;
-#if ENABLE(ASSERT)
+#if DCHECK_IS_ON()
ThreadIdentifier m_boundThread;
#endif
};
@@ -91,9 +95,15 @@ public:
T* get() const { return m_ref ? m_ref->get() : 0; }
void clear() { m_ref.clear(); }
+ T& operator*() const
+ {
+ DCHECK(get());
+ return *get();
+ }
+
T* operator->() const
{
- ASSERT(get());
+ DCHECK(get());
return get();
}
« 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