Source code

Revision control

Other Tools

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/. */
6
7
#ifndef nsProxyInfo_h__
8
#define nsProxyInfo_h__
9
10
#include "nsIProxyInfo.h"
11
#include "nsString.h"
12
#include "mozilla/Attributes.h"
13
14
// Use to support QI nsIProxyInfo to nsProxyInfo
15
#define NS_PROXYINFO_IID \
16
{ /* ed42f751-825e-4cc2-abeb-3670711a8b85 */ \
17
0xed42f751, 0x825e, 0x4cc2, { \
18
0xab, 0xeb, 0x36, 0x70, 0x71, 0x1a, 0x8b, 0x85 \
19
} \
20
}
21
22
namespace mozilla {
23
namespace net {
24
25
// This class is exposed to other classes inside Necko for fast access
26
// to the nsIProxyInfo attributes.
27
class nsProxyInfo final : public nsIProxyInfo {
28
public:
29
NS_DECLARE_STATIC_IID_ACCESSOR(NS_PROXYINFO_IID)
30
31
NS_DECL_THREADSAFE_ISUPPORTS
32
NS_DECL_NSIPROXYINFO
33
34
// Cheap accessors for use within Necko
35
const nsCString& Host() const { return mHost; }
36
int32_t Port() const { return mPort; }
37
const char* Type() const { return mType; }
38
uint32_t Flags() const { return mFlags; }
39
const nsCString& Username() const { return mUsername; }
40
const nsCString& Password() const { return mPassword; }
41
const nsCString& ProxyAuthorizationHeader() const {
42
return mProxyAuthorizationHeader;
43
}
44
const nsCString& ConnectionIsolationKey() const {
45
return mConnectionIsolationKey;
46
}
47
48
bool IsDirect();
49
bool IsHTTP();
50
bool IsHTTPS();
51
bool IsSOCKS();
52
53
private:
54
friend class nsProtocolProxyService;
55
56
explicit nsProxyInfo(const char* type = nullptr)
57
: mType(type),
58
mPort(-1),
59
mFlags(0),
60
mResolveFlags(0),
61
mTimeout(UINT32_MAX),
62
mNext(nullptr) {}
63
64
~nsProxyInfo() { NS_IF_RELEASE(mNext); }
65
66
const char* mType; // pointer to statically allocated value
67
nsCString mHost;
68
nsCString mUsername;
69
nsCString mPassword;
70
nsCString mProxyAuthorizationHeader;
71
nsCString mConnectionIsolationKey;
72
int32_t mPort;
73
uint32_t mFlags;
74
uint32_t mResolveFlags;
75
uint32_t mTimeout;
76
nsProxyInfo* mNext;
77
};
78
79
NS_DEFINE_STATIC_IID_ACCESSOR(nsProxyInfo, NS_PROXYINFO_IID)
80
81
} // namespace net
82
} // namespace mozilla
83
84
#endif // nsProxyInfo_h__