Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
channel.h File Reference

Go to the source code of this file.

Functions

ZIRCON_FFI_EXPORT zircon_dart_handle_pair_tzircon_dart_channel_create (uint32_t options)
 
ZIRCON_FFI_EXPORT int32_t zircon_dart_channel_write (zircon_dart_handle_t *handle, zircon_dart_byte_array_t *bytes, zircon_dart_handle_list_t *handles)
 

Function Documentation

◆ zircon_dart_channel_create()

ZIRCON_FFI_EXPORT zircon_dart_handle_pair_t * zircon_dart_channel_create ( uint32_t  options)

Definition at line 22 of file channel.cc.

22 {
23 zx_handle_t out0 = 0, out1 = 0;
24 zx_status_t status = zx_channel_create(options, &out0, &out1);
25 if (status != ZX_OK) {
26 return nullptr;
27 } else {
29 malloc(sizeof(zircon_dart_handle_pair_t)));
30 result->left = MakeHandle(out0);
31 result->right = MakeHandle(out1);
32 return result;
33 }
34}
static zircon_dart_handle_t * MakeHandle(zx_handle_t handle)
Definition channel.cc:15
zircon_dart_handle_t * right
Definition handle.h:24
zircon_dart_handle_t * left
Definition handle.h:23

References zircon_dart_handle_pair_t::left, MakeHandle(), and zircon_dart_handle_pair_t::right.

◆ zircon_dart_channel_write()

ZIRCON_FFI_EXPORT int32_t zircon_dart_channel_write ( zircon_dart_handle_t handle,
zircon_dart_byte_array_t bytes,
zircon_dart_handle_list_t handles 
)

Definition at line 36 of file channel.cc.

38 {
39 if (!handle || (handle->handle == ZX_HANDLE_INVALID)) {
40 return ZX_ERR_BAD_HANDLE;
41 }
42
43 std::vector<zx_handle_t> zx_handles;
44 std::vector<zircon_dart_handle_t*> handle_data =
45 *reinterpret_cast<std::vector<zircon_dart_handle_t*>*>(handles->data);
46 for (auto handle_ptr : handle_data) {
47 zx_handles.push_back(handle_ptr->handle);
48 }
49
50 zx_status_t status =
51 zx_channel_write(handle->handle, 0, bytes->data, bytes->length,
52 zx_handles.data(), zx_handles.size());
53
54 // Handles are always consumed.
55 for (auto handle_ptr : handle_data) {
56 handle_ptr->handle = ZX_HANDLE_INVALID;
57 }
58
59 return status;
60}
uint32_t handle
Definition handle.h:19

References zircon_dart_byte_array_t::data, zircon_dart_handle_list_t::data, zircon_dart_handle_t::handle, and zircon_dart_byte_array_t::length.