netwerk/base/src/nsProxyInfo.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 #include "nsProxyInfo.h"
     8 #include "nsCOMPtr.h"
    10 // Yes, we support QI to nsProxyInfo
    11 NS_IMPL_ISUPPORTS(nsProxyInfo, nsProxyInfo, nsIProxyInfo) 
    13 using namespace mozilla;
    15 NS_IMETHODIMP
    16 nsProxyInfo::GetHost(nsACString &result)
    17 {
    18   result = mHost;
    19   return NS_OK;
    20 }
    22 NS_IMETHODIMP
    23 nsProxyInfo::GetPort(int32_t *result)
    24 {
    25   *result = mPort;
    26   return NS_OK;
    27 }
    29 NS_IMETHODIMP
    30 nsProxyInfo::GetType(nsACString &result)
    31 {
    32   result = mType;
    33   return NS_OK;
    34 }
    36 NS_IMETHODIMP
    37 nsProxyInfo::GetFlags(uint32_t *result)
    38 {
    39   *result = mFlags;
    40   return NS_OK;
    41 }
    43 NS_IMETHODIMP
    44 nsProxyInfo::GetResolveFlags(uint32_t *result)
    45 {
    46   *result = mResolveFlags;
    47   return NS_OK;
    48 }
    50 NS_IMETHODIMP
    51 nsProxyInfo::GetUsername(nsACString &result)
    52 {
    53   result = mUsername;
    54   return NS_OK;
    55 }
    57 NS_IMETHODIMP
    58 nsProxyInfo::GetPassword(nsACString &result)
    59 {
    60   result = mPassword;
    61   return NS_OK;
    62 }
    64 NS_IMETHODIMP
    65 nsProxyInfo::GetFailoverTimeout(uint32_t *result)
    66 {
    67   *result = mTimeout;
    68   return NS_OK;
    69 }
    71 NS_IMETHODIMP
    72 nsProxyInfo::GetFailoverProxy(nsIProxyInfo **result)
    73 {
    74   NS_IF_ADDREF(*result = mNext);
    75   return NS_OK;
    76 }
    78 NS_IMETHODIMP
    79 nsProxyInfo::SetFailoverProxy(nsIProxyInfo *proxy)
    80 {
    81   nsCOMPtr<nsProxyInfo> pi = do_QueryInterface(proxy);
    82   NS_ENSURE_ARG(pi);
    84   pi.swap(mNext);
    85   return NS_OK;
    86 }
    88 // These pointers are declared in nsProtocolProxyService.cpp and
    89 // comparison of mType by string pointer is valid within necko
    90 namespace mozilla {
    91   extern const char kProxyType_HTTP[];
    92   extern const char kProxyType_SOCKS[];
    93   extern const char kProxyType_SOCKS4[];
    94   extern const char kProxyType_SOCKS5[];
    95   extern const char kProxyType_DIRECT[];
    96 }
    98 bool
    99 nsProxyInfo::IsDirect()
   100 {
   101   if (!mType)
   102     return true;
   103   return mType == kProxyType_DIRECT;
   104 }
   106 bool
   107 nsProxyInfo::IsHTTP()
   108 {
   109   return mType == kProxyType_HTTP;
   110 }
   112 bool
   113 nsProxyInfo::IsSOCKS()
   114 {
   115   return mType == kProxyType_SOCKS ||
   116     mType == kProxyType_SOCKS4 || mType == kProxyType_SOCKS5;
   117 }

mercurial