Bug 1350055 - fix --disable-webrtc build with new PStunAddrsRequest.ipdl r=jduell draft
authorMichael Froman <mfroman@mozilla.com>
Thu, 23 Mar 2017 20:04:41 -0500
changeset 549273 7cfbddb1168711439530b3ead47bd35bec70ab80
parent 503906 200182ef115692c4ed2909f1a8beae8a6f19d127
child 550753 5f24c4f7e6580cdbd38376c8dd3c2998776979af
push id50973
push userbmo:mfroman@nostrum.com
push dateFri, 24 Mar 2017 22:47:46 +0000
reviewersjduell
bugs1350055
milestone55.0a1
Bug 1350055 - fix --disable-webrtc build with new PStunAddrsRequest.ipdl r=jduell MozReview-Commit-ID: 5oxJtUppHWC
media/mtransport/ipc/NrIceStunAddrMessageUtils.h
media/mtransport/ipc/PStunAddrsParams.h
media/mtransport/ipc/PStunAddrsRequest.ipdl
netwerk/ipc/NeckoChild.cpp
netwerk/ipc/NeckoParent.cpp
netwerk/ipc/moz.build
--- a/media/mtransport/ipc/NrIceStunAddrMessageUtils.h
+++ b/media/mtransport/ipc/NrIceStunAddrMessageUtils.h
@@ -1,46 +1,60 @@
 /* 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/. */
 
 #ifndef mozilla_net_NrIceStunAddrMessageUtils_h
 #define mozilla_net_NrIceStunAddrMessageUtils_h
 
+// forward declare NrIceStunAddr for --disable-webrtc builds where
+// the header will not be available.
+namespace mozilla {
+  class NrIceStunAddr;
+} // namespace mozilla
+
 #include "ipc/IPCMessageUtils.h"
+#ifdef MOZ_WEBRTC
 #include "mtransport/nricestunaddr.h"
+#endif
 
 namespace IPC {
 
 template<>
 struct ParamTraits<mozilla::NrIceStunAddr>
 {
   static void Write(Message* aMsg, const mozilla::NrIceStunAddr &aParam)
   {
+#ifdef MOZ_WEBRTC
     const size_t bufSize = aParam.SerializationBufferSize();
     char* buffer = new char[bufSize];
     aParam.Serialize(buffer, bufSize);
     aMsg->WriteBytes((void*)buffer, bufSize);
     delete[] buffer;
+#endif
   }
 
   static bool Read(const Message* aMsg,
                    PickleIterator* aIter,
                    mozilla::NrIceStunAddr* aResult)
   {
+#ifdef MOZ_WEBRTC
     const size_t bufSize = aResult->SerializationBufferSize();
     char* buffer = new char[bufSize];
     bool result =
       aMsg->ReadBytesInto(aIter, (void*)buffer, bufSize);
 
     if (result) {
       result = result &&
                (NS_OK == aResult->Deserialize(buffer, bufSize));
     }
     delete[] buffer;
 
     return result;
+#else
+    return false;
+#endif
   }
 };
 
 } // namespace IPC
 
 #endif // mozilla_net_NrIceStunAddrMessageUtils_h
--- a/media/mtransport/ipc/PStunAddrsParams.h
+++ b/media/mtransport/ipc/PStunAddrsParams.h
@@ -1,20 +1,30 @@
 /* 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/. */
 
 #ifndef PStunAddrsParams_h
 #define PStunAddrsParams_h
 
+#include "nsTArray.h"
+
+#ifdef MOZ_WEBRTC
 #include "mtransport/nricestunaddr.h"
-#include "nsTArray.h"
+#endif
 
 namespace mozilla {
 namespace net {
 
 // Need to define typedef in .h file--can't seem to in ipdl.h file?
+#ifdef MOZ_WEBRTC
 typedef nsTArray<NrIceStunAddr> NrIceStunAddrArray;
+#else
+// a "dummy" typedef for --disabled-webrtc builds when the definition
+// for NrIceStunAddr is not available (otherwise we get complaints
+// about missing definitions for contructor and destructor)
+typedef nsTArray<int> NrIceStunAddrArray;
+#endif
 
 } // namespace net
 } // namespace mozilla
 
 #endif // PStunAddrsParams_h
