Flutter Engine
The Flutter Engine
Typedefs | Functions
handle.cc File Reference
#include "handle.h"
#include "flutter/fml/logging.h"
#include <iostream>
#include <vector>
#include <zircon/syscalls.h>

Go to the source code of this file.

Typedefs

using HandleVector = std::vector< zircon_dart_handle_t * >
 
using HandleVectorPtr = HandleVector *
 

Functions

static void HandleFree (void *isolate_callback_data, void *peer)
 
static void HandlePairFree (void *isolate_callback_data, void *peer)
 
void zircon_dart_handle_free (zircon_dart_handle_t *handle)
 
int32_t zircon_dart_handle_close (zircon_dart_handle_t *handle)
 
int32_t zircon_dart_handle_is_valid (zircon_dart_handle_t *handle)
 
int zircon_dart_handle_attach_finalizer (Dart_Handle object, void *pointer, intptr_t external_allocation_size)
 
int zircon_dart_handle_pair_attach_finalizer (Dart_Handle object, void *pointer, intptr_t external_allocation_size)
 
zircon_dart_handle_list_tzircon_dart_handle_list_create ()
 
void zircon_dart_handle_list_append (zircon_dart_handle_list_t *list, zircon_dart_handle_t *handle)
 
void zircon_dart_handle_list_free (zircon_dart_handle_list_t *list)
 

Typedef Documentation

◆ HandleVector

using HandleVector = std::vector<zircon_dart_handle_t*>

Definition at line 84 of file handle.cc.

◆ HandleVectorPtr

Definition at line 85 of file handle.cc.

Function Documentation

◆ HandleFree()

static void HandleFree ( void *  isolate_callback_data,
void *  peer 
)
static

Definition at line 14 of file handle.cc.

14 {
15 FML_CHECK(peer);
16 zircon_dart_handle_t* handle = reinterpret_cast<zircon_dart_handle_t*>(peer);
18}
void zircon_dart_handle_free(zircon_dart_handle_t *handle)
Definition: handle.cc:27
#define FML_CHECK(condition)
Definition: logging.h:85

◆ HandlePairFree()

static void HandlePairFree ( void *  isolate_callback_data,
void *  peer 
)
static

Definition at line 20 of file handle.cc.

20 {
21 FML_CHECK(peer);
22 zircon_dart_handle_pair_t* handle_pair =
23 reinterpret_cast<zircon_dart_handle_pair_t*>(peer);
24 free(handle_pair);
25}

◆ zircon_dart_handle_attach_finalizer()

int zircon_dart_handle_attach_finalizer ( Dart_Handle  object,
void *  pointer,
intptr_t  external_allocation_size 
)

Definition at line 54 of file handle.cc.

56 {
57 Dart_FinalizableHandle weak_handle = Dart_NewFinalizableHandle_DL(
58 object, pointer, external_allocation_size, HandleFree);
59
60 if (weak_handle == nullptr) {
61 FML_LOG(ERROR) << "Unable to attach finalizer: " << std::hex << pointer;
62 return -1;
63 }
64
65 return 1;
66}
struct _Dart_FinalizableHandle * Dart_FinalizableHandle
Definition: dart_api.h:261
static void HandleFree(void *isolate_callback_data, void *peer)
Definition: handle.cc:14
#define FML_LOG(severity)
Definition: logging.h:82
#define ERROR(message)
Definition: elf_loader.cc:260

◆ zircon_dart_handle_close()

int32_t zircon_dart_handle_close ( zircon_dart_handle_t handle)

Definition at line 35 of file handle.cc.

35 {
36 FML_CHECK(handle->handle != ZX_HANDLE_INVALID);
37 zx_status_t status = zx_handle_close(handle->handle);
38 handle->handle = ZX_HANDLE_INVALID;
39 if (status == ZX_OK) {
40 return 1;
41 } else {
42 return 0;
43 }
44}
uint32_t handle
Definition: handle.h:19

◆ zircon_dart_handle_free()

void zircon_dart_handle_free ( zircon_dart_handle_t handle)

Definition at line 27 of file handle.cc.

27 {
28 FML_CHECK(handle);
29 if (handle->handle != ZX_HANDLE_INVALID) {
31 }
32 free(handle);
33}
int32_t zircon_dart_handle_close(zircon_dart_handle_t *handle)
Definition: handle.cc:35

◆ zircon_dart_handle_is_valid()

int32_t zircon_dart_handle_is_valid ( zircon_dart_handle_t handle)

Definition at line 46 of file handle.cc.

46 {
47 if (!handle || (handle->handle == ZX_HANDLE_INVALID)) {
48 return 0;
49 } else {
50 return 1;
51 }
52}

◆ zircon_dart_handle_list_append()

void zircon_dart_handle_list_append ( zircon_dart_handle_list_t list,
zircon_dart_handle_t handle 
)

Definition at line 95 of file handle.cc.

96 {
97 FML_CHECK(list);
98 FML_CHECK(handle);
99 list->size++;
100 auto data = reinterpret_cast<HandleVectorPtr>(list->data);
101 data->push_back(handle);
102}
HandleVector * HandleVectorPtr
Definition: handle.cc:85
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ zircon_dart_handle_list_create()

zircon_dart_handle_list_t * zircon_dart_handle_list_create ( )

Definition at line 87 of file handle.cc.

87 {
90 result->size = 0;
91 result->data = new HandleVector();
92 return result;
93}
std::vector< zircon_dart_handle_t * > HandleVector
Definition: handle.cc:84
GAsyncResult * result
void * malloc(size_t size)
Definition: allocation.cc:19

◆ zircon_dart_handle_list_free()

void zircon_dart_handle_list_free ( zircon_dart_handle_list_t list)

Definition at line 104 of file handle.cc.

104 {
105 auto data = reinterpret_cast<HandleVectorPtr>(list->data);
106 data->clear();
107 delete data;
108 free(list);
109}

◆ zircon_dart_handle_pair_attach_finalizer()

int zircon_dart_handle_pair_attach_finalizer ( Dart_Handle  object,
void *  pointer,
intptr_t  external_allocation_size 
)

Definition at line 68 of file handle.cc.

71 {
72 Dart_FinalizableHandle weak_handle = Dart_NewFinalizableHandle_DL(
73 object, pointer, external_allocation_size, HandlePairFree);
74
75 if (weak_handle == nullptr) {
76 FML_LOG(ERROR) << "Unable to attach finalizer: " << std::hex << pointer;
77 return -1;
78 }
79
80 return 1;
81}
static void HandlePairFree(void *isolate_callback_data, void *peer)
Definition: handle.cc:20