blob: 5f6fbb12738bf845073f075f1d30e8bd6c863112 [file] [log] [blame]
Eric Orth4e55b362019-05-07 22:00:031// Copyright 2016 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef NET_DNS_FUZZED_HOST_RESOLVER_UTIL_H_
6#define NET_DNS_FUZZED_HOST_RESOLVER_UTIL_H_
7
8#include <memory>
9
10#include "net/dns/host_resolver.h"
11
12namespace base {
13class FuzzedDataProvider;
14}
15
16namespace net {
17
18class ContextHostResolver;
19class NetLog;
20
21// Creates a ContextHostResolver that uses a fuzzer to determine what results to
22// return. It inherits from ContextHostResolver, unlike MockHostResolver, so
23// more closely matches real behavior.
24//
25// By default uses a mocked out system resolver, though can be configured (using
26// SetDnsClientEnabled() on the underlying manager) to use the built-in async
27// resolver (Built in DNS stub resolver) with a fuzzed set of UDP/TCP sockets.
28//
29// To make behavior most deterministic, does not use the WorkerPool to run its
30// simulated platform host resolver calls, instead runs them on the thread it is
31// created on.
32//
33// Note that it does not attempt to sort the resulting AddressList when using
34// the mock system resolver path.
35//
36// The async DNS client can make system calls in AddressSorterPosix, but other
37// methods that make system calls are stubbed out.
38std::unique_ptr<ContextHostResolver> CreateFuzzedContextHostResolver(
39 const HostResolver::ManagerOptions& options,
40 NetLog* net_log,
41 base::FuzzedDataProvider* data_provider,
42 bool enable_caching);
43
44} // namespace net
45
46#endif // NET_DNS_FUZZED_HOST_RESOLVER_UTIL_H_