tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

DNSAdditionalInfo.h (1140B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #ifndef mozilla_net_DNSAdditionalInfo_h__
      6 #define mozilla_net_DNSAdditionalInfo_h__
      7 
      8 #include "nsIDNSAdditionalInfo.h"
      9 #include "nsString.h"
     10 
     11 namespace mozilla {
     12 namespace net {
     13 
     14 class DNSAdditionalInfo : public nsIDNSAdditionalInfo {
     15  NS_DECL_THREADSAFE_ISUPPORTS
     16  NS_DECL_NSIDNSADDITIONALINFO
     17 public:
     18  explicit DNSAdditionalInfo(const nsACString& aURL, int32_t aPort)
     19      : mURL(aURL), mPort(aPort) {};
     20  static nsCString URL(nsIDNSAdditionalInfo* aInfo) {
     21    nsCString url;
     22    if (aInfo) {
     23      MOZ_ALWAYS_SUCCEEDS(aInfo->GetResolverURL(url));
     24    }
     25    return url;
     26  }
     27  static int32_t Port(nsIDNSAdditionalInfo* aInfo) {
     28    int32_t port = -1;
     29    if (aInfo) {
     30      MOZ_ALWAYS_SUCCEEDS(aInfo->GetPort(&port));
     31    }
     32    return port;
     33  }
     34 
     35 private:
     36  virtual ~DNSAdditionalInfo() = default;
     37  nsCString mURL;
     38  int32_t mPort;
     39 };
     40 
     41 }  // namespace net
     42 }  // namespace mozilla
     43 
     44 #endif  // mozilla_net_DNSAdditionalInfo_h__