Chromium Code Reviews| 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 DnsResponse(DnsQuery* query); | |
| 23 | |
| 24 // Internal buffer accessor into which actual bytes of response to be | |
| 25 // read. | |
| 26 IOBuffer* io_buffer() { return io_buffer_.get(); } | |
|
agl
2011/05/30 18:35:30
see previous comment about IOBuffer and scoped_ref
agayev
2011/05/31 15:19:06
Will do.
| |
| 27 | |
| 28 // Returns the size of the DNS response. | |
| 29 int size() const { return size_; } | |
| 30 | |
| 31 // Parses response of size nbytes and puts address into |results|, | |
| 32 // returns whether succeeded or not. | |
| 33 bool Parse(int nbytes, AddressList* results); | |
|
agl
2011/05/30 18:35:30
s/int/size_t/
agayev
2011/05/31 15:19:06
This is how it is being used, I don't think I can
| |
| 34 | |
| 35 // Error code accessor. | |
| 36 int error() const { return error_; } | |
| 37 | |
| 38 private: | |
| 39 FRIEND_TEST_ALL_PREFIXES(DnsResponseTest, ResponseWithCnameA); | |
| 40 | |
| 41 // Gives access to the response bytes directly, used by tests. | |
| 42 char* data() { return io_buffer_->data(); } | |
|
agl
2011/05/30 18:35:30
const char*?
agayev
2011/05/31 15:19:06
Will do.
| |
| 43 | |
| 44 // Error code, currently either 0 or EAI_NONAME, will be amended with | |
| 45 // specific error codes in the future. | |
| 46 int error_; | |
| 47 | |
| 48 // Size of the response; initially it is one byte larger than maximum DNS | |
| 49 // response size to allow reading all possible responses as well as | |
| 50 // detecting oversized ones, adjusted once the actual response is read. | |
| 51 int size_; | |
| 52 | |
| 53 // The matching query; |this| is the response for this query. | |
| 54 DnsQuery* const query_; | |
| 55 | |
| 56 // Buffer into which response bytes are read. | |
| 57 scoped_refptr<IOBufferWithSize> io_buffer_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(DnsResponse); | |
| 60 }; | |
| 61 | |
| 62 } // namespace net | |
| 63 | |
| 64 #endif // NET_BASE_DNS_RESPONSE_H_ | |
| OLD | NEW |