1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 
6 #ifndef mozilla_netwerk_dns_mdns_libmdns_nsDNSServiceDiscovery_h
7 #define mozilla_netwerk_dns_mdns_libmdns_nsDNSServiceDiscovery_h
8 
9 #include "nsIDNSServiceDiscovery.h"
10 #include "nsCOMPtr.h"
11 #include "mozilla/RefPtr.h"
12 #include "nsRefPtrHashtable.h"
13 
14 namespace mozilla {
15 namespace net {
16 
17 class BrowseOperator;
18 class RegisterOperator;
19 
20 class nsDNSServiceDiscovery final : public nsIDNSServiceDiscovery {
21  public:
22   NS_DECL_THREADSAFE_ISUPPORTS
23   NS_DECL_NSIDNSSERVICEDISCOVERY
24 
25   explicit nsDNSServiceDiscovery() = default;
26 
27   /*
28   ** The mDNS service is started on demand. If no one uses, mDNS service will
29   ** not start. Therefore, all operations before service started will fail
30   ** and get error code |kDNSServiceErr_ServiceNotRunning| defined in dns_sd.h.
31   **/
32   nsresult Init();
33 
34   nsresult StopDiscovery(nsIDNSServiceDiscoveryListener* aListener);
35   nsresult UnregisterService(nsIDNSRegistrationListener* aListener);
36 
37  private:
38   virtual ~nsDNSServiceDiscovery() = default;
39 
40   nsRefPtrHashtable<nsISupportsHashKey, BrowseOperator> mDiscoveryMap;
41   nsRefPtrHashtable<nsISupportsHashKey, RegisterOperator> mRegisterMap;
42 };
43 
44 }  // namespace net
45 }  // namespace mozilla
46 
47 #endif  // mozilla_netwerk_dns_mdns_libmdns_nsDNSServiceDiscovery_h
48