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

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

Issue 15733008: Multicast DNS implementation (initial) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mdns_implementation2
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
(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 #ifndef NET_DNS_MDNS_LISTENER_H_
6 #define NET_DNS_MDNS_LISTENER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "net/dns/dns_query.h"
13 #include "net/dns/dns_response.h"
14 #include "net/dns/record_parsed.h"
15
16 namespace net {
17
18 extern const char kMDNSMulticastGroupIPv4[];
szym 2013/05/24 15:32:22 Why do you need this?
Noam Samuel 2013/05/24 21:59:18 I put it here so that classes other than the imple
Noam Samuel 2013/05/29 21:25:16 Done.
19 extern const char kMDNSMulticastGroupIPv6[];
20
21 class RecordParsed;
22
23 class MDnsTransaction;
szym 2013/05/24 15:32:22 I suggest you define MDnsTransaction first so that
Noam Samuel 2013/05/29 21:25:16 Done.
24
25 class MDnsListener;
26
27 enum MDnsUpdateType {
28 kMDnsRecordAdded,
29 kMDnsRecordChanged,
30 kMDnsRecordRemoved
31 };
szym 2013/05/24 15:32:22 Seems redundant with MDnsCache::UpdateType.
Noam Samuel 2013/05/24 19:00:49 MDnsCache::UpdateType contains a NoChange member,
32
33 enum MDnsTransactionResult {
34 kMDnsTransactionSuccess,
35 kMDnsTransactionTimeout,
36 kMDnsTransactionNsec
37 };
38
39 class MDnsListenerFactory {
szym 2013/05/24 15:32:22 Needs a comment. I find the name confusing. It can
Noam Samuel 2013/05/29 21:25:16 Done.
40 public:
41 class Delegate {
42 public:
43 virtual ~Delegate() {}
44
45 virtual void OnRecordUpdate(MDnsUpdateType update,
46 const RecordParsed* record) = 0;
47
48 // TODO(noamsml): Called when a record is marked nonexistent by an NSEC
49 // record.
szym 2013/05/24 15:32:22 Not sure why there's TODO here. What part is missi
Noam Samuel 2013/05/24 19:00:49 Maybe the TODO should be moved somewhere else. The
Noam Samuel 2013/05/29 21:25:16 Done.
50 virtual void OnNSecRecord(const std::string& name, unsigned type) = 0;
szym 2013/05/24 15:32:22 Spell "NSec" vs. "Nsec" consistently here and in M
Noam Samuel 2013/05/29 21:25:16 Done.
51 };
52
53 typedef base::Callback<void(MDnsTransactionResult, const RecordParsed*)>
54 QueryCallback;
55
56 virtual ~MDnsListenerFactory() {}
57
58 // Add delegate for RRType |rrtype| and name |name|.
szym 2013/05/24 15:32:22 Comment says "Add delegate" but it creates a Liste
Noam Samuel 2013/05/29 21:25:16 Done.
59 // If |name| is an empty string, listen to all notification of type
60 // |rrtype|.
61 virtual scoped_ptr<MDnsListener> CreateListener(
62 uint16 rrtype,
63 const std::string& name,
64 bool active,
szym 2013/05/24 15:32:22 Needs comment.
Noam Samuel 2013/05/29 21:25:16 Done.
65 bool alert_existing_records,
szym 2013/05/24 15:32:22 Needs comment.
Noam Samuel 2013/05/29 21:25:16 Done.
66 Delegate* delegate) = 0;
67
68 // Create a transaction to Query MDNS for a single-value query
69 // (A, AAAA, TXT, and SRV) asynchronously. May defer to cache.
70 virtual scoped_ptr<MDnsTransaction> CreateTransaction(
71 uint16 rrtype,
72 const std::string& name,
73 const QueryCallback& callback) = 0;
74
75 // Lazily create and return static instance for MDnsListenerFactory.
76 static MDnsListenerFactory* GetInstance();
77
78 // Set the global instance (for testing). MUST be called before the first call
79 // to GetInstance.
80 static void SetInstance(MDnsListenerFactory* instance);
81 };
82
83 class MDnsTransaction {
84 public:
85 // Destroing the transaction cancels pending transactions.
szym 2013/05/24 15:32:22 "Destroying" "it" would be better than "pending tr
Noam Samuel 2013/05/29 21:25:16 Done.
86 virtual ~MDnsTransaction() {}
87
88 // Get the host or service name for the query.
89 virtual const std::string& GetName() const = 0;
90
91 // Get the type for this query (SRV, TXT, A, AAA, etc)
92 virtual uint16 GetType() const = 0;
93 };
94
95 class MDnsListener {
96 public:
97 // Destroying the listener stops listening.
98 virtual ~MDnsListener() {}
99
100 // Get the host or service name for this query.
101 // Return an empty string for no name.
102 virtual const std::string& GetName() const = 0;
103
104 // Get the type for this query (SRV, TXT, A, AAA, etc)
105 virtual uint16 GetType() const = 0;
106
107 // Whether this listener is active (true) or passive (false)
szym 2013/05/24 15:32:22 What does that mean?
Noam Samuel 2013/05/24 19:00:49 An active listener is allowed to send periodic que
Noam Samuel 2013/05/29 21:25:16 Done.
108 virtual bool IsActive() const = 0;
109
110 // Applies only to listeners with names. Will send out a query for new
111 // information. |force_refresh_cache| will force a refresh of all cached
112 // entities.
113 virtual bool SendQuery(bool force_refresh_cache) = 0;
114
115 // Applies only to listeners with names. Query mDNS cache synchronously for
116 // either single- or multi- valued records.
117 virtual bool QueryCache(std::vector<const RecordParsed*>* records) const = 0;
118 };
119 } // net
120 #endif // NET_DNS_MDNS_LISTENER_H_
OLDNEW
« no previous file with comments | « net/dns/dns_response.cc ('k') | net/dns/mdns_listener.cc » ('j') | net/dns/mdns_listener_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698