Bug 925229: Turn DataChannelListener into its own header to avoid windows.h inclusion; r=jesup
authorKyle Machulis <kyle@nonpolynomial.com>
Thu, 10 Oct 2013 14:04:28 -0700
changeset 164161 c4e531db0771deed942991622e35ce5505371ee7
parent 164160 8294c1d5163800e82d31f43cbacb826104ca592f
child 164162 64c2b25224fa0297cba68792fc6443dcf7803b44
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs925229
milestone27.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 925229: Turn DataChannelListener into its own header to avoid windows.h inclusion; r=jesup
content/base/src/nsDOMDataChannel.cpp
content/base/src/nsDOMDataChannel.h
netwerk/sctp/datachannel/DataChannel.h
netwerk/sctp/datachannel/DataChannelListener.h
netwerk/sctp/datachannel/moz.build
--- a/content/base/src/nsDOMDataChannel.cpp
+++ b/content/base/src/nsDOMDataChannel.cpp
@@ -16,32 +16,39 @@
 #ifdef PR_LOGGING
 extern PRLogModuleInfo* GetDataChannelLog();
 #endif
 #undef LOG
 #define LOG(args) PR_LOG(GetDataChannelLog(), PR_LOG_DEBUG, args)
 
 
 #include "nsDOMDataChannelDeclarations.h"
+#include "nsDOMDataChannel.h"
 #include "nsIDOMFile.h"
 #include "nsIDOMDataChannel.h"
 #include "nsIDOMMessageEvent.h"
 #include "nsDOMEventTargetHelper.h"
 
 #include "nsError.h"
 #include "nsAutoPtr.h"
 #include "nsContentUtils.h"
 #include "nsCxPusher.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsNetUtil.h"
 #include "nsDOMFile.h"
 
 #include "DataChannel.h"
 
+// Since we've moved the windows.h include down here, we have to explicitly
+// undef GetBinaryType, otherwise we'll get really odd conflicts
+#ifdef GetBinaryType
+#undef GetBinaryType
+#endif
+
 using namespace mozilla;
 using namespace mozilla::dom;
 
 nsDOMDataChannel::~nsDOMDataChannel()
 {
   // Don't call us anymore!  Likely isn't an issue (or maybe just less of
   // one) once we block GC until all the (appropriate) onXxxx handlers
   // are dropped. (See WebRTC spec)
@@ -68,16 +75,23 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_IMPL_ADDREF_INHERITED(nsDOMDataChannel, nsDOMEventTargetHelper)
 NS_IMPL_RELEASE_INHERITED(nsDOMDataChannel, nsDOMEventTargetHelper)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMDataChannel)
   NS_INTERFACE_MAP_ENTRY(nsIDOMDataChannel)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
 
+nsDOMDataChannel::nsDOMDataChannel(already_AddRefed<mozilla::DataChannel> aDataChannel)
+  : mDataChannel(aDataChannel)
+  , mBinaryType(DC_BINARY_TYPE_BLOB)
+{
+  SetIsDOMBinding();
+}
+
 nsresult
 nsDOMDataChannel::Init(nsPIDOMWindow* aDOMWindow)
 {
   nsresult rv;
   nsAutoString urlParam;
 
   MOZ_ASSERT(mDataChannel);
   mDataChannel->SetListener(this, nullptr);
--- a/content/base/src/nsDOMDataChannel.h
+++ b/content/base/src/nsDOMDataChannel.h
@@ -5,32 +5,32 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsDOMDataChannel_h
 #define nsDOMDataChannel_h
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/DataChannelBinding.h"
 #include "mozilla/dom/TypedArray.h"
-#include "mozilla/net/DataChannel.h"
+#include "mozilla/net/DataChannelListener.h"
 #include "nsDOMEventTargetHelper.h"
 #include "nsIDOMDataChannel.h"
+#include "nsIInputStream.h"
+
+
+namespace mozilla {
+class DataChannel;
+};
 
 class nsDOMDataChannel : public nsDOMEventTargetHelper,
                          public nsIDOMDataChannel,
                          public mozilla::DataChannelListener
 {
 public:
-  nsDOMDataChannel(already_AddRefed<mozilla::DataChannel> aDataChannel)
-    : mDataChannel(aDataChannel)
-    , mBinaryType(DC_BINARY_TYPE_BLOB)
-  {
-    SetIsDOMBinding();
-  }
-
+  nsDOMDataChannel(already_AddRefed<mozilla::DataChannel> aDataChannel);
   ~nsDOMDataChannel();
 
   nsresult Init(nsPIDOMWindow* aDOMWindow);
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMDATACHANNEL
 
   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
--- a/netwerk/sctp/datachannel/DataChannel.h
+++ b/netwerk/sctp/datachannel/DataChannel.h
@@ -19,16 +19,17 @@
 #include "nsString.h"
 #include "nsThreadUtils.h"
 #include "nsTArray.h"
 #include "nsDeque.h"
 #include "nsIInputStream.h"
 #include "nsITimer.h"
 #include "mozilla/Mutex.h"
 #include "DataChannelProtocol.h"
+#include "DataChannelListener.h"
 #ifdef SCTP_DTLS_SUPPORTED
 #include "mtransport/sigslot.h"
 #include "mtransport/transportflow.h"
 #include "mtransport/transportlayer.h"
 #include "mtransport/transportlayerdtls.h"
 #include "mtransport/transportlayerprsock.h"
 #endif
 
@@ -86,39 +87,16 @@ public:
   }
 
   uint16_t mStream;
   uint32_t mPpid;
   size_t   mLength;
   char     *mData;
 };
 
