Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_DNS_DNS_RESPONSE_H_ | 5 #ifndef NET_DNS_DNS_RESPONSE_H_ |
| 6 #define NET_DNS_DNS_RESPONSE_H_ | 6 #define NET_DNS_DNS_RESPONSE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/string_piece.h" | 13 #include "base/string_piece.h" |
| 14 #include "base/time.h" | |
| 14 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
| 15 #include "net/base/net_util.h" | 16 #include "net/base/net_util.h" |
| 16 | 17 |
| 17 namespace net { | 18 namespace net { |
| 18 | 19 |
| 20 class AddressList; | |
| 19 class DnsQuery; | 21 class DnsQuery; |
| 20 class IOBufferWithSize; | 22 class IOBufferWithSize; |
| 21 | 23 |
| 22 namespace dns_protocol { | 24 namespace dns_protocol { |
| 23 struct Header; | 25 struct Header; |
| 24 } | 26 } |
| 25 | 27 |
| 26 // Parsed resource record. | 28 // Parsed resource record. |
| 27 struct NET_EXPORT_PRIVATE DnsResourceRecord { | 29 struct NET_EXPORT_PRIVATE DnsResourceRecord { |
| 28 DnsResourceRecord(); | 30 DnsResourceRecord(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 uint16 qtype() const; | 111 uint16 qtype() const; |
| 110 | 112 |
| 111 // Returns qname in dotted format. | 113 // Returns qname in dotted format. |
| 112 std::string GetDottedName() const; | 114 std::string GetDottedName() const; |
| 113 | 115 |
| 114 // Returns an iterator to the resource records in the answer section. | 116 // Returns an iterator to the resource records in the answer section. |
| 115 // The iterator is valid only in the scope of the DnsResponse. | 117 // The iterator is valid only in the scope of the DnsResponse. |
| 116 // This operation is idempotent. | 118 // This operation is idempotent. |
| 117 DnsRecordParser Parser() const; | 119 DnsRecordParser Parser() const; |
| 118 | 120 |
| 121 // Extracts an AddressList from this response. Returns true if succeeded. | |
| 122 bool ParseAddressList(AddressList* addr_list, base::TimeDelta* ttl) const; | |
|
mmenke
2012/02/14 18:46:00
nit: Suggest you rename this function to ParseAdd
| |
| 123 | |
| 119 private: | 124 private: |
| 120 // Convenience for header access. | 125 // Convenience for header access. |
| 121 const dns_protocol::Header* header() const; | 126 const dns_protocol::Header* header() const; |
| 122 | 127 |
| 123 // Buffer into which response bytes are read. | 128 // Buffer into which response bytes are read. |
| 124 scoped_refptr<IOBufferWithSize> io_buffer_; | 129 scoped_refptr<IOBufferWithSize> io_buffer_; |
| 125 | 130 |
| 126 // Iterator constructed after InitParse positioned at the answer section. | 131 // Iterator constructed after InitParse positioned at the answer section. |
| 127 // It is never updated afterwards, so can be used in accessors. | 132 // It is never updated afterwards, so can be used in accessors. |
| 128 DnsRecordParser parser_; | 133 DnsRecordParser parser_; |
| 129 | 134 |
| 130 DISALLOW_COPY_AND_ASSIGN(DnsResponse); | 135 DISALLOW_COPY_AND_ASSIGN(DnsResponse); |
| 131 }; | 136 }; |
| 132 | 137 |
| 133 } // namespace net | 138 } // namespace net |
| 134 | 139 |
| 135 #endif // NET_DNS_DNS_RESPONSE_H_ | 140 #endif // NET_DNS_DNS_RESPONSE_H_ |
| OLD | NEW |