nsProxyInfo.h 2.1 KB

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