Bug 306324 - Convert some bits of mailnews to frozen linkages. r=neil.
authorJan Horak <jhorak@redhat.com>
Mon, 14 Nov 2011 10:04:27 -0500
changeset 9854 ae8606c83944aa251c3955d76fe953bb62f4cf46
parent 9853 117365595f1576f1c5725f353d4b53dceb7171a9
child 9855 2320a8ec2c1ed63a8939b8bcf3b04cfa2fdcce9a
push id336
push userbugzilla@standard8.plus.com
push dateTue, 31 Jan 2012 22:15:45 +0000
treeherdercomm-beta@54945f5d278d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersneil
bugs306324
Bug 306324 - Convert some bits of mailnews to frozen linkages. r=neil.
mailnews/addrbook/src/nsAbLDAPReplicationData.cpp
mailnews/addrbook/src/nsAbLDAPReplicationQuery.cpp
mailnews/addrbook/src/nsAbMDBDirFactory.cpp
mailnews/addrbook/src/nsAbManager.cpp
mailnews/addrbook/src/nsAddrDatabase.h
mailnews/base/src/MailNewsDLF.cpp
mailnews/base/src/nsMessengerUnixIntegration.cpp
mailnews/base/util/nsMsgDBFolder.cpp
mailnews/base/util/nsMsgUtils.cpp
mailnews/base/util/nsMsgUtils.h
mailnews/compose/src/nsMsgAttachmentHandler.cpp
mailnews/compose/src/nsMsgCompose.cpp
mailnews/db/msgdb/src/nsMsgThread.cpp
mailnews/imap/src/nsImapMailFolder.cpp
mailnews/imap/src/nsImapProtocol.cpp
mailnews/import/src/nsImportAddressBooks.cpp
mailnews/import/text/src/nsTextImport.cpp
mailnews/import/vcard/src/nsVCardAddress.cpp
mailnews/import/vcard/src/nsVCardImport.cpp
--- a/mailnews/addrbook/src/nsAbLDAPReplicationData.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPReplicationData.cpp
@@ -41,16 +41,17 @@
 #include "nsILDAPMessage.h"
 #include "nsAbLDAPReplicationData.h"
 #include "nsIAbCard.h"
 #include "nsAbBaseCID.h"
 #include "nsAbUtils.h"
 #include "nsAbLDAPReplicationQuery.h"
 #include "nsILDAPErrors.h"
 #include "nsComponentManagerUtils.h"
+#include "nsMsgUtils.h"
 
 // once bug # 101252 gets fixed, this should be reverted back to be non threadsafe
 // implementation is not really thread safe since each object should exist 
 // independently along with its related independent nsAbLDAPReplicationQuery object.
 NS_IMPL_THREADSAFE_ISUPPORTS2(nsAbLDAPProcessReplicationData, nsIAbLDAPProcessReplicationData, nsILDAPMessageListener)
 
 nsAbLDAPProcessReplicationData::nsAbLDAPProcessReplicationData() :
   nsAbLDAPListenerBase(),
--- a/mailnews/addrbook/src/nsAbLDAPReplicationQuery.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPReplicationQuery.cpp
@@ -43,16 +43,17 @@
 #include "nsAbLDAPReplicationService.h"
 #include "nsAbLDAPReplicationData.h"
 #include "nsILDAPURL.h"
 #include "nsAbBaseCID.h"
 #include "nsAbUtils.h"
 #include "nsDirPrefs.h"
 #include "prmem.h"
 #include "nsComponentManagerUtils.h"
+#include "nsMsgUtils.h"
 
 NS_IMPL_THREADSAFE_ISUPPORTS1(nsAbLDAPReplicationQuery,
                               nsIAbLDAPReplicationQuery)
 
 nsAbLDAPReplicationQuery::nsAbLDAPReplicationQuery()
     :  mInitialized(PR_FALSE)
 {
 }
