summaryrefslogtreecommitdiffstats
path: root/webkit/pending
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-03 21:33:05 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-03 21:33:05 +0000
commit649b596531bbd286004ae718c795970ad98d0a1a (patch)
tree17bf069c916617f5c8827bc315eba79d83e5bd1a /webkit/pending
parent5bac4c81b89cb91f0d22e05a944d67123a8f2ba3 (diff)
downloadchromium_src-649b596531bbd286004ae718c795970ad98d0a1a.zip
chromium_src-649b596531bbd286004ae718c795970ad98d0a1a.tar.gz
chromium_src-649b596531bbd286004ae718c795970ad98d0a1a.tar.bz2
Fix a DocumentLoader leak by switching from using new to a
create method that returns a PassRefPtr. This matches what happens in the Apple windows port. I also changed the RefCounted.h deref() to be more like upstream, but it doesn't actually change how RefCounted works. Also bring the JSC RefCounted to be just like upstream. Review URL: http://codereview.chromium.org/6461 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2855 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/pending')
-rw-r--r--webkit/pending/wtf/RefCounted.h22
1 files changed, 13 insertions, 9 deletions
diff --git a/webkit/pending/wtf/RefCounted.h b/webkit/pending/wtf/RefCounted.h
index ecadc0f..256024c 100644
--- a/webkit/pending/wtf/RefCounted.h
+++ b/webkit/pending/wtf/RefCounted.h
@@ -54,12 +54,14 @@ public:
void deref()
{
ASSERT(!m_deletionHasBegun);
- if (--m_refCount <= 0 && !m_peer) {
+ ASSERT(m_refCount > 0);
+ if (m_refCount == 1 && !m_peer) {
#ifndef NDEBUG
m_deletionHasBegun = true;
#endif
delete static_cast<T*>(this);
- }
+ } else
+ --m_refCount;
}
void setPeer(void* peer)
@@ -76,7 +78,7 @@ public:
void* peer() const { return m_peer; }
- bool hasOneRef()
+ bool hasOneRef() const
{
ASSERT(!m_deletionHasBegun);
if (m_peer)
@@ -105,7 +107,7 @@ private:
template<class T> class RefCounted : Noncopyable {
public:
- RefCounted(int initialRefCount = 0)
+ RefCounted(int initialRefCount = 1)
: m_refCount(initialRefCount)
#ifndef NDEBUG
, m_deletionHasBegun(false)
@@ -122,15 +124,17 @@ public:
void deref()
{
ASSERT(!m_deletionHasBegun);
- if (--m_refCount <= 0) {
+ ASSERT(m_refCount > 0);
+ if (m_refCount == 1) {
#ifndef NDEBUG
m_deletionHasBegun = true;
-#endif
- delete static_cast<T*>(this);
- }
+#endif
+ delete static_cast<T*>(this);
+ } else
+ --m_refCount;
}
- bool hasOneRef()
+ bool hasOneRef() const
{
ASSERT(!m_deletionHasBegun);
return m_refCount == 1;