-// Implemented by consumers of a Channel to receive messages.
-// Can't nest it in DataChannelConnection because C++ doesn't allow forward
-// refs to embedded classes
-class DataChannelListener {
-public:
-  virtual ~DataChannelListener() {}
-
-  // Called when a DOMString message is received.
-  virtual nsresult OnMessageAvailable(nsISupports *aContext,
-                                      const nsACString& message) = 0;
-
-  // Called when a binary message is received.
-  virtual nsresult OnBinaryMessageAvailable(nsISupports *aContext,
-                                            const nsACString& message) = 0;
-
-  // Called when the channel is connected
-  virtual nsresult OnChannelConnected(nsISupports *aContext) = 0;
-
-  // Called when the channel is closed
-  virtual nsresult OnChannelClosed(nsISupports *aContext) = 0;
-};
-
-
 // One per PeerConnection
 class DataChannelConnection: public nsITimerCallback
 #ifdef SCTP_DTLS_SUPPORTED
                              , public sigslot::has_slots<>
 #endif
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
new file mode 100644
--- /dev/null
+++ b/netwerk/sctp/datachannel/DataChannelListener.h
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* 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 NETWERK_SCTP_DATACHANNEL_DATACHANNELLISTENER_H_
+#define NETWERK_SCTP_DATACHANNEL_DATACHANNELLISTENER_H_
+
+#include "nsISupports.h"
+#include "nsString.h"
+
+namespace mozilla {
+
+// Implemented by consumers of a Channel to receive messages.
+// Can't nest it in DataChannelConnection because C++ doesn't allow forward
+// refs to embedded classes
+class DataChannelListener {
+public:
+  virtual ~DataChannelListener() {}
+
+  // Called when a DOMString message is received.
+  virtual nsresult OnMessageAvailable(nsISupports *aContext,
+                                      const nsACString& message) = 0;
+
+  // Called when a binary message is received.
+  virtual nsresult OnBinaryMessageAvailable(nsISupports *aContext,
+                                            const nsACString& message) = 0;
+
+  // Called when the channel is connected
+  virtual nsresult OnChannelConnected(nsISupports *aContext) = 0;
+
+  // Called when the channel is closed
+  virtual nsresult OnChannelClosed(nsISupports *aContext) = 0;
+};
+
+}
+
+#endif
--- a/netwerk/sctp/datachannel/moz.build
+++ b/netwerk/sctp/datachannel/moz.build
@@ -5,17 +5,18 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_MODULE = 'necko_datachan'
 
 MODULE = 'necko'
 
 EXPORTS.mozilla.net += [
     'DataChannel.h',
-    'DataChannelProtocol.h',
+    'DataChannelListener.h',
+    'DataChannelProtocol.h'
 ]
 
 CPP_SOURCES += [
     'DataChannel.cpp',
 ]
 
 FAIL_ON_WARNINGS = True