Chromium Code Reviews| 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 "base/big_endian.h" | 7 #include "base/big_endian.h" |
| 8 #include "net/dns/dns_protocol.h" | 8 #include "net/dns/dns_protocol.h" |
| 9 #include "net/dns/dns_response.h" | 9 #include "net/dns/dns_response.h" |
| 10 | 10 |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 bitmap_data.begin(), | 252 bitmap_data.begin(), |
| 253 bitmap_data.end()); | 253 bitmap_data.end()); |
| 254 | 254 |
| 255 return rdata; | 255 return rdata; |
| 256 } | 256 } |
| 257 | 257 |
| 258 uint16_t NsecRecordRdata::Type() const { | 258 uint16_t NsecRecordRdata::Type() const { |
| 259 return NsecRecordRdata::kType; | 259 return NsecRecordRdata::kType; |
| 260 } | 260 } |
| 261 | 261 |
| 262 uint16_t NsecRecordRdata::bitmap_length() const { | |
| 263 DCHECK_LE(bitmap_.size(), 32u); | |
|
Ryan Sleevi
2016/07/06 15:28:58
It's unclear if you added this DCHECK as documenta
| |
| 264 return static_cast<uint16_t>(bitmap_.size() * 8); | |
| 265 } | |
| 266 | |
| 262 bool NsecRecordRdata::IsEqual(const RecordRdata* other) const { | 267 bool NsecRecordRdata::IsEqual(const RecordRdata* other) const { |
| 263 if (other->Type() != Type()) | 268 if (other->Type() != Type()) |
| 264 return false; | 269 return false; |
| 265 const NsecRecordRdata* nsec_other = | 270 const NsecRecordRdata* nsec_other = |
| 266 static_cast<const NsecRecordRdata*>(other); | 271 static_cast<const NsecRecordRdata*>(other); |
| 267 return bitmap_ == nsec_other->bitmap_; | 272 return bitmap_ == nsec_other->bitmap_; |
| 268 } | 273 } |
| 269 | 274 |
| 270 bool NsecRecordRdata::GetBit(unsigned i) const { | 275 bool NsecRecordRdata::GetBit(unsigned i) const { |
| 271 unsigned byte_num = i/8; | 276 unsigned byte_num = i/8; |
| 272 if (bitmap_.size() < byte_num + 1) | 277 if (bitmap_.size() < byte_num + 1) |
| 273 return false; | 278 return false; |
| 274 | 279 |
| 275 unsigned bit_num = 7 - i % 8; | 280 unsigned bit_num = 7 - i % 8; |
| 276 return (bitmap_[byte_num] & (1 << bit_num)) != 0; | 281 return (bitmap_[byte_num] & (1 << bit_num)) != 0; |
| 277 } | 282 } |
| 278 | 283 |
| 279 } // namespace net | 284 } // namespace net |
| OLD | NEW |