Bug 1348464 - Part 0: Make nsIOService::GetInstance() a simple inline function that returns a plain pointer; r=mcmanus
☠☠ backed out by d2cfefb8ff39 ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Sat, 18 Mar 2017 18:40:18 -0400
changeset 348683 4258769b457d6e5ceb839f73fd273ca5a1899e4e
parent 348682 035e1b8fe643c0839bff00a6845590fa7c12eb31
child 348684 b89cd59e4ff6185266b496978c2bd1f56dc2cf68
push id31533
push userkwierso@gmail.com
push dateTue, 21 Mar 2017 23:08:53 +0000
treeherdermozilla-central@8744e9f8eb99 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1348464
milestone55.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 1348464 - Part 0: Make nsIOService::GetInstance() a simple inline function that returns a plain pointer; r=mcmanus
netwerk/base/nsIOService.cpp
netwerk/base/nsIOService.h
netwerk/build/nsNetModule.cpp
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -331,17 +331,17 @@ nsIOService::InitializeNetworkLinkServic
 
     // After initializing the networkLinkService, query the connectivity state
     OnNetworkLinkEvent(NS_NETWORK_LINK_DATA_UNKNOWN);
 
     return rv;
 }
 
 nsIOService*
-nsIOService::GetInstance() {
+nsIOService::GetAddRefed() {
     if (!gIOService) {
         gIOService = new nsIOService();
         if (!gIOService)
             return nullptr;
         NS_ADDREF(gIOService);
 
         nsresult rv = gIOService->Init();
         if (NS_FAILED(rv)) {
--- a/netwerk/base/nsIOService.h
+++ b/netwerk/base/nsIOService.h
@@ -40,16 +40,22 @@ class nsIProtocolProxyService2;
 class nsIProxyInfo;
 class nsPIDNSService;
 class nsPISocketTransportService;
 
 namespace mozilla {
 namespace net {
 class NeckoChild;
 class nsAsyncRedirectVerifyHelper;
+class nsIOService;
+
+/**
+ * Reference to the IO service singleton. May be null.
+ */
+extern nsIOService* gIOService;
 
 class nsIOService final : public nsIIOService2
                         , public nsIObserver
                         , public nsINetUtil
                         , public nsISpeculativeConnect
                         , public nsSupportsWeakReference
                         , public nsIIOServiceInternal
 {
@@ -60,17 +66,18 @@ public:
     NS_DECL_NSIOBSERVER
     NS_DECL_NSINETUTIL
     NS_DECL_NSISPECULATIVECONNECT
     NS_DECL_NSIIOSERVICEINTERNAL
 
     // Gets the singleton instance of the IO Service, creating it as needed
     // Returns nullptr on out of memory or failure to initialize.
     // Returns an addrefed pointer.
-    static nsIOService* GetInstance();
+    static nsIOService* GetAddRefed();
+    static nsIOService* GetInstance() { return gIOService; }
 
     nsresult Init();
     nsresult NewURI(const char* aSpec, nsIURI* aBaseURI,
                                 nsIURI* *result,
                                 nsIProtocolHandler* *hdlrResult);
 
     // Called by channels before a redirect happens. This notifies the global
     // redirect observers.
@@ -189,17 +196,12 @@ private:
     // Time a network tearing down started.
     mozilla::Atomic<PRIntervalTime> mNetTearingDownStarted;
 public:
     // Used for all default buffer sizes that necko allocates.
     static uint32_t   gDefaultSegmentSize;
     static uint32_t   gDefaultSegmentCount;
 };
 
-/**
- * Reference to the IO service singleton. May be null.
- */
-extern nsIOService* gIOService;
-
 } // namespace net
 } // namespace mozilla
 
 #endif // nsIOService_h__
--- a/netwerk/build/nsNetModule.cpp
+++ b/netwerk/build/nsNetModule.cpp
@@ -55,17 +55,17 @@
 typedef nsCategoryCache<nsIContentSniffer> ContentSnifferCache;
 ContentSnifferCache* gNetSniffers = nullptr;
 ContentSnifferCache* gDataSniffers = nullptr;
 
 ///////////////////////////////////////////////////////////////////////////////
 
 #include "nsIOService.h"
 typedef mozilla::net::nsIOService nsIOService;
-NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIOService, nsIOService::GetInstance)
+NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIOService, nsIOService::GetAddRefed)
 
 #include "nsDNSService2.h"
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIDNSService,
   nsDNSService::GetXPCOMSingleton)
 
 #include "nsProtocolProxyService.h"
 typedef mozilla::net::nsProtocolProxyService nsProtocolProxyService;
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsProtocolProxyService, Init)