Bug 1890277: part 4) Add CSPParser support for the `trusted-types` directive, guarded...
[gecko.git] / netwerk / dns / DNSAdditionalInfo.h
blob658b9623dd6ce84d0e5860da575aa4cf0d5d5ee4
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/. */
5 #ifndef mozilla_net_DNSAdditionalInfo_h__
6 #define mozilla_net_DNSAdditionalInfo_h__
8 #include "nsIDNSAdditionalInfo.h"
9 #include "nsString.h"
11 namespace mozilla {
12 namespace net {
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));
25 return url;
27 static int32_t Port(nsIDNSAdditionalInfo* aInfo) {
28 int32_t port = -1;
29 if (aInfo) {
30 MOZ_ALWAYS_SUCCEEDS(aInfo->GetPort(&port));
32 return port;
35 private:
36 virtual ~DNSAdditionalInfo() = default;
37 nsCString mURL;
38 int32_t mPort;
41 } // namespace net
42 } // namespace mozilla
44 #endif // mozilla_net_DNSAdditionalInfo_h__