OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_RECORD_PARSED_H_ | 5 #ifndef NET_DNS_RECORD_PARSED_H_ |
6 #define NET_DNS_RECORD_PARSED_H_ | 6 #define NET_DNS_RECORD_PARSED_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <string> | 10 #include <string> |
9 | 11 |
10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
11 #include "base/time/time.h" | 13 #include "base/time/time.h" |
12 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
13 | 15 |
14 namespace net { | 16 namespace net { |
15 | 17 |
16 class DnsRecordParser; | 18 class DnsRecordParser; |
17 class RecordRdata; | 19 class RecordRdata; |
18 | 20 |
19 // Parsed record. This is a form of DnsResourceRecord where the rdata section | 21 // Parsed record. This is a form of DnsResourceRecord where the rdata section |
20 // has been parsed into a data structure. | 22 // has been parsed into a data structure. |
21 class NET_EXPORT_PRIVATE RecordParsed { | 23 class NET_EXPORT_PRIVATE RecordParsed { |
22 public: | 24 public: |
23 virtual ~RecordParsed(); | 25 virtual ~RecordParsed(); |
24 | 26 |
25 // All records are inherently immutable. Return a const pointer. | 27 // All records are inherently immutable. Return a const pointer. |
26 static scoped_ptr<const RecordParsed> CreateFrom(DnsRecordParser* parser, | 28 static scoped_ptr<const RecordParsed> CreateFrom(DnsRecordParser* parser, |
27 base::Time time_created); | 29 base::Time time_created); |
28 | 30 |
29 const std::string& name() const { return name_; } | 31 const std::string& name() const { return name_; } |
30 uint16 type() const { return type_; } | 32 uint16_t type() const { return type_; } |
31 uint16 klass() const { return klass_; } | 33 uint16_t klass() const { return klass_; } |
32 uint32 ttl() const { return ttl_; } | 34 uint32_t ttl() const { return ttl_; } |
33 | 35 |
34 base::Time time_created() const { return time_created_; } | 36 base::Time time_created() const { return time_created_; } |
35 | 37 |
36 template <class T> const T* rdata() const { | 38 template <class T> const T* rdata() const { |
37 if (T::kType != type_) | 39 if (T::kType != type_) |
38 return NULL; | 40 return NULL; |
39 return static_cast<const T*>(rdata_.get()); | 41 return static_cast<const T*>(rdata_.get()); |
40 } | 42 } |
41 | 43 |
42 // Check if two records have the same data. Ignores time_created and ttl. | 44 // Check if two records have the same data. Ignores time_created and ttl. |
43 // If |is_mdns| is true, ignore the top bit of the class | 45 // If |is_mdns| is true, ignore the top bit of the class |
44 // (the cache flush bit). | 46 // (the cache flush bit). |
45 bool IsEqual(const RecordParsed* other, bool is_mdns) const; | 47 bool IsEqual(const RecordParsed* other, bool is_mdns) const; |
46 | 48 |
47 private: | 49 private: |
48 RecordParsed(const std::string& name, uint16 type, uint16 klass, | 50 RecordParsed(const std::string& name, |
49 uint32 ttl, scoped_ptr<const RecordRdata> rdata, | 51 uint16_t type, |
| 52 uint16_t klass, |
| 53 uint32_t ttl, |
| 54 scoped_ptr<const RecordRdata> rdata, |
50 base::Time time_created); | 55 base::Time time_created); |
51 | 56 |
52 std::string name_; // in dotted form | 57 std::string name_; // in dotted form |
53 const uint16 type_; | 58 const uint16_t type_; |
54 const uint16 klass_; | 59 const uint16_t klass_; |
55 const uint32 ttl_; | 60 const uint32_t ttl_; |
56 | 61 |
57 const scoped_ptr<const RecordRdata> rdata_; | 62 const scoped_ptr<const RecordRdata> rdata_; |
58 | 63 |
59 const base::Time time_created_; | 64 const base::Time time_created_; |
60 }; | 65 }; |
61 | 66 |
62 } // namespace net | 67 } // namespace net |
63 | 68 |
64 #endif // NET_DNS_RECORD_PARSED_H_ | 69 #endif // NET_DNS_RECORD_PARSED_H_ |
OLD | NEW |