Bug 1426059: removed transportlayerprsock code. r=bwc
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Mon, 18 Dec 2017 20:30:05 -0800
changeset 396893 dc853f9fd97293ff703530d806ebf2633740ed69
parent 396892 efee3a8c1124c6e622c12d13f0f36bfdfbbc36dc
child 396894 d57aa14966b9c25f40b8a5cb02a588ecead76c35
push id98389
push userbtara@mozilla.com
push dateTue, 19 Dec 2017 22:17:30 +0000
treeherdermozilla-inbound@05eec51a4ec2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc
bugs1426059
milestone59.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 1426059: removed transportlayerprsock code. r=bwc MozReview-Commit-ID: IWcpxq1Z2V9
media/mtransport/README
media/mtransport/build/moz.build
media/mtransport/common.build
media/mtransport/transportlayerprsock.cpp
media/mtransport/transportlayerprsock.h
netwerk/sctp/datachannel/DataChannel.h
--- a/media/mtransport/README
+++ b/media/mtransport/README
@@ -22,38 +22,24 @@ of WebRTC, expecially because ICE contex
 network transports.
 
 
 THREADING MODEL
 There are no thread locks. It is the responsibility of the caller to
 arrange that any given TransportLayer/TransportFlow is only
 manipulated in one thread at once. One good way to do this is to run
 everything on the STS thread. Many of the existing layer implementations
-(TransportLayerPrsock, TransportLayerIce, TransportLayerLoopback)
-already run on STS so in those cases you must run on STS, though
-you can do setup on the main thread and then activate them on the
-STS.
+(TransportLayerIce, TransportLayerLoopback) already run on STS so in those
+cases you must run on STS, though you can do setup on the main thread and
+then activate them on the STS.
 
 
 EXISTING TRANSPORT LAYERS
 The following transport layers are currently implemented:
 
 * DTLS -- a wrapper around NSS's DTLS [RFC 6347] stack
 * ICE  -- a wrapper around the nICEr ICE [RFC 5245] stack.
-* Prsock -- a wrapper around NSPR sockets
 * Loopback -- a loopback IO mechanism
 * Logging -- a passthrough that just logs its data
 
-The last three are primarily for debugging.
-
-
-
-
-
+The last two are primarily for debugging.
 
 
-
-
-
-
-
-
-
--- a/media/mtransport/build/moz.build
+++ b/media/mtransport/build/moz.build
@@ -19,17 +19,16 @@ EXPORTS.mtransport += [
     '../simpletokenbucket.h',
     '../stun_socket_filter.h',
     '../transportflow.h',
     '../transportlayer.h',
     '../transportlayerdtls.h',
     '../transportlayerice.h',
     '../transportlayerlog.h',
     '../transportlayerloopback.h',
-    '../transportlayerprsock.h',
 ]
 
 include('../common.build')
 
 # These files cannot be built in unified mode because of the redefinition of
 # getLogModule, UNIMPLEMENTED, nr_socket_long_term_violation_time,
 # nr_socket_short_term_violation_time.
 SOURCES += mtransport_cppsrcs
