summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/dns_probe_job.h
blob: 6572de17ef247d4656232d78d5369aa7d17f6e4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_NET_DNS_PROBE_JOB_H_
#define CHROME_BROWSER_NET_DNS_PROBE_JOB_H_

#include "base/basictypes.h"
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"

namespace net {
class DnsClient;
class NetLog;
}

namespace chrome_browser_net {

// A job to probe the health of a DNS configuration.
class DnsProbeJob {
 public:
  enum Result {
    SERVERS_UNKNOWN,
    SERVERS_CORRECT,  // Server responds with correct answers.
    SERVERS_INCORRECT,  // Server responds with success but incorrect answer.
    // TODO(ttuttle): Do we want an "unreliable" result, for e.g. servers that
    // lie about NXDOMAIN?
    SERVERS_FAILING,  // Server responds with errors.
    SERVERS_UNREACHABLE,  // Server doesn't respond (or never got our packets)
    MAX_RESULT
  };
  typedef base::Callback<void(DnsProbeJob* job, Result result)> CallbackType;

  virtual ~DnsProbeJob() { }

  // Creates and starts a probe job.
  //
  // |dns_client| should be a DnsClient with the DnsConfig already set.
  // |callback| will be called when the probe finishes, which may happen
  // before the constructor returns (for example, if we can't create the DNS
  // transactions).
  static scoped_ptr<DnsProbeJob> CreateJob(
      scoped_ptr<net::DnsClient> dns_client,
      const CallbackType& callback,
      net::NetLog* net_log);

 protected:
  DnsProbeJob() { }

  DISALLOW_COPY_AND_ASSIGN(DnsProbeJob);
};

}  // namespace chrome_browser_net

#endif  // CHROME_BROWSER_NET_DNS_PROBE_JOB_H_