Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Unified Diff: net/base/dns_response.h

Issue 7008021: Added DnsQuery class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added DnsResponse class Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/base/dns_response.h
diff --git a/net/base/dns_response.h b/net/base/dns_response.h
new file mode 100644
index 0000000000000000000000000000000000000000..86d23183e293f61797e791e5b98d79ca8db55c09
--- /dev/null
+++ b/net/base/dns_response.h
@@ -0,0 +1,64 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_BASE_DNS_RESPONSE_H_
+#define NET_BASE_DNS_RESPONSE_H_
+#pragma once
+
+#include "net/base/dns_query.h"
+
+namespace net{
+
+class AddressList;
+
+// A class that encapsulates bits and pieces related to DNS response
+// processing.
+class DnsResponse {
+ public:
+ // Constructs a response object with an IOBuffer large enough to read
+ // every possible; |query| is a pointer to the DnsQuery for which |this|
+ // is supposed to be a response.
+ DnsResponse(DnsQuery* query);
+
+ // Internal buffer accessor into which actual bytes of response to be
+ // read.
+ 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.
+
+ // Returns the size of the DNS response.
+ int size() const { return size_; }
+
+ // Parses response of size nbytes and puts address into |results|,
+ // returns whether succeeded or not.
+ 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
+
+ // Error code accessor.
+ int error() const { return error_; }
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(DnsResponseTest, ResponseWithCnameA);
+
+ // Gives access to the response bytes directly, used by tests.
+ char* data() { return io_buffer_->data(); }
agl 2011/05/30 18:35:30 const char*?
agayev 2011/05/31 15:19:06 Will do.
+
+ // Error code, currently either 0 or EAI_NONAME, will be amended with
+ // specific error codes in the future.
+ int error_;
+
+ // Size of the response; initially it is one byte larger than maximum DNS
+ // response size to allow reading all possible responses as well as
+ // detecting oversized ones, adjusted once the actual response is read.
+ int size_;
+
+ // The matching query; |this| is the response for this query.
+ DnsQuery* const query_;
+
+ // Buffer into which response bytes are read.
+ scoped_refptr<IOBufferWithSize> io_buffer_;
+
+ DISALLOW_COPY_AND_ASSIGN(DnsResponse);
+};
+
+} // namespace net
+
+#endif // NET_BASE_DNS_RESPONSE_H_

Powered by Google App Engine
This is Rietveld 408576698