// Copyright 2023 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef SERVICES_NETWORK_PUBLIC_CPP_SIMPLE_HOST_RESOLVER_H_ #define SERVICES_NETWORK_PUBLIC_CPP_SIMPLE_HOST_RESOLVER_H_ #include <optional> #include "base/component_export.h" #include "base/functional/callback_forward.h" #include "services/network/public/mojom/host_resolver.mojom.h" namespace net { class AddressList; } // namespace net namespace network { namespace mojom { class NetworkContext; } // namespace mojom // Wraps network.mojom.HostResolver and allows it to be used with callbacks // instead of receivers effectively eliminating the need to create custom // resolver clients. // * With mojom.HostResolver: // - Create a resolver client that inherits from mojom.ResolveHostClient // and override OnComplete() method; // - Call mojom.HostResolver.ResolveHost(); // - Wait till OnComplete() is invoked and manually delete the client. // * With SimpleHostResolver: // - Call SimpleHostResolver.ResolveHost() with callback mimicking // OnComplete() and wait for it to fire. // // Prefer using this class over mojom.HostResolver unless you're interested // in OnTextResults()/OnHostnameResults() events. // // Deleting a SimpleHostResolver cancels outstanding resolve requests. class COMPONENT_EXPORT(NETWORK_CPP) SimpleHostResolver { … }; } // namespace network #endif // SERVICES_NETWORK_PUBLIC_CPP_SIMPLE_HOST_RESOLVER_H_