| 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 #include "net/dns/record_parsed.h" | 5 #include "net/dns/record_parsed.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "net/dns/dns_response.h" | 8 #include "net/dns/dns_response.h" |
| 9 #include "net/dns/record_rdata.h" | 9 #include "net/dns/record_rdata.h" |
| 10 | 10 |
| 11 namespace net { | 11 namespace net { |
| 12 | 12 |
| 13 RecordParsed::RecordParsed(const std::string& name, uint16 type, uint16 klass, | 13 RecordParsed::RecordParsed(const std::string& name, |
| 14 uint32 ttl, scoped_ptr<const RecordRdata> rdata, | 14 uint16_t type, |
| 15 uint16_t klass, |
| 16 uint32_t ttl, |
| 17 scoped_ptr<const RecordRdata> rdata, |
| 15 base::Time time_created) | 18 base::Time time_created) |
| 16 : name_(name), type_(type), klass_(klass), ttl_(ttl), rdata_(rdata.Pass()), | 19 : name_(name), |
| 17 time_created_(time_created) { | 20 type_(type), |
| 18 } | 21 klass_(klass), |
| 22 ttl_(ttl), |
| 23 rdata_(rdata.Pass()), |
| 24 time_created_(time_created) {} |
| 19 | 25 |
| 20 RecordParsed::~RecordParsed() { | 26 RecordParsed::~RecordParsed() { |
| 21 } | 27 } |
| 22 | 28 |
| 23 // static | 29 // static |
| 24 scoped_ptr<const RecordParsed> RecordParsed::CreateFrom( | 30 scoped_ptr<const RecordParsed> RecordParsed::CreateFrom( |
| 25 DnsRecordParser* parser, | 31 DnsRecordParser* parser, |
| 26 base::Time time_created) { | 32 base::Time time_created) { |
| 27 DnsResourceRecord record; | 33 DnsResourceRecord record; |
| 28 scoped_ptr<const RecordRdata> rdata; | 34 scoped_ptr<const RecordRdata> rdata; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 return scoped_ptr<const RecordParsed>(new RecordParsed(record.name, | 69 return scoped_ptr<const RecordParsed>(new RecordParsed(record.name, |
| 64 record.type, | 70 record.type, |
| 65 record.klass, | 71 record.klass, |
| 66 record.ttl, | 72 record.ttl, |
| 67 rdata.Pass(), | 73 rdata.Pass(), |
| 68 time_created)); | 74 time_created)); |
| 69 } | 75 } |
| 70 | 76 |
| 71 bool RecordParsed::IsEqual(const RecordParsed* other, bool is_mdns) const { | 77 bool RecordParsed::IsEqual(const RecordParsed* other, bool is_mdns) const { |
| 72 DCHECK(other); | 78 DCHECK(other); |
| 73 uint16 klass = klass_; | 79 uint16_t klass = klass_; |
| 74 uint16 other_klass = other->klass_; | 80 uint16_t other_klass = other->klass_; |
| 75 | 81 |
| 76 if (is_mdns) { | 82 if (is_mdns) { |
| 77 klass &= dns_protocol::kMDnsClassMask; | 83 klass &= dns_protocol::kMDnsClassMask; |
| 78 other_klass &= dns_protocol::kMDnsClassMask; | 84 other_klass &= dns_protocol::kMDnsClassMask; |
| 79 } | 85 } |
| 80 | 86 |
| 81 return name_ == other->name_ && | 87 return name_ == other->name_ && |
| 82 klass == other_klass && | 88 klass == other_klass && |
| 83 type_ == other->type_ && | 89 type_ == other->type_ && |
| 84 rdata_->IsEqual(other->rdata_.get()); | 90 rdata_->IsEqual(other->rdata_.get()); |
| 85 } | 91 } |
| 86 } | 92 } |
| OLD | NEW |