Bug 1251493 - Remove remaining references to MOZILLA_XPCOMRT_API from netwerk. r=mcmanus
authorEric Rahm <erahm@mozilla.com>
Mon, 29 Feb 2016 11:16:30 -0800
changeset 322479 7f425c877b1fe7bb7f3d18eb6e5c98ba857c8937
parent 322478 8a13b9de65139548416d7dd98444097847dbf396
child 322480 195d3130e0bfce13404d16e241373ffde7453854
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1251493
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1251493 - Remove remaining references to MOZILLA_XPCOMRT_API from netwerk. r=mcmanus
netwerk/base/nsSocketTransportService2.cpp
netwerk/base/nsURLHelper.cpp
netwerk/dns/nsDNSService2.cpp
netwerk/standalone/moz.build
--- a/netwerk/base/nsSocketTransportService2.cpp
+++ b/netwerk/base/nsSocketTransportService2.cpp
@@ -1,20 +1,18 @@
 // vim:set sw=4 sts=4 et cin:
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsSocketTransportService2.h"
-#if !defined(MOZILLA_XPCOMRT_API)
 #include "nsSocketTransport2.h"
 #include "NetworkActivityMonitor.h"
 #include "mozilla/Preferences.h"
 #include "nsIOService.h"
-#endif // !defined(MOZILLA_XPCOMRT_API)
 #include "nsASocketHandler.h"
 #include "nsError.h"
 #include "prnetdb.h"
 #include "prerror.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIObserverService.h"
@@ -605,19 +603,17 @@ nsSocketTransportService::Shutdown()
         tmpPrefService->RemoveObserver(SEND_BUFFER_PREF, this);
 
     nsCOMPtr<nsIObserverService> obsSvc = services::GetObserverService();
     if (obsSvc) {
         obsSvc->RemoveObserver(this, "profile-initial-state");
         obsSvc->RemoveObserver(this, "last-pb-context-exited");
     }
 
-#if !defined(MOZILLA_XPCOMRT_API)
     mozilla::net::NetworkActivityMonitor::Shutdown();
-#endif // !defined(MOZILLA_XPCOMRT_API)
 
     mInitialized = false;
     mShuttingDown = false;
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -695,42 +691,33 @@ nsSocketTransportService::CreateRoutedTr
                                                 uint32_t typeCount,
                                                 const nsACString &host,
                                                 int32_t port,
                                                 const nsACString &hostRoute,
                                                 int32_t portRoute,
                                                 nsIProxyInfo *proxyInfo,
                                                 nsISocketTransport **result)
 {
-#if defined(MOZILLA_XPCOMRT_API)
-    NS_WARNING("nsSocketTransportService::CreateTransport not implemented");
-    return NS_ERROR_NOT_IMPLEMENTED;
-#else
     NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
     NS_ENSURE_TRUE(port >= 0 && port <= 0xFFFF, NS_ERROR_ILLEGAL_VALUE);
 
     RefPtr<nsSocketTransport> trans = new nsSocketTransport();
     nsresult rv = trans->Init(types, typeCount, host, port, hostRoute, portRoute, proxyInfo);
     if (NS_FAILED(rv)) {
         return rv;
     }
 
     trans.forget(result);
     return NS_OK;
-#endif // defined(MOZILLA_XPCOMRT_API)
 }
 
 NS_IMETHODIMP
 nsSocketTransportService::CreateUnixDomainTransport(nsIFile *aPath,
                                                     nsISocketTransport **result)
 {
-#if defined(MOZILLA_XPCOMRT_API)
-    NS_WARNING("nsSocketTransportService::CreateUnixDomainTransport not implemented");
-    return NS_ERROR_NOT_IMPLEMENTED;
-#else
     nsresult rv;
 
     NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
 
     nsAutoCString path;
     rv = aPath->GetNativePath(path);
     if (NS_FAILED(rv))
         return rv;
@@ -738,17 +725,16 @@ nsSocketTransportService::CreateUnixDoma
     RefPtr<nsSocketTransport> trans = new nsSocketTransport();
 
     rv = trans->InitWithFilename(path.get());
     if (NS_FAILED(rv))
         return rv;
 
     trans.forget(result);
     return NS_OK;
-#endif // defined(MOZILLA_XPCOMRT_API)
 }
 
 NS_IMETHODIMP
 nsSocketTransportService::GetAutodialEnabled(bool *value)
 {
     *value = mAutodialEnabled;
     return NS_OK;
 }
