nsUDPSocketProvider.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #include "nsUDPSocketProvider.h"
  5. #include "nspr.h"
  6. using mozilla::NeckoOriginAttributes;
  7. NS_IMPL_ISUPPORTS(nsUDPSocketProvider, nsISocketProvider)
  8. nsUDPSocketProvider::~nsUDPSocketProvider()
  9. {
  10. }
  11. NS_IMETHODIMP
  12. nsUDPSocketProvider::NewSocket(int32_t aFamily,
  13. const char *aHost,
  14. int32_t aPort,
  15. nsIProxyInfo *aProxy,
  16. const NeckoOriginAttributes &originAttributes,
  17. uint32_t aFlags,
  18. PRFileDesc * *aFileDesc,
  19. nsISupports **aSecurityInfo)
  20. {
  21. NS_ENSURE_ARG_POINTER(aFileDesc);
  22. PRFileDesc* udpFD = PR_OpenUDPSocket(aFamily);
  23. if (!udpFD)
  24. return NS_ERROR_FAILURE;
  25. *aFileDesc = udpFD;
  26. return NS_OK;
  27. }
  28. NS_IMETHODIMP
  29. nsUDPSocketProvider::AddToSocket(int32_t aFamily,
  30. const char *aHost,
  31. int32_t aPort,
  32. nsIProxyInfo *aProxy,
  33. const NeckoOriginAttributes &originAttributes,
  34. uint32_t aFlags,
  35. struct PRFileDesc * aFileDesc,
  36. nsISupports **aSecurityInfo)
  37. {
  38. // does not make sense to strap a UDP socket onto an existing socket
  39. NS_NOTREACHED("Cannot layer UDP socket on an existing socket");
  40. return NS_ERROR_UNEXPECTED;
  41. }