Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
zircon::dart::System Class Reference

#include <system.h>

Inheritance diagram for zircon::dart::System:
fml::RefCountedThreadSafe< System > tonic::DartWrappable fml::internal::RefCountedThreadSafeBase

Static Public Member Functions

static Dart_Handle ChannelCreate (uint32_t options)
 
static Dart_Handle ChannelFromFile (std::string path)
 
static zx_status_t ChannelWrite (fml::RefPtr< Handle > channel, const tonic::DartByteData &data, std::vector< Handle * > handles)
 
static zx_status_t ChannelWriteEtc (fml::RefPtr< Handle > channel, const tonic::DartByteData &data, std::vector< HandleDisposition * > handle_dispositions)
 
static Dart_Handle ChannelQueryAndRead (fml::RefPtr< Handle > channel)
 
static Dart_Handle ChannelQueryAndReadEtc (fml::RefPtr< Handle > channel)
 
static Dart_Handle EventpairCreate (uint32_t options)
 
static Dart_Handle SocketCreate (uint32_t options)
 
static Dart_Handle SocketWrite (fml::RefPtr< Handle > socket, const tonic::DartByteData &data, int options)
 
static Dart_Handle SocketRead (fml::RefPtr< Handle > socket, size_t size)
 
static Dart_Handle VmoCreate (uint64_t size, uint32_t options)
 
static Dart_Handle VmoFromFile (std::string path)
 
static Dart_Handle VmoGetSize (fml::RefPtr< Handle > vmo)
 
static zx_status_t VmoSetSize (fml::RefPtr< Handle > vmo, uint64_t size)
 
static zx_status_t VmoWrite (fml::RefPtr< Handle > vmo, uint64_t offset, const tonic::DartByteData &data)
 
static Dart_Handle VmoRead (fml::RefPtr< Handle > vmo, uint64_t offset, size_t size)
 
static Dart_Handle VmoMap (fml::RefPtr< Handle > vmo)
 
static uint64_t ClockGetMonotonic ()
 
static void RegisterNatives (tonic::DartLibraryNatives *natives)
 
static zx_status_t ConnectToService (std::string path, fml::RefPtr< Handle > channel)
 

Additional Inherited Members

- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields { kPeerIndex , kNumberOfNativeFields }
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< System >
void Release () const
 
- Public Member Functions inherited from fml::internal::RefCountedThreadSafeBase
void AddRef () const
 
bool HasOneRef () const
 
void AssertHasOneRef () const
 
- Public Member Functions inherited from tonic::DartWrappable
 DartWrappable ()
 
virtual const DartWrapperInfoGetDartWrapperInfo () const =0
 
virtual void RetainDartWrappableReference () const =0
 
virtual void ReleaseDartWrappableReference () const =0
 
Dart_Handle CreateDartWrapper (DartState *dart_state)
 
void AssociateWithDartWrapper (Dart_Handle wrappable)
 
void ClearDartWrapper ()
 
Dart_WeakPersistentHandle dart_wrapper () const
 
- Protected Member Functions inherited from fml::RefCountedThreadSafe< System >
 RefCountedThreadSafe ()
 
 ~RefCountedThreadSafe ()
 
- Protected Member Functions inherited from fml::internal::RefCountedThreadSafeBase
 RefCountedThreadSafeBase ()
 
 ~RefCountedThreadSafeBase ()
 
bool Release () const
 
void Adopt ()
 
- Protected Member Functions inherited from tonic::DartWrappable
virtual ~DartWrappable ()
 
- Static Protected Member Functions inherited from tonic::DartWrappable
static Dart_PersistentHandle GetTypeForWrapper (tonic::DartState *dart_state, const tonic::DartWrapperInfo &wrapper_info)
 

Detailed Description

Definition at line 20 of file system.h.

Member Function Documentation

◆ ChannelCreate()

Dart_Handle zircon::dart::System::ChannelCreate ( uint32_t  options)
static

Definition at line 201 of file system.cc.

201 {
202 zx_handle_t out0 = 0, out1 = 0;
203 zx_status_t status = zx_channel_create(options, &out0, &out1);
204 if (status != ZX_OK) {
205 return ConstructDartObject(kHandlePairResult, ToDart(status));
206 } else {
207 return ConstructDartObject(kHandlePairResult, ToDart(status),
208 ToDart(Handle::Create(out0)),
209 ToDart(Handle::Create(out1)));
210 }
211}
const char * options
static fml::RefPtr< Handle > Create(zx_handle_t handle)
Definition handle.cc:28
Dart_Handle ToDart(const T &object)

