chromium/components/media_router/common/providers/cast/channel/cast_socket.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/media_router/common/providers/cast/channel/cast_socket.h"

#include <stdlib.h>
#include <string.h>

#include <memory>
#include <utility>

#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/numerics/safe_conversions.h"
#include "base/observer_list.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "components/media_router/common/providers/cast/channel/cast_auth_util.h"
#include "components/media_router/common/providers/cast/channel/cast_framer.h"
#include "components/media_router/common/providers/cast/channel/cast_message_util.h"
#include "components/media_router/common/providers/cast/channel/cast_transport.h"
#include "components/media_router/common/providers/cast/channel/keep_alive_delegate.h"
#include "components/media_router/common/providers/cast/channel/logger.h"
#include "components/media_router/common/providers/cast/channel/mojo_data_pump.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "net/base/address_list.h"
#include "net/base/host_port_pair.h"
#include "net/base/net_errors.h"
#include "net/ssl/ssl_info.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "third_party/openscreen/src/cast/common/channel/proto/cast_channel.pb.h"

// Helper for logging data with remote host IP and authentication state.
// Assumes |ip_endpoint_| of type net::IPEndPoint and |channel_auth_| of enum
// type ChannelAuthType are available in the current scope.
#define CONNECTION_INFO()
#define VLOG_WITH_CONNECTION
#define LOG_WITH_CONNECTION(level)

namespace cast_channel {
namespace {

bool IsTerminalState(ConnectionState state) {}

void OnConnected(
    network::mojom::NetworkContext::CreateTCPConnectedSocketCallback callback,
    int result,
    const std::optional<net::IPEndPoint>& local_addr,
    const std::optional<net::IPEndPoint>& peer_addr,
    mojo::ScopedDataPipeConsumerHandle receive_stream,
    mojo::ScopedDataPipeProducerHandle send_stream) {}

void ConnectOnUIThread(
    network::NetworkContextGetter network_context_getter,
    const net::AddressList& remote_address_list,
    mojo::PendingReceiver<network::mojom::TCPConnectedSocket> receiver,
    network::mojom::NetworkContext::CreateTCPConnectedSocketCallback callback) {}

}  // namespace

CastSocket::Observer::~Observer() {}

CastSocketImpl::CastSocketImpl(
    network::NetworkContextGetter network_context_getter,
    const CastSocketOpenParams& open_params,
    const scoped_refptr<Logger>& logger)
    :{}

CastSocketImpl::CastSocketImpl(
    network::NetworkContextGetter network_context_getter,
    const CastSocketOpenParams& open_params,
    const scoped_refptr<Logger>& logger,
    const AuthContext& auth_context)
    :{}

CastSocketImpl::~CastSocketImpl() {}

ReadyState CastSocketImpl::ready_state() const {}

ChannelError CastSocketImpl::error_state() const {}

CastChannelFlags CastSocketImpl::flags() const {}

const net::IPEndPoint& CastSocketImpl::ip_endpoint() const {}

int CastSocketImpl::id() const {}

void CastSocketImpl::set_id(int id) {}

bool CastSocketImpl::keep_alive() const {}

bool CastSocketImpl::audio_only() const {}

bool CastSocketImpl::VerifyChannelPolicy(const AuthResult& result) {}

bool CastSocketImpl::VerifyChallengeReply() {}

void CastSocketImpl::SetTransportForTesting(
    std::unique_ptr<CastTransport> transport) {}

void CastSocketImpl::SetPeerCertForTesting(
    scoped_refptr<net::X509Certificate> peer_cert) {}

void CastSocketImpl::Connect(OnOpenCallback callback) {}

void CastSocketImpl::Connect() {}

CastTransport* CastSocketImpl::transport() const {}

void CastSocketImpl::AddObserver(Observer* observer) {}

void CastSocketImpl::RemoveObserver(Observer* observer) {}

net::NetworkTrafficAnnotationTag
CastSocketImpl::GetNetworkTrafficAnnotationTag() {}

void CastSocketImpl::OnConnectTimeout() {}

void CastSocketImpl::ResetConnectLoopCallback() {}

void CastSocketImpl::PostTaskToStartConnectLoop(int result) {}

// This method performs the state machine transitions for connection flow.
// There are two entry points to this method:
// 1. Connect method: this starts the flow
// 2. Callback from network operations that finish asynchronously.
void CastSocketImpl::DoConnectLoop(int result) {}

int CastSocketImpl::DoTcpConnect() {}

int CastSocketImpl::DoTcpConnectComplete(int connect_result) {}

int CastSocketImpl::DoSslConnect() {}

int CastSocketImpl::DoSslConnectComplete(int result) {}

int CastSocketImpl::DoAuthChallengeSend() {}

int CastSocketImpl::DoAuthChallengeSendComplete(int result) {}

CastSocketImpl::AuthTransportDelegate::AuthTransportDelegate(
    CastSocketImpl* socket)
    :{}

ChannelError CastSocketImpl::AuthTransportDelegate::error_state() const {}

LastError CastSocketImpl::AuthTransportDelegate::last_error() const {}

void CastSocketImpl::AuthTransportDelegate::OnError(ChannelError error_state) {}

void CastSocketImpl::AuthTransportDelegate::OnMessage(
    const CastMessage& message) {}

void CastSocketImpl::AuthTransportDelegate::Start() {}

int CastSocketImpl::DoAuthChallengeReplyComplete(int result) {}

void CastSocketImpl::OnConnect(
    int result,
    const std::optional<net::IPEndPoint>& local_addr,
    const std::optional<net::IPEndPoint>& peer_addr,
    mojo::ScopedDataPipeConsumerHandle receive_stream,
    mojo::ScopedDataPipeProducerHandle send_stream) {}

void CastSocketImpl::OnUpgradeToTLS(
    int result,
    mojo::ScopedDataPipeConsumerHandle receive_stream,
    mojo::ScopedDataPipeProducerHandle send_stream,
    const std::optional<net::SSLInfo>& ssl_info) {}

void CastSocketImpl::DoConnectCallback() {}

void CastSocketImpl::Close(net::CompletionOnceCallback callback) {}

void CastSocketImpl::CloseInternal() {}

base::OneShotTimer* CastSocketImpl::GetTimer() {}

void CastSocketImpl::SetConnectState(ConnectionState connect_state) {}

void CastSocketImpl::SetReadyState(ReadyState ready_state) {}

void CastSocketImpl::SetErrorState(ChannelError error_state) {}

CastSocketImpl::CastSocketMessageDelegate::CastSocketMessageDelegate(
    CastSocketImpl* socket)
    :{}

CastSocketImpl::CastSocketMessageDelegate::~CastSocketMessageDelegate() {}

// CastTransport::Delegate implementation.
void CastSocketImpl::CastSocketMessageDelegate::OnError(
    ChannelError error_state) {}

void CastSocketImpl::CastSocketMessageDelegate::OnMessage(
    const CastMessage& message) {}

void CastSocketImpl::CastSocketMessageDelegate::Start() {}

CastSocketOpenParams::CastSocketOpenParams(const net::IPEndPoint& ip_endpoint,
                                           base::TimeDelta connect_timeout)
    :{}

CastSocketOpenParams::CastSocketOpenParams(
    const net::IPEndPoint& ip_endpoint,
    base::TimeDelta connect_timeout,
    base::TimeDelta liveness_timeout,
    base::TimeDelta ping_interval,
    CastDeviceCapabilitySet device_capabilities)
    :{}

}  // namespace cast_channel
#undef VLOG_WITH_CONNECTION