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

Side by Side Diff: net/dns/dns_query.h

Issue 1546623002: net: add a convenience getter accessor for dns Header to DnsQuery (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | net/dns/dns_query.cc » ('j') | net/dns/dns_query.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_DNS_DNS_QUERY_H_ 5 #ifndef NET_DNS_DNS_QUERY_H_
6 #define NET_DNS_DNS_QUERY_H_ 6 #define NET_DNS_DNS_QUERY_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "net/base/net_export.h" 15 #include "net/base/net_export.h"
16 16
17 namespace net { 17 namespace net {
18 18
19 namespace dns_protocol {
20 struct Header;
21 }
22
19 class IOBufferWithSize; 23 class IOBufferWithSize;
20 24
21 // Represents on-the-wire DNS query message as an object. 25 // Represents on-the-wire DNS query message as an object.
22 // TODO(szym): add support for the OPT pseudo-RR (EDNS0/DNSSEC). 26 // TODO(szym): add support for the OPT pseudo-RR (EDNS0/DNSSEC).
23 class NET_EXPORT_PRIVATE DnsQuery { 27 class NET_EXPORT_PRIVATE DnsQuery {
24 public: 28 public:
25 // Constructs a query message from |qname| which *MUST* be in a valid 29 // Constructs a query message from |qname| which *MUST* be in a valid
26 // DNS name format, and |qtype|. The qclass is set to IN. 30 // DNS name format, and |qtype|. The qclass is set to IN.
27 DnsQuery(uint16_t id, const base::StringPiece& qname, uint16_t qtype); 31 DnsQuery(uint16_t id, const base::StringPiece& qname, uint16_t qtype);
28 ~DnsQuery(); 32 ~DnsQuery();
(...skipping 11 matching lines...) Expand all
40 base::StringPiece question() const; 44 base::StringPiece question() const;
41 45
42 // IOBuffer accessor to be used for writing out the query. 46 // IOBuffer accessor to be used for writing out the query.
43 IOBufferWithSize* io_buffer() const { return io_buffer_.get(); } 47 IOBufferWithSize* io_buffer() const { return io_buffer_.get(); }
44 48
45 void set_flags(uint16_t flags); 49 void set_flags(uint16_t flags);
46 50
47 private: 51 private:
48 DnsQuery(const DnsQuery& orig, uint16_t id); 52 DnsQuery(const DnsQuery& orig, uint16_t id);
49 53
54 // Convenience for header access.
55 dns_protocol::Header* header();
pauljensen 2015/12/29 12:38:02 I'm not really a fan of making something hacky (th
tfarina 2015/12/29 13:57:43 dns_response.h already has an accessor like this.
pauljensen 2015/12/29 15:06:22 Casting something to a different type and derefere
56
50 // Size of the DNS name (*NOT* hostname) we are trying to resolve; used 57 // Size of the DNS name (*NOT* hostname) we are trying to resolve; used
51 // to calculate offsets. 58 // to calculate offsets.
52 size_t qname_size_; 59 size_t qname_size_;
53 60
54 // Contains query bytes to be consumed by higher level Write() call. 61 // Contains query bytes to be consumed by higher level Write() call.
55 scoped_refptr<IOBufferWithSize> io_buffer_; 62 scoped_refptr<IOBufferWithSize> io_buffer_;
56 63
57 DISALLOW_COPY_AND_ASSIGN(DnsQuery); 64 DISALLOW_COPY_AND_ASSIGN(DnsQuery);
58 }; 65 };
59 66
60 } // namespace net 67 } // namespace net
61 68
62 #endif // NET_DNS_DNS_QUERY_H_ 69 #endif // NET_DNS_DNS_QUERY_H_
OLDNEW
« no previous file with comments | « no previous file | net/dns/dns_query.cc » ('j') | net/dns/dns_query.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698