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_rdata.h" | 5 #include "net/dns/record_rdata.h" |
6 | 6 |
7 #include "net/base/big_endian.h" | 7 #include "net/base/big_endian.h" |
8 #include "net/base/dns_util.h" | 8 #include "net/base/dns_util.h" |
9 #include "net/dns/dns_protocol.h" | 9 #include "net/dns/dns_protocol.h" |
10 #include "net/dns/dns_response.h" | 10 #include "net/dns/dns_response.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 bool SrvRecordRdata::IsEqual(const RecordRdata* other) const { | 49 bool SrvRecordRdata::IsEqual(const RecordRdata* other) const { |
50 if (other->Type() != Type()) return false; | 50 if (other->Type() != Type()) return false; |
51 const SrvRecordRdata* srv_other = static_cast<const SrvRecordRdata*>(other); | 51 const SrvRecordRdata* srv_other = static_cast<const SrvRecordRdata*>(other); |
52 return weight_ == srv_other->weight_ && | 52 return weight_ == srv_other->weight_ && |
53 port_ == srv_other->port_ && | 53 port_ == srv_other->port_ && |
54 priority_ == srv_other->priority_ && | 54 priority_ == srv_other->priority_ && |
55 target_ == srv_other->target_; | 55 target_ == srv_other->target_; |
56 } | 56 } |
57 | 57 |
| 58 scoped_ptr<const RecordRdata> SrvRecordRdata::Clone() const { |
| 59 scoped_ptr<SrvRecordRdata> return_value(new SrvRecordRdata); |
| 60 |
| 61 return_value->port_ = port_; |
| 62 return_value->weight_ = weight_; |
| 63 return_value->priority_ = priority_; |
| 64 return_value->target_ = target_; |
| 65 |
| 66 return scoped_ptr<const RecordRdata>(return_value.Pass()); |
| 67 } |
| 68 |
58 ARecordRdata::ARecordRdata() { | 69 ARecordRdata::ARecordRdata() { |
59 } | 70 } |
60 | 71 |
61 ARecordRdata::~ARecordRdata() { | 72 ARecordRdata::~ARecordRdata() { |
62 } | 73 } |
63 | 74 |
64 // static | 75 // static |
65 scoped_ptr<ARecordRdata> ARecordRdata::Create( | 76 scoped_ptr<ARecordRdata> ARecordRdata::Create( |
66 const base::StringPiece& data, | 77 const base::StringPiece& data, |
67 const DnsRecordParser& parser) { | 78 const DnsRecordParser& parser) { |
(...skipping 13 matching lines...) Expand all Loading... |
81 uint16 ARecordRdata::Type() const { | 92 uint16 ARecordRdata::Type() const { |
82 return ARecordRdata::kType; | 93 return ARecordRdata::kType; |
83 } | 94 } |
84 | 95 |
85 bool ARecordRdata::IsEqual(const RecordRdata* other) const { | 96 bool ARecordRdata::IsEqual(const RecordRdata* other) const { |
86 if (other->Type() != Type()) return false; | 97 if (other->Type() != Type()) return false; |
87 const ARecordRdata* a_other = static_cast<const ARecordRdata*>(other); | 98 const ARecordRdata* a_other = static_cast<const ARecordRdata*>(other); |
88 return address_ == a_other->address_; | 99 return address_ == a_other->address_; |
89 } | 100 } |
90 | 101 |
| 102 scoped_ptr<const RecordRdata> ARecordRdata::Clone() const { |
| 103 scoped_ptr<ARecordRdata> return_value(new ARecordRdata); |
| 104 |
| 105 return_value->address_ = address_; |
| 106 |
| 107 return return_value.PassAs<const RecordRdata>(); |
| 108 } |
| 109 |
91 AAAARecordRdata::AAAARecordRdata() { | 110 AAAARecordRdata::AAAARecordRdata() { |
92 } | 111 } |
93 | 112 |
94 AAAARecordRdata::~AAAARecordRdata() { | 113 AAAARecordRdata::~AAAARecordRdata() { |
95 } | 114 } |
96 | 115 |
97 // static | 116 // static |
98 scoped_ptr<AAAARecordRdata> AAAARecordRdata::Create( | 117 scoped_ptr<AAAARecordRdata> AAAARecordRdata::Create( |
99 const base::StringPiece& data, | 118 const base::StringPiece& data, |
100 const DnsRecordParser& parser) { | 119 const DnsRecordParser& parser) { |
(...skipping 13 matching lines...) Expand all Loading... |
114 uint16 AAAARecordRdata::Type() const { | 133 uint16 AAAARecordRdata::Type() const { |
115 return AAAARecordRdata::kType; | 134 return AAAARecordRdata::kType; |
116 } | 135 } |
117 | 136 |
118 bool AAAARecordRdata::IsEqual(const RecordRdata* other) const { | 137 bool AAAARecordRdata::IsEqual(const RecordRdata* other) const { |
119 if (other->Type() != Type()) return false; | 138 if (other->Type() != Type()) return false; |
120 const AAAARecordRdata* a_other = static_cast<const AAAARecordRdata*>(other); | 139 const AAAARecordRdata* a_other = static_cast<const AAAARecordRdata*>(other); |
121 return address_ == a_other->address_; | 140 return address_ == a_other->address_; |
122 } | 141 } |
123 | 142 |
| 143 scoped_ptr<const RecordRdata> AAAARecordRdata::Clone() const { |
| 144 scoped_ptr<AAAARecordRdata> return_value(new AAAARecordRdata); |
| 145 |
| 146 return_value->address_ = address_; |
| 147 |
| 148 return return_value.PassAs<const RecordRdata>(); |
| 149 } |
| 150 |
124 CnameRecordRdata::CnameRecordRdata() { | 151 CnameRecordRdata::CnameRecordRdata() { |
125 } | 152 } |
126 | 153 |
127 CnameRecordRdata::~CnameRecordRdata() { | 154 CnameRecordRdata::~CnameRecordRdata() { |
128 } | 155 } |
129 | 156 |
130 // static | 157 // static |
131 scoped_ptr<CnameRecordRdata> CnameRecordRdata::Create( | 158 scoped_ptr<CnameRecordRdata> CnameRecordRdata::Create( |
132 const base::StringPiece& data, | 159 const base::StringPiece& data, |
133 const DnsRecordParser& parser) { | 160 const DnsRecordParser& parser) { |
134 scoped_ptr<CnameRecordRdata> rdata(new CnameRecordRdata); | 161 scoped_ptr<CnameRecordRdata> rdata(new CnameRecordRdata); |
135 | 162 |
136 if (!parser.ReadName(data.begin(), &rdata->cname_)) | 163 if (!parser.ReadName(data.begin(), &rdata->cname_)) |
137 return scoped_ptr<CnameRecordRdata>(); | 164 return scoped_ptr<CnameRecordRdata>(); |
138 | 165 |
139 return rdata.Pass(); | 166 return rdata.Pass(); |
140 } | 167 } |
141 | 168 |
142 uint16 CnameRecordRdata::Type() const { | 169 uint16 CnameRecordRdata::Type() const { |
143 return CnameRecordRdata::kType; | 170 return CnameRecordRdata::kType; |
144 } | 171 } |
145 | 172 |
146 bool CnameRecordRdata::IsEqual(const RecordRdata* other) const { | 173 bool CnameRecordRdata::IsEqual(const RecordRdata* other) const { |
147 if (other->Type() != Type()) return false; | 174 if (other->Type() != Type()) return false; |
148 const CnameRecordRdata* cname_other = | 175 const CnameRecordRdata* cname_other = |
149 static_cast<const CnameRecordRdata*>(other); | 176 static_cast<const CnameRecordRdata*>(other); |
150 return cname_ == cname_other->cname_; | 177 return cname_ == cname_other->cname_; |
151 } | 178 } |
152 | 179 |
| 180 scoped_ptr<const RecordRdata> CnameRecordRdata::Clone() const { |
| 181 scoped_ptr<CnameRecordRdata> return_value(new CnameRecordRdata); |
| 182 |
| 183 return_value->cname_ = cname_; |
| 184 |
| 185 return return_value.PassAs<const RecordRdata>(); |
| 186 } |
| 187 |
153 PtrRecordRdata::PtrRecordRdata() { | 188 PtrRecordRdata::PtrRecordRdata() { |
154 } | 189 } |
155 | 190 |
156 PtrRecordRdata::~PtrRecordRdata() { | 191 PtrRecordRdata::~PtrRecordRdata() { |
157 } | 192 } |
158 | 193 |
159 // static | 194 // static |
160 scoped_ptr<PtrRecordRdata> PtrRecordRdata::Create( | 195 scoped_ptr<PtrRecordRdata> PtrRecordRdata::Create( |
161 const base::StringPiece& data, | 196 const base::StringPiece& data, |
162 const DnsRecordParser& parser) { | 197 const DnsRecordParser& parser) { |
163 scoped_ptr<PtrRecordRdata> rdata(new PtrRecordRdata); | 198 scoped_ptr<PtrRecordRdata> rdata(new PtrRecordRdata); |
164 | 199 |
165 if (!parser.ReadName(data.begin(), &rdata->ptrdomain_)) | 200 if (!parser.ReadName(data.begin(), &rdata->ptrdomain_)) |
166 return scoped_ptr<PtrRecordRdata>(); | 201 return scoped_ptr<PtrRecordRdata>(); |
167 | 202 |
168 return rdata.Pass(); | 203 return rdata.Pass(); |
169 } | 204 } |
170 | 205 |
171 uint16 PtrRecordRdata::Type() const { | 206 uint16 PtrRecordRdata::Type() const { |
172 return PtrRecordRdata::kType; | 207 return PtrRecordRdata::kType; |
173 } | 208 } |
174 | 209 |
175 bool PtrRecordRdata::IsEqual(const RecordRdata* other) const { | 210 bool PtrRecordRdata::IsEqual(const RecordRdata* other) const { |
176 if (other->Type() != Type()) return false; | 211 if (other->Type() != Type()) return false; |
177 const PtrRecordRdata* ptr_other = static_cast<const PtrRecordRdata*>(other); | 212 const PtrRecordRdata* ptr_other = static_cast<const PtrRecordRdata*>(other); |
178 return ptrdomain_ == ptr_other->ptrdomain_; | 213 return ptrdomain_ == ptr_other->ptrdomain_; |
179 } | 214 } |
180 | 215 |
| 216 scoped_ptr<const RecordRdata> PtrRecordRdata::Clone() const { |
| 217 scoped_ptr<PtrRecordRdata> return_value(new PtrRecordRdata); |
| 218 |
| 219 return_value->ptrdomain_ = ptrdomain_; |
| 220 |
| 221 return return_value.PassAs<const RecordRdata>(); |
| 222 } |
| 223 |
181 TxtRecordRdata::TxtRecordRdata() { | 224 TxtRecordRdata::TxtRecordRdata() { |
182 } | 225 } |
183 | 226 |
184 TxtRecordRdata::~TxtRecordRdata() { | 227 TxtRecordRdata::~TxtRecordRdata() { |
185 } | 228 } |
186 | 229 |
187 // static | 230 // static |
188 scoped_ptr<TxtRecordRdata> TxtRecordRdata::Create( | 231 scoped_ptr<TxtRecordRdata> TxtRecordRdata::Create( |
189 const base::StringPiece& data, | 232 const base::StringPiece& data, |
190 const DnsRecordParser& parser) { | 233 const DnsRecordParser& parser) { |
(...skipping 14 matching lines...) Expand all Loading... |
205 return rdata.Pass(); | 248 return rdata.Pass(); |
206 } | 249 } |
207 | 250 |
208 uint16 TxtRecordRdata::Type() const { | 251 uint16 TxtRecordRdata::Type() const { |
209 return TxtRecordRdata::kType; | 252 return TxtRecordRdata::kType; |
210 } | 253 } |
211 | 254 |
212 bool TxtRecordRdata::IsEqual(const RecordRdata* other) const { | 255 bool TxtRecordRdata::IsEqual(const RecordRdata* other) const { |
213 if (other->Type() != Type()) return false; | 256 if (other->Type() != Type()) return false; |
214 const TxtRecordRdata* txt_other = static_cast<const TxtRecordRdata*>(other); | 257 const TxtRecordRdata* txt_other = static_cast<const TxtRecordRdata*>(other); |
| 258 |
215 return texts_ == txt_other->texts_; | 259 return texts_ == txt_other->texts_; |
216 } | 260 } |
217 | 261 |
| 262 scoped_ptr<const RecordRdata> TxtRecordRdata::Clone() const { |
| 263 scoped_ptr<TxtRecordRdata> return_value(new TxtRecordRdata); |
| 264 |
| 265 return_value->texts_ = texts_; |
| 266 |
| 267 return return_value.PassAs<const RecordRdata>(); |
| 268 } |
| 269 |
218 } // namespace net | 270 } // namespace net |
OLD | NEW |