#include "services/network/p2p/socket.h"
#include <utility>
#include "base/containers/span_reader.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "net/base/net_errors.h"
#include "services/network/p2p/socket_tcp.h"
#include "services/network/p2p/socket_udp.h"
#include "services/network/proxy_resolving_client_socket_factory.h"
namespace {
enum class SocketErrorCode { … };
const uint32_t kStunMagicCookie = …;
static SocketErrorCode MapNetErrorToSocketErrorCode(int net_err) { … }
}
namespace network {
P2PSocket::P2PSocket(Delegate* delegate,
mojo::PendingRemote<mojom::P2PSocketClient> client,
mojo::PendingReceiver<mojom::P2PSocket> socket,
ProtocolType protocol_type)
: … { … }
P2PSocket::~P2PSocket() = default;
bool P2PSocket::GetStunPacketType(base::span<const uint8_t> data,
StunMessageType* type) { … }
bool P2PSocket::IsRequestOrResponse(StunMessageType type) { … }
void P2PSocket::ReportSocketError(int result, const char* histogram_name) { … }
std::unique_ptr<P2PSocket> P2PSocket::Create(
Delegate* delegate,
mojo::PendingRemote<mojom::P2PSocketClient> client,
mojo::PendingReceiver<mojom::P2PSocket> socket,
P2PSocketType type,
const net::NetworkTrafficAnnotationTag& traffic_annotation,
net::NetLog* net_log,
ProxyResolvingClientSocketFactory* proxy_resolving_socket_factory,
P2PMessageThrottler* throttler,
std::optional<base::UnguessableToken> devtools_token) { … }
mojo::PendingRemote<mojom::P2PSocketClient>
P2PSocket::ReleaseClientForTesting() { … }
mojo::PendingReceiver<mojom::P2PSocket> P2PSocket::ReleaseReceiverForTesting() { … }
void P2PSocket::OnError() { … }
}