tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

WebTransportChild.cpp (2442B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "mozilla/dom/WebTransportChild.h"
      8 
      9 #include "mozilla/dom/WebTransport.h"
     10 #include "mozilla/dom/WebTransportLog.h"
     11 
     12 namespace mozilla::dom {
     13 
     14 void WebTransportChild::Shutdown(bool aClose) {
     15  LOG(("WebTransportChild::Shutdown() for %p (%p)", this, mTransport));
     16  mTransport = nullptr;
     17  if (!aClose || !CanSend()) {
     18    return;
     19  }
     20 
     21  Close();
     22 }
     23 
     24 void WebTransportChild::CloseAll() {
     25  // XXX need impl
     26 }
     27 
     28 ::mozilla::ipc::IPCResult WebTransportChild::RecvCloseAll(
     29    CloseAllResolver&& aResolver) {
     30  CloseAll();
     31  aResolver(NS_OK);
     32  return IPC_OK();
     33 }
     34 
     35 ::mozilla::ipc::IPCResult WebTransportChild::RecvRemoteClosed(
     36    const bool& aCleanly, const uint32_t& aCode, const nsACString& aReason) {
     37  if (mTransport) {
     38    RefPtr<WebTransport> self(mTransport);
     39    self->RemoteClosed(aCleanly, aCode, aReason);
     40  }
     41  return IPC_OK();
     42 }
     43 
     44 ::mozilla::ipc::IPCResult WebTransportChild::RecvIncomingBidirectionalStream(
     45    const uint64_t& aStreamId, const RefPtr<DataPipeReceiver>& aIncoming,
     46    const RefPtr<DataPipeSender>& aOutgoing) {
     47  if (mTransport) {
     48    RefPtr<WebTransport> self(mTransport);
     49    self->NewBidirectionalStream(aStreamId, aIncoming, aOutgoing);
     50  }
     51  return IPC_OK();
     52 }
     53 
     54 ::mozilla::ipc::IPCResult WebTransportChild::RecvIncomingUnidirectionalStream(
     55    const uint64_t& aStreamId, const RefPtr<DataPipeReceiver>& aStream) {
     56  if (mTransport) {
     57    RefPtr<WebTransport> self(mTransport);
     58    self->NewUnidirectionalStream(aStreamId, aStream);
     59  }
     60  return IPC_OK();
     61 }
     62 
     63 ::mozilla::ipc::IPCResult WebTransportChild::RecvIncomingDatagram(
     64    nsTArray<uint8_t>&& aData, const TimeStamp& aRecvTimeStamp) {
     65  if (mTransport) {
     66    RefPtr<WebTransport> self(mTransport);
     67    self->NewDatagramReceived(std::move(aData), aRecvTimeStamp);
     68  }
     69  return IPC_OK();
     70 }
     71 
     72 ::mozilla::ipc::IPCResult WebTransportChild::RecvOnStreamResetOrStopSending(
     73    const uint64_t& aStreamId, const StreamResetOrStopSendingError& aError) {
     74  if (mTransport) {
     75    RefPtr<WebTransport> self(mTransport);
     76    self->OnStreamResetOrStopSending(aStreamId, aError);
     77  }
     78  return IPC_OK();
     79 }
     80 
     81 }  // namespace mozilla::dom