Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/netwerk/base/nsProxyInfo.h
Line
Count
Source (jump to first uncovered line)
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,                                      \
18
    0x825e,                                          \
19
    0x4cc2,                                          \
20
    {0xab, 0xeb, 0x36, 0x70, 0x71, 0x1a, 0x8b, 0x85} \
21
}
22
23
namespace mozilla {
24
namespace net {
25
26
// This class is exposed to other classes inside Necko for fast access
27
// to the nsIProxyInfo attributes.
28
class nsProxyInfo final : public nsIProxyInfo
29
{
30
public:
31
  NS_DECLARE_STATIC_IID_ACCESSOR(NS_PROXYINFO_IID)
32
33
  NS_DECL_THREADSAFE_ISUPPORTS
34
  NS_DECL_NSIPROXYINFO
35
36
  // Cheap accessors for use within Necko
37
0
  const nsCString &Host()  { return mHost; }
38
0
  int32_t          Port()  { return mPort; }
39
0
  const char      *Type()  { return mType; }
40
0
  uint32_t         Flags() { return mFlags; }
41
0
  const nsCString &Username()  { return mUsername; }
42
0
  const nsCString &Password()  { return mPassword; }
43
44
  bool IsDirect();
45
  bool IsHTTP();
46
  bool IsHTTPS();
47
  bool IsSOCKS();
48
49
private:
50
  friend class nsProtocolProxyService;
51
52
  explicit nsProxyInfo(const char *type = nullptr)
53
    : mType(type)
54
    , mPort(-1)
55
    , mFlags(0)
56
    , mResolveFlags(0)
57
    , mTimeout(UINT32_MAX)
58
    , mNext(nullptr)
59
0
  {}
60
61
  ~nsProxyInfo()
62
0
  {
63
0
    NS_IF_RELEASE(mNext);
64
0
  }
65
66
  const char  *mType;  // pointer to statically allocated value
67
  nsCString    mHost;
68
  nsCString    mUsername;
69
  nsCString    mPassword;
70
  int32_t      mPort;
71
  uint32_t     mFlags;
72
  uint32_t     mResolveFlags;
73
  uint32_t     mTimeout;
74
  nsProxyInfo *mNext;
75
};
76
77
NS_DEFINE_STATIC_IID_ACCESSOR(nsProxyInfo, NS_PROXYINFO_IID)
78
79
} // namespace net
80
} // namespace mozilla
81
82
#endif // nsProxyInfo_h__