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