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 an object with an IOBuffer large enough to read | |
20 // one byte more than largest possible response, to detect malformed | |
21 // responses; |query| is a pointer to the DnsQuery for which |this| | |
22 // is supposed to be a response. | |
23 explicit DnsResponse(DnsQuery* query); | |
24 | |
25 // Internal buffer accessor into which actual bytes of response will be | |
26 // read. | |
27 IOBufferWithSize* io_buffer() { return io_buffer_.get(); } | |
28 | |
29 // Parses response of size nbytes and puts address into |results|, | |
30 // returns net_error code in case of failure. | |
31 int Parse(int nbytes, AddressList* results); | |
32 | |
33 private: | |
34 // The matching query; |this| is the response for |query_|. We do not | |
35 // own it, lifetime of |this| should be within the limits of lifetime of | |
36 // |query_|. | |
37 const DnsQuery* const query_; | |
38 | |
39 // Buffer into which response bytes are read. | |
40 scoped_refptr<IOBufferWithSize> io_buffer_; | |
41 | |
42 DISALLOW_COPY_AND_ASSIGN(DnsResponse); | |
43 }; | |
44 | |
45 } // namespace net | |
46 | |
47 #endif // NET_BASE_DNS_RESPONSE_H_ | |
OLD | NEW |