Chromium Code Reviews| 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" | |
|
cbentzel
2011/06/28 19:08:18
You don't need this include anymore
willchan no longer on Chromium
2011/06/28 19:10:47
Is this header still necessary?
agayev
2011/06/28 19:49:55
Done.
| |
| 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" |
| 15 #include "net/base/rand_callback.h" | |
| 14 | 16 |
| 15 namespace net{ | 17 namespace net { |
| 16 | 18 |
| 17 // Represents on-the-wire DNS query message as an object. | 19 // Represents on-the-wire DNS query message as an object. |
| 18 class NET_TEST DnsQuery { | 20 class NET_TEST DnsQuery { |
| 19 public: | 21 public: |
| 20 // Constructs a query message from |dns_name| which *MUST* be in a valid | 22 // 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. | 23 // DNS name format, and |qtype| which must be either kDNS_A or kDNS_AAA. |
| 22 | 24 |
| 23 // Every generated object has a random ID, hence two objects generated | 25 // Every generated object has a random ID, hence two objects generated |
| 24 // with the same set of constructor arguments are generally not equal; | 26 // 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_|. | 27 // 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)()); | 28 DnsQuery(const std::string& dns_name, |
| 29 uint16 qtype, | |
| 30 const RandIntCallback& rand_int); | |
| 27 ~DnsQuery(); | 31 ~DnsQuery(); |
| 28 | 32 |
| 29 // Clones |this| verbatim with ID field of the header regenerated. | 33 // Clones |this| verbatim with ID field of the header regenerated. |
| 30 DnsQuery* CloneWithNewId() const; | 34 DnsQuery* CloneWithNewId() const; |
| 31 | 35 |
| 32 // DnsQuery field accessors. | 36 // DnsQuery field accessors. |
| 33 uint16 id() const; | 37 uint16 id() const; |
| 34 uint16 qtype() const; | 38 uint16 qtype() const; |
| 35 | 39 |
| 36 // Returns the size of the Question section of the query. Used when | 40 // Returns the size of the Question section of the query. Used when |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 57 void RandomizeId(); | 61 void RandomizeId(); |
| 58 | 62 |
| 59 // Size of the DNS name (*NOT* hostname) we are trying to resolve; used | 63 // Size of the DNS name (*NOT* hostname) we are trying to resolve; used |
| 60 // to calculate offsets. | 64 // to calculate offsets. |
| 61 size_t dns_name_size_; | 65 size_t dns_name_size_; |
| 62 | 66 |
| 63 // Contains query bytes to be consumed by higher level Write() call. | 67 // Contains query bytes to be consumed by higher level Write() call. |
| 64 scoped_refptr<IOBufferWithSize> io_buffer_; | 68 scoped_refptr<IOBufferWithSize> io_buffer_; |
| 65 | 69 |
| 66 // PRNG function for generating IDs. | 70 // PRNG function for generating IDs. |
| 67 uint64 (*prng_)(); | 71 RandIntCallback rand_int_; |
| 68 }; | 72 }; |
| 69 | 73 |
| 70 } // namespace net | 74 } // namespace net |
| 71 | 75 |
| 72 #endif // NET_BASE_DNS_QUERY_H_ | 76 #endif // NET_BASE_DNS_QUERY_H_ |
| OLD | NEW |