nsIProtocolProxyService.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /*
  2. * DO NOT EDIT. THIS FILE IS GENERATED FROM c:/mozilla/netwerk/base/public/nsIProtocolProxyService.idl
  3. */
  4. #ifndef __gen_nsIProtocolProxyService_h__
  5. #define __gen_nsIProtocolProxyService_h__
  6. #ifndef __gen_nsISupports_h__
  7. #include "nsISupports.h"
  8. #endif
  9. /* For IDL files that don't want to include root IDL files. */
  10. #ifndef NS_NO_VTABLE
  11. #define NS_NO_VTABLE
  12. #endif
  13. class nsICancelable; /* forward declaration */
  14. class nsIProtocolProxyCallback; /* forward declaration */
  15. class nsIProtocolProxyFilter; /* forward declaration */
  16. class nsIProxyInfo; /* forward declaration */
  17. class nsIChannel; /* forward declaration */
  18. class nsIURI; /* forward declaration */
  19. /* starting interface: nsIProtocolProxyService */
  20. #define NS_IPROTOCOLPROXYSERVICE_IID_STR "e38ab577-786e-4a7f-936b-7ae4c7d877b2"
  21. #define NS_IPROTOCOLPROXYSERVICE_IID \
  22. {0xe38ab577, 0x786e, 0x4a7f, \
  23. { 0x93, 0x6b, 0x7a, 0xe4, 0xc7, 0xd8, 0x77, 0xb2 }}
  24. /**
  25. * nsIProtocolProxyService provides methods to access information about
  26. * various network proxies.
  27. *
  28. * @status UNDER_REVIEW
  29. */
  30. class NS_NO_VTABLE nsIProtocolProxyService : public nsISupports {
  31. public:
  32. NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPROTOCOLPROXYSERVICE_IID)
  33. /**
  34. * This flag may be passed to the resolve method to request that it fail
  35. * instead of block the calling thread. Proxy Auto Config (PAC) may
  36. * perform a synchronous DNS query, which may not return immediately. So,
  37. * calling resolve without this flag may result in locking up the calling
  38. * thread for a lengthy period of time.
  39. *
  40. * By passing this flag to resolve, one can failover to asyncResolve to
  41. * avoid locking up the calling thread if a PAC query is required.
  42. *
  43. * When this flag is passed to resolve, resolve may throw the exception
  44. * NS_BASE_STREAM_WOULD_BLOCK to indicate that it failed due to this flag
  45. * being present.
  46. */
  47. enum { RESOLVE_NON_BLOCKING = 1U };
  48. /**
  49. * This method returns a nsIProxyInfo instance that identifies a proxy to
  50. * be used for loading the given URI. Otherwise, this method returns null
  51. * indicating that a direct connection should be used.
  52. *
  53. * @param aURI
  54. * The URI to test.
  55. * @param aFlags
  56. * A bit-wise OR of the RESOLVE_ flags defined above. Pass 0 to
  57. * specify the default behavior.
  58. *
  59. * NOTE: If this proxy is unavailable, getFailoverForProxy may be called
  60. * to determine the correct secondary proxy to be used.
  61. *
  62. * NOTE: If the protocol handler for the given URI supports
  63. * nsIProxiedProtocolHandler, then the nsIProxyInfo instance returned from
  64. * resolve may be passed to the newProxiedChannel method to create a
  65. * nsIChannel to the given URI that uses the specified proxy.
  66. *
  67. * NOTE: However, if the nsIProxyInfo type is "http", then it means that
  68. * the given URI should be loaded using the HTTP protocol handler, which
  69. * also supports nsIProxiedProtocolHandler.
  70. *
  71. * NOTE: If PAC is configured, and the PAC file has not yet been loaded,
  72. * then this method will return a nsIProxyInfo instance with a type of
  73. * "unknown" to indicate to the consumer that asyncResolve should be used
  74. * to wait for the PAC file to finish loading. Otherwise, the consumer
  75. * may choose to treat the result as type "direct" if desired.
  76. *
  77. * @see nsIProxiedProtocolHandler::newProxiedChannel
  78. */
  79. /* nsIProxyInfo resolve (in nsIURI aURI, in unsigned long aFlags); */
  80. NS_IMETHOD Resolve(nsIURI *aURI, PRUint32 aFlags, nsIProxyInfo **_retval) = 0;
  81. /**
  82. * This method is an asychronous version of the resolve method. Unlike
  83. * resolve, this method is guaranteed not to block the calling thread
  84. * waiting for DNS queries to complete. This method is intended as a
  85. * substitute for resolve when the result is not needed immediately.
  86. *
  87. * @param aURI
  88. * The URI to test.
  89. * @param aFlags
  90. * A bit-wise OR of the RESOLVE_ flags defined above. Pass 0 to
  91. * specify the default behavior.
  92. * @param aCallback
  93. * The object to be notified when the result is available.
  94. *
  95. * @return An object that can be used to cancel the asychronous operation.
  96. */
  97. /* nsICancelable asyncResolve (in nsIURI aURI, in unsigned long aFlags, in nsIProtocolProxyCallback aCallback); */
  98. NS_IMETHOD AsyncResolve(nsIURI *aURI, PRUint32 aFlags, nsIProtocolProxyCallback *aCallback, nsICancelable **_retval) = 0;
  99. /**
  100. * This method may be called to construct a nsIProxyInfo instance from
  101. * the given parameters. This method may be useful in conjunction with
  102. * nsISocketTransportService::createTransport for creating, for example,
  103. * a SOCKS connection.
  104. *
  105. * @param aType
  106. * The proxy type. This is a string value that identifies the proxy
  107. * type. Standard values include:
  108. * "http" - specifies a HTTP proxy
  109. * "socks" - specifies a SOCKS version 5 proxy
  110. * "socks4" - specifies a SOCKS version 4 proxy
  111. * "direct" - specifies a direct connection (useful for failover)
  112. * The type name is case-insensitive. Other string values may be
  113. * possible.
  114. * @param aHost
  115. * The proxy hostname or IP address.
  116. * @param aPort
  117. * The proxy port.
  118. * @param aFlags
  119. * Flags associated with this connection. See nsIProxyInfo.idl
  120. * for currently defined flags.
  121. * @param aFailoverTimeout
  122. * Specifies the length of time (in seconds) to ignore this proxy if
  123. * this proxy fails. Pass PR_UINT32_MAX to specify the default
  124. * timeout value, causing nsIProxyInfo::failoverTimeout to be
  125. * assigned the default value.
  126. * @param aFailoverProxy
  127. * Specifies the next proxy to try if this proxy fails. This
  128. * parameter may be null.
  129. */
  130. /* nsIProxyInfo newProxyInfo (in ACString aType, in AUTF8String aHost, in long aPort, in unsigned long aFlags, in unsigned long aFailoverTimeout, in nsIProxyInfo aFailoverProxy); */
  131. NS_IMETHOD NewProxyInfo(const nsACString & aType, const nsACString & aHost, PRInt32 aPort, PRUint32 aFlags, PRUint32 aFailoverTimeout, nsIProxyInfo *aFailoverProxy, nsIProxyInfo **_retval) = 0;
  132. /**
  133. * If the proxy identified by aProxyInfo is unavailable for some reason,
  134. * this method may be called to access an alternate proxy that may be used
  135. * instead. As a side-effect, this method may affect future result values
  136. * from resolve/asyncResolve as well as from getFailoverForProxy.
  137. *
  138. * @param aProxyInfo
  139. * The proxy that was unavailable.
  140. * @param aURI
  141. * The URI that was originally passed to resolve/asyncResolve.
  142. * @param aReason
  143. * The error code corresponding to the proxy failure. This value
  144. * may be used to tune the delay before this proxy is used again.
  145. *
  146. * @throw NS_ERROR_NOT_AVAILABLE if there is no alternate proxy available.
  147. */
  148. /* nsIProxyInfo getFailoverForProxy (in nsIProxyInfo aProxyInfo, in nsIURI aURI, in nsresult aReason); */
  149. NS_IMETHOD GetFailoverForProxy(nsIProxyInfo *aProxyInfo, nsIURI *aURI, nsresult aReason, nsIProxyInfo **_retval) = 0;
  150. /**
  151. * This method may be used to register a proxy filter instance. Each proxy
  152. * filter is registered with an associated position that determines the
  153. * order in which the filters are applied (starting from position 0). When
  154. * resolve/asyncResolve is called, it generates a list of proxies for the
  155. * given URI, and then it applies the proxy filters. The filters have the
  156. * opportunity to modify the list of proxies.
  157. *
  158. * If two filters register for the same position, then the filters will be
  159. * visited in the order in which they were registered.
  160. *
  161. * If the filter is already registered, then its position will be updated.
  162. *
  163. * After filters have been run, any disabled or disallowed proxies will be
  164. * removed from the list. A proxy is disabled if it had previously failed-
  165. * over to another proxy (see getFailoverForProxy). A proxy is disallowed,
  166. * for example, if it is a HTTP proxy and the nsIProtocolHandler for the
  167. * queried URI does not permit proxying via HTTP.
  168. *
  169. * If a nsIProtocolHandler disallows all proxying, then filters will never
  170. * have a chance to intercept proxy requests for such URLs.
  171. *
  172. * @param aFilter
  173. * The nsIProtocolProxyFilter instance to be registered.
  174. * @param aPosition
  175. * The position of the filter.
  176. *
  177. * NOTE: It is possible to construct filters that compete with one another
  178. * in undesirable ways. This API does not attempt to protect against such
  179. * problems. It is recommended that any extensions that choose to call
  180. * this method make their position value configurable at runtime (perhaps
  181. * via the preferences service).
  182. */
  183. /* void registerFilter (in nsIProtocolProxyFilter aFilter, in unsigned long aPosition); */
  184. NS_IMETHOD RegisterFilter(nsIProtocolProxyFilter *aFilter, PRUint32 aPosition) = 0;
  185. /**
  186. * This method may be used to unregister a proxy filter instance. All
  187. * filters will be automatically unregistered at XPCOM shutdown.
  188. *
  189. * @param aFilter
  190. * The nsIProtocolProxyFilter instance to be unregistered.
  191. */
  192. /* void unregisterFilter (in nsIProtocolProxyFilter aFilter); */
  193. NS_IMETHOD UnregisterFilter(nsIProtocolProxyFilter *aFilter) = 0;
  194. };
  195. /* Use this macro when declaring classes that implement this interface. */
  196. #define NS_DECL_NSIPROTOCOLPROXYSERVICE \
  197. NS_IMETHOD Resolve(nsIURI *aURI, PRUint32 aFlags, nsIProxyInfo **_retval); \
  198. NS_IMETHOD AsyncResolve(nsIURI *aURI, PRUint32 aFlags, nsIProtocolProxyCallback *aCallback, nsICancelable **_retval); \
  199. NS_IMETHOD NewProxyInfo(const nsACString & aType, const nsACString & aHost, PRInt32 aPort, PRUint32 aFlags, PRUint32 aFailoverTimeout, nsIProxyInfo *aFailoverProxy, nsIProxyInfo **_retval); \
  200. NS_IMETHOD GetFailoverForProxy(nsIProxyInfo *aProxyInfo, nsIURI *aURI, nsresult aReason, nsIProxyInfo **_retval); \
  201. NS_IMETHOD RegisterFilter(nsIProtocolProxyFilter *aFilter, PRUint32 aPosition); \
  202. NS_IMETHOD UnregisterFilter(nsIProtocolProxyFilter *aFilter);
  203. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  204. #define NS_FORWARD_NSIPROTOCOLPROXYSERVICE(_to) \
  205. NS_IMETHOD Resolve(nsIURI *aURI, PRUint32 aFlags, nsIProxyInfo **_retval) { return _to Resolve(aURI, aFlags, _retval); } \
  206. NS_IMETHOD AsyncResolve(nsIURI *aURI, PRUint32 aFlags, nsIProtocolProxyCallback *aCallback, nsICancelable **_retval) { return _to AsyncResolve(aURI, aFlags, aCallback, _retval); } \
  207. NS_IMETHOD NewProxyInfo(const nsACString & aType, const nsACString & aHost, PRInt32 aPort, PRUint32 aFlags, PRUint32 aFailoverTimeout, nsIProxyInfo *aFailoverProxy, nsIProxyInfo **_retval) { return _to NewProxyInfo(aType, aHost, aPort, aFlags, aFailoverTimeout, aFailoverProxy, _retval); } \
  208. NS_IMETHOD GetFailoverForProxy(nsIProxyInfo *aProxyInfo, nsIURI *aURI, nsresult aReason, nsIProxyInfo **_retval) { return _to GetFailoverForProxy(aProxyInfo, aURI, aReason, _retval); } \
  209. NS_IMETHOD RegisterFilter(nsIProtocolProxyFilter *aFilter, PRUint32 aPosition) { return _to RegisterFilter(aFilter, aPosition); } \
  210. NS_IMETHOD UnregisterFilter(nsIProtocolProxyFilter *aFilter) { return _to UnregisterFilter(aFilter); }
  211. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  212. #define NS_FORWARD_SAFE_NSIPROTOCOLPROXYSERVICE(_to) \
  213. NS_IMETHOD Resolve(nsIURI *aURI, PRUint32 aFlags, nsIProxyInfo **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Resolve(aURI, aFlags, _retval); } \
  214. NS_IMETHOD AsyncResolve(nsIURI *aURI, PRUint32 aFlags, nsIProtocolProxyCallback *aCallback, nsICancelable **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->AsyncResolve(aURI, aFlags, aCallback, _retval); } \
  215. NS_IMETHOD NewProxyInfo(const nsACString & aType, const nsACString & aHost, PRInt32 aPort, PRUint32 aFlags, PRUint32 aFailoverTimeout, nsIProxyInfo *aFailoverProxy, nsIProxyInfo **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->NewProxyInfo(aType, aHost, aPort, aFlags, aFailoverTimeout, aFailoverProxy, _retval); } \
  216. NS_IMETHOD GetFailoverForProxy(nsIProxyInfo *aProxyInfo, nsIURI *aURI, nsresult aReason, nsIProxyInfo **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetFailoverForProxy(aProxyInfo, aURI, aReason, _retval); } \
  217. NS_IMETHOD RegisterFilter(nsIProtocolProxyFilter *aFilter, PRUint32 aPosition) { return !_to ? NS_ERROR_NULL_POINTER : _to->RegisterFilter(aFilter, aPosition); } \
  218. NS_IMETHOD UnregisterFilter(nsIProtocolProxyFilter *aFilter) { return !_to ? NS_ERROR_NULL_POINTER : _to->UnregisterFilter(aFilter); }
  219. #if 0
  220. /* Use the code below as a template for the implementation class for this interface. */
  221. /* Header file */
  222. class nsProtocolProxyService : public nsIProtocolProxyService
  223. {
  224. public:
  225. NS_DECL_ISUPPORTS
  226. NS_DECL_NSIPROTOCOLPROXYSERVICE
  227. nsProtocolProxyService();
  228. private:
  229. ~nsProtocolProxyService();
  230. protected:
  231. /* additional members */
  232. };
  233. /* Implementation file */
  234. NS_IMPL_ISUPPORTS1(nsProtocolProxyService, nsIProtocolProxyService)
  235. nsProtocolProxyService::nsProtocolProxyService()
  236. {
  237. /* member initializers and constructor code */
  238. }
  239. nsProtocolProxyService::~nsProtocolProxyService()
  240. {
  241. /* destructor code */
  242. }
  243. /* nsIProxyInfo resolve (in nsIURI aURI, in unsigned long aFlags); */
  244. NS_IMETHODIMP nsProtocolProxyService::Resolve(nsIURI *aURI, PRUint32 aFlags, nsIProxyInfo **_retval)
  245. {
  246. return NS_ERROR_NOT_IMPLEMENTED;
  247. }
  248. /* nsICancelable asyncResolve (in nsIURI aURI, in unsigned long aFlags, in nsIProtocolProxyCallback aCallback); */
  249. NS_IMETHODIMP nsProtocolProxyService::AsyncResolve(nsIURI *aURI, PRUint32 aFlags, nsIProtocolProxyCallback *aCallback, nsICancelable **_retval)
  250. {
  251. return NS_ERROR_NOT_IMPLEMENTED;
  252. }
  253. /* nsIProxyInfo newProxyInfo (in ACString aType, in AUTF8String aHost, in long aPort, in unsigned long aFlags, in unsigned long aFailoverTimeout, in nsIProxyInfo aFailoverProxy); */
  254. NS_IMETHODIMP nsProtocolProxyService::NewProxyInfo(const nsACString & aType, const nsACString & aHost, PRInt32 aPort, PRUint32 aFlags, PRUint32 aFailoverTimeout, nsIProxyInfo *aFailoverProxy, nsIProxyInfo **_retval)
  255. {
  256. return NS_ERROR_NOT_IMPLEMENTED;
  257. }
  258. /* nsIProxyInfo getFailoverForProxy (in nsIProxyInfo aProxyInfo, in nsIURI aURI, in nsresult aReason); */
  259. NS_IMETHODIMP nsProtocolProxyService::GetFailoverForProxy(nsIProxyInfo *aProxyInfo, nsIURI *aURI, nsresult aReason, nsIProxyInfo **_retval)
  260. {
  261. return NS_ERROR_NOT_IMPLEMENTED;
  262. }
  263. /* void registerFilter (in nsIProtocolProxyFilter aFilter, in unsigned long aPosition); */
  264. NS_IMETHODIMP nsProtocolProxyService::RegisterFilter(nsIProtocolProxyFilter *aFilter, PRUint32 aPosition)
  265. {
  266. return NS_ERROR_NOT_IMPLEMENTED;
  267. }
  268. /* void unregisterFilter (in nsIProtocolProxyFilter aFilter); */
  269. NS_IMETHODIMP nsProtocolProxyService::UnregisterFilter(nsIProtocolProxyFilter *aFilter)
  270. {
  271. return NS_ERROR_NOT_IMPLEMENTED;
  272. }
  273. /* End of implementation class template. */
  274. #endif
  275. #endif /* __gen_nsIProtocolProxyService_h__ */