| 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_RESPONSE_H_ | 5 #ifndef NET_BASE_DNS_RESPONSE_H_ |
| 6 #define NET_BASE_DNS_RESPONSE_H_ | 6 #define NET_BASE_DNS_RESPONSE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "net/base/dns_query.h" | 9 #include "net/base/dns_query.h" |
| 10 | 10 |
| 11 namespace net{ | 11 namespace net{ |
| 12 | 12 |
| 13 class AddressList; | 13 // Represents on-the-wire DNS response as an object; allows extracting |
| 14 | 14 // records. |
| 15 // A class that encapsulates bits and pieces related to DNS response | |
| 16 // processing. | |
| 17 class DnsResponse { | 15 class DnsResponse { |
| 18 public: | 16 public: |
| 19 // Constructs an object with an IOBuffer large enough to read | 17 // Constructs an object with an IOBuffer large enough to read |
| 20 // one byte more than largest possible response, to detect malformed | 18 // one byte more than largest possible response, to detect malformed |
| 21 // responses; |query| is a pointer to the DnsQuery for which |this| | 19 // responses; |query| is a pointer to the DnsQuery for which |this| |
| 22 // is supposed to be a response. | 20 // is supposed to be a response. |
| 23 explicit DnsResponse(DnsQuery* query); | 21 explicit DnsResponse(DnsQuery* query); |
| 24 ~DnsResponse(); | 22 ~DnsResponse(); |
| 25 | 23 |
| 26 // Internal buffer accessor into which actual bytes of response will be | 24 // Internal buffer accessor into which actual bytes of response will be |
| 27 // read. | 25 // read. |
| 28 IOBufferWithSize* io_buffer() { return io_buffer_.get(); } | 26 IOBufferWithSize* io_buffer() { return io_buffer_.get(); } |
| 29 | 27 |
| 30 // Parses response of size nbytes and puts address into |results|, | 28 // Parses response of size nbytes and puts address into |ip_addresses|, |
| 31 // returns net_error code in case of failure. | 29 // returns net_error code in case of failure. |
| 32 int Parse(int nbytes, AddressList* results); | 30 int Parse(int nbytes, std::vector<IPAddressNumber>* ip_addresses); |
| 33 | 31 |
| 34 private: | 32 private: |
| 35 // The matching query; |this| is the response for |query_|. We do not | 33 // The matching query; |this| is the response for |query_|. We do not |
| 36 // own it, lifetime of |this| should be within the limits of lifetime of | 34 // own it, lifetime of |this| should be within the limits of lifetime of |
| 37 // |query_|. | 35 // |query_|. |
| 38 const DnsQuery* const query_; | 36 const DnsQuery* const query_; |
| 39 | 37 |
| 40 // Buffer into which response bytes are read. | 38 // Buffer into which response bytes are read. |
| 41 scoped_refptr<IOBufferWithSize> io_buffer_; | 39 scoped_refptr<IOBufferWithSize> io_buffer_; |
| 42 | 40 |
| 43 DISALLOW_COPY_AND_ASSIGN(DnsResponse); | 41 DISALLOW_COPY_AND_ASSIGN(DnsResponse); |
| 44 }; | 42 }; |
| 45 | 43 |
| 46 } // namespace net | 44 } // namespace net |
| 47 | 45 |
| 48 #endif // NET_BASE_DNS_RESPONSE_H_ | 46 #endif // NET_BASE_DNS_RESPONSE_H_ |
| OLD | NEW |