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_IMPL_H_ | 5 #ifndef NET_DNS_MDNS_CLIENT_IMPL_H_ |
6 #define NET_DNS_MDNS_CLIENT_IMPL_H_ | 6 #define NET_DNS_MDNS_CLIENT_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 uint16 rrtype, | 174 uint16 rrtype, |
175 const std::string& name, | 175 const std::string& name, |
176 MDnsListener::Delegate* delegate) OVERRIDE; | 176 MDnsListener::Delegate* delegate) OVERRIDE; |
177 | 177 |
178 virtual scoped_ptr<MDnsTransaction> CreateTransaction( | 178 virtual scoped_ptr<MDnsTransaction> CreateTransaction( |
179 uint16 rrtype, | 179 uint16 rrtype, |
180 const std::string& name, | 180 const std::string& name, |
181 int flags, | 181 int flags, |
182 const MDnsTransaction::ResultCallback& callback) OVERRIDE; | 182 const MDnsTransaction::ResultCallback& callback) OVERRIDE; |
183 | 183 |
184 // Returns true when the client is listening for network packets. | 184 virtual bool StartListening() OVERRIDE; |
185 bool IsListeningForTests(); | 185 virtual void StopListening() OVERRIDE; |
186 | 186 virtual bool IsListening() const OVERRIDE; |
187 bool AddListenRef(); | |
188 void SubtractListenRef(); | |
189 | 187 |
190 Core* core() { return core_.get(); } | 188 Core* core() { return core_.get(); } |
191 | 189 |
192 private: | 190 private: |
193 // This method causes the client to stop listening for packets. The | |
194 // call for it is deferred through the message loop after the last | |
195 // listener is removed. If another listener is added after a | |
196 // shutdown is scheduled but before it actually runs, the shutdown | |
197 // will be canceled. | |
198 void Shutdown(); | |
199 | |
200 scoped_ptr<Core> core_; | 191 scoped_ptr<Core> core_; |
201 int listen_refs_; | |
202 | 192 |
203 scoped_ptr<MDnsConnection::SocketFactory> socket_factory_; | 193 scoped_ptr<MDnsConnection::SocketFactory> socket_factory_; |
204 | 194 |
205 DISALLOW_COPY_AND_ASSIGN(MDnsClientImpl); | 195 DISALLOW_COPY_AND_ASSIGN(MDnsClientImpl); |
206 }; | 196 }; |
207 | 197 |
208 class MDnsListenerImpl : public MDnsListener, | 198 class MDnsListenerImpl : public MDnsListener, |
209 public base::SupportsWeakPtr<MDnsListenerImpl> { | 199 public base::SupportsWeakPtr<MDnsListenerImpl> { |
210 public: | 200 public: |
211 MDnsListenerImpl(uint16 rrtype, | 201 MDnsListenerImpl(uint16 rrtype, |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 MDnsClientImpl* client_; | 289 MDnsClientImpl* client_; |
300 | 290 |
301 bool started_; | 291 bool started_; |
302 int flags_; | 292 int flags_; |
303 | 293 |
304 DISALLOW_COPY_AND_ASSIGN(MDnsTransactionImpl); | 294 DISALLOW_COPY_AND_ASSIGN(MDnsTransactionImpl); |
305 }; | 295 }; |
306 | 296 |
307 } // namespace net | 297 } // namespace net |
308 #endif // NET_DNS_MDNS_CLIENT_IMPL_H_ | 298 #endif // NET_DNS_MDNS_CLIENT_IMPL_H_ |
OLD | NEW |