nsTLSSocketProvider.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. *
  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. #include "mozilla/BasePrincipal.h"
  7. #include "nsTLSSocketProvider.h"
  8. #include "nsNSSIOLayer.h"
  9. #include "nsError.h"
  10. using mozilla::NeckoOriginAttributes;
  11. nsTLSSocketProvider::nsTLSSocketProvider()
  12. {
  13. }
  14. nsTLSSocketProvider::~nsTLSSocketProvider()
  15. {
  16. }
  17. NS_IMPL_ISUPPORTS(nsTLSSocketProvider, nsISocketProvider)
  18. NS_IMETHODIMP
  19. nsTLSSocketProvider::NewSocket(int32_t family,
  20. const char *host,
  21. int32_t port,
  22. nsIProxyInfo *proxy,
  23. const NeckoOriginAttributes &originAttributes,
  24. uint32_t flags,
  25. PRFileDesc **_result,
  26. nsISupports **securityInfo)
  27. {
  28. nsresult rv = nsSSLIOLayerNewSocket(family,
  29. host,
  30. port,
  31. proxy,
  32. originAttributes,
  33. _result,
  34. securityInfo,
  35. true,
  36. flags);
  37. return (NS_FAILED(rv)) ? NS_ERROR_SOCKET_CREATE_FAILED : NS_OK;
  38. }
  39. // Add the SSL IO layer to an existing socket
  40. NS_IMETHODIMP
  41. nsTLSSocketProvider::AddToSocket(int32_t family,
  42. const char *host,
  43. int32_t port,
  44. nsIProxyInfo *proxy,
  45. const NeckoOriginAttributes &originAttributes,
  46. uint32_t flags,
  47. PRFileDesc *aSocket,
  48. nsISupports **securityInfo)
  49. {
  50. nsresult rv = nsSSLIOLayerAddToSocket(family,
  51. host,
  52. port,
  53. proxy,
  54. originAttributes,
  55. aSocket,
  56. securityInfo,
  57. true,
  58. flags);
  59. return (NS_FAILED(rv)) ? NS_ERROR_SOCKET_CREATE_FAILED : NS_OK;
  60. }