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

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

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 unified diff | Download patch
OLDNEW
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 #ifndef NET_DNS_RECORD_PARSED_H_ 5 #ifndef NET_DNS_RECORD_PARSED_H_
6 #define NET_DNS_RECORD_PARSED_H_ 6 #define NET_DNS_RECORD_PARSED_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/time.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "net/base/net_export.h" 12 #include "net/base/net_export.h"
12 13
13 namespace net { 14 namespace net {
14 15
15 class DnsRecordParser; 16 class DnsRecordParser;
16 class RecordRdata; 17 class RecordRdata;
17 18
18 // Parsed record. This is a form of DnsResourceRecord where the rdata section 19 // Parsed record. This is a form of DnsResourceRecord where the rdata section
19 // has been parsed into a data structure. 20 // has been parsed into a data structure.
20 class NET_EXPORT_PRIVATE RecordParsed { 21 class NET_EXPORT_PRIVATE RecordParsed {
21 public: 22 public:
23 RecordParsed(const RecordParsed&);
22 virtual ~RecordParsed(); 24 virtual ~RecordParsed();
23 25
24 // All records are inherently immutable. Return a const pointer. 26 // All records are inherently immutable. Return a const pointer.
25 static scoped_ptr<const RecordParsed> CreateFrom(DnsRecordParser* parser); 27 static scoped_ptr<const RecordParsed> CreateFrom(DnsRecordParser* parser,
28 base::Time time_created);
26 29
27 const std::string& name() const { return name_; } 30 const std::string& name() const { return name_; }
28 uint16 type() const { return type_; } 31 uint16 type() const { return type_; }
29 uint16 klass() const { return klass_; } 32 uint16 klass() const { return klass_; }
30 uint32 ttl() const { return ttl_; } 33 uint32 ttl() const { return ttl_; }
31 34
35 base::Time time_created() const { return time_created_; }
36
32 template <class T> const T* rdata() const { 37 template <class T> const T* rdata() const {
33 if (T::kType != type_) 38 if (T::kType != type_)
34 return NULL; 39 return NULL;
35 return static_cast<const T*>(rdata_.get()); 40 return static_cast<const T*>(rdata_.get());
36 } 41 }
37 42
43 // Check if two records have the same data. Ignores time_created and ttl.
44 // If |is_mdns| is true, ignore the top bit of the class
45 // (the cache flush bit).
46 bool IsEqual(const RecordParsed* other, bool is_mdns) const;
47
38 private: 48 private:
39 RecordParsed(const std::string& name, uint16 type, uint16 klass, uint32 ttl, 49 RecordParsed(const std::string& name, uint16 type, uint16 klass,
40 scoped_ptr<const RecordRdata> rdata); 50 uint32 ttl, scoped_ptr<const RecordRdata> rdata,
51 base::Time time_created);
41 52
42 std::string name_; // in dotted form 53 std::string name_; // in dotted form
43 const uint16 type_; 54 const uint16 type_;
44 const uint16 klass_; 55 const uint16 klass_;
45 const uint32 ttl_; 56 const uint32 ttl_;
46 57
47 const scoped_ptr<const RecordRdata> rdata_; 58 const scoped_ptr<const RecordRdata> rdata_;
48 59
49 DISALLOW_COPY_AND_ASSIGN(RecordParsed); 60 const base::Time time_created_;
50 }; 61 };
51 62
52 } // namespace net 63 } // namespace net
53 64
54 #endif // NET_DNS_RECORD_PARSED_H_ 65 #endif // NET_DNS_RECORD_PARSED_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698