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

Unified Diff: net/base/dns_query.h

Issue 6995088: Break the dependency of DnsQuery and DnsResponse from AddressList (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comment. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/base/dns_query.cc » ('j') | net/base/dns_query_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/dns_query.h
diff --git a/net/base/dns_query.h b/net/base/dns_query.h
index bc25997e9e881c2bd235f13ec9bfb11efc899d7d..f2c2a21cc7f4c2dc33456d6ac4616b26911ead22 100644
--- a/net/base/dns_query.h
+++ b/net/base/dns_query.h
@@ -8,63 +8,59 @@
#include <string>
-#include "net/base/address_family.h"
#include "net/base/io_buffer.h"
#include "net/base/net_util.h"
namespace net{
-// A class that encapsulates bits and pieces related to DNS request processing.
+// Represents on-the-wire DNS query string as an object.
cbentzel 2011/06/09 15:24:25 Perhaps "DNS query message" instead of "DNS query
agayev 2011/06/09 15:35:18 Done.
class DnsQuery {
public:
- // Constructs an object containing an IOBuffer with raw DNS query string
- // for |hostname| with the given |address_family|; |port| is here due to
- // legacy -- getaddrinfo() takes service name, which is mapped to some
- // port and returns sockaddr_in structures with ports filled in, so do we
- // -- look at DnsResponse::Parse() to see where it is used.
+ // Constructs a query string from |dns_name| which *MUST* be in a valid
+ // DNS name format, and |qtype| which must be either kDNS_A or kDNS_AAA.
// Every generated object has a random ID, hence two objects generated
// with the same set of constructor arguments are generally not equal;
// there is a 1/2^16 chance of them being equal due to size of |id_|.
- DnsQuery(const std::string& hostname, AddressFamily address_family, int port);
+ DnsQuery(const std::string& dns_name, uint16 qtype);
~DnsQuery();
- // Returns true if the constructed object was valid.
- bool IsValid() const { return io_buffer_.get() != NULL; }
+ // Clones |this| verbatim with ID field of the header regenerated.
+ DnsQuery* CloneWithNewId() const;
- // DnsQuery field accessors. These should only be called on an object
- // for whom |IsValid| is true.
- int port() const;
+ // DnsQuery field accessors.
uint16 id() const;
uint16 qtype() const;
- AddressFamily address_family() const;
- const std::string& hostname() const;
+
+ // Returns the size of the Question section of the query. Used when
+ // matching the response.
+ size_t question_size() const;
+
+ // Returns pointer to the Question section of the query. Used when
+ // matching the response.
+ const char* question_data() const;
// IOBuffer accessor to be used for writing out the query.
- IOBufferWithSize* io_buffer() const;
+ IOBufferWithSize* io_buffer() const { return io_buffer_; }
cbentzel 2011/06/09 15:24:25 This could be const IOBufferWithSize* - but you'd
agayev 2011/06/09 15:35:18 In another CL perhaps.
private:
- // Port to be used by corresponding DnsResponse when filling sockaddr_ins
- // to be returned.
- int port_;
+ // Copy constructor to be used only by CloneWithNewId; it's not public
+ // since there is a semantic difference -- this does not construct an
+ // exact copy!
+ DnsQuery(const DnsQuery& rhs);
- // ID of the query.
- uint16 id_;
+ // Not implemented; just to prevent the assignment.
+ void operator=(const DnsQuery&);
- // Type of query, currently, either A or AAAA.
- uint16 qtype_;
+ // Randomizes ID field of the query string.
+ void RandomizeId();
- // Address family of the query; used when constructing new object from
- // this one.
- AddressFamily address_family_;
-
- // Hostname that we are trying to resolve.
- std::string hostname_;
+ // Size of the DNS name (*NOT* hostname) we are trying to resolve; used
+ // to calculate offsets.
+ size_t dns_name_size_;
// Contains query bytes to be consumed by higher level Write() call.
scoped_refptr<IOBufferWithSize> io_buffer_;
-
- DISALLOW_COPY_AND_ASSIGN(DnsQuery);
};
} // namespace net
« no previous file with comments | « no previous file | net/base/dns_query.cc » ('j') | net/base/dns_query_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698