chromium/remoting/protocol/jingle_session.cc

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

#include "remoting/protocol/jingle_session.h"

#include <stdint.h>

#include <limits>
#include <memory>
#include <utility>

#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_split.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "remoting/base/constants.h"
#include "remoting/protocol/authenticator.h"
#include "remoting/protocol/content_description.h"
#include "remoting/protocol/errors.h"
#include "remoting/protocol/jingle_messages.h"
#include "remoting/protocol/jingle_session_manager.h"
#include "remoting/protocol/session_config.h"
#include "remoting/protocol/session_observer.h"
#include "remoting/protocol/session_plugin.h"
#include "remoting/protocol/transport.h"
#include "remoting/signaling/iq_sender.h"
#include "remoting/signaling/xmpp_constants.h"
#include "third_party/libjingle_xmpp/xmllite/xmlelement.h"
#include "third_party/webrtc/api/candidate.h"

XmlElement;

namespace remoting::protocol {

namespace {

// Timeouts have been temporarily increased for testing.
// TODO(rkjnsn): Revert default and session timeouts once done with testing.

// How long we should wait for a response from the other end. This value is used
// for all requests except |transport-info|.
// const int kDefaultMessageTimeout = 10;
const int kDefaultMessageTimeout =;  // For testing

// During a reconnection, it usually takes longer for the peer to respond due to
// pending messages in the channel from the previous session.  From experiment,
// it can take up to 20s for the session to reconnect. To make it safe, setting
// the timeout to 30s.
// const int kSessionInitiateAndAcceptTimeout = kDefaultMessageTimeout * 3;
const int kSessionInitiateAndAcceptTimeout =;  // For testing

// Timeout for the transport-info messages.
const int kTransportInfoTimeout =;

// Special value for an invalid sequential ID for an incoming IQ.
const int kInvalid =;

// Special value indicating that any sequential ID is valid for the next
// incoming IQ.
const int kAny =;

ErrorCode AuthRejectionReasonToErrorCode(
    Authenticator::RejectionReason reason) {}

// Extracts a sequential id from the id attribute of the IQ stanza.
int GetSequentialId(const std::string& id) {}

}  // namespace

// A Queue that sorts incoming messages and returns them in the ascending order
// of sequence ids. The sequence id can be extracted from the ID attribute of
// an IQ stanza, which have the following format <opaque_string>_<sequence_id>.
//
// Background:
// The chromoting signaling channel does not guarantee that the incoming IQs are
// delivered in the order that it is sent.
//
// This behavior leads to transient session setup failures.  For instance,
// a <transport-info> that is sent after a <session-info> message is sometimes
// delivered to the client out of order, causing the client to close the
// session due to an unexpected request.
class JingleSession::OrderedMessageQueue {};

std::vector<JingleSession::PendingMessage>
JingleSession::OrderedMessageQueue::OnIncomingMessage(
    const std::string& id,
    JingleSession::PendingMessage&& message) {}

void JingleSession::OrderedMessageQueue::SetInitialId(const std::string& id) {}

JingleSession::PendingMessage::PendingMessage() = default;
JingleSession::PendingMessage::PendingMessage(PendingMessage&& moved) = default;
JingleSession::PendingMessage::PendingMessage(
    std::unique_ptr<JingleMessage> message,
    ReplyCallback reply_callback)
    :{}
JingleSession::PendingMessage::~PendingMessage() = default;

JingleSession::PendingMessage& JingleSession::PendingMessage::operator=(
    PendingMessage&& moved) = default;

JingleSession::JingleSession(JingleSessionManager* session_manager)
    :{}

JingleSession::~JingleSession() {}

void JingleSession::SetEventHandler(Session::EventHandler* event_handler) {}

ErrorCode JingleSession::error() const {}

void JingleSession::StartConnection(
    const SignalingAddress& peer_address,
    std::unique_ptr<Authenticator> authenticator) {}

void JingleSession::InitializeIncomingConnection(
    const std::string& message_id,
    const JingleMessage& initiate_message,
    std::unique_ptr<Authenticator> authenticator) {}

void JingleSession::AcceptIncomingConnection(
    const JingleMessage& initiate_message) {}

void JingleSession::ContinueAcceptIncomingConnection() {}

const std::string& JingleSession::jid() {}

const SessionConfig& JingleSession::config() {}

const Authenticator& JingleSession::authenticator() const {}

void JingleSession::SetTransport(Transport* transport) {}

void JingleSession::SendTransportInfo(
    std::unique_ptr<jingle_xmpp::XmlElement> transport_info) {}

void JingleSession::Close(protocol::ErrorCode error) {}

void JingleSession::AddPlugin(SessionPlugin* plugin) {}

void JingleSession::SendMessage(std::unique_ptr<JingleMessage> message) {}

void JingleSession::OnMessageResponse(JingleMessage::ActionType request_type,
                                      IqRequest* request,
                                      const jingle_xmpp::XmlElement* response) {}

void JingleSession::OnTransportInfoResponse(
    IqRequest* request,
    const jingle_xmpp::XmlElement* response) {}

void JingleSession::OnIncomingMessage(const std::string& id,
                                      std::unique_ptr<JingleMessage> message,
                                      ReplyCallback reply_callback) {}

void JingleSession::ProcessIncomingMessage(
    std::unique_ptr<JingleMessage> message,
    ReplyCallback reply_callback) {}

void JingleSession::OnAccept(std::unique_ptr<JingleMessage> message,
                             ReplyCallback reply_callback) {}

void JingleSession::OnSessionInfo(std::unique_ptr<JingleMessage> message,
                                  ReplyCallback reply_callback) {}

void JingleSession::OnTransportInfo(std::unique_ptr<JingleMessage> message,
                                    ReplyCallback reply_callback) {}

void JingleSession::OnTerminate(std::unique_ptr<JingleMessage> message,
                                ReplyCallback reply_callback) {}

void JingleSession::OnAuthenticatorStateChangeAfterAccepted() {}

bool JingleSession::InitializeConfigFromDescription(
    const ContentDescription* description) {}

void JingleSession::ProcessAuthenticationStep() {}

void JingleSession::OnAuthenticated() {}

void JingleSession::SetState(State new_state) {}

bool JingleSession::is_session_active() {}

void JingleSession::ProcessIncomingPluginMessage(const JingleMessage& message) {}

void JingleSession::AddPluginAttachments(JingleMessage* message) {}

void JingleSession::SendSessionInitiateMessage() {}

std::string JingleSession::GetNextOutgoingId() {}

}  // namespace remoting::protocol