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

Unified Diff: net/dns/dns_response.h

Issue 9190031: DnsClient refactoring + features (timeout, suffix search, server rotation). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renamed dns_client -> dns_transaction. Created 8 years, 11 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/dns/dns_response.h
diff --git a/net/dns/dns_response.h b/net/dns/dns_response.h
index ddd2c2089439ad47997ec4435982e9c4f0e9c207..545db1578fb82253a235f26a273ab3d77755a8e2 100644
--- a/net/dns/dns_response.h
+++ b/net/dns/dns_response.h
@@ -46,11 +46,14 @@ class NET_EXPORT_PRIVATE DnsRecordParser {
DnsRecordParser(const void* packet, size_t length, size_t offset);
// Returns |true| if initialized.
- bool IsValid() const { return packet_ != NULL; }
+ bool is_valid() const { return packet_ != NULL; }
cbentzel 2012/01/13 22:17:25 Old naming scheme is more appropriate here.
// Returns |true| if no more bytes remain in the packet.
bool AtEnd() const { return cur_ == packet_ + length_; }
+ // Returns current offset into the packet.
+ size_t offset() const { return cur_ - packet_; }
+
// Parses a (possibly compressed) DNS name from the packet starting at
// |pos|. Stores output (even partial) in |out| unless |out| is NULL. |out|
// is stored in the dotted form, e.g., "example.com". Returns number of bytes
@@ -91,15 +94,26 @@ class NET_EXPORT_PRIVATE DnsResponse {
// |query| id or question.
bool InitParse(int nbytes, const DnsQuery& query);
+ // Returns true if response is valid, that is, after successful InitParse.
+ bool is_valid() const;
cbentzel 2012/01/13 22:17:25 Ditto, prefer IsValid().
+
+ // All of the methods below are valid only if the response is valid.
+
// Accessors for the header.
- uint8 flags0() const; // first byte of flags
- uint8 flags1() const; // second byte of flags excluding rcode
+ uint16 flags() const; // excluding rcode
uint8 rcode() const;
int answer_count() const;
- // Returns an iterator to the resource records in the answer section. Must be
- // called after InitParse. The iterator is valid only in the scope of the
- // DnsResponse.
+ // Accessors to the question. The qname is unparsed.
+ base::StringPiece qname() const;
cbentzel 2012/01/13 22:17:25 Where are these being used?
szym 2012/01/17 15:38:25 I'm not sure these will be used outside of tests.
+ uint16 qtype() const;
+
+ // Returns qname in dotted format.
+ std::string GetDottedName() const;
+
+ // Returns an iterator to the resource records in the answer section.
+ // The iterator is valid only in the scope of the DnsResponse.
+ // This operation is idempotent.
DnsRecordParser Parser() const;
private:
@@ -110,6 +124,7 @@ class NET_EXPORT_PRIVATE DnsResponse {
scoped_refptr<IOBufferWithSize> io_buffer_;
// Iterator constructed after InitParse positioned at the answer section.
+ // It is never updated afterwards, so can be used in accessors.
DnsRecordParser parser_;
DISALLOW_COPY_AND_ASSIGN(DnsResponse);
« no previous file with comments | « net/dns/dns_query.cc ('k') | net/dns/dns_response.cc » ('j') | net/dns/dns_response.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698