Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Side by Side Diff: net/base/dns_query.h

Issue 7056050: Revert 87809 - Added DnsQuery class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/base/dns_query.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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_BASE_DNS_QUERY_H_
6 #define NET_BASE_DNS_QUERY_H_
7 #pragma once
8
9 #include <string>
10
11 #include "net/base/address_family.h"
12 #include "net/base/io_buffer.h"
13 #include "net/base/net_util.h"
14
15 namespace net{
16
17 // A class that encapsulates bits and pieces related to DNS request processing.
18 class DnsQuery {
19 public:
20 // Constructs an object containing an IOBuffer with raw DNS query string
21 // for |hostname| with the given |address_family|; |port| is here due to
22 // legacy -- getaddrinfo() takes service name, which is mapped to some
23 // port and returns sockaddr_in structures with ports filled in, so do we
24 // -- look at DnsResponse::Parse() to see where it is used.
25
26 // Every generated object has a random ID, hence two objects generated
27 // with the same set of constructor arguments are generally not equal;
28 // there is a 1/2^16 chance of them being equal due to size of |id_|.
29 DnsQuery(const std::string& hostname, AddressFamily address_family, int port);
30
31 // Returns true if the constructed object was valid.
32 bool IsValid() const { return io_buffer_.get() != NULL; }
33
34 // DnsQuery field accessors. These should only be called on an object
35 // for whom |IsValid| is true.
36 int port() const;
37 uint16 id() const;
38 uint16 qtype() const;
39 AddressFamily address_family() const;
40 const std::string& hostname() const;
41
42 // IOBuffer accessor to be used for writing out the query.
43 IOBufferWithSize* io_buffer() const;
44
45 private:
46 // Port to be used by corresponding DnsResponse when filling sockaddr_ins
47 // to be returned.
48 int port_;
49
50 // ID of the query.
51 uint16 id_;
52
53 // Type of query, currently, either A or AAAA.
54 uint16 qtype_;
55
56 // Address family of the query; used when constructing new object from
57 // this one.
58 AddressFamily address_family_;
59
60 // Hostname that we are trying to resolve.
61 std::string hostname_;
62
63 // Contains query bytes to be consumed by higher level Write() call.
64 scoped_refptr<IOBufferWithSize> io_buffer_;
65
66 DISALLOW_COPY_AND_ASSIGN(DnsQuery);
67 };
68
69 } // namespace net
70
71 #endif // NET_BASE_DNS_QUERY_H_
OLDNEW
« no previous file with comments | « no previous file | net/base/dns_query.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698