chromium/third_party/webrtc/rtc_base/async_dns_resolver.cc

/*
 *  Copyright 2023 The WebRTC Project Authors. All rights reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#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   // notdef(__native_client__)
int ResolveHostname(absl::string_view hostname,
                    int family,
                    std::vector<rtc::IPAddress>& addresses) {}
#endif  // !__native_client__

// Special task posting for Mac/iOS
#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)();
}

// Post a task into the system-defined global concurrent queue.
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  // defined(WEBRTC_MAC) || defined(WEBRTC_IOS)

}  // namespace

class AsyncDnsResolver::State : public rtc::RefCountedBase {};

AsyncDnsResolver::AsyncDnsResolver() :{}

AsyncDnsResolver::~AsyncDnsResolver() {}

void AsyncDnsResolver::Start(const rtc::SocketAddress& addr,
                             absl::AnyInvocable<void()> callback) {}

// Start address resolution of the hostname in `addr` matching `family`.
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 {}

}  // namespace webrtc