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

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
« no previous file with comments | « net/dns/record_parsed.h ('k') | net/dns/record_parsed_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/record_parsed.cc
diff --git a/net/dns/record_parsed.cc b/net/dns/record_parsed.cc
index f02fbe3e85e362d7063d70ce0448fd7f7f03de8a..0ef96460865a1a2fcb742c1d917e29e4625e679f 100644
--- a/net/dns/record_parsed.cc
+++ b/net/dns/record_parsed.cc
@@ -4,14 +4,17 @@
#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() {
@@ -19,7 +22,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 +34,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 +50,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 +61,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());
}
}
« no previous file with comments | « net/dns/record_parsed.h ('k') | net/dns/record_parsed_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698