--- a/mailnews/addrbook/src/nsAbMDBDirFactory.cpp
+++ b/mailnews/addrbook/src/nsAbMDBDirFactory.cpp
@@ -36,17 +36,17 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * 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 ***** */
 
 #include "nsAbMDBDirFactory.h"
 #include "nsAbUtils.h"
-#include "nsString.h"
+#include "nsStringGlue.h"
 #include "nsServiceManagerUtils.h"
 #include "nsILocalFile.h"
 #include "nsIAbManager.h"
 #include "nsIAbMDBDirectory.h"
 #include "nsAbMDBDirFactory.h"
 #include "nsIAddrDBListener.h"
 #include "nsIAddrDatabase.h"
 #include "nsEnumeratorUtils.h"
--- a/mailnews/addrbook/src/nsAbManager.cpp
+++ b/mailnews/addrbook/src/nsAbManager.cpp
@@ -294,19 +294,17 @@ NS_IMETHODIMP nsAbManager::GetDirectory(
     // Construct the appropriate nsIAbDirectory...
     nsCAutoString contractID;
     contractID.AssignLiteral(NS_AB_DIRECTORY_TYPE_CONTRACTID_PREFIX);
     contractID.Append(scheme);
     directory = do_CreateInstance(contractID.get(), &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Init it with the URI
-    const nsAFlatCString& flatURI = PromiseFlatCString(aURI);
-
-    rv = directory->Init(flatURI.get());
+    rv = directory->Init(PromiseFlatCString(aURI).get());
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Check if this directory was initiated with a search query.  If so,
     // we don't cache it.
     bool isQuery = false;
     rv = directory->GetIsQuery(&isQuery);
     NS_ENSURE_SUCCESS(rv, rv);
 
--- a/mailnews/addrbook/src/nsAddrDatabase.h
+++ b/mailnews/addrbook/src/nsAddrDatabase.h
@@ -43,16 +43,17 @@
 #include "nsIAddrDatabase.h"
 #include "mdb.h"
 #include "nsStringGlue.h"
 #include "nsIAddrDBListener.h"
 #include "nsCOMPtr.h"
 #include "nsTObserverArray.h"
 #include "nsIEnumerator.h"
 #include "nsWeakPtr.h"
+#include "nsIWeakReferenceUtils.h"
 
 typedef enum
 {
   AB_NotifyInserted,
   AB_NotifyDeleted,
   AB_NotifyPropertyChanged
 } AB_NOTIFY_CODE;
 
--- a/mailnews/base/src/MailNewsDLF.cpp
+++ b/mailnews/base/src/MailNewsDLF.cpp
@@ -40,16 +40,17 @@
 #include "MailNewsDLF.h"
 #include "nsIChannel.h"
 #include "plstr.h"
 #include "nsStringGlue.h"
 #include "nsICategoryManager.h"
 #include "nsIServiceManager.h"
 #include "nsIStreamConverterService.h"
 #include "nsNetCID.h"
+#include "nsMsgUtils.h"
 
 namespace mozilla {
 namespace mailnews {
 NS_IMPL_ISUPPORTS1(MailNewsDLF, nsIDocumentLoaderFactory)
 
 MailNewsDLF::MailNewsDLF()
 {
 }
--- a/mailnews/base/src/nsMessengerUnixIntegration.cpp
+++ b/mailnews/base/src/nsMessengerUnixIntegration.cpp
@@ -78,16 +78,17 @@
 #include "nsIWeakReferenceUtils.h"
 
 #include "nsNativeCharsetUtils.h"
 #include "nsToolkitCompsCID.h"
 #include "nsMsgUtils.h"
 #include "msgCore.h"
 #include "nsCOMArray.h"
 #include "nsIMutableArray.h"
+#include "nsMemory.h"
 
 #define ALERT_CHROME_URL "chrome://messenger/content/newmailalert.xul"
 #define NEW_MAIL_ALERT_ICON "chrome://messenger/skin/icons/new-mail-alert.png"
 #define SHOW_ALERT_PREF "mail.biff.show_alert"
 #define SHOW_ALERT_PREVIEW_LENGTH "mail.biff.alert.preview_length"
 #define SHOW_ALERT_PREVIEW_LENGTH_DEFAULT 40
 #define SHOW_ALERT_PREVIEW "mail.biff.alert.show_preview"
 #define SHOW_ALERT_SENDER  "mail.biff.alert.show_sender"
--- a/mailnews/base/util/nsMsgDBFolder.cpp
+++ b/mailnews/base/util/nsMsgDBFolder.cpp
@@ -139,25 +139,27 @@ NS_IMPL_ISUPPORTS_INHERITED6(nsMsgDBFold
                              nsIDBChangeListener, nsIUrlListener,
                              nsIJunkMailClassificationListener,
                              nsIMsgTraitClassificationListener)
 
 #define MSGDBFOLDER_ATOM(name_, value_) nsIAtom* nsMsgDBFolder::name_ = nsnull;
 #include "nsMsgDBFolderAtomList.h"
 #undef MSGDBFOLDER_ATOM
 
+#ifdef MOZILLA_INTERNAL_API // These macros are relevant only for internal API
 #define MSGDBFOLDER_ATOM(name_, value_) NS_STATIC_ATOM_BUFFER(name_##_buffer, value_)
 #include "nsMsgDBFolderAtomList.h"
 #undef MSGDBFOLDER_ATOM
 
 const nsStaticAtom nsMsgDBFolder::folder_atoms[] = {
 #define MSGDBFOLDER_ATOM(name_, value_) NS_STATIC_ATOM(name_##_buffer, &nsMsgDBFolder::name_),
 #include "nsMsgDBFolderAtomList.h"
 #undef MSGDBFOLDER_ATOM
 };
+#endif
 
 nsMsgDBFolder::nsMsgDBFolder(void)
 : mAddListener(PR_TRUE),
   mNewMessages(PR_FALSE),
   mGettingNewMessages(PR_FALSE),
   mLastMessageLoaded(nsMsgKey_None),
   mFlags(0),
   mNumUnreadMessages(-1),
@@ -175,17 +177,19 @@ nsMsgDBFolder::nsMsgDBFolder(void)
   mIsServerIsValid(PR_FALSE),
   mIsServer(PR_FALSE),
   mInVFEditSearchScope (PR_FALSE)
 {
   if (mInstanceCount++ <=0) {
 #ifdef MOZILLA_INTERNAL_API //FIXME NS_RegisterStaticAtoms
     NS_RegisterStaticAtoms(folder_atoms, NS_ARRAY_LENGTH(folder_atoms));
 #else
-    NS_ERROR("NS_RegisterStaticAtoms not implemented in frozen linkage");
+#define MSGDBFOLDER_ATOM(name_, value_) name_ = MsgNewPermanentAtom(value_);
+#include "nsMsgDBFolderAtomList.h"
+#undef MSGDBFOLDER_ATOM
 #endif
     initializeStrings();
     createCollationKeyGenerator();
 #ifdef MSG_FASTER_URI_PARSING
     mParsingURL = do_CreateInstance(NS_STANDARDURL_CONTRACTID);
 #endif
     LL_I2L(gtimeOfLastPurgeCheck, 0);
   }
--- a/mailnews/base/util/nsMsgUtils.cpp
+++ b/mailnews/base/util/nsMsgUtils.cpp
@@ -1888,16 +1888,26 @@ NS_MSG_BASE nsIAtom* MsgNewAtom(const ch
   nsCOMPtr<nsIAtomService> atomService(do_GetService("@mozilla.org/atom-service;1"));
   nsIAtom* atom = nsnull;
 
   if (atomService)
     atomService->GetAtomUTF8(aString, &atom);
   return atom;
 }
 
+NS_MSG_BASE nsIAtom* MsgNewPermanentAtom(const char* aString)
+{
+  nsCOMPtr<nsIAtomService> atomService(do_GetService("@mozilla.org/atom-service;1"));
+  nsIAtom* atom = nsnull;
+
+  if (atomService)
+    atomService->GetPermanentAtomUTF8(aString, &atom);
+  return atom;
+}
+
 NS_MSG_BASE void MsgReplaceSubstring(nsAString &str, const nsAString &what, const nsAString &replacement)
 {
   const PRUnichar* replacement_str;
   PRUint32 replacementLength = replacement.BeginReading(&replacement_str);
   PRUint32 whatLength = what.Length();
   PRInt32 i = 0;
 
   while ((i = str.Find(what, i)) != kNotFound)
--- a/mailnews/base/util/nsMsgUtils.h
+++ b/mailnews/base/util/nsMsgUtils.h
@@ -419,16 +419,18 @@ NS_MSG_BASE void MsgCompressWhitespace(n
 /// Equivalent of nsEscapeHTML(aString)
 NS_MSG_BASE char *MsgEscapeHTML(const char *aString);
 /// Equivalent of nsEscapeHTML2(aBuffer, aLen)
 NS_MSG_BASE PRUnichar *MsgEscapeHTML2(const PRUnichar *aBuffer, PRInt32 aLen);
 // Existing replacement for IsUTF8
 NS_MSG_BASE bool MsgIsUTF8(const nsACString& aString);
 /// Equivalent of NS_NewAtom(aUTF8String)
 NS_MSG_BASE nsIAtom* MsgNewAtom(const char* aString);
+/// Replacement of NS_RegisterStaticAtoms
+NS_MSG_BASE nsIAtom* MsgNewPermanentAtom(const char* aString);
 /// Equivalent of do_GetAtom(aUTF8String)
 inline already_AddRefed<nsIAtom> MsgGetAtom(const char* aUTF8String)
 {
   return MsgNewAtom(aUTF8String);
 }
 /// Equivalent of ns(C)String::ReplaceSubstring(what, replacement)
 NS_MSG_BASE void MsgReplaceSubstring(nsAString &str, const nsAString &what, const nsAString &replacement);
 NS_MSG_BASE void MsgReplaceSubstring(nsACString &str, const char *what, const char *replacement);
--- a/mailnews/compose/src/nsMsgAttachmentHandler.cpp
+++ b/mailnews/compose/src/nsMsgAttachmentHandler.cpp
@@ -487,17 +487,17 @@ nsMsgAttachmentHandler::PickCharset()
     return NS_OK;
   
   nsCOMPtr<nsICharsetDetector> detector =
     do_CreateInstance(NS_CHARSET_DETECTOR_CONTRACTID_BASE
                              "universal_charset_detector");
   if (!detector)
   {
     nsresult rv;
-    nsAdoptingString detectorName;
+    nsString detectorName;
     nsCOMPtr<nsIPrefBranch> prefBranch =
       do_GetService(NS_PREFSERVICE_CONTRACTID,&rv);
     NS_ENSURE_SUCCESS(rv,rv);
 
     if (prefBranch)
     {
       nsCOMPtr<nsIPrefLocalizedString> prefLocalString;
       prefBranch->GetComplexValue("intl.charset.detector",
--- a/mailnews/compose/src/nsMsgCompose.cpp
+++ b/mailnews/compose/src/nsMsgCompose.cpp
@@ -4072,17 +4072,17 @@ nsMsgCompose::LoadDataFromFile(nsILocalF
   if (NS_FAILED(ConvertToUnicode(sigEncoding.get(), readStr, sigData)))
     CopyASCIItoUTF16(readStr, sigData);
 
   //remove sig meta charset to allow user charset override during composition
   if (removeSigCharset)
   {
     nsCAutoString metaCharset("charset=");
     metaCharset.Append(sigEncoding);
-    PRInt32 pos = sigData.Find(metaCharset.BeginReading(), PR_TRUE);
+    PRInt32 pos = sigData.Find(metaCharset.BeginReading(), true);
     if (pos != kNotFound)
       sigData.Cut(pos, metaCharset.Length());
   }
 
   return NS_OK;
 }
 
 nsresult
@@ -4300,19 +4300,19 @@ nsMsgCompose::ProcessSignature(nsIMsgIde
         sigOutput.AppendLiteral(htmlsigopen);
       else
         sigOutput.Append(NS_ConvertASCIItoUTF16(preopen));
     }
     else
       sigOutput.AppendLiteral(CRLF);
 
     if ((reply_on_top != 1 || sig_bottom || !aQuoted) &&
-        sigData.Find("\r-- \r", PR_TRUE) < 0 &&
-        sigData.Find("\n-- \n", PR_TRUE) < 0 &&
-        sigData.Find("\n-- \r", PR_TRUE) < 0)
+        sigData.Find("\r-- \r", true) < 0 &&
+        sigData.Find("\n-- \n", true) < 0 &&
+        sigData.Find("\n-- \r", true) < 0)
     {
       nsDependentSubstring firstFourChars(sigData, 0, 4);
 
       if ((mType == nsIMsgCompType::NewsPost || !suppressSigSep) && 
          !(firstFourChars.EqualsLiteral("-- \n") ||
            firstFourChars.EqualsLiteral("-- \r")))
       {
         sigOutput.AppendLiteral(dashes);
@@ -5370,17 +5370,17 @@ nsMsgCompose::SetIdentity(nsIMsgIdentity
       {
         nsAutoString attributeName;
         nsAutoString attributeValue;
         attributeName.AssignLiteral("class");
 
         rv = element->GetAttribute(attributeName, attributeValue);
         if (NS_SUCCEEDED(rv))
         {
-          if (attributeValue.Find("moz-signature", PR_TRUE) != kNotFound)
+          if (attributeValue.Find("moz-signature", true) != kNotFound)
           {
             //Now, I am sure I get the right node!
             m_editor->BeginTransaction();
             node->GetPreviousSibling(getter_AddRefs(tempNode));
             rv = m_editor->DeleteNode(node);
             if (NS_FAILED(rv))
             {
               m_editor->EndTransaction();
--- a/mailnews/db/msgdb/src/nsMsgThread.cpp
+++ b/mailnews/db/msgdb/src/nsMsgThread.cpp
@@ -32,19 +32,19 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * 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 ***** */
 
 #include "msgCore.h"
-#include "nsMsgThread.h"
 #include "nsMsgDatabase.h"
 #include "nsCOMPtr.h"
+#include "nsMsgThread.h"
 #include "MailNewsTypes2.h"
 
 NS_IMPL_ISUPPORTS1(nsMsgThread, nsIMsgThread)
 
 nsMsgThread::nsMsgThread()
 {
   MOZ_COUNT_CTOR(nsMsgThread);
   Init();
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -127,17 +127,16 @@
 #include "nsArrayUtils.h"
 #include "nsArrayEnumerator.h"
 #include "nsAutoSyncManager.h"
 #include "nsIMsgFilterCustomAction.h"
 #include "nsMsgReadStateTxn.h"
 #include "nsIStringEnumerator.h"
 #include "nsIMsgStatusFeedback.h"
 #include "nsAlgorithm.h"
-#include "nsPrintfCString.h"
 #include "nsMsgLineBuffer.h"
 
 static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
 static NS_DEFINE_CID(kParseMailMsgStateCID, NS_PARSEMAILMSGSTATE_CID);
 static NS_DEFINE_CID(kCImapHostSessionList, NS_IIMAPHOSTSESSIONLIST_CID);
 
 extern PRLogModuleInfo *gAutoSyncLog;
 extern PRLogModuleInfo* IMAP;
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -733,17 +733,17 @@ nsresult nsImapProtocol::SetupWithUrl(ns
       if (msgWindow)
       {
         nsCOMPtr<nsIDocShell> docShell;
         msgWindow->GetMessageWindowDocShell(getter_AddRefs(docShell));
         nsCOMPtr<nsIInterfaceRequestor> ir(do_QueryInterface(docShell));
         nsCOMPtr<nsIInterfaceRequestor> interfaceRequestor;
         msgWindow->GetNotificationCallbacks(getter_AddRefs(interfaceRequestor));
         nsCOMPtr<nsIInterfaceRequestor> aggregateIR;
-        NS_NewInterfaceRequestorAggregation(interfaceRequestor, ir, getter_AddRefs(aggregateIR));
+        MsgNewInterfaceRequestorAggregation(interfaceRequestor, ir, getter_AddRefs(aggregateIR));
         m_mockChannel->SetNotificationCallbacks(aggregateIR);
       }
     }
 
     // since we'll be making calls directly from the imap thread to the channel listener,
     // we need to turn it into a proxy object....we'll assume that the listener is on the same thread
     // as the event sink queue
     if (aRealStreamListener)
--- a/mailnews/import/src/nsImportAddressBooks.cpp
+++ b/mailnews/import/src/nsImportAddressBooks.cpp
@@ -33,16 +33,17 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * 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 ***** */
 
 #include "prprf.h"
 #include "plstr.h"
+#include "nsCOMPtr.h"
 #include "nsIImportService.h"
 #include "nsIImportAddressBooks.h"
 #include "nsIImportGeneric.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIImportABDescriptor.h"
 #include "nsIImportFieldMap.h"
 #include "nsStringGlue.h"
 #include "nsILocalFile.h"
--- a/mailnews/import/text/src/nsTextImport.cpp
+++ b/mailnews/import/text/src/nsTextImport.cpp
@@ -46,16 +46,17 @@
 */
 #ifdef MOZ_LOGGING
 // sorry, this has to be before the pre-compiled header
 #define FORCE_PR_LOG /* Allow logging in the release build */
 #endif
 
 #include "nscore.h"
 #include "nsIServiceManager.h"
+#include "nsCOMPtr.h"
 #include "nsIImportService.h"
 #include "nsMsgI18N.h"
 #include "nsIComponentManager.h"
 #include "nsTextImport.h"
 #include "nsIMemory.h"
 #include "nsIImportGeneric.h"
 #include "nsIImportAddressBooks.h"
 #include "nsIImportABDescriptor.h"
--- a/mailnews/import/vcard/src/nsVCardAddress.cpp
+++ b/mailnews/import/vcard/src/nsVCardAddress.cpp
@@ -43,16 +43,17 @@
 #include "nsIAbManager.h"
 #include "nsIAddrDatabase.h"
 #include "nsIFile.h"
 #include "nsIInputStream.h"
 #include "nsILineInputStream.h"
 
 #include "plstr.h"
 #include "msgCore.h"
+#include "nsMsgUtils.h"
 
 nsVCardAddress::nsVCardAddress()
 {
 }
 
 nsVCardAddress::~nsVCardAddress()
 {
 }
--- a/mailnews/import/vcard/src/nsVCardImport.cpp
+++ b/mailnews/import/vcard/src/nsVCardImport.cpp
@@ -44,16 +44,17 @@
 
 #include "nscore.h"
 #include "nsIAddrDatabase.h"
 #include "nsIFile.h"
 #include "nsIImportABDescriptor.h"
 #include "nsIImportAddressBooks.h"
 #include "nsIImportFieldMap.h"
 #include "nsIImportGeneric.h"
+#include "nsCOMPtr.h"
 #include "nsIImportService.h"
 #include "nsILocalFile.h"
 #include "nsImportStringBundle.h"
 #include "nsISupportsArray.h"
 #include "nsServiceManagerUtils.h"
 #include "nsTextFormatter.h"
 #include "nsVCardAddress.h"
 #include "nsVCardImport.h"