Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2007)

Unified Diff: net/dns/record_parsed.cc

Issue 14697022: Cache for mDNS records (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@record_parsed_klassbit
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/dns/record_parsed.cc
diff --git a/net/dns/record_parsed.cc b/net/dns/record_parsed.cc
index f02fbe3e85e362d7063d70ce0448fd7f7f03de8a..f88e3fa67f62632d7c236321674f12d76663911b 100644
--- a/net/dns/record_parsed.cc
+++ b/net/dns/record_parsed.cc
@@ -4,14 +4,23 @@
#include "net/dns/record_parsed.h"
+#include "base/logging.h"
#include "net/dns/dns_response.h"
#include "net/dns/record_rdata.h"
namespace net {
RecordParsed::RecordParsed(const std::string& name, uint16 type, uint16 klass,
- uint32 ttl, scoped_ptr<const RecordRdata> rdata)
- : name_(name), type_(type), klass_(klass), ttl_(ttl), rdata_(rdata.Pass()) {
+ uint32 ttl, scoped_ptr<const RecordRdata> rdata,
+ base::Time time_created)
+ : name_(name), type_(type), klass_(klass), ttl_(ttl), rdata_(rdata.Pass()),
+ time_created_(time_created) {
+}
+
+RecordParsed::RecordParsed(const RecordParsed& other)
+ : name_(other.name_), type_(other.type_), klass_(other.klass_),
+ ttl_(other.ttl_), rdata_(other.rdata_->Copy()),
+ time_created_(other.time_created_) {
}
RecordParsed::~RecordParsed() {
@@ -19,7 +28,8 @@ RecordParsed::~RecordParsed() {
// static
scoped_ptr<const RecordParsed> RecordParsed::CreateFrom(
- DnsRecordParser* parser) {
+ DnsRecordParser* parser,
+ base::Time time_created) {
DnsResourceRecord record;
scoped_ptr<const RecordRdata> rdata;
@@ -30,6 +40,9 @@ scoped_ptr<const RecordParsed> RecordParsed::CreateFrom(
case ARecordRdata::kType:
rdata = ARecordRdata::Create(record.rdata, *parser);
break;
+ case AAAARecordRdata::kType:
+ rdata = AAAARecordRdata::Create(record.rdata, *parser);
+ break;
case CnameRecordRdata::kType:
rdata = CnameRecordRdata::Create(record.rdata, *parser);
break;
@@ -43,6 +56,7 @@ scoped_ptr<const RecordParsed> RecordParsed::CreateFrom(
rdata = TxtRecordRdata::Create(record.rdata, *parser);
break;
default:
+ LOG(WARNING) << "Unknown RData type for recieved record: " << record.type;
return scoped_ptr<const RecordParsed>();
}
@@ -53,6 +67,23 @@ scoped_ptr<const RecordParsed> RecordParsed::CreateFrom(
record.type,
record.klass,
record.ttl,
- rdata.Pass()));
+ rdata.Pass(),
+ time_created));
+}
+
+bool RecordParsed::IsEqual(const RecordParsed* other, bool is_mdns) const {
+ DCHECK(other);
+ uint16 klass = klass_;
+ uint16 other_klass = other->klass_;
+
+ if (is_mdns) {
+ klass &= dns_protocol::kMDnsClassMask;
+ other_klass &= dns_protocol::kMDnsClassMask;
+ }
+
+ return name_ == other->name_ &&
+ klass == other_klass &&
+ type_ == other->type_ &&
+ rdata_->IsEqual(other->rdata_.get());
}
}

Powered by Google App Engine
This is Rietveld 408576698