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