/* 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 PSocketProcess;
include protocol PInputChannelThrottleQueue;

include IPCStream;
include NeckoChannelParams;

include "mozilla/ipc/TransportSecurityInfoUtils.h";
include "mozilla/net/NeckoMessageUtils.h";
include "mozilla/net/ClassOfService.h";

using class mozilla::net::nsHttpRequestHead from "nsHttpRequestHead.h";
using class mozilla::net::nsHttpHeaderArray from "nsHttpHeaderArray.h";
using mozilla::net::NetAddr from "mozilla/net/DNS.h";
using mozilla::net::ClassOfService from "mozilla/net/ClassOfService.h";
[RefCounted] using class nsITransportSecurityInfo from "nsITransportSecurityInfo.h";
using mozilla::net::TRRSkippedReason from "nsITRRSkipReason.h";
using nsIRequest::TRRMode from "nsIRequest.h";
using nsILoadInfo::IPAddressSpace from "nsILoadInfo.h";
using struct mozilla::net::LNAPerms from "mozilla/net/HttpTransactionShell.h";
using mozilla::net::HttpTrafficCategory from "mozilla/net/HttpTrafficAnalyzer.h";

namespace mozilla {
namespace net {

struct NetworkAddressArg {
  NetAddr selfAddr;
  NetAddr peerAddr;
  bool resolvedByTRR;
  TRRMode mode;
  TRRSkippedReason trrSkipReason;
  bool echConfigUsed;
};

protocol PHttpTransaction
{
  manager PSocketProcess;

parent:
  async OnStartRequest(nsresult                            status,
                       nsHttpResponseHead?                 responseHead,
                       nullable nsITransportSecurityInfo   securityInfo,
                       bool                                proxyConnectFailed,
                       TimingStructArgs                    timings,
                       nsHttpResponseHead?                 proxyConnectResponseHead,
                       uint8_t[]                           dataForSniffer,
                       nsCString?                          altSvcUsed,
                       bool                                dataToChildProcess,
                       bool                                restarted,
                       uint32_t                            HTTPSSVCReceivedStage,
                       bool                                supportsHttp3,
                       TRRMode trrMode,
                       TRRSkippedReason trrSkipReason,
                       uint32_t caps,
                       TimeStamp onStartRequestStart,
                       HttpConnectionInfoCloneArgs connInfoArgs, IPAddressSpace targetIpAddressSpace);
  async OnTransportStatus(nsresult status,
                          int64_t progress,
                          int64_t progressMax,
                          NetworkAddressArg? networkAddressArg);
  async OnDataAvailable(nsCString data,
                        uint64_t  offset,
                        TimeStamp onDataAvailableStart);
  async OnStopRequest(nsresult status,
                      bool responseIsComplete,
                      int64_t transferSize,
                      TimingStructArgs timings,
                      nsHttpHeaderArray? responseTrailers,
                      TransactionObserverResult? transactionObserverResult,
                      TimeStamp lastActiveTabOptimization,
                      TimeStamp onStopRequestStart);
  async OnInitFailed(nsresult status);
  async EarlyHint(nsCString linkHeader, nsCString referrerPolicy, nsCString cspHeader);

child:
  async __delete__();
  async Init(uint32_t caps,
             HttpConnectionInfoCloneArgs aArgs,
             nsHttpRequestHead reqHeaders,
             IPCStream? requestBody,
             uint64_t reqContentLength,
             uint64_t topLevelOuterContentWindowId,
             HttpTrafficCategory httpTrafficCategory,
             uint64_t requestContextID,
             ClassOfService classOfService,
             uint32_t initialRwin,
             bool responseTimeoutEnabled,
             uint64_t channelId,
             bool hasTransactionObserver,
             PInputChannelThrottleQueue? throttleQueue,
             bool aIsDocumentLoad,
             IPAddressSpace aParentIPAddressSpace,
             LNAPerms aLnaPermissionStatus,
             TimeStamp aRedirectStart,
             TimeStamp aRedirectEnd);

  async CancelPump(nsresult status);
  async SuspendPump();
  async ResumePump();

  async SetDNSWasRefreshed();
  async DontReuseConnection();
  async SetH2WSConnRefTaken();
};

} // namespace net
} // namespace mozilla
