| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_BASE_DNS_QUERY_H_ | 5 #ifndef NET_BASE_DNS_QUERY_H_ |
| 6 #define NET_BASE_DNS_QUERY_H_ | 6 #define NET_BASE_DNS_QUERY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/rand_util.h" |
| 11 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
| 12 #include "net/base/net_api.h" | 13 #include "net/base/net_api.h" |
| 13 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
| 14 | 15 |
| 15 namespace net{ | 16 namespace net{ |
| 16 | 17 |
| 17 // Represents on-the-wire DNS query message as an object. | 18 // Represents on-the-wire DNS query message as an object. |
| 18 class NET_TEST DnsQuery { | 19 class NET_TEST DnsQuery { |
| 19 public: | 20 public: |
| 20 // Constructs a query message from |dns_name| which *MUST* be in a valid | 21 // Constructs a query message from |dns_name| which *MUST* be in a valid |
| 21 // DNS name format, and |qtype| which must be either kDNS_A or kDNS_AAA. | 22 // DNS name format, and |qtype| which must be either kDNS_A or kDNS_AAA. |
| 22 | 23 |
| 23 // Every generated object has a random ID, hence two objects generated | 24 // Every generated object has a random ID, hence two objects generated |
| 24 // with the same set of constructor arguments are generally not equal; | 25 // with the same set of constructor arguments are generally not equal; |
| 25 // there is a 1/2^16 chance of them being equal due to size of |id_|. | 26 // there is a 1/2^16 chance of them being equal due to size of |id_|. |
| 26 DnsQuery(const std::string& dns_name, uint16 qtype, uint64 (*prng)()); | 27 DnsQuery(const std::string& dns_name, |
| 28 uint16 qtype, |
| 29 const base::RandIntCallback& rand_int); |
| 27 ~DnsQuery(); | 30 ~DnsQuery(); |
| 28 | 31 |
| 29 // Clones |this| verbatim with ID field of the header regenerated. | 32 // Clones |this| verbatim with ID field of the header regenerated. |
| 30 DnsQuery* CloneWithNewId() const; | 33 DnsQuery* CloneWithNewId() const; |
| 31 | 34 |
| 32 // DnsQuery field accessors. | 35 // DnsQuery field accessors. |
| 33 uint16 id() const; | 36 uint16 id() const; |
| 34 uint16 qtype() const; | 37 uint16 qtype() const; |
| 35 | 38 |
| 36 // Returns the size of the Question section of the query. Used when | 39 // Returns the size of the Question section of the query. Used when |
| (...skipping 20 matching lines...) Expand all Loading... |
| 57 void RandomizeId(); | 60 void RandomizeId(); |
| 58 | 61 |
| 59 // Size of the DNS name (*NOT* hostname) we are trying to resolve; used | 62 // Size of the DNS name (*NOT* hostname) we are trying to resolve; used |
| 60 // to calculate offsets. | 63 // to calculate offsets. |
| 61 size_t dns_name_size_; | 64 size_t dns_name_size_; |
| 62 | 65 |
| 63 // Contains query bytes to be consumed by higher level Write() call. | 66 // Contains query bytes to be consumed by higher level Write() call. |
| 64 scoped_refptr<IOBufferWithSize> io_buffer_; | 67 scoped_refptr<IOBufferWithSize> io_buffer_; |
| 65 | 68 |
| 66 // PRNG function for generating IDs. | 69 // PRNG function for generating IDs. |
| 67 uint64 (*prng_)(); | 70 base::RandIntCallback rand_int_; |
| 68 }; | 71 }; |
| 69 | 72 |
| 70 } // namespace net | 73 } // namespace net |
| 71 | 74 |
| 72 #endif // NET_BASE_DNS_QUERY_H_ | 75 #endif // NET_BASE_DNS_QUERY_H_ |
| OLD | NEW |