While loading url in current tab should check if any prerender page avaliable.
[chromium-blink-merge.git] / net / dns / dns_transaction.h
blobfaf4f64e79d85859ec84e3aa42f99de44d14033c
1 // Copyright (c) 2012 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.
5 #ifndef NET_DNS_DNS_TRANSACTION_H_
6 #define NET_DNS_DNS_TRANSACTION_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "net/base/net_export.h"
15 namespace net {
17 class BoundNetLog;
18 class DnsResponse;
19 class DnsSession;
21 // DnsTransaction implements a stub DNS resolver as defined in RFC 1034.
22 // The DnsTransaction takes care of retransmissions, name server fallback (or
23 // round-robin), suffix search, and simple response validation ("does it match
24 // the query") to fight poisoning.
26 // Destroying DnsTransaction cancels the underlying network effort.
27 class NET_EXPORT_PRIVATE DnsTransaction {
28 public:
29 virtual ~DnsTransaction() {}
31 // Returns the original |hostname|.
32 virtual const std::string& GetHostname() const = 0;
34 // Returns the |qtype|.
35 virtual uint16 GetType() const = 0;
37 // Starts the transaction. Always completes asynchronously.
38 virtual void Start() = 0;
41 // Creates DnsTransaction which performs asynchronous DNS search.
42 // It does NOT perform caching, aggregation or prioritization of transactions.
44 // Destroying the factory does NOT affect any already created DnsTransactions.
45 class NET_EXPORT_PRIVATE DnsTransactionFactory {
46 public:
47 // Called with the response or NULL if no matching response was received.
48 // Note that the |GetDottedName()| of the response may be different than the
49 // original |hostname| as a result of suffix search.
50 typedef base::Callback<void(DnsTransaction* transaction,
51 int neterror,
52 const DnsResponse* response)> CallbackType;
54 virtual ~DnsTransactionFactory() {}
56 // Creates DnsTransaction for the given |hostname| and |qtype| (assuming
57 // QCLASS is IN). |hostname| should be in the dotted form. A dot at the end
58 // implies the domain name is fully-qualified and will be exempt from suffix
59 // search. |hostname| should not be an IP literal.
61 // The transaction will run |callback| upon asynchronous completion.
62 // The |net_log| is used as the parent log.
63 virtual scoped_ptr<DnsTransaction> CreateTransaction(
64 const std::string& hostname,
65 uint16 qtype,
66 const CallbackType& callback,
67 const BoundNetLog& net_log) WARN_UNUSED_RESULT = 0;
69 // Creates a DnsTransactionFactory which creates DnsTransactionImpl using the
70 // |session|.
71 static scoped_ptr<DnsTransactionFactory> CreateFactory(
72 DnsSession* session) WARN_UNUSED_RESULT;
75 } // namespace net
77 #endif // NET_DNS_DNS_TRANSACTION_H_