Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 1 | #ifndef ANDROID_PDX_CLIENT_CHANNEL_H_ |
| 2 | #define ANDROID_PDX_CLIENT_CHANNEL_H_ |
| 3 | |
Corey Tabaka | 52ea25c | 2017-09-13 18:02:48 -0700 | [diff] [blame] | 4 | #include <vector> |
| 5 | |
Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 6 | #include <pdx/channel_handle.h> |
| 7 | #include <pdx/file_handle.h> |
| 8 | #include <pdx/status.h> |
| 9 | |
| 10 | struct iovec; |
| 11 | |
| 12 | namespace android { |
| 13 | namespace pdx { |
| 14 | |
| 15 | class ClientChannel { |
| 16 | public: |
| 17 | virtual ~ClientChannel() = default; |
| 18 | |
| 19 | // Returns a tag that uniquely identifies a specific underlying IPC transport. |
| 20 | virtual uint32_t GetIpcTag() const = 0; |
| 21 | |
| 22 | virtual int event_fd() const = 0; |
Corey Tabaka | 6890d95 | 2017-01-19 15:02:59 -0800 | [diff] [blame] | 23 | virtual Status<int> GetEventMask(int events) = 0; |
| 24 | |
Corey Tabaka | 52ea25c | 2017-09-13 18:02:48 -0700 | [diff] [blame] | 25 | struct EventSource { |
| 26 | int event_fd; |
| 27 | int event_mask; |
| 28 | }; |
| 29 | |
| 30 | // Returns a set of event-generating fds with and event mask for each. These |
| 31 | // fds are owned by the ClientChannel and must never be closed by the caller. |
| 32 | virtual std::vector<EventSource> GetEventSources() const = 0; |
| 33 | |
Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame] | 34 | virtual LocalChannelHandle& GetChannelHandle() = 0; |
| 35 | virtual void* AllocateTransactionState() = 0; |
| 36 | virtual void FreeTransactionState(void* state) = 0; |
| 37 | |
| 38 | virtual Status<void> SendImpulse(int opcode, const void* buffer, |
| 39 | size_t length) = 0; |
| 40 | |
| 41 | virtual Status<int> SendWithInt(void* transaction_state, int opcode, |
| 42 | const iovec* send_vector, size_t send_count, |
| 43 | const iovec* receive_vector, |
| 44 | size_t receive_count) = 0; |
| 45 | virtual Status<LocalHandle> SendWithFileHandle( |
| 46 | void* transaction_state, int opcode, const iovec* send_vector, |
| 47 | size_t send_count, const iovec* receive_vector, size_t receive_count) = 0; |
| 48 | virtual Status<LocalChannelHandle> SendWithChannelHandle( |
| 49 | void* transaction_state, int opcode, const iovec* send_vector, |
| 50 | size_t send_count, const iovec* receive_vector, size_t receive_count) = 0; |
| 51 | |
| 52 | virtual FileReference PushFileHandle(void* transaction_state, |
| 53 | const LocalHandle& handle) = 0; |
| 54 | virtual FileReference PushFileHandle(void* transaction_state, |
| 55 | const BorrowedHandle& handle) = 0; |
| 56 | virtual ChannelReference PushChannelHandle( |
| 57 | void* transaction_state, const LocalChannelHandle& handle) = 0; |
| 58 | virtual ChannelReference PushChannelHandle( |
| 59 | void* transaction_state, const BorrowedChannelHandle& handle) = 0; |
| 60 | virtual bool GetFileHandle(void* transaction_state, FileReference ref, |
| 61 | LocalHandle* handle) const = 0; |
| 62 | virtual bool GetChannelHandle(void* transaction_state, ChannelReference ref, |
| 63 | LocalChannelHandle* handle) const = 0; |
| 64 | }; |
| 65 | |
| 66 | } // namespace pdx |
| 67 | } // namespace android |
| 68 | |
| 69 | #endif // ANDROID_PDX_CLIENT_CHANNEL_H_ |