Bug 1673340 - Revert changes done in Bug 1668851, 1663718 and 1497249 r=necko-reviewers,dragana
authorKershaw Chang <kershaw@mozilla.com>
Tue, 27 Oct 2020 11:13:13 +0000
changeset 554651 4ae81cad3fea54d6c59b3a8d866572192d707d5d
parent 554650 739ba4d3ca93b75c770bc1e87a3fc0bdea238f49
child 554652 d4e30013410539a9ff33d4e13d5290ec0cfa4987
push id129507
push userkjang@mozilla.com
push dateTue, 27 Oct 2020 11:16:33 +0000
treeherderautoland@4ae81cad3fea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnecko-reviewers, dragana
bugs1673340, 1668851, 1663718, 1497249
milestone84.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 1673340 - Revert changes done in Bug 1668851, 1663718 and 1497249 r=necko-reviewers,dragana Differential Revision: https://phabricator.services.mozilla.com/D94808
dom/media/webrtc/transport/ipc/WebrtcTCPSocket.cpp
netwerk/protocol/http/HttpConnectionMgrChild.cpp
netwerk/protocol/http/HttpConnectionMgrChild.h
netwerk/protocol/http/HttpConnectionMgrParent.cpp
netwerk/protocol/http/PHttpConnectionMgr.ipdl
netwerk/protocol/http/nsHttpChannel.cpp
netwerk/protocol/http/nsIHttpChannelInternal.idl
netwerk/protocol/websocket/IPCTransportProvider.cpp
netwerk/protocol/websocket/PWebSocketConnection.ipdl
netwerk/protocol/websocket/WebSocketChannel.cpp
netwerk/protocol/websocket/WebSocketChannel.h
netwerk/protocol/websocket/WebSocketConnectionChild.cpp
netwerk/protocol/websocket/WebSocketConnectionChild.h
netwerk/protocol/websocket/WebSocketConnectionParent.cpp
netwerk/protocol/websocket/WebSocketConnectionParent.h
netwerk/protocol/websocket/moz.build
netwerk/protocol/websocket/nsIWebSocketConnection.idl
netwerk/protocol/websocket/nsWebSocketConnection.cpp
netwerk/protocol/websocket/nsWebSocketConnection.h
taskcluster/ci/test/mochitest.yml
--- a/dom/media/webrtc/transport/ipc/WebrtcTCPSocket.cpp
+++ b/dom/media/webrtc/transport/ipc/WebrtcTCPSocket.cpp
@@ -549,22 +549,16 @@ WebrtcTCPSocket::OnTransportAvailable(ns
     CloseWithReason(rv);
     return rv;
   }
 
   FinishOpen();
   return NS_OK;
 }
 
-NS_IMETHODIMP
-WebrtcTCPSocket::OnWebSocketConnectionAvailable(
-    nsIWebSocketConnection* aConnection) {
-  return NS_OK;
-}
-
 void WebrtcTCPSocket::FinishOpen() {
   MOZ_ASSERT(OnSocketThread());
   // mTransport, mSocketIn, and mSocketOut are all set. We may have set them in
   // OnTransportAvailable (in the http/https proxy case), or in
   // OpenWithoutHttpProxy. From here on out, this class functions the same for
   // these two cases.
 
   mSocketIn->AsyncWait(this, 0, 0, nullptr);
--- a/netwerk/protocol/http/HttpConnectionMgrChild.cpp
+++ b/netwerk/protocol/http/HttpConnectionMgrChild.cpp
@@ -6,17 +6,16 @@
 
 // HttpLog.h should generally be included first
 #include "HttpLog.h"
 
 #include "HttpConnectionMgrChild.h"
 #include "HttpTransactionChild.h"
 #include "AltSvcTransactionChild.h"
 #include "EventTokenBucket.h"
-#include "mozilla/net/WebSocketConnectionChild.h"
 #include "nsHttpConnectionInfo.h"
 #include "nsHttpConnectionMgr.h"
 #include "nsHttpHandler.h"
 #include "nsISpeculativeConnect.h"
 
 namespace mozilla {
 namespace net {
 
@@ -173,30 +172,10 @@ mozilla::ipc::IPCResult HttpConnectionMg
   if (aTrans) {
     trans = static_cast<AltSvcTransactionChild*>(*aTrans)->CreateTransaction();
   }
 
   Unused << mConnMgr->SpeculativeConnect(cinfo, overrider, aCaps, trans);
   return IPC_OK();
 }
 
-already_AddRefed<PWebSocketConnectionChild>
-HttpConnectionMgrChild::AllocPWebSocketConnectionChild(
-    PHttpTransactionChild* aTransWithStickyConn) {
-  RefPtr<WebSocketConnectionChild> actor = new WebSocketConnectionChild();
-  return actor.forget();
-}
-
-mozilla::ipc::IPCResult
-HttpConnectionMgrChild::RecvPWebSocketConnectionConstructor(
-    PWebSocketConnectionChild* aActor,
-    PHttpTransactionChild* aTransWithStickyConn) {
-  RefPtr<WebSocketConnectionChild> child =
-      static_cast<WebSocketConnectionChild*>(aActor);
-  nsCOMPtr<nsIHttpUpgradeListener> listener =
-      static_cast<nsIHttpUpgradeListener*>(child.get());
-  Unused << mConnMgr->CompleteUpgrade(
-      ToRealHttpTransaction(aTransWithStickyConn), listener);
-  return IPC_OK();
-}
-
 }  // namespace net
 }  // namespace mozilla
--- a/netwerk/protocol/http/HttpConnectionMgrChild.h
+++ b/netwerk/protocol/http/HttpConnectionMgrChild.h
@@ -36,22 +36,16 @@ class HttpConnectionMgrChild final : pub
       PHttpTransactionChild* aTrans, const uint32_t& aClassOfService);
   mozilla::ipc::IPCResult RecvCancelTransaction(PHttpTransactionChild* aTrans,
                                                 const nsresult& aReason);
   mozilla::ipc::IPCResult RecvSpeculativeConnect(
       HttpConnectionInfoCloneArgs aConnInfo,
       Maybe<SpeculativeConnectionOverriderArgs> aOverriderArgs, uint32_t aCaps,
       Maybe<PAltSvcTransactionChild*> aTrans);
 
-  already_AddRefed<PWebSocketConnectionChild> AllocPWebSocketConnectionChild(
-      PHttpTransactionChild* aTransWithStickyConn);
-  mozilla::ipc::IPCResult RecvPWebSocketConnectionConstructor(
-      PWebSocketConnectionChild* aActor,
-      PHttpTransactionChild* aTransWithStickyConn) override;
-
  private:
   virtual ~HttpConnectionMgrChild();
 
   RefPtr<nsHttpConnectionMgr> mConnMgr;
 };
 
 }  // namespace net
 }  // namespace mozilla
--- a/netwerk/protocol/http/HttpConnectionMgrParent.cpp
+++ b/netwerk/protocol/http/HttpConnectionMgrParent.cpp
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // HttpLog.h should generally be included first
 #include "HttpLog.h"
 
 #include "HttpConnectionMgrParent.h"
 #include "AltSvcTransactionParent.h"
 #include "mozilla/net/HttpTransactionParent.h"