--- a/media/mtransport/common.build
+++ b/media/mtransport/common.build
@@ -20,17 +20,16 @@ mtransport_lcppsrcs = [
     'stun_socket_filter.cpp',
     'test_nr_socket.cpp',
     'transportflow.cpp',
     'transportlayer.cpp',
     'transportlayerdtls.cpp',
     'transportlayerice.cpp',
     'transportlayerlog.cpp',
     'transportlayerloopback.cpp',
-    'transportlayerprsock.cpp',
 ]
 
 mtransport_cppsrcs = [
     '/media/mtransport/%s' % s for s in sorted(mtransport_lcppsrcs)
 ]
 
 LOCAL_INCLUDES += [
     '/media/mtransport/',
deleted file mode 100644
--- a/media/mtransport/transportlayerprsock.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/* -*- 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/. */
-
-// Original author: ekr@rtfm.com
-
-#include "logging.h"
-#include "nspr.h"
-#include "prerror.h"
-#include "prio.h"
-
-#include "nsCOMPtr.h"
-#include "nsASocketHandler.h"
-#include "nsISocketTransportService.h"
-#include "nsNetCID.h"
-#include "nsServiceManagerUtils.h"
-#include "nsXPCOM.h"
-
-#include "transportflow.h"
-#include "transportlayerprsock.h"
-
-namespace mozilla {
-
-MOZ_MTLOG_MODULE("mtransport")
-
-nsresult TransportLayerPrsock::InitInternal() {
-  // Get the transport service as a transport service
-  nsresult rv;
-  stservice_ = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
-
-  if (!NS_SUCCEEDED(rv)) {
-    MOZ_MTLOG(ML_ERROR, "Couldn't get socket transport service");
-    return rv;
-  }
-
-  return NS_OK;
-}
-
-void TransportLayerPrsock::Import(PRFileDesc *fd, nsresult *result) {
-  if (state_ != TS_INIT) {
-    *result = NS_ERROR_NOT_INITIALIZED;
-    return;
-  }
-
-  MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Importing()");
-  fd_ = fd;
-  handler_ = new SocketHandler(this, fd);
-
-  nsresult rv = stservice_->AttachSocket(fd_, handler_);
-  if (!NS_SUCCEEDED(rv)) {
-    *result = rv;
-    return;
-  }
-
-  TL_SET_STATE(TS_OPEN);
-
-  *result = NS_OK;
-}
-
-int TransportLayerPrsock::SendPacket(const unsigned char *data, size_t len) {
-  MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "SendPacket(" << len << ")");
-  if (state_ != TS_OPEN) {
-    MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Can't send packet on closed interface");
-    return TE_INTERNAL;
-  }
-
-  int32_t status;
-  status = PR_Write(fd_, data, len);
-  if (status >= 0) {
-    MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Wrote " << len << " bytes");
-    return status;
-  }
-
-  PRErrorCode err = PR_GetError();
-  if (err == PR_WOULD_BLOCK_ERROR) {
-    MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Write blocked");
-    return TE_WOULDBLOCK;
-  }
-
-
-  MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Write error; channel closed");
-  TL_SET_STATE(TS_ERROR);
-  return TE_ERROR;
-}
-
-void TransportLayerPrsock::OnSocketReady(PRFileDesc *fd, int16_t outflags) {
-  if (!(outflags & PR_POLL_READ)) {
-    return;
-  }
-
-  MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "OnSocketReady(flags=" << outflags << ")");
-
-  unsigned char buf[1600];
-  int32_t rv = PR_Read(fd, buf, sizeof(buf));
-
-  if (rv > 0) {
-    // Successful read
-    MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Read " << rv << " bytes");
-    SignalPacketReceived(this, buf, rv);
-  } else if (rv == 0) {
-    MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Read 0 bytes; channel closed");
-    TL_SET_STATE(TS_CLOSED);
-  } else {
-    PRErrorCode err = PR_GetError();
-
-    if (err != PR_WOULD_BLOCK_ERROR) {
-      MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Read error; channel closed");
-      TL_SET_STATE(TS_ERROR);
-    }
-  }
-}
-
-NS_IMPL_ISUPPORTS0(TransportLayerPrsock::SocketHandler)
-}  // close namespace
deleted file mode 100644
--- a/media/mtransport/transportlayerprsock.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/* -*- 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/. */
-
-// Original author: ekr@rtfm.com
-
-#ifndef transportlayerprsock_h__
-#define transportlayerprsock_h__
-
-#include "nspr.h"
-#include "prio.h"
-
-#include "nsASocketHandler.h"
-#include "nsCOMPtr.h"
-#include "nsISocketTransportService.h"
-#include "nsXPCOM.h"
-
-#include "m_cpp_utils.h"
-#include "transportflow.h"
-#include "transportlayer.h"
-
-namespace mozilla {
-
-class TransportLayerPrsock : public TransportLayer {
- public:
-  TransportLayerPrsock() : fd_(nullptr), handler_() {}
-
-  virtual ~TransportLayerPrsock() {
-    Detach();
-  }
-
-
-  // Internal initializer
-  nsresult InitInternal() override;
-
-  void Import(PRFileDesc *fd, nsresult *result);
-
-  void Detach() {
-    handler_->Detach();
-  }
-
-  // Implement TransportLayer
-  TransportResult SendPacket(const unsigned char *data, size_t len) override;
-
-  TRANSPORT_LAYER_ID("prsock")
-
- private:
-  DISALLOW_COPY_ASSIGN(TransportLayerPrsock);
-
-  // Inner class
-  class SocketHandler : public nsASocketHandler {
-   public:
-      SocketHandler(TransportLayerPrsock *prsock, PRFileDesc *fd) :
-        prsock_(prsock), fd_(fd) {
-        mPollFlags = PR_POLL_READ;
-      }
-
-      void Detach() {
-        mCondition = NS_BASE_STREAM_CLOSED;
-        prsock_ = nullptr;
-      }
-
-      // Implement nsASocket
-      virtual void OnSocketReady(PRFileDesc *fd, int16_t outflags) override {
-        if (prsock_) {
-          prsock_->OnSocketReady(fd, outflags);
-        }
-      }
-
-      virtual void OnSocketDetached(PRFileDesc *fd) override {
-        if (prsock_) {
-          prsock_->OnSocketDetached(fd);
-        }
-        PR_Close(fd_);
-      }
-
-      virtual void IsLocal(bool *aIsLocal) override {
-        // TODO(jesup): better check? Does it matter? (likely no)
-        *aIsLocal = false;
-      }
-
-      virtual uint64_t ByteCountSent() override { return 0; }
-      virtual uint64_t ByteCountReceived() override { return 0; }
-
-      // nsISupports methods
-      NS_DECL_THREADSAFE_ISUPPORTS
-
-      private:
-      TransportLayerPrsock *prsock_;
-      PRFileDesc *fd_;
-   private:
-      DISALLOW_COPY_ASSIGN(SocketHandler);
-      virtual ~SocketHandler() {}
-  };
-
-  // Allow SocketHandler to talk to our APIs
-  friend class SocketHandler;
-
-  // Functions to be called by SocketHandler
-  void OnSocketReady(PRFileDesc *fd, int16_t outflags);
-  void OnSocketDetached(PRFileDesc *fd) {
-    TL_SET_STATE(TS_CLOSED);
-  }
-  void IsLocal(bool *aIsLocal) {
-    // TODO(jesup): better check? Does it matter? (likely no)
-    *aIsLocal = false;
-  }
-
-  PRFileDesc *fd_;
-  RefPtr<SocketHandler> handler_;
-  nsCOMPtr<nsISocketTransportService> stservice_;
-
-};
-
-
-
-}  // close namespace
-#endif
--- a/netwerk/sctp/datachannel/DataChannel.h
+++ b/netwerk/sctp/datachannel/DataChannel.h
@@ -25,17 +25,16 @@
 #include "DataChannelProtocol.h"
 #include "DataChannelListener.h"
 #include "mozilla/net/NeckoTargetHolder.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
 
 #ifndef DATACHANNEL_LOG
 #define DATACHANNEL_LOG(args)
 #endif
 
 #ifndef EALREADY
 #define EALREADY  WSAEALREADY