@@ -801,19 +787,17 @@ nsSocketTransportService::Run()
 #ifdef MOZ_NUWA_PROCESS
     if (IsNuwaProcess()) {
         NuwaMarkCurrentThread(nullptr, nullptr);
     }
 #endif
 
     SOCKET_LOG(("STS thread init\n"));
 
-#if !defined(MOZILLA_XPCOMRT_API)
     psm::InitializeSSLServerCertVerificationThreads();
-#endif // !defined(MOZILLA_XPCOMRT_API)
 
     gSocketThread = PR_GetCurrentThread();
 
     // add thread event to poll list (mThreadEvent may be nullptr)
     mPollList[0].fd = mThreadEvent;
     mPollList[0].in_flags = PR_POLL_READ;
     mPollList[0].out_flags = 0;
 
@@ -966,19 +950,17 @@ nsSocketTransportService::Run()
     Reset(false);
 
     // Final pass over the event queue. This makes sure that events posted by
     // socket detach handlers get processed.
     NS_ProcessPendingEvents(thread);
 
     gSocketThread = nullptr;
 
-#if !defined(MOZILLA_XPCOMRT_API)
     psm::StopSSLServerCertVerificationThreads();
-#endif // !defined(MOZILLA_XPCOMRT_API)
 
     SOCKET_LOG(("STS thread exit\n"));
     return NS_OK;
 }
 
 void
 nsSocketTransportService::DetachSocketWithGuard(bool aGuardLocals,
                                                 SocketContext *socketList,
@@ -1064,25 +1046,21 @@ nsSocketTransportService::DoPollIteratio
     // limit the first time we exceed 30.
     if ((mActiveCount > 30) && !mProbedMaxCount)
         ProbeMaxCount();
 #endif
 
     // Measures seconds spent while blocked on PR_Poll
     uint32_t pollInterval = 0;
     int32_t n = 0;
-    *pollDuration = 0;    
-#if !defined(MOZILLA_XPCOMRT_API)
+    *pollDuration = 0;
     if (!gIOService->IsNetTearingDown()) {
         // Let's not do polling during shutdown.
         n = Poll(wait, &pollInterval, pollDuration);
     }
-#else
-    n = Poll(wait, &pollInterval, pollDuration);
-#endif // defined(MOZILLA_XPCOMRT_API)
 
     if (n < 0) {
         SOCKET_LOG(("  PR_Poll error [%d] os error [%d]\n", PR_GetError(),
                     PR_GetOSError()));
     }
     else {
         //
         // service "active" sockets...
@@ -1161,22 +1139,18 @@ nsSocketTransportService::DoPollIteratio
     }
 
     return NS_OK;
 }
 
 nsresult
 nsSocketTransportService::UpdatePrefs()
 {
-#if defined(MOZILLA_XPCOMRT_API)
-    NS_WARNING("nsSocketTransportService::UpdatePrefs not implemented");
-    return NS_ERROR_NOT_IMPLEMENTED;
-#else
     mSendBufferSize = 0;
-    
+
     nsCOMPtr<nsIPrefBranch> tmpPrefService = do_GetService(NS_PREFSERVICE_CONTRACTID);
     if (tmpPrefService) {
         int32_t bufferSize;
         nsresult rv = tmpPrefService->GetIntPref(SEND_BUFFER_PREF, &bufferSize);
         if (NS_SUCCEEDED(rv) && bufferSize > 0)
             mSendBufferSize = bufferSize;
 
         // Default TCP Keepalive Values.
@@ -1224,19 +1198,18 @@ nsSocketTransportService::UpdatePrefs()
 
         int32_t maxTimeForPrClosePref;
         rv = tmpPrefService->GetIntPref(MAX_TIME_FOR_PR_CLOSE_DURING_SHUTDOWN,
                                         &maxTimeForPrClosePref);
         if (NS_SUCCEEDED(rv) && maxTimeForPrClosePref >=0) {
             mMaxTimeForPrClosePref = PR_MillisecondsToInterval(maxTimeForPrClosePref);
         }
     }
-    
+
     return NS_OK;
-#endif // defined(MOZILLA_XPCOMRT_API)
 }
 
 void
 nsSocketTransportService::OnKeepaliveEnabledPrefChange()
 {
     // Dispatch to socket thread if we're not executing there.
     if (PR_GetCurrentThread() != gSocketThread) {
         gSocketTransportService->Dispatch(
@@ -1271,31 +1244,29 @@ nsSocketTransportService::NotifyKeepaliv
     sock->mHandler->OnKeepaliveEnabledPrefChange(mKeepaliveEnabledPref);
 }
 
 NS_IMETHODIMP
 nsSocketTransportService::Observe(nsISupports *subject,
                                   const char *topic,
                                   const char16_t *data)
 {
-#if !defined(MOZILLA_XPCOMRT_API)
     if (!strcmp(topic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
         UpdatePrefs();
         return NS_OK;
     }
 
     if (!strcmp(topic, "profile-initial-state")) {
         int32_t blipInterval = Preferences::GetInt(BLIP_INTERVAL_PREF, 0);
         if (blipInterval <= 0) {
             return NS_OK;
         }
 
         return net::NetworkActivityMonitor::Init(blipInterval);
     }
-#endif // !defined(MOZILLA_XPCOMRT_API)
 
     if (!strcmp(topic, "last-pb-context-exited")) {
         nsCOMPtr<nsIRunnable> ev =
           NS_NewRunnableMethod(this,
                                &nsSocketTransportService::ClosePrivateConnections);
         nsresult rv = Dispatch(ev, nsIEventTarget::DISPATCH_NORMAL);
         NS_ENSURE_SUCCESS(rv, rv);
     }
@@ -1319,19 +1290,17 @@ nsSocketTransportService::ClosePrivateCo
         }
     }
     for (int32_t i = mIdleCount - 1; i >= 0; --i) {
         if (mIdleList[i].mHandler->mIsPrivate) {
             DetachSocket(mIdleList, &mIdleList[i]);
         }
     }
 
-#if !defined(MOZILLA_XPCOMRT_API)
     mozilla::ClearPrivateSSLState();
-#endif // !defined(MOZILLA_XPCOMRT_API)
 }
 
 NS_IMETHODIMP
 nsSocketTransportService::GetSendBufferSize(int32_t *value)
 {
     *value = mSendBufferSize;
     return NS_OK;
 }
--- a/netwerk/base/nsURLHelper.cpp
+++ b/netwerk/base/nsURLHelper.cpp
@@ -50,20 +50,18 @@ InitGlobals()
     parser = do_GetService(NS_STDURLPARSER_CONTRACTID);
     NS_ASSERTION(parser, "failed getting 'std' url parser");
     if (parser) {
         gStdURLParser = parser.get();
         NS_ADDREF(gStdURLParser);
     }
 
     gInitialized = true;
-#if !defined(MOZILLA_XPCOMRT_API)
     Preferences::AddIntVarCache(&gMaxLength,
                                 "network.standard-url.max-length", 1048576);
-#endif
 }
 
 void
 net_ShutdownURLHelper()
 {
     if (gInitialized) {
         NS_IF_RELEASE(gNoAuthURLParser);
         NS_IF_RELEASE(gAuthURLParser);
@@ -106,61 +104,51 @@ net_GetStdURLParser()
 }
 
 //---------------------------------------------------------------------------
 // GetFileFromURLSpec implementations
 //---------------------------------------------------------------------------
 nsresult
 net_GetURLSpecFromDir(nsIFile *aFile, nsACString &result)
 {
-#if defined(MOZILLA_XPCOMRT_API)
-    NS_WARNING("net_GetURLSpecFromDir not implemented");
-    return NS_ERROR_NOT_IMPLEMENTED;
-#else
     nsAutoCString escPath;
     nsresult rv = net_GetURLSpecFromActualFile(aFile, escPath);
     if (NS_FAILED(rv))
         return rv;
 
     if (escPath.Last() != '/') {
         escPath += '/';
     }
-    
+
     result = escPath;
     return NS_OK;
-#endif // defined(MOZILLA_XPCOMRT_API)
 }
 
 nsresult
 net_GetURLSpecFromFile(nsIFile *aFile, nsACString &result)
 {
-#if defined(MOZILLA_XPCOMRT_API)
-    NS_WARNING("net_GetURLSpecFromFile not implemented");
-    return NS_ERROR_NOT_IMPLEMENTED;
-#else
     nsAutoCString escPath;
     nsresult rv = net_GetURLSpecFromActualFile(aFile, escPath);
     if (NS_FAILED(rv))
         return rv;
 
     // if this file references a directory, then we need to ensure that the
     // URL ends with a slash.  this is important since it affects the rules
     // for relative URL resolution when this URL is used as a base URL.
     // if the file does not exist, then we make no assumption about its type,
     // and simply leave the URL unmodified.
     if (escPath.Last() != '/') {
         bool dir;
         rv = aFile->IsDirectory(&dir);
         if (NS_SUCCEEDED(rv) && dir)
             escPath += '/';
     }
-    
+
     result = escPath;
     return NS_OK;
-#endif // defined(MOZILLA_XPCOMRT_API)
 }
 
 //----------------------------------------------------------------------------
 // file:// URL parsing
 //----------------------------------------------------------------------------
 
 nsresult
 net_ParseFileURL(const nsACString &inURL,
@@ -463,41 +451,35 @@ net_ResolveRelativePath(const nsACString
     result = path;
     return NS_OK;
 }
 
 //----------------------------------------------------------------------------
 // scheme fu
 //----------------------------------------------------------------------------
 
-#if !defined(MOZILLA_XPCOMRT_API)
 static bool isAsciiAlpha(char c) {
     return nsCRT::IsAsciiAlpha(c);
 }
 
 static bool
 net_IsValidSchemeChar(const char aChar)
 {
     if (nsCRT::IsAsciiAlpha(aChar) || nsCRT::IsAsciiDigit(aChar) ||
         aChar == '+' || aChar == '.' || aChar == '-') {
         return true;
     }
     return false;
 }
-#endif
 
 /* Extract URI-Scheme if possible */
 nsresult
 net_ExtractURLScheme(const nsACString &inURI,
                      nsACString& scheme)
 {
-#if defined(MOZILLA_XPCOMRT_API)
-    NS_WARNING("net_ExtractURLScheme not implemented");
-    return NS_ERROR_NOT_IMPLEMENTED;
-#else
     Tokenizer p(inURI, "\r\n\t");
 
     while (p.CheckWhite() || p.CheckChar(' ')) {
         // Skip leading whitespace
     }
 
     p.Record();
     if (!p.CheckChar(isAsciiAlpha)) {
@@ -511,17 +493,16 @@ net_ExtractURLScheme(const nsACString &i
 
     if (!p.CheckChar(':')) {
         return NS_ERROR_MALFORMED_URI;
     }
 
     p.Claim(scheme);
     scheme.StripChars("\r\n\t");
     return NS_OK;
-#endif
 }
 
 bool
 net_IsValidScheme(const char *scheme, uint32_t schemeLen)
 {
     // first char must be alpha
     if (!nsCRT::IsAsciiAlpha(*scheme))
         return false;
@@ -537,17 +518,16 @@ net_IsValidScheme(const char *scheme, ui
     }
 
     return true;
 }
 
 bool
 net_IsAbsoluteURL(const nsACString& uri)
 {
-#if !defined(MOZILLA_XPCOMRT_API)
     Tokenizer p(uri, "\r\n\t");
 
     while (p.CheckWhite() || p.CheckChar(' ')) {
         // Skip leading whitespace
     }
 
     // First char must be alpha
     if (!p.CheckChar(isAsciiAlpha)) {
@@ -566,17 +546,16 @@ net_IsAbsoluteURL(const nsACString& uri)
         return false;
     }
     p.SkipWhites();
 
     if (p.CheckChar('/')) {
         // aSpec is really absolute. Ignore aBaseURI in this case
         return true;
     }
-#endif
     return false;
 }
 
 bool
 net_FilterURIString(const char *str, nsACString& result)
 {
     NS_PRECONDITION(str, "Must have a non-null string!");
     result.Truncate();
--- a/netwerk/dns/nsDNSService2.cpp
+++ b/netwerk/dns/nsDNSService2.cpp
@@ -30,19 +30,17 @@
 #include "nsCharSeparatedTokenizer.h"
 #include "nsNetAddr.h"
 #include "nsProxyRelease.h"
 #include "nsIObserverService.h"
 #include "nsINetworkLinkService.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/net/NeckoCommon.h"
-#if !defined(MOZILLA_XPCOMRT_API)
 #include "mozilla/net/ChildDNSService.h"
-#endif // !defined(MOZILLA_XPCOMRT_API)
 #include "mozilla/net/DNSListenerProxy.h"
 #include "mozilla/Services.h"
 
 using namespace mozilla;
 using namespace mozilla::net;
 
 static const char kPrefDnsCacheEntries[]     = "network.dnsCacheEntries";
 static const char kPrefDnsCacheExpiration[]  = "network.dnsCacheExpiration";
@@ -499,21 +497,19 @@ NS_IMPL_ISUPPORTS(nsDNSService, nsIDNSSe
  * nsDNSService impl:
  * singleton instance ctor/dtor methods
  ******************************************************************************/
 static nsDNSService *gDNSService;
 
 nsIDNSService*
 nsDNSService::GetXPCOMSingleton()
 {
-#if !defined(MOZILLA_XPCOMRT_API)
     if (IsNeckoChild()) {
         return ChildDNSService::GetSingleton();
     }
-#endif // !defined(MOZILLA_XPCOMRT_API)
 
     return GetSingleton();
 }
 
 nsDNSService*
 nsDNSService::GetSingleton()
 {
     NS_ASSERTION(!IsNeckoChild(), "not a parent process");
@@ -637,29 +633,25 @@ nsDNSService::Init()
 
             while (tokenizer.hasMoreTokens()) {
                 mLocalDomains.PutEntry(tokenizer.nextToken());
             }
         }
         mNotifyResolution = notifyResolution;
     }
 
-#if !defined(MOZILLA_XPCOMRT_API)
     RegisterWeakMemoryReporter(this);
-#endif // !defined(MOZILLA_XPCOMRT_API)
 
     return rv;
 }
 
 NS_IMETHODIMP
 nsDNSService::Shutdown()
 {
-#if !defined(MOZILLA_XPCOMRT_API)
     UnregisterWeakMemoryReporter(this);
-#endif // !defined(MOZILLA_XPCOMRT_API)
 
     RefPtr<nsHostResolver> res;
     {
         MutexAutoLock lock(mLock);
         res = mResolver;
         mResolver = nullptr;
     }
     if (res) {
--- a/netwerk/standalone/moz.build
+++ b/netwerk/standalone/moz.build
@@ -40,12 +40,11 @@ SOURCES += sorted(src_list)
 LOCAL_INCLUDES = [
     '../base',
     '../build',
     '../dns',
 ]
 
 DEFINES['IDNA2008'] = False
 DEFINES['MOZILLA_INTERNAL_API'] = True
-DEFINES['MOZILLA_XPCOMRT_API'] = True
 DEFINES['MOZILLA_EXTERNAL_LINKAGE'] = True
 
 include('/ipc/chromium/chromium-config.mozbuild')