| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 static scoped_ptr<const RecordParsed> CreateFrom(DnsRecordParser* parser, | 26 static scoped_ptr<const RecordParsed> CreateFrom(DnsRecordParser* parser, |
| 27 base::Time time_created); | 27 base::Time time_created); |
| 28 | 28 |
| 29 const std::string& name() const { return name_; } | 29 const std::string& name() const { return name_; } |
| 30 uint16 type() const { return type_; } | 30 uint16 type() const { return type_; } |
| 31 uint16 klass() const { return klass_; } | 31 uint16 klass() const { return klass_; } |
| 32 uint32 ttl() const { return ttl_; } | 32 uint32 ttl() const { return ttl_; } |
| 33 | 33 |
| 34 base::Time time_created() const { return time_created_; } | 34 base::Time time_created() const { return time_created_; } |
| 35 | 35 |
| 36 template <class T> const T* rdata() const { | 36 template <class T> |
| 37 const T* rdata() const { |
| 37 if (T::kType != type_) | 38 if (T::kType != type_) |
| 38 return NULL; | 39 return NULL; |
| 39 return static_cast<const T*>(rdata_.get()); | 40 return static_cast<const T*>(rdata_.get()); |
| 40 } | 41 } |
| 41 | 42 |
| 42 // Check if two records have the same data. Ignores time_created and ttl. | 43 // 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 | 44 // If |is_mdns| is true, ignore the top bit of the class |
| 44 // (the cache flush bit). | 45 // (the cache flush bit). |
| 45 bool IsEqual(const RecordParsed* other, bool is_mdns) const; | 46 bool IsEqual(const RecordParsed* other, bool is_mdns) const; |
| 46 | 47 |
| 47 private: | 48 private: |
| 48 RecordParsed(const std::string& name, uint16 type, uint16 klass, | 49 RecordParsed(const std::string& name, |
| 49 uint32 ttl, scoped_ptr<const RecordRdata> rdata, | 50 uint16 type, |
| 51 uint16 klass, |
| 52 uint32 ttl, |
| 53 scoped_ptr<const RecordRdata> rdata, |
| 50 base::Time time_created); | 54 base::Time time_created); |
| 51 | 55 |
| 52 std::string name_; // in dotted form | 56 std::string name_; // in dotted form |
| 53 const uint16 type_; | 57 const uint16 type_; |
| 54 const uint16 klass_; | 58 const uint16 klass_; |
| 55 const uint32 ttl_; | 59 const uint32 ttl_; |
| 56 | 60 |
| 57 const scoped_ptr<const RecordRdata> rdata_; | 61 const scoped_ptr<const RecordRdata> rdata_; |
| 58 | 62 |
| 59 const base::Time time_created_; | 63 const base::Time time_created_; |
| 60 }; | 64 }; |
| 61 | 65 |
| 62 } // namespace net | 66 } // namespace net |
| 63 | 67 |
| 64 #endif // NET_DNS_RECORD_PARSED_H_ | 68 #endif // NET_DNS_RECORD_PARSED_H_ |
| OLD | NEW |