◆ ChannelFromFile()

Dart_Handle zircon::dart::System::ChannelFromFile ( std::string  path)
static

Definition at line 219 of file system.cc.

219 {
220 fml::UniqueFD fd;
221 if (zx_status_t status = FdFromPath(path.c_str(), fd); status != ZX_OK) {
222 return ConstructDartObject(kHandleResult, ToDart(status));
223 }
224
225 zx::handle handle;
226 if (zx_status_t status =
227 fdio_fd_transfer(fd.release(), handle.reset_and_get_address());
228 status != ZX_OK) {
229 return ConstructDartObject(kHandleResult, ToDart(status));
230 }
231 zx_info_handle_basic_t info;
232 if (zx_status_t status = handle.get_info(ZX_INFO_HANDLE_BASIC, &info,
233 sizeof(info), nullptr, nullptr);
234 status != ZX_OK) {
235 return ConstructDartObject(kHandleResult, ToDart(status));
236 }
237 if (info.type != ZX_OBJ_TYPE_CHANNEL) {
238 return ConstructDartObject(kHandleResult, ToDart(ZX_ERR_WRONG_TYPE));
239 }
240
241 return ConstructDartObject(kHandleResult, ToDart(ZX_OK),
242 ToDart(Handle::Create(handle.release())));
243}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57

◆ ChannelQueryAndRead()

Dart_Handle zircon::dart::System::ChannelQueryAndRead ( fml::RefPtr< Handle channel)
static

Definition at line 306 of file system.cc.

306 {
307 if (!channel || !channel->is_valid()) {
308 return ConstructDartObject(kReadResult, ToDart(ZX_ERR_BAD_HANDLE));
309 }
310
311 uint32_t actual_bytes = 0;
312 uint32_t actual_handles = 0;
313
314 // Query the size of the next message.
315 zx_status_t status = zx_channel_read(channel->handle(), 0, nullptr, nullptr,
316 0, 0, &actual_bytes, &actual_handles);
317 if (status != ZX_ERR_BUFFER_TOO_SMALL) {
318 // An empty message or an error.
319 return ConstructDartObject(kReadResult, ToDart(status));
320 }
321
322 // Allocate space for the bytes and handles.
323 ByteDataScope bytes(actual_bytes);
324 FML_DCHECK(bytes.is_valid());
325 std::vector<zx_handle_t> handles(actual_handles);
326
327 // Make the call to actually get the message.
328 status = zx_channel_read(channel->handle(), 0, bytes.data(), handles.data(),
329 bytes.size(), handles.size(), &actual_bytes,
330 &actual_handles);
331 FML_DCHECK(status != ZX_OK || bytes.size() == actual_bytes);
332
333 bytes.Release();
334
335 if (status == ZX_OK) {
336 FML_DCHECK(handles.size() == actual_handles);
337
338 // return a ReadResult object.
339 return ConstructDartObject(kReadResult, ToDart(status), bytes.dart_handle(),
340 ToDart(actual_bytes), MakeHandleList(handles));
341 } else {
342 return ConstructDartObject(kReadResult, ToDart(status));
343 }
344}
#define FML_DCHECK(condition)
Definition logging.h:103

◆ ChannelQueryAndReadEtc()

Dart_Handle zircon::dart::System::ChannelQueryAndReadEtc ( fml::RefPtr< Handle channel)
static

Definition at line 346 of file system.cc.

346 {
347 if (!channel || !channel->is_valid()) {
348 return ConstructDartObject(kReadEtcResult, ToDart(ZX_ERR_BAD_HANDLE));
349 }
350
351 uint32_t actual_bytes = 0;
352 uint32_t actual_handles = 0;
353
354 // Query the size of the next message.
355 zx_status_t status = zx_channel_read(channel->handle(), 0, nullptr, nullptr,
356 0, 0, &actual_bytes, &actual_handles);
357 if (status != ZX_ERR_BUFFER_TOO_SMALL) {
358 // An empty message or an error.
359 return ConstructDartObject(kReadEtcResult, ToDart(status));
360 }
361
362 // Allocate space for the bytes and handles.
363 ByteDataScope bytes(actual_bytes);
364 FML_DCHECK(bytes.is_valid());
365 std::vector<zx_handle_info_t> handles(actual_handles);
366
367 // Make the call to actually get the message.
368 status = zx_channel_read_etc(channel->handle(), 0, bytes.data(),
369 handles.data(), bytes.size(), handles.size(),
370 &actual_bytes, &actual_handles);
371 FML_DCHECK(status != ZX_OK || bytes.size() == actual_bytes);
372
373 bytes.Release();
374
375 if (status == ZX_OK) {
376 FML_DCHECK(handles.size() == actual_handles);
377
378 // return a ReadResult object.
379 return ConstructDartObject(kReadEtcResult, ToDart(status),
380 bytes.dart_handle(), ToDart(actual_bytes),
381 MakeHandleInfoList(handles));
382 } else {
383 return ConstructDartObject(kReadEtcResult, ToDart(status));
384 }
385}

