1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsProxyInfo_h__
8 #define nsProxyInfo_h__
10 #include "nsIProxyInfo.h"
12 #include "mozilla/Atomics.h"
13 #include "mozilla/Attributes.h"
15 // Use to support QI nsIProxyInfo to nsProxyInfo
16 #define NS_PROXYINFO_IID \
17 { /* ed42f751-825e-4cc2-abeb-3670711a8b85 */ \
18 0xed42f751, 0x825e, 0x4cc2, { \
19 0xab, 0xeb, 0x36, 0x70, 0x71, 0x1a, 0x8b, 0x85 \
26 class ProxyInfoCloneArgs
;
28 // This class is exposed to other classes inside Necko for fast access
29 // to the nsIProxyInfo attributes.
30 class nsProxyInfo final
: public nsIProxyInfo
{
32 NS_DECLARE_STATIC_IID_ACCESSOR(NS_PROXYINFO_IID
)
34 NS_DECL_THREADSAFE_ISUPPORTS
37 // Cheap accessors for use within Necko
38 const nsCString
& Host() const { return mHost
; }
39 int32_t Port() const { return mPort
; }
40 const char* Type() const { return mType
; }
41 uint32_t Flags() const { return mFlags
; }
42 const nsCString
& Username() const { return mUsername
; }
43 const nsCString
& Password() const { return mPassword
; }
44 uint32_t Timeout() { return mTimeout
; }
45 uint32_t ResolveFlags() { return mResolveFlags
; }
46 const nsCString
& ProxyAuthorizationHeader() const {
47 return mProxyAuthorizationHeader
;
49 const nsCString
& ConnectionIsolationKey() const {
50 return mConnectionIsolationKey
;
58 static void SerializeProxyInfo(nsProxyInfo
* aProxyInfo
,
59 nsTArray
<ProxyInfoCloneArgs
>& aResult
);
60 static nsProxyInfo
* DeserializeProxyInfo(
61 const nsTArray
<ProxyInfoCloneArgs
>& aArgs
);
63 already_AddRefed
<nsProxyInfo
> CloneProxyInfoWithNewResolveFlags(
64 uint32_t aResolveFlags
);
67 friend class nsProtocolProxyService
;
69 explicit nsProxyInfo(const char* type
= nullptr) : mType(type
) {}
71 nsProxyInfo(const nsACString
& aType
, const nsACString
& aHost
, int32_t aPort
,
72 const nsACString
& aUsername
, const nsACString
& aPassword
,
73 uint32_t aFlags
, uint32_t aTimeout
, uint32_t aResolveFlags
,
74 const nsACString
& aProxyAuthorizationHeader
,
75 const nsACString
& aConnectionIsolationKey
);
77 ~nsProxyInfo() { NS_IF_RELEASE(mNext
); }
79 const char* mType
; // pointer to statically allocated value
83 nsCString mProxyAuthorizationHeader
;
84 nsCString mConnectionIsolationKey
;
87 // We need to read on multiple threads, but don't need to sync on anything
89 Atomic
<uint32_t, Relaxed
> mResolveFlags
{0};
90 uint32_t mTimeout
{UINT32_MAX
};
91 nsProxyInfo
* mNext
{nullptr};
94 NS_DEFINE_STATIC_IID_ACCESSOR(nsProxyInfo
, NS_PROXYINFO_IID
)
97 } // namespace mozilla
99 #endif // nsProxyInfo_h__