chromium/components/media_router/common/providers/cast/channel/cast_message_handler.h

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

#ifndef COMPONENTS_MEDIA_ROUTER_COMMON_PROVIDERS_CAST_CHANNEL_CAST_MESSAGE_HANDLER_H_
#define COMPONENTS_MEDIA_ROUTER_COMMON_PROVIDERS_CAST_CHANNEL_CAST_MESSAGE_HANDLER_H_

#include <optional>
#include <string_view>

#include "base/callback_list.h"
#include "base/containers/flat_map.h"
#include "base/containers/flat_set.h"
#include "base/gtest_prod_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/observer_list_types.h"
#include "base/sequence_checker.h"
#include "base/time/tick_clock.h"
#include "base/timer/timer.h"
#include "base/token.h"
#include "base/values.h"
#include "components/media_router/common/providers/cast/channel/cast_message_util.h"
#include "components/media_router/common/providers/cast/channel/cast_socket.h"
#include "services/data_decoder/public/cpp/data_decoder.h"

namespace cast_channel {

class CastSocketService;

template <typename CallbackType>
struct PendingRequest {};

// |app_id|: ID of app the result is for.
// |result|: Availability result from the receiver.
GetAppAvailabilityCallback;

// Represents an app availability request to a Cast sink.
struct GetAppAvailabilityRequest
    : public PendingRequest<GetAppAvailabilityCallback> {};

struct LaunchSessionCallbackWrapper;

// Represents an app launch request to a Cast sink.
// The callback sets `out_callback` if launch handling is not done and we're
// expecting another launch response from the receiver that we'd need to handle.
// `out_callback` is not set if the caller is certain that no more launch
// response handling is needed (alternatively we could guarantee that it's not
// null, but that'd require more boilerplate code).
// We need to use an output parameter instead of a return value because we
// cannot bind a weak_ptr to a function with a return value.
// We need a wrapper struct because LaunchSessionCallback's definition cannot
// depend on itself.
LaunchSessionCallback;
LaunchSessionRequest;

struct LaunchSessionCallbackWrapper {};

enum class Result {};
ResultCallback;

// Represents an app stop request to a Cast sink.
StopSessionRequest;

// Reresents request for a sink to set its volume level.
SetVolumeRequest;

// Represents a virtual connection on a cast channel. A virtual connection is
// given by a source and destination ID pair, and must be created before
// messages can be sent. Virtual connections are managed by CastMessageHandler.
struct VirtualConnection {};

struct InternalMessage {};

// Default timeout amount for requests waiting for a response.
constexpr base::TimeDelta kRequestTimeout =;

// Handles messages that are sent between this browser instance and the Cast
// devices connected to it. This class also manages virtual connections (VCs)
// with each connected Cast device and ensures a proper VC exists before the
// message is sent. This makes the concept of VC transparent to the client.
// This class may be created on any sequence, but other methods (including
// destructor) must be run on the same sequence that CastSocketService runs on.
class CastMessageHandler : public CastSocket::Observer {};

}  // namespace cast_channel

#endif  // COMPONENTS_MEDIA_ROUTER_COMMON_PROVIDERS_CAST_CHANNEL_CAST_MESSAGE_HANDLER_H_