◆ ChannelWrite()

zx_status_t zircon::dart::System::ChannelWrite ( fml::RefPtr< Handle channel,
const tonic::DartByteData data,
std::vector< Handle * >  handles 
)
static

Definition at line 245 of file system.cc.

247 {
248 if (!channel || !channel->is_valid()) {
249 data.Release();
250 return ZX_ERR_BAD_HANDLE;
251 }
252
253 std::vector<zx_handle_t> zx_handles;
254 for (Handle* handle : handles) {
255 zx_handles.push_back(handle->handle());
256 }
257
258 zx_status_t status = zx_channel_write(channel->handle(), 0, data.data(),
259 data.length_in_bytes(),
260 zx_handles.data(), zx_handles.size());
261 // Handles are always consumed.
262 for (Handle* handle : handles) {
263 handle->ReleaseHandle();
264 }
265
266 data.Release();
267 return status;
268}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

◆ ChannelWriteEtc()

zx_status_t zircon::dart::System::ChannelWriteEtc ( fml::RefPtr< Handle channel,
const tonic::DartByteData data,
std::vector< HandleDisposition * >  handle_dispositions 
)
static

Definition at line 270 of file system.cc.

273 {
274 if (!channel || !channel->is_valid()) {
275 data.Release();
276 return ZX_ERR_BAD_HANDLE;
277 }
278
279 std::vector<zx_handle_disposition_t> zx_handle_dispositions;
280 for (HandleDisposition* handle : handle_dispositions) {
281 FML_DCHECK(handle->result() == ZX_OK);
282 zx_handle_dispositions.push_back({.operation = handle->operation(),
283 .handle = handle->handle()->handle(),
284 .type = handle->type(),
285 .rights = handle->rights(),
286 .result = ZX_OK});
287 }
288
289 zx_status_t status = zx_channel_write_etc(
290 channel->handle(), 0, data.data(), data.length_in_bytes(),
291 zx_handle_dispositions.data(), zx_handle_dispositions.size());
292
293 for (size_t i = 0; i < handle_dispositions.size(); ++i) {
294 handle_dispositions[i]->set_result(zx_handle_dispositions[i].result);
295
296 // Handles that are not copied (i.e. moved) are always consumed.
297 if (handle_dispositions[i]->operation() != ZX_HANDLE_OP_DUPLICATE) {
298 handle_dispositions[i]->handle()->ReleaseHandle();
299 }
300 }
301
302 data.Release();
303 return status;
304}
static void operation(T operation, uint32_t &a, uint32_t b, uint32_t c, uint32_t d, uint32_t x, uint8_t s, uint32_t t)
Definition SkMD5.cpp:144
GAsyncResult * result

◆ ClockGetMonotonic()

uint64_t zircon::dart::System::ClockGetMonotonic ( )
static

Definition at line 571 of file system.cc.

571 {
572 return zx_clock_get_monotonic();
573}

◆ ConnectToService()

zx_status_t zircon::dart::System::ConnectToService ( std::string  path,
fml::RefPtr< Handle channel 
)
static

Definition at line 213 of file system.cc.

214 {
215 return fdio_ns_service_connect(GetNamespace(), path.c_str(),
216 channel->ReleaseHandle());
217}

◆ EventpairCreate()

Dart_Handle zircon::dart::System::EventpairCreate ( uint32_t  options)
static

Definition at line 387 of file system.cc.

387 {
388 zx_handle_t out0 = 0, out1 = 0;
389 zx_status_t status = zx_eventpair_create(0, &out0, &out1);
390 if (status != ZX_OK) {
391 return ConstructDartObject(kHandlePairResult, ToDart(status));
392 } else {
393 return ConstructDartObject(kHandlePairResult, ToDart(status),
394 ToDart(Handle::Create(out0)),
395 ToDart(Handle::Create(out1)));
396 }
397}

