RilSocketConsumer.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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_RilSocketConsumer_h
  6. #define mozilla_ipc_RilSocketConsumer_h
  7. #include "mozilla/UniquePtr.h"
  8. class JSContext;
  9. namespace mozilla {
  10. namespace ipc {
  11. class UnixSocketBuffer;
  12. /**
  13. * |RilSocketConsumer| handles socket events and received data.
  14. */
  15. class RilSocketConsumer
  16. {
  17. public:
  18. /**
  19. * Method to be called whenever data is received. RIL-worker only.
  20. *
  21. * @param aCx The RIL worker's JS context.
  22. * @param aIndex The index that has been given to the stream socket.
  23. * @param aBuffer Data received from the socket.
  24. */
  25. virtual void ReceiveSocketData(JSContext* aCx,
  26. int aIndex,
  27. UniquePtr<UnixSocketBuffer>& aBuffer) = 0;
  28. /**
  29. * Callback for socket success. Consumer-thread only.
  30. *
  31. * @param aIndex The index that has been given to the stream socket.
  32. */
  33. virtual void OnConnectSuccess(int aIndex) = 0;
  34. /**
  35. * Callback for socket errors. Consumer-thread only.
  36. *
  37. * @param aIndex The index that has been given to the stream socket.
  38. */
  39. virtual void OnConnectError(int aIndex) = 0;
  40. /**
  41. * Callback for socket disconnect. Consumer-thread only.
  42. *
  43. * @param aIndex The index that has been given to the stream socket.
  44. */
  45. virtual void OnDisconnect(int aIndex) = 0;
  46. protected:
  47. virtual ~RilSocketConsumer();
  48. };
  49. }
  50. }
  51. #endif