Bug 712835 (part 3 of 3) - Move AtomImpl and PermanentAtomImpl out of the header. r=khuey.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 22 Dec 2011 17:24:44 -0800
changeset 84649 fa8de405cc873ef1f68fa0e2ded9b21ce544ec8f
parent 84648 4b655c46d0713d8edb1e9946da037698a5572cbb
child 84650 10ea92a6a8503b5f0f04db8951e5ca733839f70e
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs712835
milestone12.0a1
Bug 712835 (part 3 of 3) - Move AtomImpl and PermanentAtomImpl out of the header. r=khuey.
xpcom/ds/nsAtomTable.cpp
xpcom/ds/nsAtomTable.h
--- a/xpcom/ds/nsAtomTable.cpp
+++ b/xpcom/ds/nsAtomTable.cpp
@@ -73,16 +73,97 @@ static nsDataHashtable<nsStringHashKey, 
 
 /**
  * Whether it is still OK to add atoms to gStaticAtomTable.
  */
 static bool gStaticAtomTableSealed = false;
 
 //----------------------------------------------------------------------
 
+/**
+ * Note that AtomImpl objects are sometimes converted into PermanentAtomImpl
+ * objects using placement new and just overwriting the vtable pointer.
+ */
+
+class AtomImpl : public nsIAtom {
+public:
+  AtomImpl(const nsAString& aString);
+
+  // This is currently only used during startup when creating a permanent atom
+  // from NS_RegisterStaticAtoms
+  AtomImpl(nsStringBuffer* aData, PRUint32 aLength);
+
+protected:
+  // This is only intended to be used when a normal atom is turned into a
+  // permanent one.
+  AtomImpl() {
+    // We can't really assert that mString is a valid nsStringBuffer string,
+    // so do the best we can do and check for some consistencies.
+    NS_ASSERTION((mLength + 1) * sizeof(PRUnichar) <=
+                 nsStringBuffer::FromData(mString)->StorageSize() &&
+                 mString[mLength] == 0,
+                 "Not initialized atom");
+  }
+
+  // We don't need a virtual destructor here because PermanentAtomImpl
+  // deletions aren't handled through Release().
+  ~AtomImpl();
+
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIATOM
+
+  enum { REFCNT_PERMANENT_SENTINEL = PR_UINT32_MAX };
+
+  virtual bool IsPermanent();
+
+  // We can't use the virtual function in the base class destructor.
+  bool IsPermanentInDestructor() {
+    return mRefCnt == REFCNT_PERMANENT_SENTINEL;
+  }
+
+  // for |#ifdef NS_BUILD_REFCNT_LOGGING| access to reference count
+  nsrefcnt GetRefCount() { return mRefCnt; }
+
+  size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
+};
+
+/**
+ * A non-refcounted implementation of nsIAtom.
+ */
+
+class PermanentAtomImpl : public AtomImpl {
+public:
+  PermanentAtomImpl(const nsAString& aString)
+    : AtomImpl(aString)
+  {}
+  PermanentAtomImpl(nsStringBuffer* aData, PRUint32 aLength)
+    : AtomImpl(aData, aLength)
+  {}
+  PermanentAtomImpl()
+  {}
+
+  ~PermanentAtomImpl();
+  NS_IMETHOD_(nsrefcnt) AddRef();
+  NS_IMETHOD_(nsrefcnt) Release();
+
+  virtual bool IsPermanent();
+
+  // SizeOfIncludingThis() isn't needed -- the one inherited from AtomImpl is
+  // good enough, because PermanentAtomImpl doesn't add any new data members.
+
+  void* operator new(size_t size, AtomImpl* aAtom) CPP_THROW_NEW;
+  void* operator new(size_t size) CPP_THROW_NEW
+  {
+    return ::operator new(size);
+  }
+};
+
+//----------------------------------------------------------------------
+
 struct AtomTableEntry : public PLDHashEntryHdr {
   AtomImpl* mAtom;
 };
 
 struct AtomTableKey
 {
   AtomTableKey(const PRUnichar* aUTF16String, PRUint32 aLength)
     : mUTF16String(aUTF16String),
--- a/xpcom/ds/nsAtomTable.h
+++ b/xpcom/ds/nsAtomTable.h
@@ -33,95 +33,16 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsAtomTable_h__
 #define nsAtomTable_h__
 
-#include "nsIAtom.h"
-#include "nsStringBuffer.h"
-
-/**
- * Note that AtomImpl objects are sometimes converted into PermanentAtomImpl
- * objects using placement new and just overwriting the vtable pointer.
- */
-
-class AtomImpl : public nsIAtom {
-public:
-  AtomImpl(const nsAString& aString);
-
-  // This is currently only used during startup when creating a permanent atom
-  // from NS_RegisterStaticAtoms
-  AtomImpl(nsStringBuffer* aData, PRUint32 aLength);
-
-protected:
-  // This is only intended to be used when a normal atom is turned into a
-  // permanent one.
-  AtomImpl() {
-    // We can't really assert that mString is a valid nsStringBuffer string,
-    // so do the best we can do and check for some consistencies.
-    NS_ASSERTION((mLength + 1) * sizeof(PRUnichar) <=
-                 nsStringBuffer::FromData(mString)->StorageSize() &&
-                 mString[mLength] == 0,
-                 "Not initialized atom");
-  }
-
-  // We don't need a virtual destructor here because PermanentAtomImpl
-  // deletions aren't handled through Release().
-  ~AtomImpl();
-
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIATOM
-
-  enum { REFCNT_PERMANENT_SENTINEL = PR_UINT32_MAX };
-
-  virtual bool IsPermanent();
-
-  // We can't use the virtual function in the base class destructor.
-  bool IsPermanentInDestructor() {
-    return mRefCnt == REFCNT_PERMANENT_SENTINEL;
-  }
-
-  // for |#ifdef NS_BUILD_REFCNT_LOGGING| access to reference count
-  nsrefcnt GetRefCount() { return mRefCnt; }
-
-  size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
-};
-
-/**
- * A non-refcounted implementation of nsIAtom.
- */
-
-class PermanentAtomImpl : public AtomImpl {
-public:
-  PermanentAtomImpl(const nsAString& aString)
-    : AtomImpl(aString)
-  {}
-  PermanentAtomImpl(nsStringBuffer* aData, PRUint32 aLength)
-    : AtomImpl(aData, aLength)
-  {}
-  PermanentAtomImpl()
-  {}
-
-  ~PermanentAtomImpl();
-  NS_IMETHOD_(nsrefcnt) AddRef();
-  NS_IMETHOD_(nsrefcnt) Release();
-
-  virtual bool IsPermanent();
-
-  // SizeOfIncludingThis() isn't needed -- the one inherited from AtomImpl is
-  // good enough, because PermanentAtomImpl doesn't add any new data members.
-
-  void* operator new(size_t size, AtomImpl* aAtom) CPP_THROW_NEW;
-  void* operator new(size_t size) CPP_THROW_NEW
-  {
-    return ::operator new(size);
-  }
-};
+#include <stdlib.h>
+#include "nscore.h"
 
 void NS_PurgeAtomTable();
 
 size_t NS_SizeOfAtomTableIncludingThis(nsMallocSizeOfFun aMallocSizeOf);
 
 #endif // nsAtomTable_h__