Bug 1336086 - remove mozilla::services::_external_Get*Service; r=bsmedberg,jesup
authorNathan Froyd <froydnj@mozilla.com>
Fri, 03 Feb 2017 11:52:02 -0500
changeset 332449 b7e4323f4e73ca7c4e735bc8ade299d6649ecf90
parent 332448 d1fed2fda52d20c942973a2b498a64941256a549
child 332450 673c3bd921c7d8f25309c05ead4a3c18e658ce66
push id86534
push usernfroyd@mozilla.com
push dateFri, 03 Feb 2017 16:52:13 +0000
treeherdermozilla-inbound@b7e4323f4e73 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, jesup
bugs1336086
milestone54.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 1336086 - remove mozilla::services::_external_Get*Service; r=bsmedberg,jesup Removing the exported symbols is straightforward enough. The only wrinkle is that PeerConnectionCtx.cpp gets compiled with and without MOZILLA_INTERNAL_API. When compiling without MOZILLA_INTERNAL_API, mozilla::services::Get*Service was redirected to the _external_* symbol variants. But as the _external_* symbols no longer exist, PeerConnectionCtx.cpp's code no longer worked. Fortunately, PeerConnectionCtx.cpp already contains a few #ifdef MOZILLA_INTERNAL_API blocks to handle internal/external compilation; fixing this newest issue was just a matter of extending existing blocks and adding new ones. The key observation is that we never added any observers when compiling without MOZILLA_INTERNAL_API, so we can #ifdef out the removals of observers, as those would have no effect, and simply skip getting the observer service for the observer additions if we're compiling without MOZILLA_INTERNAL_API.
media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp
xpcom/build/Services.cpp
xpcom/build/Services.h
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp
@@ -41,53 +41,55 @@ class PeerConnectionCtxObserver : public
 {
 public:
   NS_DECL_ISUPPORTS
 
   PeerConnectionCtxObserver() {}
 
   void Init()
     {
+#ifdef MOZILLA_INTERNAL_API
       nsCOMPtr<nsIObserverService> observerService =
         services::GetObserverService();
       if (!observerService)
         return;
 
       nsresult rv = NS_OK;
 
-#ifdef MOZILLA_INTERNAL_API
       rv = observerService->AddObserver(this,
                                         NS_XPCOM_SHUTDOWN_OBSERVER_ID,
                                         false);
       MOZ_ALWAYS_SUCCEEDS(rv);
       rv = observerService->AddObserver(this,
                                         NS_IOSERVICE_OFFLINE_STATUS_TOPIC,
                                         false);
       MOZ_ALWAYS_SUCCEEDS(rv);
+      (void) rv;
 #endif
-      (void) rv;
     }
 
   NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
                      const char16_t* aData) override {
     if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
       CSFLogDebug(logTag, "Shutting down PeerConnectionCtx");
       PeerConnectionCtx::Destroy();
 
+#ifdef MOZILLA_INTERNAL_API
       nsCOMPtr<nsIObserverService> observerService =
         services::GetObserverService();
       if (!observerService)
         return NS_ERROR_FAILURE;
 
       nsresult rv = observerService->RemoveObserver(this,
                                            NS_IOSERVICE_OFFLINE_STATUS_TOPIC);
       MOZ_ALWAYS_SUCCEEDS(rv);
       rv = observerService->RemoveObserver(this,
                                            NS_XPCOM_SHUTDOWN_OBSERVER_ID);
       MOZ_ALWAYS_SUCCEEDS(rv);
+#endif
 
       // Make sure we're not deleted while still inside ::Observe()
       RefPtr<PeerConnectionCtxObserver> kungFuDeathGrip(this);
       PeerConnectionCtx::gPeerConnectionCtxObserver = nullptr;
     }
     if (strcmp(aTopic, NS_IOSERVICE_OFFLINE_STATUS_TOPIC) == 0) {
       const nsLiteralString onlineString(u"" NS_IOSERVICE_ONLINE);
       const nsLiteralString offlineString(u"" NS_IOSERVICE_OFFLINE);
@@ -103,22 +105,24 @@ public:
       }
     }
     return NS_OK;
   }
 
 private:
   virtual ~PeerConnectionCtxObserver()
     {
+#ifdef MOZILLA_INTERNAL_API
       nsCOMPtr<nsIObserverService> observerService =
         services::GetObserverService();
       if (observerService) {
         observerService->RemoveObserver(this, NS_IOSERVICE_OFFLINE_STATUS_TOPIC);
         observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
       }
+#endif
     }
 };
 
 NS_IMPL_ISUPPORTS(PeerConnectionCtxObserver, nsIObserver);
 }
 
 namespace mozilla {
 
--- a/xpcom/build/Services.cpp
+++ b/xpcom/build/Services.cpp
@@ -43,21 +43,16 @@ using namespace mozilla::services;
       return nullptr;                                                   \
     }                                                                   \
     if (!g##NAME) {                                                     \
       nsCOMPtr<TYPE> os = do_GetService(CONTRACT_ID);                   \
       os.swap(g##NAME);                                                 \
     }                                                                   \
     nsCOMPtr<TYPE> ret = g##NAME;                                       \
     return ret.forget();                                                \
-  }                                                                     \
-  NS_EXPORT_(already_AddRefed<TYPE>)                                    \
-  mozilla::services::_external_Get##NAME()                              \
-  {                                                                     \
-    return Get##NAME();                                                 \
   }
 
 #include "ServiceList.h"
 #undef MOZ_SERVICE
 
 /**
  * Clears service cache, sets gXPCOMShuttingDown
  */
--- a/xpcom/build/Services.h
+++ b/xpcom/build/Services.h
@@ -17,28 +17,17 @@
 #undef MOZ_SERVICE
 #undef MOZ_USE_NAMESPACE
 
 namespace mozilla {
 namespace services {
 
 #ifdef MOZILLA_INTERNAL_API
 #define MOZ_SERVICE(NAME, TYPE, SERVICE_CID)                        \
-    already_AddRefed<TYPE> Get##NAME();                             \
-    NS_EXPORT_(already_AddRefed<TYPE>) _external_Get##NAME();
-
-#include "ServiceList.h"
-#undef MOZ_SERVICE
-#else
-#define MOZ_SERVICE(NAME, TYPE, SERVICE_CID)                        \
-    NS_IMPORT_(already_AddRefed<TYPE>) _external_Get##NAME();       \
-    inline already_AddRefed<TYPE> Get##NAME()                       \
-    {                                                               \
-        return _external_Get##NAME();                               \
-    }
+    already_AddRefed<TYPE> Get##NAME();
 
 #include "ServiceList.h"
 #undef MOZ_SERVICE
 #endif
 
 } // namespace services
 } // namespace mozilla