◆ RegisterNatives()

void zircon::dart::System::RegisterNatives ( tonic::DartLibraryNatives natives)
static

Definition at line 606 of file system.cc.

606 {
608}
void Register(std::initializer_list< Entry > entries)
#define FOR_EACH_STATIC_BINDING(V)
Definition handle.cc:112
#define DART_REGISTER_NATIVE_STATIC_(CLASS, METHOD)
Definition handle.cc:126

◆ SocketCreate()

Dart_Handle zircon::dart::System::SocketCreate ( uint32_t  options)
static

Definition at line 399 of file system.cc.

399 {
400 zx_handle_t out0 = 0, out1 = 0;
401 zx_status_t status = zx_socket_create(options, &out0, &out1);
402 if (status != ZX_OK) {
403 return ConstructDartObject(kHandlePairResult, ToDart(status));
404 } else {
405 return ConstructDartObject(kHandlePairResult, ToDart(status),
406 ToDart(Handle::Create(out0)),
407 ToDart(Handle::Create(out1)));
408 }
409}

◆ SocketRead()

Dart_Handle zircon::dart::System::SocketRead ( fml::RefPtr< Handle socket,
size_t  size 
)
static

Definition at line 426 of file system.cc.

426 {
427 if (!socket || !socket->is_valid()) {
428 return ConstructDartObject(kReadResult, ToDart(ZX_ERR_BAD_HANDLE));
429 }
430
431 ByteDataScope bytes(size);
432 size_t actual;
433 zx_status_t status =
434 zx_socket_read(socket->handle(), 0, bytes.data(), size, &actual);
435 bytes.Release();
436 if (status == ZX_OK) {
437 FML_DCHECK(actual <= size);
438 return ConstructDartObject(kReadResult, ToDart(status), bytes.dart_handle(),
439 ToDart(actual));
440 }
441
442 return ConstructDartObject(kReadResult, ToDart(status));
443}

◆ SocketWrite()

Dart_Handle zircon::dart::System::SocketWrite ( fml::RefPtr< Handle socket,
const tonic::DartByteData data,
int  options 
)
static

Definition at line 411 of file system.cc.

413 {
414 if (!socket || !socket->is_valid()) {
415 data.Release();
416 return ConstructDartObject(kWriteResult, ToDart(ZX_ERR_BAD_HANDLE));
417 }
418
419 size_t actual;
420 zx_status_t status = zx_socket_write(socket->handle(), options, data.data(),
421 data.length_in_bytes(), &actual);
422 data.Release();
423 return ConstructDartObject(kWriteResult, ToDart(status), ToDart(actual));
424}

◆ VmoCreate()

Dart_Handle zircon::dart::System::VmoCreate ( uint64_t  size,
uint32_t  options 
)
static

Definition at line 445 of file system.cc.

445 {
446 zx_handle_t vmo = ZX_HANDLE_INVALID;
447 zx_status_t status = zx_vmo_create(size, options, &vmo);
448 if (status != ZX_OK) {
449 return ConstructDartObject(kHandleResult, ToDart(status));
450 } else {
451 return ConstructDartObject(kHandleResult, ToDart(status),
452 ToDart(Handle::Create(vmo)));
453 }
454}

◆ VmoFromFile()

Dart_Handle zircon::dart::System::VmoFromFile ( std::string  path)
static

Definition at line 456 of file system.cc.

456 {
457 fml::UniqueFD fd;
458 if (zx_status_t status = FdFromPath(path.c_str(), fd); status != ZX_OK) {
459 return ConstructDartObject(kHandleResult, ToDart(status));
460 }
461
462 struct stat stat_struct;
463 if (fstat(fd.get(), &stat_struct) != 0) {
464 // TODO: can we return errno?
465 return ConstructDartObject(kFromFileResult, ToDart(ZX_ERR_IO));
466 }
467 zx::vmo vmo;
468 if (zx_status_t status =
469 fdio_get_vmo_clone(fd.get(), vmo.reset_and_get_address());
470 status != ZX_OK) {
471 return ConstructDartObject(kFromFileResult, ToDart(status));
472 }
473
474 return ConstructDartObject(kFromFileResult, ToDart(ZX_OK),
475 ToDart(Handle::Create(vmo.release())),
476 ToDart(stat_struct.st_size));
477}
const T & get() const

