RilConnector.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_ipc_RilConnector_h
  6. #define mozilla_ipc_RilConnector_h
  7. #include "mozilla/ipc/UnixSocketConnector.h"
  8. namespace mozilla {
  9. namespace ipc {
  10. /**
  11. * |RilConnector| creates sockets for connecting to rild.
  12. */
  13. class RilConnector final : public UnixSocketConnector
  14. {
  15. public:
  16. RilConnector(const nsACString& aAddressString,
  17. unsigned long aClientId);
  18. ~RilConnector();
  19. // Methods for |UnixSocketConnector|
  20. //
  21. nsresult ConvertAddressToString(const struct sockaddr& aAddress,
  22. socklen_t aAddressLength,
  23. nsACString& aAddressString) override;
  24. nsresult CreateListenSocket(struct sockaddr* aAddress,
  25. socklen_t* aAddressLength,
  26. int& aListenFd) override;
  27. nsresult AcceptStreamSocket(int aListenFd,
  28. struct sockaddr* aAddress,
  29. socklen_t* aAddressLen,
  30. int& aStreamFd) override;
  31. nsresult CreateStreamSocket(struct sockaddr* aAddress,
  32. socklen_t* aAddressLength,
  33. int& aStreamFd) override;
  34. nsresult Duplicate(UnixSocketConnector*& aConnector) override;
  35. private:
  36. nsresult CreateSocket(int aDomain, int& aFd) const;
  37. nsresult SetSocketFlags(int aFd) const;
  38. nsresult CreateAddress(int aDomain,
  39. struct sockaddr& aAddress,
  40. socklen_t& aAddressLength) const;
  41. nsCString mAddressString;
  42. unsigned long mClientId;
  43. };
  44. }
  45. }
  46. #endif