netwerk/base/src/nsProxyInfo.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/base/src/nsProxyInfo.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef nsProxyInfo_h__
    1.11 +#define nsProxyInfo_h__
    1.12 +
    1.13 +#include "nsIProxyInfo.h"
    1.14 +#include "nsString.h"
    1.15 +#include "mozilla/Attributes.h"
    1.16 +
    1.17 +// Use to support QI nsIProxyInfo to nsProxyInfo
    1.18 +#define NS_PROXYINFO_IID \
    1.19 +{ /* ed42f751-825e-4cc2-abeb-3670711a8b85 */         \
    1.20 +    0xed42f751,                                      \
    1.21 +    0x825e,                                          \
    1.22 +    0x4cc2,                                          \
    1.23 +    {0xab, 0xeb, 0x36, 0x70, 0x71, 0x1a, 0x8b, 0x85} \
    1.24 +}
    1.25 +
    1.26 +// This class is exposed to other classes inside Necko for fast access
    1.27 +// to the nsIProxyInfo attributes.
    1.28 +class nsProxyInfo MOZ_FINAL : public nsIProxyInfo
    1.29 +{
    1.30 +public:
    1.31 +  NS_DECLARE_STATIC_IID_ACCESSOR(NS_PROXYINFO_IID)
    1.32 +
    1.33 +  NS_DECL_THREADSAFE_ISUPPORTS
    1.34 +  NS_DECL_NSIPROXYINFO
    1.35 +
    1.36 +  // Cheap accessors for use within Necko
    1.37 +  const nsCString &Host()  { return mHost; }
    1.38 +  int32_t          Port()  { return mPort; }
    1.39 +  const char      *Type()  { return mType; }
    1.40 +  uint32_t         Flags() { return mFlags; }
    1.41 +
    1.42 +  bool IsDirect();
    1.43 +  bool IsHTTP();
    1.44 +  bool IsSOCKS();
    1.45 +
    1.46 +private:
    1.47 +  friend class nsProtocolProxyService;
    1.48 +
    1.49 +  nsProxyInfo(const char *type = nullptr)
    1.50 +    : mType(type)
    1.51 +    , mPort(-1)
    1.52 +    , mFlags(0)
    1.53 +    , mResolveFlags(0)
    1.54 +    , mTimeout(UINT32_MAX)
    1.55 +    , mNext(nullptr)
    1.56 +  {}
    1.57 +
    1.58 +  ~nsProxyInfo()
    1.59 +  {
    1.60 +    NS_IF_RELEASE(mNext);
    1.61 +  }
    1.62 +
    1.63 +  const char  *mType;  // pointer to statically allocated value
    1.64 +  nsCString    mHost;
    1.65 +  nsCString    mUsername;
    1.66 +  nsCString    mPassword;
    1.67 +  int32_t      mPort;
    1.68 +  uint32_t     mFlags;
    1.69 +  uint32_t     mResolveFlags;
    1.70 +  uint32_t     mTimeout;
    1.71 +  nsProxyInfo *mNext;
    1.72 +};
    1.73 +
    1.74 +NS_DEFINE_STATIC_IID_ACCESSOR(nsProxyInfo, NS_PROXYINFO_IID)
    1.75 +
    1.76 +#endif // nsProxyInfo_h__

mercurial