--- a/media/mtransport/ipc/PStunAddrsRequest.ipdl
+++ b/media/mtransport/ipc/PStunAddrsRequest.ipdl
@@ -1,15 +1,14 @@
 /* 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 protocol PNecko;
 
-using class mozilla::NrIceStunAddr from "mtransport/nricestunaddr.h";
 using NrIceStunAddrArray from "mozilla/net/PStunAddrsParams.h";
 
 include "mozilla/net/NrIceStunAddrMessageUtils.h";
 
 namespace mozilla {
 namespace net {
 
 async protocol PStunAddrsRequest
--- a/netwerk/ipc/NeckoChild.cpp
+++ b/netwerk/ipc/NeckoChild.cpp
@@ -18,17 +18,19 @@
 #include "mozilla/net/WebSocketEventListenerChild.h"
 #include "mozilla/net/DNSRequestChild.h"
 #include "mozilla/net/ChannelDiverterChild.h"
 #include "mozilla/net/IPCTransportProvider.h"
 #include "mozilla/dom/network/TCPSocketChild.h"
 #include "mozilla/dom/network/TCPServerSocketChild.h"
 #include "mozilla/dom/network/UDPSocketChild.h"
 #include "mozilla/net/AltDataOutputStreamChild.h"
+#ifdef MOZ_WEBRTC
 #include "mozilla/net/StunAddrsRequestChild.h"
+#endif
 
 #ifdef NECKO_PROTOCOL_rtsp
 #include "mozilla/net/RtspControllerChild.h"
 #include "mozilla/net/RtspChannelChild.h"
 #endif
 #include "SerializedLoadContext.h"
 #include "nsIOService.h"
 #include "nsINetworkPredictor.h"
@@ -97,18 +99,20 @@ NeckoChild::AllocPStunAddrsRequestChild(
   // an existing object
   NS_NOTREACHED("AllocPStunAddrsRequestChild should not be called on child");
   return nullptr;
 }
 
 bool
 NeckoChild::DeallocPStunAddrsRequestChild(PStunAddrsRequestChild* aActor)
 {
+#ifdef MOZ_WEBRTC
   StunAddrsRequestChild* p = static_cast<StunAddrsRequestChild*>(aActor);
   p->ReleaseIPDLReference();
+#endif
   return true;
 }
 
 PAltDataOutputStreamChild*
 NeckoChild::AllocPAltDataOutputStreamChild(
         const nsCString& type,
         PHttpChannelChild* channel)
 {
--- a/netwerk/ipc/NeckoParent.cpp
+++ b/netwerk/ipc/NeckoParent.cpp
@@ -20,17 +20,19 @@
 #include "mozilla/Unused.h"
 #ifdef NECKO_PROTOCOL_rtsp
 #include "mozilla/net/RtspControllerParent.h"
 #include "mozilla/net/RtspChannelParent.h"
 #endif
 #include "mozilla/net/DNSRequestParent.h"
 #include "mozilla/net/ChannelDiverterParent.h"
 #include "mozilla/net/IPCTransportProvider.h"
+#ifdef MOZ_WEBRTC
 #include "mozilla/net/StunAddrsRequestParent.h"
+#endif
 #include "mozilla/dom/ChromeUtils.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/TabContext.h"
 #include "mozilla/dom/TabParent.h"
 #include "mozilla/dom/network/TCPSocketParent.h"
 #include "mozilla/dom/network/TCPServerSocketParent.h"
 #include "mozilla/dom/network/UDPSocketParent.h"
 #include "mozilla/dom/workers/ServiceWorkerManager.h"
@@ -325,26 +327,32 @@ NeckoParent::RecvPHttpChannelConstructor
     return IPC_FAIL_NO_REASON(this);
   }
   return IPC_OK();
 }
 
 PStunAddrsRequestParent*
 NeckoParent::AllocPStunAddrsRequestParent()
 {
+#ifdef MOZ_WEBRTC
   StunAddrsRequestParent* p = new StunAddrsRequestParent();
   p->AddRef();
   return p;
+#else
+  return nullptr;
+#endif
 }
 
 bool
 NeckoParent::DeallocPStunAddrsRequestParent(PStunAddrsRequestParent* aActor)
 {
+#ifdef MOZ_WEBRTC
   StunAddrsRequestParent* p = static_cast<StunAddrsRequestParent*>(aActor);
   p->Release();
+#endif
   return true;
 }
 
 PAltDataOutputStreamParent*
 NeckoParent::AllocPAltDataOutputStreamParent(
         const nsCString& type,
         PHttpChannelParent* channel)
 {
--- a/netwerk/ipc/moz.build
+++ b/netwerk/ipc/moz.build
@@ -23,16 +23,26 @@ IPDL_SOURCES = [
     'NeckoChannelParams.ipdlh',
     'PChannelDiverter.ipdl',
     'PDataChannel.ipdl',
     'PNecko.ipdl',
     'PRtspChannel.ipdl',
     'PRtspController.ipdl',
 ]
 
+# needed so --disable-webrtc builds work (yes, a bit messy)
+if not CONFIG['MOZ_WEBRTC']:
+  IPDL_SOURCES += [
+      '../../media/mtransport/ipc/PStunAddrsRequest.ipdl',
+  ]
+  EXPORTS.mozilla.net += [
+      '../../media/mtransport/ipc/NrIceStunAddrMessageUtils.h',
+      '../../media/mtransport/ipc/PStunAddrsParams.h',
+  ]
+
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '/caps',
     '/modules/libjar',
     '/netwerk/base',