nsDNSService2.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  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. #ifndef nsDNSService2_h__
  6. #define nsDNSService2_h__
  7. #include "nsPIDNSService.h"
  8. #include "nsIIDNService.h"
  9. #include "nsIMemoryReporter.h"
  10. #include "nsIObserver.h"
  11. #include "nsHostResolver.h"
  12. #include "nsAutoPtr.h"
  13. #include "nsString.h"
  14. #include "nsTHashtable.h"
  15. #include "nsHashKeys.h"
  16. #include "mozilla/Mutex.h"
  17. #include "mozilla/Attributes.h"
  18. class nsDNSService final : public nsPIDNSService
  19. , public nsIObserver
  20. , public nsIMemoryReporter
  21. {
  22. public:
  23. NS_DECL_THREADSAFE_ISUPPORTS
  24. NS_DECL_NSPIDNSSERVICE
  25. NS_DECL_NSIDNSSERVICE
  26. NS_DECL_NSIOBSERVER
  27. NS_DECL_NSIMEMORYREPORTER
  28. nsDNSService();
  29. static nsIDNSService* GetXPCOMSingleton();
  30. size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
  31. bool GetOffline() const;
  32. private:
  33. ~nsDNSService();
  34. static nsDNSService* GetSingleton();
  35. uint16_t GetAFForLookup(const nsACString &host, uint32_t flags);
  36. nsresult PreprocessHostname(bool aLocalDomain,
  37. const nsACString &aInput,
  38. nsIIDNService *aIDN,
  39. nsACString &aACE);
  40. RefPtr<nsHostResolver> mResolver;
  41. nsCOMPtr<nsIIDNService> mIDN;
  42. // mLock protects access to mResolver and mIPv4OnlyDomains
  43. mozilla::Mutex mLock;
  44. // mIPv4OnlyDomains is a comma-separated list of domains for which only
  45. // IPv4 DNS lookups are performed. This allows the user to disable IPv6 on
  46. // a per-domain basis and work around broken DNS servers. See bug 68796.
  47. nsAdoptingCString mIPv4OnlyDomains;
  48. bool mDisableIPv6;
  49. bool mDisablePrefetch;
  50. bool mBlockDotOnion;
  51. bool mFirstTime;
  52. bool mNotifyResolution;
  53. bool mOfflineLocalhost;
  54. nsTHashtable<nsCStringHashKey> mLocalDomains;
  55. };
  56. #endif //nsDNSService2_h__