Autogenerated with:
cp dom/.clang-format netwerk/ && mach format netwerk/**.{cpp,h,mm}
Manual fixes:
* mozurl/cbindgen.toml (including headers earlier)
* NetlinkService.h (forward-declaring a necessary struct)
* nsIWebSocketChannel.idl (forward-declaring OriginAttributes).
* nsAsyncRedirectVerifyHelper.h (forward-declaring nsIEventTarget)
* CapsuleEncoder.h gets a missing Capsule forward-decl.
* WebSocketConnectionBase.h gets some missing includes.
* HappyEyeballsConnectionAttempt gets some missing includes.
* nsUDPSocket missed nsSocketTransportService2.h for OnSocketThread().
* HttpInfo missed a forward declaration.
* MockHttpAuth missed an nsCOMPtr include.
* nsHttpAuthManager missed a forward declaration for nsIHttpAuthCache.
* WebTransportSessionProxy was using mozilla::Mutex in a member without
including it.
* win32 fixes to keep include order because windows headers suck.
* nsInputStreamPump needs an Atomics.h include.
Differential Revision: https://phabricator.services.mozilla.com/D311696
86 lines
4.3 KiB
C++
86 lines
4.3 KiB
C++
/* 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_WebSocketConnectionBase_h
|
|
#define mozilla_net_WebSocketConnectionBase_h
|
|
|
|
// Architecture view:
|
|
// Parent Process Socket Process
|
|
// ┌─────────────────┐ IPC ┌────────────────────────┐
|
|
// │ WebSocketChannel│ ┌─────►WebSocketConnectionChild│
|
|
// └─────────┬───────┘ │ └─────────┬──────────────┘
|
|
// │ │ │
|
|
// ┌──────────▼───────────────┐ │ ┌─────────▼─────────┐
|
|
// │ WebSocketConnectionParent├──┘ │WebSocketConnection│
|
|
// └──────────────────────────┘ └─────────┬─────────┘
|
|
// │
|
|
// ┌─────────▼─────────┐
|
|
// │ nsSocketTransport │
|
|
// └───────────────────┘
|
|
// The main reason that we need WebSocketConnectionBase is that we need to
|
|
// encapsulate nsSockTransport, nsSocketOutoutStream, and nsSocketInputStream.
|
|
// These three objects only live in socket process, so we provide the necessary
|
|
// interfaces in WebSocketConnectionBase and WebSocketConnectionListener for
|
|
// reading/writing the real socket.
|
|
//
|
|
// The output path when WebSocketChannel wants to write data to socket:
|
|
// - WebSocketConnectionParent::WriteOutputData
|
|
// - WebSocketConnectionParent::SendWriteOutputData
|
|
// - WebSocketConnectionChild::RecvWriteOutputData
|
|
// - WebSocketConnection::WriteOutputData
|
|
// - WebSocketConnection::OnOutputStreamReady (writes data to the real socket)
|
|
//
|
|
// The input path when data is able to read from the socket
|
|
// - WebSocketConnection::OnInputStreamReady
|
|
// - WebSocketConnectionChild::OnDataReceived
|
|
// - WebSocketConnectionChild::SendOnDataReceived
|
|
// - WebSocketConnectionParent::RecvOnDataReceived
|
|
// - WebSocketChannel::OnDataReceived
|
|
//
|
|
// The path that WebSocketConnection is constructed.
|
|
// - nsHttpChannel::OnStopRequest
|
|
// - HttpConnectionMgrShell::CompleteUpgrade
|
|
// - HttpConnectionMgrParent::CompleteUpgrade (we store the
|
|
// nsIHttpUpgradeListener in a table and send an id to socket process)
|
|
// - HttpConnectionMgrParent::SendStartWebSocketConnection
|
|
// - HttpConnectionMgrChild::RecvStartWebSocketConnection (the listener id is
|
|
// saved in WebSocketConnectionChild and will be used when the socket
|
|
// transport is available)
|
|
// - WebSocketConnectionChild::Init (an IPC channel between socket thread in
|
|
// socket process and background thread in parent process is created)
|
|
// - nsHttpConnectionMgr::CompleteUpgrade
|
|
// - WebSocketConnectionChild::OnTransportAvailable (WebSocketConnection is
|
|
// created)
|
|
// - WebSocketConnectionChild::SendOnTransportAvailable
|
|
// - WebSocketConnectionParent::RecvOnTransportAvailable
|
|
// - WebSocketChannel::OnWebSocketConnectionAvailable
|
|
|
|
#include "nsISupports.h"
|
|
|
|
class nsITransportSecurityInfo;
|
|
class nsIEventTarget;
|
|
|
|
namespace mozilla::net {
|
|
|
|
class WebSocketConnectionListener;
|
|
|
|
class WebSocketConnectionBase : public nsISupports {
|
|
public:
|
|
virtual nsresult Init(WebSocketConnectionListener* aListener) = 0;
|
|
virtual void GetIoTarget(nsIEventTarget** aTarget) = 0;
|
|
virtual void Close() = 0;
|
|
virtual nsresult WriteOutputData(const uint8_t* aHdrBuf,
|
|
uint32_t aHdrBufLength,
|
|
const uint8_t* aPayloadBuf,
|
|
uint32_t aPayloadBufLength) = 0;
|
|
virtual nsresult StartReading() = 0;
|
|
virtual void DrainSocketData() = 0;
|
|
virtual nsresult GetSecurityInfo(
|
|
nsITransportSecurityInfo** aSecurityInfo) = 0;
|
|
};
|
|
|
|
} // namespace mozilla::net
|
|
|
|
#endif // mozilla_net_WebSocketConnectionBase_h
|