-#include "mozilla/net/WebSocketConnectionParent.h"
 #include "nsHttpConnectionInfo.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsISpeculativeConnect.h"
 #include "nsIOService.h"
 #include "nsQueryObject.h"
 
 namespace mozilla {
 namespace net {
@@ -252,23 +251,18 @@ void HttpConnectionMgrParent::ExcludeHtt
 nsresult HttpConnectionMgrParent::ClearConnectionHistory() {
   // Do nothing here. ClearConnectionHistory() will be triggered by
   // observer notification in socket process.
   return NS_OK;
 }
 
 nsresult HttpConnectionMgrParent::CompleteUpgrade(
     HttpTransactionShell* aTrans, nsIHttpUpgradeListener* aUpgradeListener) {
-  MOZ_ASSERT(aTrans->AsHttpTransactionParent());
-
-  RefPtr<WebSocketConnectionParent> wsConnParent =
-      new WebSocketConnectionParent(aUpgradeListener);
-  Unused << SendPWebSocketConnectionConstructor(
-      wsConnParent, aTrans->AsHttpTransactionParent());
-  return NS_OK;
+  // TODO: fix this in bug 1497249
+  return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 nsHttpConnectionMgr* HttpConnectionMgrParent::AsHttpConnectionMgr() {
   return nullptr;
 }
 
 HttpConnectionMgrParent* HttpConnectionMgrParent::AsHttpConnectionMgrParent() {
   return this;
--- a/netwerk/protocol/http/PHttpConnectionMgr.ipdl
+++ b/netwerk/protocol/http/PHttpConnectionMgr.ipdl
@@ -3,40 +3,37 @@
 
 /* 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 PAltSvcTransaction;
 include protocol PSocketProcess;
 include protocol PHttpTransaction;
-include protocol PWebSocketConnection;
 
 include NeckoChannelParams;
 
 namespace mozilla {
 namespace net {
 
 async refcounted protocol PHttpConnectionMgr
 {
   manager PSocketProcess;
-  manages PWebSocketConnection;
 
 child:
   async __delete__();
 
   async DoShiftReloadConnectionCleanupWithConnInfo(HttpConnectionInfoCloneArgs aArgs);
   async UpdateCurrentTopLevelOuterContentWindowId(uint64_t aWindowId);
   async AddTransaction(PHttpTransaction aTrans, int32_t aPriority);
   async AddTransactionWithStickyConn(PHttpTransaction aTrans, int32_t aPriority,
                                      PHttpTransaction aTransWithStickyConn);
   async RescheduleTransaction(PHttpTransaction aTrans, int32_t aPriority);
   async UpdateClassOfServiceOnTransaction(PHttpTransaction aTrans,
                                           uint32_t aClassOfService);
   async CancelTransaction(PHttpTransaction aTrans, nsresult aReason);
   async SpeculativeConnect(HttpConnectionInfoCloneArgs aConnInfo,
                            SpeculativeConnectionOverriderArgs? aOverriderArgs,
                            uint32_t aCaps, PAltSvcTransaction? aTrans);
-  async PWebSocketConnection(PHttpTransaction aTransWithStickyConn);
 };
 
 } // namespace net
 } // namespace mozilla
\ No newline at end of file
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -8180,23 +8180,16 @@ nsresult nsHttpChannel::ContinueOnStopRe
                            (mResponseHead->Status() == 200 &&
                             mResponseHead->Version() == HttpVersion::v2_0));
 
   bool upgradeConnect = mUpgradeProtocolCallback && aTransWithStickyConn &&
                         (mCaps & NS_HTTP_CONNECT_ONLY) && mResponseHead &&
                         mResponseHead->Status() == 200;
 
   if (upgradeWebsocket || upgradeConnect) {
-    // TODO: Support connection upgrade for socket process in bug 1632809.
-    if (nsIOService::UseSocketProcess() && upgradeConnect) {
-      Unused << mUpgradeProtocolCallback->OnUpgradeFailed(
-          NS_ERROR_NOT_IMPLEMENTED);
-      return ContinueOnStopRequest(aStatus, aIsFromNet, aContentComplete);
-    }
-
     nsresult rv = gHttpHandler->CompleteUpgrade(aTransWithStickyConn,
                                                 mUpgradeProtocolCallback);
     if (NS_FAILED(rv)) {
       LOG(("  CompleteUpgrade failed with %" PRIx32,
            static_cast<uint32_t>(rv)));
 
       // This ensures that WebSocketChannel::OnStopRequest will be
       // called with an error so the session is properly aborted.
--- a/netwerk/protocol/http/nsIHttpChannelInternal.idl
+++ b/netwerk/protocol/http/nsIHttpChannelInternal.idl
@@ -22,32 +22,29 @@ native TimeStamp(mozilla::TimeStamp);
 
 interface nsIAsyncInputStream;
 interface nsIAsyncOutputStream;
 interface nsIPrincipal;
 interface nsIProxyInfo;
 interface nsISecurityConsoleMessage;
 interface nsISocketTransport;
 interface nsIURI;
-interface nsIWebSocketConnection;
 
 /**
  * The callback interface for nsIHttpChannelInternal::HTTPUpgrade()
  */
 
 [scriptable, uuid(5b515449-ab64-4dba-b3cd-da8fc2f83064)]
 interface nsIHttpUpgradeListener : nsISupports
 {
     [must_use] void onTransportAvailable(in nsISocketTransport   aTransport,
                                          in nsIAsyncInputStream  aSocketIn,
                                          in nsIAsyncOutputStream aSocketOut);
 
     [must_use] void onUpgradeFailed(in nsresult aErrorCode);
-
-    [must_use] void onWebSocketConnectionAvailable(in nsIWebSocketConnection aConnection);
 };
 
 /**
  * Dumping ground for http.  This interface will never be frozen.  If you are
  * using any feature exposed by this interface, be aware that this interface
  * will change and you will be broken.  You have been warned.
  */
 [builtinclass, scriptable, uuid(4e28263d-1e03-46f4-aa5c-9512f91957f9)]
--- a/netwerk/protocol/websocket/IPCTransportProvider.cpp
+++ b/netwerk/protocol/websocket/IPCTransportProvider.cpp
@@ -44,22 +44,16 @@ TransportProviderParent::OnTransportAvai
   mSocketOut = aSocketOut;
 
   MaybeNotify();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-TransportProviderParent::OnWebSocketConnectionAvailable(
-    nsIWebSocketConnection* aConnection) {
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 TransportProviderParent::OnUpgradeFailed(nsresult aErrorCode) { return NS_OK; }
 
 void TransportProviderParent::MaybeNotify() {
   if (!mListener || !mTransport) {
     return;
   }
 
   DebugOnly<nsresult> rv =
deleted file mode 100644
--- a/netwerk/protocol/websocket/PWebSocketConnection.ipdl
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */
-/* 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 PHttpConnectionMgr;
-
-namespace mozilla {
-namespace net {
-
-async refcounted protocol PWebSocketConnection
-{
-  manager PHttpConnectionMgr;
-
-parent:
-  async OnTransportAvailable(nsCString securityInfoSerialization);
-  async OnError(nsresult aStatus);
-  async OnTCPClosed();
-  async OnDataReceived(uint8_t[] aData);
-  async OnUpgradeFailed(nsresult aReason);
-  async OnDataSent();
-
-child:
-  async EnqueueOutgoingData(uint8_t[] aData);
-  async StartReading();
-  async DrainSocketData();
-
-  async __delete__();
-
-};
-
-} //namespace net
-} //namespace mozilla
--- a/netwerk/protocol/websocket/WebSocketChannel.cpp
+++ b/netwerk/protocol/websocket/WebSocketChannel.cpp
@@ -51,17 +51,16 @@
 #include "nsProxyRelease.h"
 #include "nsNetUtil.h"
 #include "nsINode.h"
 #include "mozilla/StaticMutex.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/TimeStamp.h"
 #include "nsSocketTransportService2.h"
 #include "nsINSSErrorsService.h"
-#include "nsWebSocketConnection.h"
 
 #include "plbase64.h"
 #include "prmem.h"
 #include "prnetdb.h"
 #include "zlib.h"
 #include <algorithm>
 
 // rather than slurp up all of nsIWebSocket.idl, which lives outside necko, just
@@ -71,20 +70,20 @@
 using namespace mozilla;
 using namespace mozilla::net;
 
 namespace mozilla {
 namespace net {
 
 NS_IMPL_ISUPPORTS(WebSocketChannel, nsIWebSocketChannel, nsIHttpUpgradeListener,
                   nsIRequestObserver, nsIStreamListener, nsIProtocolHandler,
+                  nsIInputStreamCallback, nsIOutputStreamCallback,
                   nsITimerCallback, nsIDNSListener, nsIProtocolProxyCallback,
                   nsIInterfaceRequestor, nsIChannelEventSink,
-                  nsIThreadRetargetableRequest, nsIObserver, nsINamed,
-                  nsIWebSocketConnectionListener)
+                  nsIThreadRetargetableRequest, nsIObserver, nsINamed)
 
 // We implement RFC 6455, which uses Sec-WebSocket-Version: 13 on the wire.
 #define SEC_WEBSOCKET_VERSION "13"
 
 /*
  * About SSL unsigned certificates
  *
  * wss will not work to a host using an unsigned certificate unless there
@@ -1120,17 +1119,18 @@ WebSocketChannel::WebSocketChannel()
       mStopOnClose(NS_OK),
       mServerCloseCode(CLOSE_ABNORMAL),
       mScriptCloseCode(0),
       mFragmentOpcode(nsIWebSocketFrame::OPCODE_CONTINUATION),
       mFragmentAccumulator(0),
       mBuffered(0),
       mBufferSize(kIncomingBufferInitialSize),
       mCurrentOut(nullptr),
-      mHdrOutSize(0),
+      mCurrentOutSent(0),
+      mHdrOutToSend(0),
       mHdrOut(nullptr),
       mDynamicOutputSize(0),
       mDynamicOutput(nullptr),
       mPrivateBrowsing(false),
       mConnectionLogService(nullptr),
       mMutex("WebSocketChannel::mMutex") {
   MOZ_ASSERT(NS_IsMainThread(), "not main thread");
 
@@ -1893,17 +1893,17 @@ void WebSocketChannel::EnqueueOutgoingMe
   MOZ_ASSERT(OnSocketThread(), "not on socket thread");
 
   LOG(
       ("WebSocketChannel::EnqueueOutgoingMessage %p "
        "queueing msg %p [type=%s len=%d]\n",
        this, aMsg, msgNames[aMsg->GetMsgType()], aMsg->Length()));
 
   aQueue.Push(aMsg);
-  DoEnqueueOutgoingMessage();
+  OnOutputStreamReady(mSocketOut);
 }
 
 uint16_t WebSocketChannel::ResultToCloseCode(nsresult resultCode) {
   if (NS_SUCCEEDED(resultCode)) return CLOSE_NORMAL;
 
   switch (resultCode) {
     case NS_ERROR_FILE_TOO_BIG:
     case NS_ERROR_OUT_OF_MEMORY:
@@ -1943,16 +1943,17 @@ void WebSocketChannel::PrimeNewOutgoingM
 
   WsMsgType msgType = mCurrentOut->GetMsgType();
 
   LOG(
       ("WebSocketChannel::PrimeNewOutgoingMessage "
        "%p found queued msg %p [type=%s len=%d]\n",
        this, mCurrentOut, msgNames[msgType], mCurrentOut->Length()));
 
+  mCurrentOutSent = 0;
   mHdrOut = mOutHeader;
 
   uint8_t maskBit = mIsServerSide ? 0 : kMaskBit;
   uint8_t maskSize = mIsServerSide ? 0 : 4;
 
   uint8_t* payload = nullptr;
 
   if (msgType == kMsgTypeFin) {
@@ -1973,35 +1974,35 @@ void WebSocketChannel::PrimeNewOutgoingM
 
     // The close reason code sits in the first 2 bytes of payload
     // If the channel user provided a code and reason during Close()
     // and there isn't an internal error, use that.
     if (NS_SUCCEEDED(mStopOnClose)) {
       if (mScriptCloseCode) {
         NetworkEndian::writeUint16(payload, mScriptCloseCode);
         mOutHeader[1] += 2;
-        mHdrOutSize = 4 + maskSize;
+        mHdrOutToSend = 4 + maskSize;
         if (!mScriptCloseReason.IsEmpty()) {
           MOZ_ASSERT(mScriptCloseReason.Length() <= 123,
                      "Close Reason Too Long");
           mOutHeader[1] += mScriptCloseReason.Length();
-          mHdrOutSize += mScriptCloseReason.Length();
+          mHdrOutToSend += mScriptCloseReason.Length();
           memcpy(payload + 2, mScriptCloseReason.BeginReading(),
-                 std::min<uint32_t>(mScriptCloseReason.Length(), 123));
+                 mScriptCloseReason.Length());
         }
       } else {
         // No close code/reason, so payload length = 0.  We must still send mask
         // even though it's not used.  Keep payload offset so we write mask
         // below.
-        mHdrOutSize = 2 + maskSize;
+        mHdrOutToSend = 2 + maskSize;
       }
     } else {
       NetworkEndian::writeUint16(payload, ResultToCloseCode(mStopOnClose));
       mOutHeader[1] += 2;
-      mHdrOutSize = 4 + maskSize;
+      mHdrOutToSend = 4 + maskSize;
     }
 
     if (mServerClosed) {
       /* bidi close complete */
       mReleaseOnTransmit = 1;
     } else if (NS_FAILED(mStopOnClose)) {
       /* result of abort session - give up */
       StopSession(mStopOnClose);
@@ -2059,28 +2060,28 @@ void WebSocketChannel::PrimeNewOutgoingM
              "deflated [origLength=%d, newLength=%d].\n",
              this, mCurrentOut, mCurrentOut->OrigLength(),
              mCurrentOut->Length()));
       }
     }
 
     if (mCurrentOut->Length() < 126) {
       mOutHeader[1] = mCurrentOut->Length() | maskBit;
-      mHdrOutSize = 2 + maskSize;
+      mHdrOutToSend = 2 + maskSize;
     } else if (mCurrentOut->Length() <= 0xffff) {
       mOutHeader[1] = 126 | maskBit;
       NetworkEndian::writeUint16(mOutHeader + sizeof(uint16_t),
                                  mCurrentOut->Length());
-      mHdrOutSize = 4 + maskSize;
+      mHdrOutToSend = 4 + maskSize;
     } else {
       mOutHeader[1] = 127 | maskBit;
       NetworkEndian::writeUint64(mOutHeader + 2, mCurrentOut->Length());
-      mHdrOutSize = 10 + maskSize;
+      mHdrOutToSend = 10 + maskSize;
     }
-    payload = mOutHeader + mHdrOutSize;
+    payload = mOutHeader + mHdrOutToSend;
   }
 
   MOZ_ASSERT(payload, "payload offset not found");
 
   uint32_t mask = 0;
   if (!mIsServerSide) {
     // Perform the sending mask. Never use a zero mask
     do {
@@ -2112,43 +2113,55 @@ void WebSocketChannel::PrimeNewOutgoingM
 
   RefPtr<WebSocketFrame> frame = mService->CreateFrameIfNeeded(
       mOutHeader[0] & WebSocketChannel::kFinalFragBit,
       mOutHeader[0] & WebSocketChannel::kRsv1Bit,
       mOutHeader[0] & WebSocketChannel::kRsv2Bit,
       mOutHeader[0] & WebSocketChannel::kRsv3Bit,
       mOutHeader[0] & WebSocketChannel::kOpcodeBitsMask,
       mOutHeader[1] & WebSocketChannel::kMaskBit, mask, payload,
-      mHdrOutSize - (payload - mOutHeader), mCurrentOut->BeginOrigReading(),
+      mHdrOutToSend - (payload - mOutHeader), mCurrentOut->BeginOrigReading(),
       mCurrentOut->OrigLength());
 
   if (frame) {
     mService->FrameSent(mSerial, mInnerWindowID, frame.forget());
   }
 
   if (mask) {
-    while (payload < (mOutHeader + mHdrOutSize)) {
+    while (payload < (mOutHeader + mHdrOutToSend)) {
       *payload ^= mask >> 24;
       mask = RotateLeft(mask, 8);
       payload++;
     }
 
     // Mask the real message payloads
     ApplyMask(mask, mCurrentOut->BeginWriting(), mCurrentOut->Length());
   }
 
-  // Transmitting begins - mHdrOutSize bytes from mOutHeader and
-  // mCurrentOut->Length() bytes from mCurrentOut.
+  int32_t len = mCurrentOut->Length();
+
+  // for small frames, copy it all together for a contiguous write
+  if (len && len <= kCopyBreak) {
+    memcpy(mOutHeader + mHdrOutToSend, mCurrentOut->BeginWriting(), len);
+    mHdrOutToSend += len;
+    mCurrentOutSent = len;
+  }
+
+  // Transmitting begins - mHdrOutToSend bytes from mOutHeader and
+  // mCurrentOut->Length() bytes from mCurrentOut. The latter may be
+  // coaleseced into the former for small messages or as the result of the
+  // compression process.
 
   cleanupAfterFailure.release();
 }
 
 void WebSocketChannel::DeleteCurrentOutGoingMessage() {
   delete mCurrentOut;
   mCurrentOut = nullptr;
+  mCurrentOutSent = 0;
 }
 
 void WebSocketChannel::EnsureHdrOut(uint32_t size) {
   LOG(("WebSocketChannel::EnsureHdrOut() %p [%d]\n", this, size));
 
   if (mDynamicOutputSize < size) {
     mDynamicOutputSize = size;
     mDynamicOutput = (uint8_t*)moz_xrealloc(mDynamicOutput, mDynamicOutputSize);
@@ -2184,19 +2197,33 @@ class RemoveObserverRunnable : public Ru
 void WebSocketChannel::CleanupConnection() {
   LOG(("WebSocketChannel::CleanupConnection() %p", this));
 
   if (mLingeringCloseTimer) {
     mLingeringCloseTimer->Cancel();
     mLingeringCloseTimer = nullptr;
   }
 
-  if (mConnection) {
-    mConnection->Close();
-    mConnection = nullptr;
+  if (mSocketIn) {
+    if (mDataStarted) {
+      mSocketIn->AsyncWait(nullptr, 0, 0, nullptr);
+    }
+    mSocketIn = nullptr;
+  }
+
+  if (mSocketOut) {
+    mSocketOut->AsyncWait(nullptr, 0, 0, nullptr);
+    mSocketOut = nullptr;
+  }
+
+  if (mTransport) {
+    mTransport->SetSecurityCallbacks(nullptr);
+    mTransport->SetEventSink(nullptr, nullptr);
+    mTransport->Close(NS_BASE_STREAM_CLOSED);
+    mTransport = nullptr;
   }
 
   if (mConnectionLogService && !mPrivateBrowsing) {
     mConnectionLogService->RemoveHost(mHost, mSerial);
   }
 
   // This method can run in any thread, but the observer has to be removed on
   // the main-thread.
@@ -2254,25 +2281,40 @@ void WebSocketChannel::DoStopSession(nsr
     mReconnectDelayTimer = nullptr;
   }
 
   if (mPingTimer) {
     mPingTimer->Cancel();
     mPingTimer = nullptr;
   }
 
-  if (mConnection && !mTCPClosed && mDataStarted) {
-    // Drain, within reason, this socket.
-    mConnection->DrainSocketData();
+  if (mSocketIn && !mTCPClosed && mDataStarted) {
+    // Drain, within reason, this socket. if we leave any data
+    // unconsumed (including the tcp fin) a RST will be generated
+    // The right thing to do here is shutdown(SHUT_WR) and then wait
+    // a little while to see if any data comes in.. but there is no
+    // reason to delay things for that when the websocket handshake
+    // is supposed to guarantee a quiet connection except for that fin.
+
+    char buffer[512];
+    uint32_t count = 0;
+    uint32_t total = 0;
+    nsresult rv;
+    do {
+      total += count;
+      rv = mSocketIn->Read(buffer, 512, &count);
+      if (rv != NS_BASE_STREAM_WOULD_BLOCK && (NS_FAILED(rv) || count == 0))
+        mTCPClosed = true;
+    } while (NS_SUCCEEDED(rv) && count > 0 && total < 32000);
   }
 
   int32_t sessionCount = kLingeringCloseThreshold;
   nsWSAdmissionManager::GetSessionCount(sessionCount);
 
-  if (!mTCPClosed && mConnection && sessionCount < kLingeringCloseThreshold) {
+  if (!mTCPClosed && mTransport && sessionCount < kLingeringCloseThreshold) {
     // 7.1.1 says that the client SHOULD wait for the server to close the TCP
     // connection. This is so we can reuse port numbers before 2 MSL expires,
     // which is not really as much of a concern for us as the amount of state
     // that might be accrued by keeping this channel object around waiting for
     // the server. We handle the SHOULD by waiting a short time in the common
     // case, but not waiting in the case of high concurrency.
     //
     // Normally this will be taken care of in AbortSession() after mTCPClosed
@@ -2329,17 +2371,17 @@ void WebSocketChannel::AbortSession(nsre
   }
 
   {
     MutexAutoLock lock(mMutex);
     if (mStopped) {
       return;
     }
 
-    if (mConnection && reason != NS_BASE_STREAM_CLOSED && !mRequestedClose &&
+    if (mTransport && reason != NS_BASE_STREAM_CLOSED && !mRequestedClose &&
         !mClientClosed && !mServerClosed && mDataStarted) {
       mRequestedClose = true;
       mStopOnClose = reason;
       mSocketThread->Dispatch(
           new OutboundEnqueuer(this,
                                new OutboundMessage(kMsgTypeFin, VoidCString())),
           nsIEventTarget::DISPATCH_NORMAL);
       return;
@@ -2807,47 +2849,40 @@ nsresult WebSocketChannel::StartWebsocke
           ("WebSocketChannel::StartWebsocketData channel already closed, not "
            "starting data"));
       return NS_ERROR_NOT_AVAILABLE;
     }
 
     mDataStarted = true;
   }
 
-  rv = mConnection->StartReading();
+  rv = mSocketIn->AsyncWait(this, 0, 0, mSocketThread);
   if (NS_FAILED(rv)) {
     LOG(
-        ("WebSocketChannel::StartWebsocketData mConnection->StartReading() "
-         "failed "
+        ("WebSocketChannel::StartWebsocketData mSocketIn->AsyncWait() failed "
          "with error 0x%08" PRIx32,
          static_cast<uint32_t>(rv)));
     return mSocketThread->Dispatch(
         NewRunnableMethod<nsresult>("net::WebSocketChannel::AbortSession", this,
                                     &WebSocketChannel::AbortSession, rv),
         NS_DISPATCH_NORMAL);
   }
 
-  RefPtr<WebSocketChannel> self = this;
-  rv = mSocketThread->Dispatch(
-      NS_NewRunnableFunction("net::WebSocketChannel::StartPinging",
-                             [self]() {
-                               if (self->mPingInterval) {
-                                 Unused << self->StartPinging();
-                               }
-                               // Try to send the messages in the queue out
-                               // immediately.
-                               self->DoEnqueueOutgoingMessage();
-                             }),
-      NS_DISPATCH_NORMAL);
-  if (NS_FAILED(rv)) {
-    LOG(
-        ("WebSocketChannel::StartWebsocketData Could not start pinging, "
-         "rv=0x%08" PRIx32,
-         static_cast<uint32_t>(rv)));
-    return rv;
+  if (mPingInterval) {
+    rv = mSocketThread->Dispatch(
+        NewRunnableMethod("net::WebSocketChannel::StartPinging", this,
+                          &WebSocketChannel::StartPinging),
+        NS_DISPATCH_NORMAL);
+    if (NS_FAILED(rv)) {
+      LOG(
+          ("WebSocketChannel::StartWebsocketData Could not start pinging, "
+           "rv=0x%08" PRIx32,
+           static_cast<uint32_t>(rv)));
+      return rv;
+    }
   }
 
   LOG(("WebSocketChannel::StartWebsocketData Notifying Listener %p",
        mListenerMT ? mListenerMT->mListener.get() : nullptr));
 
   if (mListenerMT) {
     rv = mListenerMT->mListener->OnStart(mListenerMT->mContext);
     if (NS_FAILED(rv)) {
@@ -3173,18 +3208,18 @@ WebSocketChannel::GetName(nsACString& aN
 
 // nsIWebSocketChannel
 
 NS_IMETHODIMP
 WebSocketChannel::GetSecurityInfo(nsISupports** aSecurityInfo) {
   LOG(("WebSocketChannel::GetSecurityInfo() %p\n", this));
   MOZ_ASSERT(NS_IsMainThread(), "not main thread");
 
-  if (mConnection) {
-    if (NS_FAILED(mConnection->GetSecurityInfo(aSecurityInfo)))
+  if (mTransport) {
+    if (NS_FAILED(mTransport->GetSecurityInfo(aSecurityInfo)))
       *aSecurityInfo = nullptr;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 WebSocketChannel::AsyncOpen(nsIURI* aURI, const nsACString& aOrigin,
                             uint64_t aInnerWindowID,
@@ -3524,42 +3559,24 @@ WebSocketChannel::OnTransportAvailable(n
     LOG(("WebSocketChannel::OnTransportAvailable: Already stopped"));
     return NS_OK;
   }
 
   MOZ_ASSERT(NS_IsMainThread(), "not main thread");
   MOZ_ASSERT(!mRecvdHttpUpgradeTransport, "OTA duplicated");
   MOZ_ASSERT(aSocketIn, "OTA with invalid socketIn");
 
-  return OnWebSocketConnectionAvailable(
-      new nsWebSocketConnection(aTransport, aSocketIn, aSocketOut));
-}
-
-NS_IMETHODIMP
-WebSocketChannel::OnWebSocketConnectionAvailable(
-    nsIWebSocketConnection* aConnection) {
-  LOG(
-      ("WebSocketChannel::OnWebSocketConnectionAvailable %p [%p] "
-       "rcvdonstart=%d\n",
-       this, aConnection, mGotUpgradeOK));
-
-  MOZ_ASSERT(NS_IsMainThread(), "not main thread");
-  MOZ_ASSERT(!mRecvdHttpUpgradeTransport,
-             "OnWebSocketConnectionAvailable duplicated");
-  MOZ_ASSERT(aConnection,
-             "OnWebSocketConnectionAvailable with invalid connection");
-
-  if (mStopped) {
-    LOG(("WebSocketChannel::OnWebSocketConnectionAvailable: Already stopped"));
-    aConnection->Close();
-    return NS_OK;
-  }
-
-  mConnection = aConnection;
-  nsresult rv = mConnection->Init(this, mSocketThread);
+  mTransport = aTransport;
+  mSocketIn = aSocketIn;
+  mSocketOut = aSocketOut;
+
+  nsresult rv;
+  rv = mTransport->SetEventSink(nullptr, nullptr);
+  if (NS_FAILED(rv)) return rv;
+  rv = mTransport->SetSecurityCallbacks(this);
   if (NS_FAILED(rv)) return rv;
 
   mRecvdHttpUpgradeTransport = 1;
   if (mGotUpgradeOK) {
     // We're now done CONNECTING, which means we can now open another,
     // perhaps parallel, connection to the same host if one
     // is pending
     nsWSAdmissionManager::OnConnected(this);
@@ -3841,42 +3858,143 @@ WebSocketChannel::OnStopRequest(nsIReque
   mChannel = nullptr;
   mHttpChannel = nullptr;
   mLoadGroup = nullptr;
   mCallbacks = nullptr;
 
   return NS_OK;
 }
 
-void WebSocketChannel::DoEnqueueOutgoingMessage() {
-  LOG(("WebSocketChannel::DoEnqueueOutgoingMessage() %p\n", this));
+// nsIInputStreamCallback
+
+NS_IMETHODIMP
+WebSocketChannel::OnInputStreamReady(nsIAsyncInputStream* aStream) {
+  LOG(("WebSocketChannel::OnInputStreamReady() %p\n", this));
   MOZ_ASSERT(OnSocketThread(), "not on socket thread");
 
-  if (!mCurrentOut) PrimeNewOutgoingMessage();
-
-  if (mCurrentOut && mConnection) {
-    LOG(
-        ("WebSocketChannel::DoEnqueueOutgoingMessage: "
-         "Try to send %u of hdr/copybreak and %u of data\n",
-         mHdrOutSize, mCurrentOut->Length()));
-
-    nsresult rv = mConnection->EnqueueOutputData(
-        mHdrOut, mHdrOutSize, (uint8_t*)mCurrentOut->BeginReading(),
-        mCurrentOut->Length());
-
-    LOG(("WebSocketChannel::DoEnqueueOutgoingMessage: rv %" PRIx32 "\n",
-         static_cast<uint32_t>(rv)));
+  if (!mSocketIn)  // did we we clean up the socket after scheduling InputReady?
+    return NS_OK;
+
+  // this is after the http upgrade - so we are speaking websockets
+  char buffer[2048];
+  uint32_t count;
+  nsresult rv;
+
+  do {
+    rv = mSocketIn->Read((char*)buffer, 2048, &count);
+    LOG(("WebSocketChannel::OnInputStreamReady: read %u rv %" PRIx32 "\n",
+         count, static_cast<uint32_t>(rv)));
+
+    if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
+      mSocketIn->AsyncWait(this, 0, 0, mSocketThread);
+      return NS_OK;
+    }
 
     if (NS_FAILED(rv)) {
       AbortSession(rv);
-      return;
+      return rv;
+    }
+
+    if (count == 0) {
+      AbortSession(NS_BASE_STREAM_CLOSED);
+      return NS_OK;
+    }
+
+    if (mStopped) {
+      continue;
+    }
+
+    rv = ProcessInput((uint8_t*)buffer, count);
+    if (NS_FAILED(rv)) {
+      AbortSession(rv);
+      return rv;
+    }
+  } while (NS_SUCCEEDED(rv) && mSocketIn);
+
+  return NS_OK;
+}
+
+// nsIOutputStreamCallback
+
+NS_IMETHODIMP
+WebSocketChannel::OnOutputStreamReady(nsIAsyncOutputStream* aStream) {
+  LOG(("WebSocketChannel::OnOutputStreamReady() %p\n", this));
+  MOZ_ASSERT(OnSocketThread(), "not on socket thread");
+  nsresult rv;
+
+  if (!mCurrentOut) PrimeNewOutgoingMessage();
+
+  while (mCurrentOut && mSocketOut) {
+    const char* sndBuf;
+    uint32_t toSend;
+    uint32_t amtSent;
+
+    if (mHdrOut) {
+      sndBuf = (const char*)mHdrOut;
+      toSend = mHdrOutToSend;
+      LOG(
+          ("WebSocketChannel::OnOutputStreamReady: "
+           "Try to send %u of hdr/copybreak\n",
+           toSend));
+    } else {
+      sndBuf = (char*)mCurrentOut->BeginReading() + mCurrentOutSent;
+      toSend = mCurrentOut->Length() - mCurrentOutSent;
+      if (toSend > 0) {
+        LOG(
+            ("WebSocketChannel::OnOutputStreamReady: "
+             "Try to send %u of data\n",
+             toSend));
+      }
+    }
+
+    if (toSend == 0) {
+      amtSent = 0;
+    } else {
+      rv = mSocketOut->Write(sndBuf, toSend, &amtSent);
+      LOG(("WebSocketChannel::OnOutputStreamReady: write %u rv %" PRIx32 "\n",
+           amtSent, static_cast<uint32_t>(rv)));
+
+      if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
+        mSocketOut->AsyncWait(this, 0, 0, mSocketThread);
+        return NS_OK;
+      }
+
+      if (NS_FAILED(rv)) {
+        AbortSession(rv);
+        return NS_OK;
+      }
+    }
+
+    if (mHdrOut) {
+      if (amtSent == toSend) {
+        mHdrOut = nullptr;
+        mHdrOutToSend = 0;
+      } else {
+        mHdrOut += amtSent;
+        mHdrOutToSend -= amtSent;
+        mSocketOut->AsyncWait(this, 0, 0, mSocketThread);
+      }
+    } else {
+      if (amtSent == toSend) {
+        if (!mStopped) {
+          mTargetThread->Dispatch(
+              new CallAcknowledge(this, mCurrentOut->OrigLength()),
+              NS_DISPATCH_NORMAL);
+        }
+        DeleteCurrentOutGoingMessage();
+        PrimeNewOutgoingMessage();
+      } else {
+        mCurrentOutSent += amtSent;
+        mSocketOut->AsyncWait(this, 0, 0, mSocketThread);
+      }
     }
   }
 
   if (mReleaseOnTransmit) ReleaseSession();
+  return NS_OK;
 }
 
 // nsIStreamListener
 
 NS_IMETHODIMP
 WebSocketChannel::OnDataAvailable(nsIRequest* aRequest,
                                   nsIInputStream* aInputStream,
                                   uint64_t aOffset, uint32_t aCount) {
@@ -3889,51 +4007,12 @@ WebSocketChannel::OnDataAvailable(nsIReq
   // response code in OnStartRequest().. so we can ignore the data here
 
   LOG(("WebSocketChannel::OnDataAvailable: HTTP data unexpected len>=%u\n",
        aCount));
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
-WebSocketChannel::OnError(nsresult aStatus) {
-  AbortSession(aStatus);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-WebSocketChannel::OnTCPClosed() {
-  if (mLingeringCloseTimer) {
-    MOZ_ASSERT(mStopped, "Lingering without Stop");
-    LOG(("WebSocketChannel:: Cleanup connection based on TCP Close"));
-    CleanupConnection();
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-WebSocketChannel::OnDataReceived(uint8_t* aData, uint32_t aCount) {
-  return ProcessInput(aData, aCount);
-}
-
-NS_IMETHODIMP
-WebSocketChannel::OnDataSent() {
-  MOZ_ASSERT(OnSocketThread(), "not on socket thread");
-
-  if (mCurrentOut) {
-    if (!mStopped) {
-      mTargetThread->Dispatch(
-          new CallAcknowledge(this, mCurrentOut->OrigLength()),
-          NS_DISPATCH_NORMAL);
-    }
-    DeleteCurrentOutGoingMessage();
-    PrimeNewOutgoingMessage();
-  }
-
-  return NS_OK;
-}
-
 }  // namespace net
 }  // namespace mozilla
 
 #undef CLOSE_GOING_AWAY
--- a/netwerk/protocol/websocket/WebSocketChannel.h
+++ b/netwerk/protocol/websocket/WebSocketChannel.h
@@ -14,17 +14,16 @@
 #include "nsIAsyncOutputStream.h"
 #include "nsITimer.h"
 #include "nsIDNSListener.h"
 #include "nsINamed.h"
 #include "nsIObserver.h"
 #include "nsIProtocolProxyCallback.h"
 #include "nsIChannelEventSink.h"
 #include "nsIHttpChannelInternal.h"
-#include "nsIWebSocketConnection.h"
 #include "BaseWebSocketChannel.h"
 
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsDeque.h"
 #include "mozilla/Atomics.h"
 
 class nsIAsyncVerifyRedirectCallback;
@@ -59,39 +58,41 @@ enum wsConnectingState {
   CONNECTING_QUEUED,      // Waiting for other ws to same host to finish opening
   CONNECTING_DELAYED,     // Delayed by "reconnect after failure" algorithm
   CONNECTING_IN_PROGRESS  // Started connection: waiting for result
 };
 
 class WebSocketChannel : public BaseWebSocketChannel,
                          public nsIHttpUpgradeListener,
                          public nsIStreamListener,
+                         public nsIInputStreamCallback,
+                         public nsIOutputStreamCallback,
                          public nsITimerCallback,
                          public nsIDNSListener,
                          public nsIObserver,
                          public nsIProtocolProxyCallback,
                          public nsIInterfaceRequestor,
                          public nsIChannelEventSink,
-                         public nsINamed,
-                         public nsIWebSocketConnectionListener {
+                         public nsINamed {
   friend class WebSocketFrame;
 
  public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIHTTPUPGRADELISTENER
   NS_DECL_NSIREQUESTOBSERVER
   NS_DECL_NSISTREAMLISTENER
+  NS_DECL_NSIINPUTSTREAMCALLBACK
+  NS_DECL_NSIOUTPUTSTREAMCALLBACK
   NS_DECL_NSITIMERCALLBACK
   NS_DECL_NSIDNSLISTENER
   NS_DECL_NSIPROTOCOLPROXYCALLBACK
   NS_DECL_NSIINTERFACEREQUESTOR
   NS_DECL_NSICHANNELEVENTSINK
   NS_DECL_NSIOBSERVER
   NS_DECL_NSINAMED
-  NS_DECL_NSIWEBSOCKETCONNECTIONLISTENER
 
   // nsIWebSocketChannel methods BaseWebSocketChannel didn't implement for us
   //
   NS_IMETHOD AsyncOpen(nsIURI* aURI, const nsACString& aOrigin,
                        uint64_t aWindowID, nsIWebSocketListener* aListener,
                        nsISupports* aContext) override;
   NS_IMETHOD Close(uint16_t aCode, const nsACString& aReason) override;
   NS_IMETHOD SendMsg(const nsACString& aMsg) override;
@@ -136,17 +137,16 @@ class WebSocketChannel : public BaseWebS
 
   // Common send code for binary + text msgs
   [[nodiscard]] nsresult SendMsgCommon(const nsACString& aMsg, bool isBinary,
                                        uint32_t length,
                                        nsIInputStream* aStream = nullptr);
 
   void EnqueueOutgoingMessage(nsDeque<OutboundMessage>& aQueue,
                               OutboundMessage* aMsg);
-  void DoEnqueueOutgoingMessage();
 
   void PrimeNewOutgoingMessage();
   void DeleteCurrentOutGoingMessage();
   void GeneratePong(uint8_t* payload, uint32_t len);
   void GeneratePing();
 
   [[nodiscard]] nsresult OnNetworkChanged();
   [[nodiscard]] nsresult StartPinging();
@@ -207,17 +207,19 @@ class WebSocketChannel : public BaseWebS
   // then to IP address (unless we're leaving DNS resolution to a proxy server)
   nsCString mAddress;
   int32_t mPort;  // WS server port
 
   // Used for off main thread access to the URI string.
   nsCString mHost;
   nsString mEffectiveURL;
 
-  nsCOMPtr<nsIWebSocketConnection> mConnection;
+  nsCOMPtr<nsISocketTransport> mTransport;
+  nsCOMPtr<nsIAsyncInputStream> mSocketIn;
+  nsCOMPtr<nsIAsyncOutputStream> mSocketOut;
 
   nsCOMPtr<nsITimer> mCloseTimer;
   uint32_t mCloseTimeout; /* milliseconds */
 
   nsCOMPtr<nsITimer> mOpenTimer;
   uint32_t mOpenTimeout;         /* milliseconds */
   wsConnectingState mConnecting; /* 0 if not connecting */
   nsCOMPtr<nsITimer> mReconnectDelayTimer;
@@ -273,26 +275,27 @@ class WebSocketChannel : public BaseWebS
 
   uint8_t* mFramePtr;
   uint8_t* mBuffer;
   uint8_t mFragmentOpcode;
   uint32_t mFragmentAccumulator;
   uint32_t mBuffered;
   uint32_t mBufferSize;
 
+  // These are for the send buffers
+  const static int32_t kCopyBreak = 1000;
+
   OutboundMessage* mCurrentOut;
+  uint32_t mCurrentOutSent;
   nsDeque<OutboundMessage> mOutgoingMessages;
   nsDeque<OutboundMessage> mOutgoingPingMessages;
   nsDeque<OutboundMessage> mOutgoingPongMessages;
-  uint32_t mHdrOutSize;
+  uint32_t mHdrOutToSend;
   uint8_t* mHdrOut;
-  // This is used to store the frame header and the close reason.
-  // Since the length of close reason can not be larger than 123, 256 is
-  // enough here.
-  uint8_t mOutHeader[256];
+  uint8_t mOutHeader[kCopyBreak + 16];
   UniquePtr<PMCECompression> mPMCECompressor;
   uint32_t mDynamicOutputSize;
   uint8_t* mDynamicOutput;
   bool mPrivateBrowsing;
 
   nsCOMPtr<nsIDashboardEventNotifier> mConnectionLogService;
 
   mozilla::Mutex mMutex;
deleted file mode 100644
--- a/netwerk/protocol/websocket/WebSocketConnectionChild.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et ft=cpp : */
-/* 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 "WebSocketLog.h"
-#include "WebSocketConnectionChild.h"
-
-#include "nsISerializable.h"
-#include "nsSerializationHelper.h"
-#include "nsThreadUtils.h"
-#include "nsWebSocketConnection.h"
-
-namespace mozilla {
-namespace net {
-
-NS_IMPL_ISUPPORTS(WebSocketConnectionChild, nsIWebSocketConnectionListener,
-                  nsIHttpUpgradeListener)
-
-WebSocketConnectionChild::WebSocketConnectionChild() {
-  LOG(("WebSocketConnectionChild ctor %p\n", this));
-}
-
-WebSocketConnectionChild::~WebSocketConnectionChild() {
-  LOG(("WebSocketConnectionChild dtor %p\n", this));
-}
-
-// nsIHttpUpgradeListener
-NS_IMETHODIMP
-WebSocketConnectionChild::OnTransportAvailable(
-    nsISocketTransport* aTransport, nsIAsyncInputStream* aSocketIn,
-    nsIAsyncOutputStream* aSocketOut) {
-  if (!NS_IsMainThread()) {
-    nsCOMPtr<nsISocketTransport> transport = aTransport;
-    nsCOMPtr<nsIAsyncInputStream> inputStream = aSocketIn;
-    nsCOMPtr<nsIAsyncOutputStream> outputStream = aSocketOut;
-    RefPtr<WebSocketConnectionChild> self = this;
-    return NS_DispatchToMainThread(
-        NS_NewRunnableFunction("WebSocketConnectionChild::OnTransportAvailable",
-                               [self, transport, inputStream, outputStream]() {
-                                 Unused << self->OnTransportAvailable(
-                                     transport, inputStream, outputStream);
-                               }),
-        NS_DISPATCH_NORMAL);
-  }
-
-  LOG(("WebSocketConnectionChild::OnTransportAvailable %p\n", this));
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(!mConnection, "already called");
-  MOZ_ASSERT(aTransport);
-
-  nsAutoCString serializedSecurityInfo;
-  nsCOMPtr<nsISupports> secInfoSupp;
-  aTransport->GetSecurityInfo(getter_AddRefs(secInfoSupp));
-  if (secInfoSupp) {
-    nsCOMPtr<nsISerializable> secInfoSer = do_QueryInterface(secInfoSupp);
-    if (secInfoSer) {
-      NS_SerializeToString(secInfoSer, serializedSecurityInfo);
-    }
-  }
-
-  mConnection = new nsWebSocketConnection(aTransport, aSocketIn, aSocketOut);
-  nsresult rv = mConnection->Init(this, GetCurrentEventTarget());
-  if (NS_FAILED(rv)) {
-    Unused << SendOnError(rv);
-    return NS_OK;
-  }
-
-  Unused << SendOnTransportAvailable(serializedSecurityInfo);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-WebSocketConnectionChild::OnWebSocketConnectionAvailable(
-    nsIWebSocketConnection* aConnection) {
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-WebSocketConnectionChild::OnUpgradeFailed(nsresult aReason) {
-  if (!NS_IsMainThread()) {
-    return NS_DispatchToMainThread(NewRunnableMethod<nsresult>(
-        "WebSocketConnectionChild::OnUpgradeFailed", this,
-        &WebSocketConnectionChild::OnUpgradeFailed, aReason));
-  }
-
-  if (CanSend()) {
-    Unused << SendOnUpgradeFailed(aReason);
-  }
-  return NS_OK;
-}
-
-mozilla::ipc::IPCResult WebSocketConnectionChild::RecvEnqueueOutgoingData(
-    nsTArray<uint8_t>&& aData) {
-  LOG(("WebSocketConnectionChild::RecvEnqueueOutgoingData %p\n", this));
-
-  if (!mConnection) {
-    MOZ_ASSERT(false);
-    return IPC_FAIL(this, "Connection is not available");
-  }
-
-  mConnection->EnqueueOutputData(std::move(aData));
-  return IPC_OK();
-}
-
-mozilla::ipc::IPCResult WebSocketConnectionChild::RecvStartReading() {
-  LOG(("WebSocketConnectionChild::RecvStartReading %p\n", this));
-
-  if (!mConnection) {
-    MOZ_ASSERT(false);
-    return IPC_FAIL(this, "Connection is not available");
-  }
-
-  mConnection->StartReading();
-  return IPC_OK();
-}
-
-mozilla::ipc::IPCResult WebSocketConnectionChild::RecvDrainSocketData() {
-  LOG(("WebSocketConnectionChild::RecvDrainSocketData %p\n", this));
-
-  if (!mConnection) {
-    MOZ_ASSERT(false);
-    return IPC_FAIL(this, "Connection is not available");
-  }
-
-  mConnection->DrainSocketData();
-  return IPC_OK();
-}
-
-mozilla::ipc::IPCResult WebSocketConnectionChild::Recv__delete__() {
-  LOG(("WebSocketConnectionChild::Recv__delete__ %p\n", this));
-
-  if (!mConnection) {
-    return IPC_OK();
-  }
-
-  mConnection->Close();
-  mConnection = nullptr;
-  return IPC_OK();
-}
-
-NS_IMETHODIMP
-WebSocketConnectionChild::OnError(nsresult aStatus) {
-  LOG(("WebSocketConnectionChild::OnError %p\n", this));
-
-  if (CanSend()) {
-    Unused << SendOnError(aStatus);
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-WebSocketConnectionChild::OnTCPClosed() {
-  LOG(("WebSocketConnectionChild::OnTCPClosed %p\n", this));
-
-  if (CanSend()) {
-    Unused << SendOnTCPClosed();
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-WebSocketConnectionChild::OnDataReceived(uint8_t* aData, uint32_t aCount) {
-  LOG(("WebSocketConnectionChild::OnDataReceived %p\n", this));
-
-  if (CanSend()) {
-    nsTArray<uint8_t> data;
-    data.AppendElements(aData, aCount);
-    Unused << SendOnDataReceived(std::move(data));
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-WebSocketConnectionChild::OnDataSent() {
-  LOG(("WebSocketConnectionChild::OnDataSent %p\n", this));
-
-  if (CanSend()) {
-    Unused << SendOnDataSent();
-  }
-  return NS_OK;
-}
-
-void WebSocketConnectionChild::ActorDestroy(ActorDestroyReason aWhy) {
-  LOG(("WebSocketConnectionChild::ActorDestroy %p\n", this));
-  if (mConnection) {
-    mConnection->Close();
-    mConnection = nullptr;
-  }
-}
-
-}  // namespace net
-}  // namespace mozilla
deleted file mode 100644
--- a/netwerk/protocol/websocket/WebSocketConnectionChild.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et ft=cpp : */
-/* 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_WebSocketConnectionChild_h
-#define mozilla_net_WebSocketConnectionChild_h
-
-#include "mozilla/net/PWebSocketConnectionChild.h"
-#include "nsIHttpChannelInternal.h"
-#include "nsISupportsImpl.h"
-#include "nsIWebSocketConnection.h"
-
-namespace mozilla {
-namespace net {
-
-class nsWebSocketConnection;
-
-// WebSocketConnectionChild only lives in socket process and uses
-// nsWebSocketConnection to send/read data from socket. Only IPDL holds a strong
-// reference to WebSocketConnectionChild, so the life time of
-// WebSocketConnectionChild is bound to the IPC actor.
-
-class WebSocketConnectionChild final : public PWebSocketConnectionChild,
-                                       public nsIHttpUpgradeListener,
-                                       public nsIWebSocketConnectionListener {
- public:
-  NS_DECL_THREADSAFE_ISUPPORTS
-  NS_DECL_NSIHTTPUPGRADELISTENER
-  NS_DECL_NSIWEBSOCKETCONNECTIONLISTENER
-
-  WebSocketConnectionChild();
-
-  mozilla::ipc::IPCResult RecvEnqueueOutgoingData(nsTArray<uint8_t>&& aData);
-  mozilla::ipc::IPCResult RecvStartReading();
-  mozilla::ipc::IPCResult RecvDrainSocketData();
-  mozilla::ipc::IPCResult Recv__delete__() override;
-
-  void ActorDestroy(ActorDestroyReason aWhy) override;
-
- private:
-  virtual ~WebSocketConnectionChild();
-
-  RefPtr<nsWebSocketConnection> mConnection;
-};
-
-}  // namespace net
-}  // namespace mozilla
-
-#endif  // mozilla_net_WebSocketConnectionChild_h
deleted file mode 100644
--- a/netwerk/protocol/websocket/WebSocketConnectionParent.cpp
+++ /dev/null
@@ -1,259 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et ft=cpp : */
-/* 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 "WebSocketLog.h"
-#include "WebSocketConnectionParent.h"
-
-#include "nsIHttpChannelInternal.h"
-#include "nsSerializationHelper.h"
-#include "nsThreadUtils.h"
-
-namespace mozilla {
-namespace net {
-
-NS_IMPL_ADDREF(WebSocketConnectionParent)
-NS_IMPL_RELEASE(WebSocketConnectionParent)
-NS_INTERFACE_MAP_BEGIN(WebSocketConnectionParent)
-  NS_INTERFACE_MAP_ENTRY(nsIWebSocketConnection)
-  NS_INTERFACE_MAP_ENTRY_CONCRETE(WebSocketConnectionParent)
-NS_INTERFACE_MAP_END
-
-WebSocketConnectionParent::WebSocketConnectionParent(
-    nsIHttpUpgradeListener* aListener)
-    : mUpgradeListener(aListener), mClosed(false) {
-  LOG(("WebSocketConnectionParent ctor %p\n", this));
-  MOZ_ASSERT(mUpgradeListener);
-}
-
-WebSocketConnectionParent::~WebSocketConnectionParent() {
-  LOG(("WebSocketConnectionParent dtor %p\n", this));
-}
-
-mozilla::ipc::IPCResult WebSocketConnectionParent::RecvOnTransportAvailable(
-    const nsCString& aSecurityInfoSerialization) {
-  LOG(("WebSocketConnectionParent::RecvOnTransportAvailable %p\n", this));
-  if (!aSecurityInfoSerialization.IsEmpty()) {
-    nsresult rv = NS_DeserializeObject(aSecurityInfoSerialization,
-                                       getter_AddRefs(mSecurityInfo));
-    MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv),
-                          "Deserializing security info should not fail");
-    Unused << rv;  // So we don't get an unused error in release builds.
-  }
-
-  if (mUpgradeListener) {
-    Unused << mUpgradeListener->OnWebSocketConnectionAvailable(this);
-    mUpgradeListener = nullptr;
-  }
-  return IPC_OK();
-}
-
-static inline void DispatchHelper(nsIEventTarget* aTarget, const char* aName,
-                                  std::function<void()>&& aTask) {
-  if (aTarget->IsOnCurrentThread()) {
-    aTask();
-  } else {
-    aTarget->Dispatch(NS_NewRunnableFunction(aName, std::move(aTask)),
-                      NS_DISPATCH_NORMAL);
-  }
-}
-
-mozilla::ipc::IPCResult WebSocketConnectionParent::RecvOnError(
-    const nsresult& aStatus) {
-  LOG(("WebSocketConnectionParent::RecvOnError %p\n", this));
-  MOZ_ASSERT(mEventTarget);
-
-  RefPtr<WebSocketConnectionParent> self = this;
-  auto task = [self{std::move(self)}, aStatus]() {
-    if (self->mListener) {
-      self->mListener->OnError(aStatus);
-    }
-  };
-
-  DispatchHelper(mEventTarget, "WebSocketConnectionParent::RecvOnError",
-                 std::move(task));
-  return IPC_OK();
-}
-
-mozilla::ipc::IPCResult WebSocketConnectionParent::RecvOnUpgradeFailed(
-    const nsresult& aReason) {
-  RefPtr<WebSocketConnectionParent> self = this;
-  auto task = [self{std::move(self)}, aReason]() {
-    if (self->mUpgradeListener) {
-      Unused << self->mUpgradeListener->OnUpgradeFailed(aReason);
-      self->mUpgradeListener = nullptr;
-    }
-  };
-
-  DispatchHelper(mEventTarget, "WebSocketConnectionParent::RecvOnUpgradeFailed",
-                 std::move(task));
-  return IPC_OK();
-}
-
-mozilla::ipc::IPCResult WebSocketConnectionParent::RecvOnTCPClosed() {
-  LOG(("WebSocketConnectionParent::RecvOnTCPClosed %p\n", this));
-  MOZ_ASSERT(mEventTarget);
-
-  RefPtr<WebSocketConnectionParent> self = this;
-  auto task = [self{std::move(self)}]() {
-    if (self->mListener) {
-      self->mListener->OnTCPClosed();
-    }
-  };
-
-  DispatchHelper(mEventTarget, "WebSocketConnectionParent::RecvOnTCPClosed",
-                 std::move(task));
-  return IPC_OK();
-}
-
-mozilla::ipc::IPCResult WebSocketConnectionParent::RecvOnDataReceived(
-    nsTArray<uint8_t>&& aData) {
-  LOG(("WebSocketConnectionParent::RecvOnDataReceived %p\n", this));
-  MOZ_ASSERT(mEventTarget);
-
-  RefPtr<WebSocketConnectionParent> self = this;
-  auto task = [self{std::move(self)},
-               data = CopyableTArray{std::move(aData)}]() {
-    if (self->mListener) {
-      uint8_t* buffer = const_cast<uint8_t*>(data.Elements());
-      nsresult rv = self->mListener->OnDataReceived(buffer, data.Length());
-      if (NS_FAILED(rv)) {
-        self->mListener->OnError(rv);
-      }
-    }
-  };
-
-  DispatchHelper(mEventTarget, "WebSocketConnectionParent::RecvOnDataReceived",
-                 std::move(task));
-  return IPC_OK();
-}
-
-mozilla::ipc::IPCResult WebSocketConnectionParent::RecvOnDataSent() {
-  LOG(("WebSocketConnectionParent::RecvOnDataSent %p\n", this));
-  MOZ_ASSERT(mEventTarget);
-
-  RefPtr<WebSocketConnectionParent> self = this;
-  auto task = [self{std::move(self)}]() {
-    if (self->mListener) {
-      Unused << self->mListener->OnDataSent();
-    }
-  };
-
-  DispatchHelper(mEventTarget, "WebSocketConnectionParent::RecvOnDataSent",
-                 std::move(task));
-  return IPC_OK();
-}
-
-void WebSocketConnectionParent::ActorDestroy(ActorDestroyReason aWhy) {
-  LOG(("WebSocketConnectionParent::ActorDestroy %p aWhy=%d\n", this, aWhy));
-  if (!mClosed) {
-    // Treat this as an error when IPC is closed before
-    // WebSocketConnectionParent::Close() is called.
-    nsCOMPtr<nsIWebSocketConnectionListener> listener;
-    listener.swap(mListener);
-    if (listener) {
-      listener->OnError(NS_ERROR_FAILURE);
-    }
-  }
-};
-
-NS_IMETHODIMP
-WebSocketConnectionParent::Init(nsIWebSocketConnectionListener* aListener,
-                                nsIEventTarget* aEventTarget) {
-  NS_ENSURE_ARG_POINTER(aListener);
-  NS_ENSURE_ARG_POINTER(aEventTarget);
-
-  mListener = aListener;
-  mEventTarget = aEventTarget;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-WebSocketConnectionParent::Close() {
-  LOG(("WebSocketConnectionParent::Close %p\n", this));
-
-  RefPtr<WebSocketConnectionParent> self = this;
-  auto task = [self{std::move(self)}]() {
-    self->mClosed = true;
-    if (self->CanSend()) {
-      Unused << self->Send__delete__(self);
-      self->mListener = nullptr;
-    }
-  };
-
-  DispatchHelper(GetMainThreadEventTarget(), "WebSocketConnectionParent::Close",
-                 std::move(task));
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-WebSocketConnectionParent::EnqueueOutputData(const uint8_t* aHdrBuf,
-                                             uint32_t aHdrBufLength,
-                                             const uint8_t* aPayloadBuf,
-                                             uint32_t aPayloadBufLength) {
-  LOG(("WebSocketConnectionParent::EnqueueOutputData %p\n", this));
-
-  RefPtr<WebSocketConnectionParent> self = this;
-  nsTArray<uint8_t> data;
-  data.AppendElements(aHdrBuf, aHdrBufLength);
-  data.AppendElements(aPayloadBuf, aPayloadBufLength);
-  auto task = [self{std::move(self)},
-               data = CopyableTArray{std::move(data)}]() mutable {
-    if (self->CanSend()) {
-      Unused << self->SendEnqueueOutgoingData(std::move(data));
-    }
-  };
-
-  DispatchHelper(GetMainThreadEventTarget(),
-                 "WebSocketConnectionParent::EnqueOutputData", std::move(task));
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-WebSocketConnectionParent::StartReading() {
-  LOG(("WebSocketConnectionParent::StartReading %p\n", this));
-
-  RefPtr<WebSocketConnectionParent> self = this;
-  auto task = [self{std::move(self)}]() {
-    if (self->CanSend()) {
-      Unused << self->SendStartReading();
-    }
-  };
-
-  DispatchHelper(GetMainThreadEventTarget(),
-                 "WebSocketConnectionParent::SendStartReading",
-                 std::move(task));
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-WebSocketConnectionParent::DrainSocketData() {
-  LOG(("WebSocketConnectionParent::DrainSocketData %p\n", this));
-
-  RefPtr<WebSocketConnectionParent> self = this;
-  auto task = [self{std::move(self)}]() {
-    if (self->CanSend()) {
-      Unused << self->SendDrainSocketData();
-    }
-  };
-
-  DispatchHelper(GetMainThreadEventTarget(),
-                 "WebSocketConnectionParent::DrainSocketData", std::move(task));
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-WebSocketConnectionParent::GetSecurityInfo(nsISupports** aSecurityInfo) {
-  LOG(("WebSocketConnectionParent::GetSecurityInfo() %p\n", this));
-  MOZ_ASSERT(NS_IsMainThread());
-
-  NS_ENSURE_ARG_POINTER(aSecurityInfo);
-  nsCOMPtr<nsISupports> info = mSecurityInfo;
-  info.forget(aSecurityInfo);
-  return NS_OK;
-}
-
-}  // namespace net
-}  // namespace mozilla
deleted file mode 100644
--- a/netwerk/protocol/websocket/WebSocketConnectionParent.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et ft=cpp : */
-/* 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_WebSocketConnectionParent_h
-#define mozilla_net_WebSocketConnectionParent_h
-
-#include "mozilla/net/PWebSocketConnectionParent.h"
-#include "nsISupportsImpl.h"
-#include "nsIWebSocketConnection.h"
-
-class nsIHttpUpgradeListener;
-
-namespace mozilla {
-namespace net {
-
-// WebSocketConnectionParent implements nsIWebSocketConnection and provides
-// interface for WebSocketChannel to send/receive data. The ownership model for
-// TransportProvider is that IPDL and WebSocketChannel hold strong reference of
-// WebSocketConnectionParent. When nsIWebSocketConnection::Close is called, a
-// __delete__ message will be sent and the IPC actor will be deallocated as
-// well.
-
-#define WEB_SOCKET_CONNECTION_PARENT_IID             \
-  {                                                  \
-    0x1cc3cb61, 0x0c09, 0x4f58, {                    \
-      0x9a, 0x64, 0x44, 0xf7, 0x92, 0x86, 0xbc, 0x00 \
-    }                                                \
-  }
-
-class WebSocketConnectionParent final : public PWebSocketConnectionParent,
-                                        public nsIWebSocketConnection {
- public:
-  NS_DECL_THREADSAFE_ISUPPORTS
-  NS_DECL_NSIWEBSOCKETCONNECTION
-  NS_DECLARE_STATIC_IID_ACCESSOR(WEB_SOCKET_CONNECTION_PARENT_IID)
-
-  explicit WebSocketConnectionParent(nsIHttpUpgradeListener* aListener);
-
-  mozilla::ipc::IPCResult RecvOnTransportAvailable(
-      const nsCString& aSecurityInfoSerialization);
-  mozilla::ipc::IPCResult RecvOnError(const nsresult& aStatus);
-  mozilla::ipc::IPCResult RecvOnTCPClosed();
-  mozilla::ipc::IPCResult RecvOnDataReceived(nsTArray<uint8_t>&& aData);
-  mozilla::ipc::IPCResult RecvOnUpgradeFailed(const nsresult& aReason);
-  mozilla::ipc::IPCResult RecvOnDataSent();
-
-  void ActorDestroy(ActorDestroyReason aWhy) override;
-
- private:
-  virtual ~WebSocketConnectionParent();
-
-  nsCOMPtr<nsIHttpUpgradeListener> mUpgradeListener;
-  nsCOMPtr<nsIWebSocketConnectionListener> mListener;
-  nsCOMPtr<nsIEventTarget> mEventTarget;
-  nsCOMPtr<nsISupports> mSecurityInfo;
-  bool mClosed;
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(WebSocketConnectionParent,
-                              WEB_SOCKET_CONNECTION_PARENT_IID)
-
-}  // namespace net
-}  // namespace mozilla
-
-#endif  // mozilla_net_WebSocketConnectionParent_h
--- a/netwerk/protocol/websocket/moz.build
+++ b/netwerk/protocol/websocket/moz.build
@@ -5,57 +5,50 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 with Files("**"):
     BUG_COMPONENT = ("Core", "Networking: WebSockets")
 
 XPIDL_SOURCES += [
     "nsITransportProvider.idl",
     "nsIWebSocketChannel.idl",
-    "nsIWebSocketConnection.idl",
     "nsIWebSocketEventService.idl",
     "nsIWebSocketImpl.idl",
     "nsIWebSocketListener.idl",
 ]
 
 XPIDL_MODULE = "necko_websocket"
 
 EXPORTS.mozilla.net += [
     "BaseWebSocketChannel.h",
     "IPCTransportProvider.h",
     "WebSocketChannel.h",
     "WebSocketChannelChild.h",
     "WebSocketChannelParent.h",
-    "WebSocketConnectionChild.h",
-    "WebSocketConnectionParent.h",
     "WebSocketEventListenerChild.h",
     "WebSocketEventListenerParent.h",
     "WebSocketEventService.h",
     "WebSocketFrame.h",
 ]
 
 UNIFIED_SOURCES += [
     "BaseWebSocketChannel.cpp",
     "IPCTransportProvider.cpp",
-    "nsWebSocketConnection.cpp",
     "WebSocketChannel.cpp",
     "WebSocketChannelChild.cpp",
     "WebSocketChannelParent.cpp",
-    "WebSocketConnectionChild.cpp",
-    "WebSocketConnectionParent.cpp",
     "WebSocketEventListenerChild.cpp",
     "WebSocketEventListenerParent.cpp",
     "WebSocketEventService.cpp",
     "WebSocketFrame.cpp",
 ]
 
 IPDL_SOURCES += [
     "PTransportProvider.ipdl",
     "PWebSocket.ipdl",
-    "PWebSocketConnection.ipdl",
     "PWebSocketEventListener.ipdl",
 ]
 
 include("/ipc/chromium/chromium-config.mozbuild")
 
 FINAL_LIBRARY = "xul"
 
 LOCAL_INCLUDES += [
deleted file mode 100644
--- a/netwerk/protocol/websocket/nsIWebSocketConnection.idl
+++ /dev/null
@@ -1,80 +0,0 @@
-/* vim:set ts=4 sw=4 et cindent: */
-/* 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 "nsISupports.idl"
-
-interface nsIEventTarget;
-interface nsIWebSocketConnectionListener;
-
-/**
- * nsIWebSocketConnection
- *
- * An internal interface that only uses for WebSocketChannel.
- * Provides methods for sending and receving data.
- */
-[uuid(4256eb9e-61eb-4ec9-b8c6-b68aee3ba390)]
-interface nsIWebSocketConnection : nsISupports
-{
-    /**
-     * Initialize a WebSocketConnection.
-     *
-     * @param aListener
-     *        The listener to be notified when data is recevied or
-     *        an error happened.
-     * @param aEventTarget
-     *        The event target where the listener's methods will be called.
-     */
-    void init(in nsIWebSocketConnectionListener aListener, in nsIEventTarget aEventTarget);
-
-    /**
-     * Close the connection.
-     */
-    void close();
-
-    /**
-     * Put the outgoing data into a queue.
-     */
-    void EnqueueOutputData([const, array, size_is(aHdrBufLength)]in uint8_t aHdrBuf,
-                                                              in unsigned long aHdrBufLength,
-                           [const, array, size_is(aPayloadBufLength)]in uint8_t aPayloadBuf,
-                                                              in unsigned long aPayloadBufLength);
-
-    /**
-     * Let the connection start reading the data.
-     */
-    void startReading();
-
-    /**
-     * Keep reading the data until there is nothing to read.
-     */
-    void drainSocketData();
-
-    /**
-     * Transport-level security information (if any)
-     */
-    [must_use] readonly attribute nsISupports securityInfo;
-};
-
-/**
- * nsIWebSocketConnectionListener
- *
- * The listener used to receive the status update or incoming data.
- */
-[scriptable, uuid(1c6ab15b-8a0c-4d76-81f8-326a6e0bcb90)]
-interface nsIWebSocketConnectionListener : nsISupports
-{
-    void onError(in nsresult aStatus);
-
-    void onTCPClosed();
-
-    void onDataReceived([array, size_is(dataLength)]in uint8_t data,
-                        in unsigned long dataLength);
-
-    /**
-     * Called to inform the listener that the outgoing data is written
-     * to socket.
-     */
-    void onDataSent();
-};
deleted file mode 100644
--- a/netwerk/protocol/websocket/nsWebSocketConnection.cpp
+++ /dev/null
@@ -1,257 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et 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/. */
-
-#include "nsWebSocketConnection.h"
-
-#include "WebSocketLog.h"
-#include "nsIOService.h"
-#include "nsISocketTransport.h"
-
-NS_IMPL_ISUPPORTS(nsWebSocketConnection, nsIWebSocketConnection,
-                  nsIInputStreamCallback, nsIOutputStreamCallback)
-
-nsWebSocketConnection::nsWebSocketConnection(
-    nsISocketTransport* aTransport, nsIAsyncInputStream* aInputStream,
-    nsIAsyncOutputStream* aOutputStream)
-    : mTransport(aTransport),
-      mSocketIn(aInputStream),
-      mSocketOut(aOutputStream),
-      mWriteOffset(0),
-      mStartReadingCalled(false) {
-  LOG(("nsWebSocketConnection ctor %p\n", this));
-}
-
-nsWebSocketConnection::~nsWebSocketConnection() {
-  LOG(("nsWebSocketConnection dtor %p\n", this));
-}
-
-NS_IMETHODIMP
-nsWebSocketConnection::Init(nsIWebSocketConnectionListener* aListener,
-                            nsIEventTarget* aEventTarget) {
-  NS_ENSURE_ARG_POINTER(aListener);
-  NS_ENSURE_ARG_POINTER(aEventTarget);
-
-  mListener = aListener;
-  mEventTarget = aEventTarget;
-
-  if (!mTransport) {
-    return NS_ERROR_FAILURE;
-  }
-
-  if (XRE_IsParentProcess()) {
-    nsCOMPtr<nsIInterfaceRequestor> callbacks = do_QueryInterface(mListener);
-    mTransport->SetSecurityCallbacks(callbacks);
-  } else {
-    // NOTE: we don't use security callbacks in socket process.
-    mTransport->SetSecurityCallbacks(nullptr);
-  }
-  return mTransport->SetEventSink(nullptr, nullptr);
-}
-
-NS_IMETHODIMP
-nsWebSocketConnection::Close() {
-  LOG(("nsWebSocketConnection::Close %p\n", this));
-  if (mTransport) {
-    mTransport->SetSecurityCallbacks(nullptr);
-    mTransport->SetEventSink(nullptr, nullptr);
-    mTransport->Close(NS_BASE_STREAM_CLOSED);
-    mTransport = nullptr;
-  }
-
-  if (mSocketIn) {
-    if (mStartReadingCalled) {
-      mSocketIn->AsyncWait(nullptr, 0, 0, nullptr);
-    }
-    mSocketIn = nullptr;
-  }
-
-  if (mSocketOut) {
-    mSocketOut->AsyncWait(nullptr, 0, 0, nullptr);
-    mSocketOut = nullptr;
-  }
-
-  return NS_OK;
-}
-
-nsresult nsWebSocketConnection::EnqueueOutputData(nsTArray<uint8_t>&& aData) {
-  MOZ_ASSERT(mEventTarget->IsOnCurrentThread());
-
-  if (!mSocketOut) {
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-
-  mOutputQueue.emplace_back(std::move(aData));
-  OnOutputStreamReady(mSocketOut);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsWebSocketConnection::EnqueueOutputData(const uint8_t* aHdrBuf,
-                                         uint32_t aHdrBufLength,
-                                         const uint8_t* aPayloadBuf,
-                                         uint32_t aPayloadBufLength) {
-  LOG(("nsWebSocketConnection::EnqueueOutputData %p\n", this));
-  MOZ_ASSERT(mEventTarget->IsOnCurrentThread());
-
-  if (!mSocketOut) {
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-
-  nsTArray<uint8_t> data;
-  data.AppendElements(aHdrBuf, aHdrBufLength);
-  data.AppendElements(aPayloadBuf, aPayloadBufLength);
-  mOutputQueue.emplace_back(std::move(data));
-
-  OnOutputStreamReady(mSocketOut);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsWebSocketConnection::StartReading() {
-  if (!mSocketIn) {
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-
-  MOZ_ASSERT(!mStartReadingCalled, "StartReading twice");
-  mStartReadingCalled = true;
-  return mSocketIn->AsyncWait(this, 0, 0, mEventTarget);
-}
-
-NS_IMETHODIMP
-nsWebSocketConnection::DrainSocketData() {
-  MOZ_ASSERT(mEventTarget->IsOnCurrentThread());
-
-  if (!mSocketIn || !mListener) {
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-
-  // If we leave any data unconsumed (including the tcp fin) a RST will be
-  // generated The right thing to do here is shutdown(SHUT_WR) and then wait a
-  // little while to see if any data comes in.. but there is no reason to delay
-  // things for that when the websocket handshake is supposed to guarantee a
-  // quiet connection except for that fin.
-  char buffer[512];
-  uint32_t count = 0;
-  uint32_t total = 0;
-  nsresult rv;
-  do {
-    total += count;
-    rv = mSocketIn->Read(buffer, 512, &count);
-    if (rv != NS_BASE_STREAM_WOULD_BLOCK && (NS_FAILED(rv) || count == 0)) {
-      mListener->OnTCPClosed();
-    }
-  } while (NS_SUCCEEDED(rv) && count > 0 && total < 32000);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsWebSocketConnection::GetSecurityInfo(nsISupports** aSecurityInfo) {
-  LOG(("nsWebSocketConnection::GetSecurityInfo() %p\n", this));
-  MOZ_ASSERT(NS_IsMainThread(), "not main thread");
-
-  if (mTransport) {
-    if (NS_FAILED(mTransport->GetSecurityInfo(aSecurityInfo)))
-      *aSecurityInfo = nullptr;
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsWebSocketConnection::OnInputStreamReady(nsIAsyncInputStream* aStream) {
-  LOG(("nsWebSocketConnection::OnInputStreamReady() %p\n", this));
-  MOZ_ASSERT(mEventTarget->IsOnCurrentThread());
-  MOZ_ASSERT(mListener);
-
-  // did we we clean up the socket after scheduling InputReady?
-  if (!mSocketIn) {
-    return NS_OK;
-  }
-
-  // this is after the http upgrade - so we are speaking websockets
-  uint8_t buffer[2048];
-  uint32_t count;
-  nsresult rv;
-
-  do {
-    rv = mSocketIn->Read((char*)buffer, 2048, &count);
-    LOG(("nsWebSocketConnection::OnInputStreamReady: read %u rv %" PRIx32 "\n",
-         count, static_cast<uint32_t>(rv)));
-
-    if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
-      mSocketIn->AsyncWait(this, 0, 0, mEventTarget);
-      return NS_OK;
-    }
-
-    if (NS_FAILED(rv)) {
-      mListener->OnError(rv);
-      return rv;
-    }
-
-    if (count == 0) {
-      mListener->OnError(NS_BASE_STREAM_CLOSED);
-      return NS_OK;
-    }
-
-    rv = mListener->OnDataReceived(buffer, count);
-    if (NS_FAILED(rv)) {
-      mListener->OnError(rv);
-      return rv;
-    }
-  } while (NS_SUCCEEDED(rv) && mSocketIn && mListener);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsWebSocketConnection::OnOutputStreamReady(nsIAsyncOutputStream* aStream) {
-  LOG(("nsWebSocketConnection::OnOutputStreamReady() %p\n", this));
-  MOZ_ASSERT(mEventTarget->IsOnCurrentThread());
-  MOZ_ASSERT(mListener);
-
-  if (!mSocketOut) {
-    return NS_OK;
-  }
-
-  while (!mOutputQueue.empty()) {
-    const OutputData& data = mOutputQueue.front();
-
-    char* buffer = reinterpret_cast<char*>(
-                       const_cast<uint8_t*>(data.GetData().Elements())) +
-                   mWriteOffset;
-    uint32_t toWrite = data.GetData().Length() - mWriteOffset;
-
-    uint32_t wrote = 0;
-    nsresult rv = mSocketOut->Write(buffer, toWrite, &wrote);
-    LOG(("nsWebSocketConnection::OnOutputStreamReady: write %u rv %" PRIx32,
-         wrote, static_cast<uint32_t>(rv)));
-
-    if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
-      mSocketOut->AsyncWait(this, 0, 0, mEventTarget);
-      return NS_OK;
-    }
-
-    if (NS_FAILED(rv)) {
-      LOG(("nsWebSocketConnection::OnOutputStreamReady %p failed %u\n", this,
-           static_cast<uint32_t>(rv)));
-      mListener->OnError(rv);
-      return NS_OK;
-    }
-
-    mWriteOffset += wrote;
-
-    if (toWrite == wrote) {
-      mWriteOffset = 0;
-      mOutputQueue.pop_front();
-      Unused << mListener->OnDataSent();
-    } else {
-      mSocketOut->AsyncWait(this, 0, 0, mEventTarget);
-      return NS_OK;
-    }
-  }
-
-  return NS_OK;
-}
deleted file mode 100644
--- a/netwerk/protocol/websocket/nsWebSocketConnection.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et 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 mozilla_net_nsWebSocketConnection_h
-#define mozilla_net_nsWebSocketConnection_h
-
-#include <list>
-
-#include "nsISupports.h"
-#include "nsIStreamListener.h"
-#include "nsIAsyncInputStream.h"
-#include "nsIAsyncOutputStream.h"
-#include "nsIWebSocketConnection.h"
-
-class nsISocketTransport;
-
-namespace mozilla {
-namespace net {
-
-class nsWebSocketConnection : public nsIWebSocketConnection,
-                              public nsIInputStreamCallback,
-                              public nsIOutputStreamCallback {
- public:
-  NS_DECL_THREADSAFE_ISUPPORTS
-  NS_DECL_NSIWEBSOCKETCONNECTION
-  NS_DECL_NSIINPUTSTREAMCALLBACK
-  NS_DECL_NSIOUTPUTSTREAMCALLBACK
-
-  explicit nsWebSocketConnection(nsISocketTransport* aTransport,
-                                 nsIAsyncInputStream* aInputStream,
-                                 nsIAsyncOutputStream* aOutputStream);
-
-  nsresult EnqueueOutputData(nsTArray<uint8_t>&& aData);
-
- private:
-  virtual ~nsWebSocketConnection();
-
-  class OutputData {
-   public:
-    explicit OutputData(nsTArray<uint8_t>&& aData) : mData(std::move(aData)) {
-      MOZ_COUNT_CTOR(OutputData);
-    }
-
-    ~OutputData() { MOZ_COUNT_DTOR(OutputData); }
-
-    const nsTArray<uint8_t>& GetData() const { return mData; }
-
-   private:
-    nsTArray<uint8_t> mData;
-  };
-
-  nsCOMPtr<nsIWebSocketConnectionListener> mListener;
-  nsCOMPtr<nsISocketTransport> mTransport;
-  nsCOMPtr<nsIAsyncInputStream> mSocketIn;
-  nsCOMPtr<nsIAsyncOutputStream> mSocketOut;
-  nsCOMPtr<nsIEventTarget> mEventTarget;
-  size_t mWriteOffset;
-  std::list<OutputData> mOutputQueue;
-  bool mStartReadingCalled;
-};
-
-}  // namespace net
-}  // namespace mozilla
-
-#endif  // mozilla_net_nsWebSocketConnection_h
--- a/taskcluster/ci/test/mochitest.yml
+++ b/taskcluster/ci/test/mochitest.yml
@@ -7,17 +7,17 @@ job-defaults:
         category: mochitest
     target:
         by-test-platform:
             android-em-7.*: geckoview-androidTest.apk
             android-hw.*: geckoview-androidTest.apk
             default: null
     variants:
         by-test-platform:
-            linux.*64/debug: ['fission', 'socketprocess_networking']
+            linux.*64/debug: ['fission']
             default: ['fission']
     run-on-projects: built-projects
     fission-run-on-projects:
         by-test-platform:
             linux.*64-qr/debug: ['trunk']
             linux.*64-shippable-qr/opt: ['mozilla-central']
             linux.*64-shippable/.*: ['mozilla-central']
             linux.*64/debug: ['mozilla-central']