◆ VmoGetSize()

Dart_Handle zircon::dart::System::VmoGetSize ( fml::RefPtr< Handle vmo)
static

Definition at line 479 of file system.cc.

479 {
480 if (!vmo || !vmo->is_valid()) {
481 return ConstructDartObject(kGetSizeResult, ToDart(ZX_ERR_BAD_HANDLE));
482 }
483
484 uint64_t size;
485 zx_status_t status = zx_vmo_get_size(vmo->handle(), &size);
486
487 return ConstructDartObject(kGetSizeResult, ToDart(status), ToDart(size));
488}
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259

◆ VmoMap()

Dart_Handle zircon::dart::System::VmoMap ( fml::RefPtr< Handle vmo)
static

Definition at line 543 of file system.cc.

543 {
544 if (!vmo || !vmo->is_valid())
545 return ConstructDartObject(kMapResult, ToDart(ZX_ERR_BAD_HANDLE));
546
547 uint64_t size;
548 zx_status_t status = zx_vmo_get_size(vmo->handle(), &size);
549 if (status != ZX_OK)
550 return ConstructDartObject(kMapResult, ToDart(status));
551
552 uintptr_t mapped_addr;
553 status = zx_vmar_map(zx_vmar_root_self(), ZX_VM_PERM_READ, 0, vmo->handle(),
554 0, size, &mapped_addr);
555 if (status != ZX_OK)
556 return ConstructDartObject(kMapResult, ToDart(status));
557
558 void* data = reinterpret_cast<void*>(mapped_addr);
560 static_cast<intptr_t>(size));
562
563 SizedRegion* r = new SizedRegion(data, size);
564 Dart_NewFinalizableHandle(object, reinterpret_cast<void*>(r),
565 static_cast<intptr_t>(size) + sizeof(*r),
566 System::VmoMapFinalizer);
567
568 return ConstructDartObject(kMapResult, ToDart(ZX_OK), object);
569}
DART_EXPORT Dart_FinalizableHandle Dart_NewFinalizableHandle(Dart_Handle object, void *peer, intptr_t external_allocation_size, Dart_HandleFinalizer callback)
DART_EXPORT Dart_Handle Dart_NewExternalTypedData(Dart_TypedData_Type type, void *data, intptr_t length)
struct _Dart_Handle * Dart_Handle
Definition dart_api.h:258
@ Dart_TypedData_kUint8
Definition dart_api.h:2606
bool CheckAndHandleError(Dart_Handle handle)
Definition dart_error.cc:33

◆ VmoRead()

Dart_Handle zircon::dart::System::VmoRead ( fml::RefPtr< Handle vmo,
uint64_t  offset,
size_t  size 
)
static

Definition at line 512 of file system.cc.

514 {
515 if (!vmo || !vmo->is_valid()) {
516 return ConstructDartObject(kReadResult, ToDart(ZX_ERR_BAD_HANDLE));
517 }
518
519 // TODO: constrain size?
520 ByteDataScope bytes(size);
521 zx_status_t status = zx_vmo_read(vmo->handle(), bytes.data(), offset, size);
522 bytes.Release();
523 if (status == ZX_OK) {
524 return ConstructDartObject(kReadResult, ToDart(status), bytes.dart_handle(),
525 ToDart(size));
526 }
527 return ConstructDartObject(kReadResult, ToDart(status));
528}
Point offset

◆ VmoSetSize()

zx_status_t zircon::dart::System::VmoSetSize ( fml::RefPtr< Handle vmo,
uint64_t  size 
)
static

Definition at line 490 of file system.cc.

490 {
491 if (!vmo || !vmo->is_valid()) {
492 return ZX_ERR_BAD_HANDLE;
493 }
494 return zx_vmo_set_size(vmo->handle(), size);
495}

◆ VmoWrite()

zx_status_t zircon::dart::System::VmoWrite ( fml::RefPtr< Handle vmo,
uint64_t  offset,
const tonic::DartByteData data 
)
static

Definition at line 497 of file system.cc.

499 {
500 if (!vmo || !vmo->is_valid()) {
501 data.Release();
502 return ZX_ERR_BAD_HANDLE;
503 }
504
505 zx_status_t status =
506 zx_vmo_write(vmo->handle(), data.data(), offset, data.length_in_bytes());
507
508 data.Release();
509 return status;
510}

The documentation for this class was generated from the following files: