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

Side by Side Diff: net/dns/record_parsed.cc

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/dns/record_parsed.h"
6
7 #include "base/logging.h"
8 #include "net/dns/dns_response.h"
9 #include "net/dns/record_rdata.h"
10
11 namespace net {
12
13 RecordParsed::RecordParsed(const std::string& name, uint16 type, uint16 klass,
14 uint32 ttl, scoped_ptr<const RecordRdata> rdata,
15 base::Time time_created)
16 : name_(name), type_(type), klass_(klass), ttl_(ttl), rdata_(rdata.Pass()),
17 time_created_(time_created) {
18 }
19
20 RecordParsed::~RecordParsed() {
21 }
22
23 // static
24 scoped_ptr<const RecordParsed> RecordParsed::CreateFrom(
25 DnsRecordParser* parser,
26 base::Time time_created) {
27 DnsResourceRecord record;
28 scoped_ptr<const RecordRdata> rdata;
29
30 if (!parser->ReadRecord(&record))
31 return scoped_ptr<const RecordParsed>();
32
33 switch (record.type) {
34 case ARecordRdata::kType:
35 rdata = ARecordRdata::Create(record.rdata, *parser);
36 break;
37 case AAAARecordRdata::kType:
38 rdata = AAAARecordRdata::Create(record.rdata, *parser);
39 break;
40 case CnameRecordRdata::kType:
41 rdata = CnameRecordRdata::Create(record.rdata, *parser);
42 break;
43 case PtrRecordRdata::kType:
44 rdata = PtrRecordRdata::Create(record.rdata, *parser);
45 break;
46 case SrvRecordRdata::kType:
47 rdata = SrvRecordRdata::Create(record.rdata, *parser);
48 break;
49 case TxtRecordRdata::kType:
50 rdata = TxtRecordRdata::Create(record.rdata, *parser);
51 break;
52 case NsecRecordRdata::kType:
53 rdata = NsecRecordRdata::Create(record.rdata, *parser);
54 break;
55 default:
56 DVLOG(1) << "Unknown RData type for received record: " << record.type;
57 return scoped_ptr<const RecordParsed>();
58 }
59
60 if (!rdata.get())
61 return scoped_ptr<const RecordParsed>();
62
63 return scoped_ptr<const RecordParsed>(new RecordParsed(record.name,
64 record.type,
65 record.klass,
66 record.ttl,
67 rdata.Pass(),
68 time_created));
69 }
70
71 bool RecordParsed::IsEqual(const RecordParsed* other, bool is_mdns) const {
72 DCHECK(other);
73 uint16 klass = klass_;
74 uint16 other_klass = other->klass_;
75
76 if (is_mdns) {
77 klass &= dns_protocol::kMDnsClassMask;
78 other_klass &= dns_protocol::kMDnsClassMask;
79 }
80
81 return name_ == other->name_ &&
82 klass == other_klass &&
83 type_ == other->type_ &&
84 rdata_->IsEqual(other->rdata_.get());
85 }
86 }
OLDNEW
« 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