OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_MDNS_CLIENT_H_ | 5 #ifndef NET_DNS_MDNS_CLIENT_H_ |
6 #define NET_DNS_MDNS_CLIENT_H_ | 6 #define NET_DNS_MDNS_CLIENT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/scoped_ptr.h" |
12 #include "net/base/ip_endpoint.h" | 13 #include "net/base/ip_endpoint.h" |
13 #include "net/dns/dns_query.h" | 14 #include "net/dns/dns_query.h" |
14 #include "net/dns/dns_response.h" | 15 #include "net/dns/dns_response.h" |
15 #include "net/dns/record_parsed.h" | 16 #include "net/dns/record_parsed.h" |
16 | 17 |
17 template <typename T> | |
18 class ScopedVector; | |
19 | |
20 namespace net { | 18 namespace net { |
21 | 19 |
22 class DatagramServerSocket; | 20 class DatagramServerSocket; |
23 class RecordParsed; | 21 class RecordParsed; |
24 | 22 |
25 // Represents a one-time record lookup. A transaction takes one | 23 // Represents a one-time record lookup. A transaction takes one |
26 // associated callback (see |MDnsClient::CreateTransaction|) and calls it | 24 // associated callback (see |MDnsClient::CreateTransaction|) and calls it |
27 // whenever a matching record has been found, either from the cache or | 25 // whenever a matching record has been found, either from the cache or |
28 // by querying the network (it may choose to query either or both based on its | 26 // by querying the network (it may choose to query either or both based on its |
29 // creation flags, see MDnsTransactionFlags). Network-based transactions will | 27 // creation flags, see MDnsTransactionFlags). Network-based transactions will |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 virtual const std::string& GetName() const = 0; | 122 virtual const std::string& GetName() const = 0; |
125 | 123 |
126 // Get the type for this query (SRV, TXT, A, AAA, etc) | 124 // Get the type for this query (SRV, TXT, A, AAA, etc) |
127 virtual uint16 GetType() const = 0; | 125 virtual uint16 GetType() const = 0; |
128 }; | 126 }; |
129 | 127 |
130 // Creates bound datagram sockets ready to use by MDnsClient. | 128 // Creates bound datagram sockets ready to use by MDnsClient. |
131 class NET_EXPORT MDnsSocketFactory { | 129 class NET_EXPORT MDnsSocketFactory { |
132 public: | 130 public: |
133 virtual ~MDnsSocketFactory() {} | 131 virtual ~MDnsSocketFactory() {} |
134 virtual void CreateSockets(ScopedVector<DatagramServerSocket>* sockets) = 0; | 132 virtual void CreateSockets( |
| 133 std::vector<scoped_ptr<DatagramServerSocket>>* sockets) = 0; |
135 | 134 |
136 static scoped_ptr<MDnsSocketFactory> CreateDefault(); | 135 static scoped_ptr<MDnsSocketFactory> CreateDefault(); |
137 }; | 136 }; |
138 | 137 |
139 // Listens for Multicast DNS on the local network. You can access information | 138 // Listens for Multicast DNS on the local network. You can access information |
140 // regarding multicast DNS either by creating an |MDnsListener| to be notified | 139 // regarding multicast DNS either by creating an |MDnsListener| to be notified |
141 // of new records, or by creating an |MDnsTransaction| to look up the value of a | 140 // of new records, or by creating an |MDnsTransaction| to look up the value of a |
142 // specific records. When all listeners and active transactions are destroyed, | 141 // specific records. When all listeners and active transactions are destroyed, |
143 // the client stops listening on the network and destroys the cache. | 142 // the client stops listening on the network and destroys the cache. |
144 class NET_EXPORT MDnsClient { | 143 class NET_EXPORT MDnsClient { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 // Create sockets, binds socket to MDns endpoint, and sets multicast interface | 180 // Create sockets, binds socket to MDns endpoint, and sets multicast interface |
182 // and joins multicast group on for |interface_index|. | 181 // and joins multicast group on for |interface_index|. |
183 // Returns NULL if failed. | 182 // Returns NULL if failed. |
184 NET_EXPORT scoped_ptr<DatagramServerSocket> CreateAndBindMDnsSocket( | 183 NET_EXPORT scoped_ptr<DatagramServerSocket> CreateAndBindMDnsSocket( |
185 AddressFamily address_family, | 184 AddressFamily address_family, |
186 uint32 interface_index); | 185 uint32 interface_index); |
187 | 186 |
188 } // namespace net | 187 } // namespace net |
189 | 188 |
190 #endif // NET_DNS_MDNS_CLIENT_H_ | 189 #endif // NET_DNS_MDNS_CLIENT_H_ |
OLD | NEW |