#include <memory>
#include <utility>
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/notreached.h"
#include "base/task/single_thread_task_runner.h"
#include "chrome/browser/local_discovery/service_discovery_client_impl.h"
#include "net/dns/public/dns_protocol.h"
#include "net/dns/record_rdata.h"
namespace local_discovery {
namespace {
const int kLocalDomainSecondAddressTimeoutMs = …;
const int kInitialRequeryTimeSeconds = …;
const int kMaxRequeryTimeSeconds = …;
}
ServiceDiscoveryClientImpl::ServiceDiscoveryClientImpl(
net::MDnsClient* mdns_client) : … { … }
ServiceDiscoveryClientImpl::~ServiceDiscoveryClientImpl() { … }
std::unique_ptr<ServiceWatcher>
ServiceDiscoveryClientImpl::CreateServiceWatcher(
const std::string& service_type,
ServiceWatcher::UpdatedCallback callback) { … }
std::unique_ptr<ServiceResolver>
ServiceDiscoveryClientImpl::CreateServiceResolver(
const std::string& service_name,
ServiceResolver::ResolveCompleteCallback callback) { … }
std::unique_ptr<LocalDomainResolver>
ServiceDiscoveryClientImpl::CreateLocalDomainResolver(
const std::string& domain,
net::AddressFamily address_family,
LocalDomainResolver::IPAddressCallback callback) { … }
ServiceWatcherImpl::ServiceWatcherImpl(const std::string& service_type,
ServiceWatcher::UpdatedCallback callback,
net::MDnsClient* mdns_client)
: … { … }
void ServiceWatcherImpl::Start() { … }
ServiceWatcherImpl::~ServiceWatcherImpl() { … }
void ServiceWatcherImpl::DiscoverNewServices() { … }
void ServiceWatcherImpl::SetActivelyRefreshServices(
bool actively_refresh_services) { … }
void ServiceWatcherImpl::ReadCachedServices() { … }
bool ServiceWatcherImpl::CreateTransaction(
bool network,
bool cache,
std::unique_ptr<net::MDnsTransaction>* transaction) { … }
std::string ServiceWatcherImpl::GetServiceType() const { … }
void ServiceWatcherImpl::OnRecordUpdate(
net::MDnsListener::UpdateType update,
const net::RecordParsed* record) { … }
void ServiceWatcherImpl::OnCachePurged() { … }
void ServiceWatcherImpl::OnTransactionResponse(
std::unique_ptr<net::MDnsTransaction>* transaction,
net::MDnsTransaction::Result result,
const net::RecordParsed* record) { … }
ServiceWatcherImpl::ServiceListeners::ServiceListeners(
const std::string& service_name,
ServiceWatcherImpl* watcher,
net::MDnsClient* mdns_client)
: … { … }
ServiceWatcherImpl::ServiceListeners::~ServiceListeners() { … }
bool ServiceWatcherImpl::ServiceListeners::Start() { … }
void ServiceWatcherImpl::ServiceListeners::SetActiveRefresh(
bool active_refresh) { … }
void ServiceWatcherImpl::ServiceListeners::OnSRVRecord(
net::MDnsTransaction::Result result,
const net::RecordParsed* record) { … }
void ServiceWatcherImpl::ServiceListeners::set_has_srv(bool has_srv) { … }
void ServiceWatcherImpl::AddService(const std::string& service) { … }
void ServiceWatcherImpl::AddSRV(const std::string& service) { … }
void ServiceWatcherImpl::DeferUpdate(ServiceWatcher::UpdateType update_type,
const std::string& service_name) { … }
void ServiceWatcherImpl::DeliverDeferredUpdate(
ServiceWatcher::UpdateType update_type, const std::string& service_name) { … }
void ServiceWatcherImpl::RemovePTR(const std::string& service) { … }
void ServiceWatcherImpl::RemoveSRV(const std::string& service) { … }
void ServiceWatcherImpl::OnNsecRecord(const std::string& name,
unsigned rrtype) { … }
void ServiceWatcherImpl::ScheduleQuery(int timeout_seconds) { … }
void ServiceWatcherImpl::SendQuery(int next_timeout_seconds) { … }
ServiceResolverImpl::ServiceResolverImpl(const std::string& service_name,
ResolveCompleteCallback callback,
net::MDnsClient* mdns_client)
: … { … }
void ServiceResolverImpl::StartResolving() { … }
ServiceResolverImpl::~ServiceResolverImpl() { … }
bool ServiceResolverImpl::CreateTxtTransaction() { … }
void ServiceResolverImpl::CreateATransaction() { … }
bool ServiceResolverImpl::CreateSrvTransaction() { … }
std::string ServiceResolverImpl::GetName() const { … }
void ServiceResolverImpl::SrvRecordTransactionResponse(
net::MDnsTransaction::Result status, const net::RecordParsed* record) { … }
void ServiceResolverImpl::TxtRecordTransactionResponse(
net::MDnsTransaction::Result status, const net::RecordParsed* record) { … }
void ServiceResolverImpl::ARecordTransactionResponse(
net::MDnsTransaction::Result status, const net::RecordParsed* record) { … }
void ServiceResolverImpl::AlertCallbackIfReady() { … }
void ServiceResolverImpl::ServiceNotFound(
ServiceResolver::RequestStatus status) { … }
ServiceResolver::RequestStatus ServiceResolverImpl::MDnsStatusToRequestStatus(
net::MDnsTransaction::Result status) const { … }
const std::vector<std::string>& ServiceResolverImpl::RecordToMetadata(
const net::RecordParsed* record) const { … }
net::HostPortPair ServiceResolverImpl::RecordToAddress(
const net::RecordParsed* record) const { … }
net::IPAddress ServiceResolverImpl::RecordToIPAddress(
const net::RecordParsed* record) const { … }
LocalDomainResolverImpl::LocalDomainResolverImpl(
const std::string& domain,
net::AddressFamily address_family,
IPAddressCallback callback,
net::MDnsClient* mdns_client)
: … { … }
LocalDomainResolverImpl::~LocalDomainResolverImpl() { … }
void LocalDomainResolverImpl::Start() { … }
std::unique_ptr<net::MDnsTransaction>
LocalDomainResolverImpl::CreateTransaction(uint16_t type) { … }
void LocalDomainResolverImpl::OnTransactionComplete(
net::MDnsTransaction::Result result, const net::RecordParsed* record) { … }
bool LocalDomainResolverImpl::IsSuccess() { … }
void LocalDomainResolverImpl::SendResolvedAddresses() { … }
}