#include "rtc_base/async_dns_resolver.h"
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "api/make_ref_counted.h"
#include "rtc_base/logging.h"
#include "rtc_base/platform_thread.h"
#if defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
#include <dispatch/dispatch.h>
#endif
namespace webrtc {
namespace {
#ifdef __native_client__
int ResolveHostname(absl::string_view hostname,
int family,
std::vector<rtc::IPAddress>* addresses) {
RTC_DCHECK_NOTREACHED();
RTC_LOG(LS_WARNING) << "ResolveHostname() is not implemented for NaCl";
return -1;
}
#else
int ResolveHostname(absl::string_view hostname,
int family,
std::vector<rtc::IPAddress>& addresses) { … }
#endif
#if defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
void GlobalGcdRunTask(void* context) {
std::unique_ptr<absl::AnyInvocable<void() &&>> task(
static_cast<absl::AnyInvocable<void() &&>*>(context));
std::move (*task)();
}
void PostTaskToGlobalQueue(
std::unique_ptr<absl::AnyInvocable<void() &&>> task) {
dispatch_async_f(
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
task.release(), &GlobalGcdRunTask);
}
#endif
}
class AsyncDnsResolver::State : public rtc::RefCountedBase { … };
AsyncDnsResolver::AsyncDnsResolver() : … { … }
AsyncDnsResolver::~AsyncDnsResolver() { … }
void AsyncDnsResolver::Start(const rtc::SocketAddress& addr,
absl::AnyInvocable<void()> callback) { … }
void AsyncDnsResolver::Start(const rtc::SocketAddress& addr,
int family,
absl::AnyInvocable<void()> callback) { … }
const AsyncDnsResolverResult& AsyncDnsResolver::result() const { … }
bool AsyncDnsResolverResultImpl::GetResolvedAddress(
int family,
rtc::SocketAddress* addr) const { … }
int AsyncDnsResolverResultImpl::GetError() const { … }
}