Index: net/dns/record_rdata.cc |
diff --git a/net/dns/record_rdata.cc b/net/dns/record_rdata.cc |
index 1de3a4c8b5fedaa379ce0d7f217825a889daba72..121fe2468d0fab3f64883ceee573416a9abac5ae 100644 |
--- a/net/dns/record_rdata.cc |
+++ b/net/dns/record_rdata.cc |
@@ -9,6 +9,8 @@ |
#include "net/dns/dns_protocol.h" |
#include "net/dns/dns_response.h" |
+// TODO(noamsml): PRE-SUBMIT figure out better way to pass scoped_ptrs. |
+ |
namespace net { |
static const size_t kSrvRecordMinimumSize = 6; |
@@ -42,6 +44,30 @@ scoped_ptr<SrvRecordRdata> SrvRecordRdata::Create( |
return rdata.Pass(); |
} |
+uint16 SrvRecordRdata::Type() const { |
+ return SrvRecordRdata::kType; |
+} |
+ |
+bool SrvRecordRdata::IsEqual(const RecordRdata* other) const { |
+ if (other->Type() != Type()) return false; |
+ const SrvRecordRdata* srv_other = static_cast<const SrvRecordRdata*>(other); |
+ return weight_ == srv_other->weight_ && |
+ port_ == srv_other->port_ && |
+ priority_ == srv_other->priority_ && |
+ target_ == srv_other->target_; |
+} |
+ |
+scoped_ptr<const RecordRdata> SrvRecordRdata::Copy() const { |
+ scoped_ptr<SrvRecordRdata> return_value(new SrvRecordRdata); |
+ |
+ return_value->port_ = port_; |
+ return_value->weight_ = weight_; |
+ return_value->priority_ = priority_; |
+ return_value->target_ = target_; |
+ |
+ return scoped_ptr<const RecordRdata>(return_value.Pass()); |
szym
2013/05/14 18:14:27
I think you can use |return_value.PassAs<const Rec
Noam Samuel
2013/05/15 20:17:57
Done.
|
+} |
+ |
ARecordRdata::ARecordRdata() { |
} |
@@ -65,6 +91,65 @@ scoped_ptr<ARecordRdata> ARecordRdata::Create( |
return rdata.Pass(); |
} |
+uint16 ARecordRdata::Type() const { |
+ return ARecordRdata::kType; |
+} |
+ |
+bool ARecordRdata::IsEqual(const RecordRdata* other) const { |
+ if (other->Type() != Type()) return false; |
+ const ARecordRdata* a_other = static_cast<const ARecordRdata*>(other); |
+ return address_ == a_other->address_; |
+} |
+ |
+scoped_ptr<const RecordRdata> ARecordRdata::Copy() const { |
+ scoped_ptr<ARecordRdata> return_value(new ARecordRdata); |
+ |
+ return_value->address_ = address_; |
+ |
+ return scoped_ptr<const RecordRdata>(return_value.Pass()); |
+} |
+ |
+AAAARecordRdata::AAAARecordRdata() { |
+} |
+ |
+AAAARecordRdata::~AAAARecordRdata() { |
+} |
+ |
+// static |
+scoped_ptr<AAAARecordRdata> AAAARecordRdata::Create( |
+ const base::StringPiece& data, |
+ const DnsRecordParser& parser) { |
+ if (data.size() != kIPv6AddressSize) |
+ return scoped_ptr<AAAARecordRdata>(); |
+ |
+ scoped_ptr<AAAARecordRdata> rdata(new AAAARecordRdata); |
+ |
+ rdata->address_.resize(kIPv6AddressSize); |
+ for (unsigned i = 0; i < kIPv6AddressSize; ++i) { |
+ rdata->address_[i] = data[i]; |
+ } |
+ |
+ return rdata.Pass(); |
+} |
+ |
+uint16 AAAARecordRdata::Type() const { |
+ return AAAARecordRdata::kType; |
+} |
+ |
+bool AAAARecordRdata::IsEqual(const RecordRdata* other) const { |
+ if (other->Type() != Type()) return false; |
+ const AAAARecordRdata* a_other = static_cast<const AAAARecordRdata*>(other); |
+ return address_ == a_other->address_; |
+} |
+ |
+scoped_ptr<const RecordRdata> AAAARecordRdata::Copy() const { |
+ scoped_ptr<AAAARecordRdata> return_value(new AAAARecordRdata); |
+ |
+ return_value->address_ = address_; |
+ |
+ return scoped_ptr<const RecordRdata>(return_value.Pass()); |
+} |
+ |
CnameRecordRdata::CnameRecordRdata() { |
} |
@@ -83,6 +168,25 @@ scoped_ptr<CnameRecordRdata> CnameRecordRdata::Create( |
return rdata.Pass(); |
} |
+uint16 CnameRecordRdata::Type() const { |
+ return CnameRecordRdata::kType; |
+} |
+ |
+bool CnameRecordRdata::IsEqual(const RecordRdata* other) const { |
+ if (other->Type() != Type()) return false; |
+ const CnameRecordRdata* cname_other = |
+ static_cast<const CnameRecordRdata*>(other); |
+ return cname_ == cname_other->cname_; |
+} |
+ |
+scoped_ptr<const RecordRdata> CnameRecordRdata::Copy() const { |
+ scoped_ptr<CnameRecordRdata> return_value(new CnameRecordRdata); |
+ |
+ return_value->cname_ = cname_; |
+ |
+ return scoped_ptr<const RecordRdata>(return_value.Pass()); |
+} |
+ |
PtrRecordRdata::PtrRecordRdata() { |
} |
@@ -101,6 +205,24 @@ scoped_ptr<PtrRecordRdata> PtrRecordRdata::Create( |
return rdata.Pass(); |
} |
+uint16 PtrRecordRdata::Type() const { |
+ return PtrRecordRdata::kType; |
+} |
+ |
+bool PtrRecordRdata::IsEqual(const RecordRdata* other) const { |
+ if (other->Type() != Type()) return false; |
+ const PtrRecordRdata* ptr_other = static_cast<const PtrRecordRdata*>(other); |
+ return ptrdomain_ == ptr_other->ptrdomain_; |
+} |
+ |
+scoped_ptr<const RecordRdata> PtrRecordRdata::Copy() const { |
+ scoped_ptr<PtrRecordRdata> return_value(new PtrRecordRdata); |
+ |
+ return_value->ptrdomain_ = ptrdomain_; |
+ |
+ return scoped_ptr<const RecordRdata>(return_value.Pass()); |
+} |
+ |
TxtRecordRdata::TxtRecordRdata() { |
} |
@@ -128,4 +250,23 @@ scoped_ptr<TxtRecordRdata> TxtRecordRdata::Create( |
return rdata.Pass(); |
} |
+uint16 TxtRecordRdata::Type() const { |
+ return TxtRecordRdata::kType; |
+} |
+ |
+bool TxtRecordRdata::IsEqual(const RecordRdata* other) const { |
+ if (other->Type() != Type()) return false; |
+ const TxtRecordRdata* txt_other = static_cast<const TxtRecordRdata*>(other); |
+ |
+ return texts_ == txt_other->texts_; |
+} |
+ |
+scoped_ptr<const RecordRdata> TxtRecordRdata::Copy() const { |
+ scoped_ptr<TxtRecordRdata> return_value(new TxtRecordRdata); |
+ |
+ return_value->texts_ = texts_; |
+ |
+ return scoped_ptr<const RecordRdata>(return_value.Pass()); |
+} |
+ |
} // namespace net |