#include "chrome/browser/media/router/providers/cast/cast_app_discovery_service.h"
#include "base/functional/bind.h"
#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/tick_clock.h"
#include "chrome/browser/media/router/providers/cast/cast_media_route_provider_metrics.h"
#include "components/media_router/common/providers/cast/channel/cast_message_handler.h"
#include "components/media_router/common/providers/cast/channel/cast_socket.h"
#include "components/media_router/common/providers/cast/channel/cast_socket_service.h"
namespace media_router {
namespace {
constexpr char kLoggerComponent[] = …;
static constexpr base::TimeDelta kRefreshThreshold = …;
}
CastAppDiscoveryServiceImpl::CastAppDiscoveryServiceImpl(
cast_channel::CastMessageHandler* message_handler,
cast_channel::CastSocketService* socket_service,
MediaSinkServiceBase* media_sink_service,
const base::TickClock* clock)
: … { … }
CastAppDiscoveryServiceImpl::~CastAppDiscoveryServiceImpl() { … }
base::CallbackListSubscription
CastAppDiscoveryServiceImpl::StartObservingMediaSinks(
const CastMediaSource& source,
const SinkQueryCallback& callback) { … }
void CastAppDiscoveryServiceImpl::Refresh() { … }
scoped_refptr<base::SequencedTaskRunner>
CastAppDiscoveryServiceImpl::task_runner() { … }
void CastAppDiscoveryServiceImpl::MaybeRemoveSinkQueryEntry(
const CastMediaSource& source) { … }
void CastAppDiscoveryServiceImpl::Init() { … }
void CastAppDiscoveryServiceImpl::OnSinkAddedOrUpdated(
const MediaSinkInternal& sink) { … }
void CastAppDiscoveryServiceImpl::OnSinkRemoved(const MediaSinkInternal& sink) { … }
void CastAppDiscoveryServiceImpl::RequestAppAvailability(
cast_channel::CastSocket* socket,
const std::string& app_id,
const MediaSinkInternal& sink) { … }
void CastAppDiscoveryServiceImpl::UpdateAppAvailability(
base::TimeTicks start_time,
const MediaSinkInternal& sink,
const std::string& app_id,
cast_channel::GetAppAvailabilityResult availability) { … }
void CastAppDiscoveryServiceImpl::UpdateSinkQueries(
const std::vector<CastMediaSource>& sources) { … }
std::vector<MediaSinkInternal> CastAppDiscoveryServiceImpl::GetSinksByIds(
const base::flat_set<MediaSink::Id>& sink_ids) const { … }
bool CastAppDiscoveryServiceImpl::ShouldRefreshAppAvailability(
const MediaSink::Id& sink_id,
const std::string& app_id,
base::TimeTicks now) const { … }
}