Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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 zx_status_t IobWrite (fml::RefPtr< Handle > iob, uint32_t region_index, const tonic::DartByteData &data)
 
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 199 of file system.cc.

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

References zircon::dart::Handle::Create().

◆ ChannelFromFile()

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

Definition at line 217 of file system.cc.

217 {
218 fml::UniqueFD fd;
219 if (zx_status_t status = FdFromPath(path.c_str(), fd); status != ZX_OK) {
220 return ConstructDartObject(kHandleResult, ToDart(status));
221 }
222
223 zx::handle handle;
224 if (zx_status_t status =
225 fdio_fd_transfer(fd.release(), handle.reset_and_get_address());
226 status != ZX_OK) {
227 return ConstructDartObject(kHandleResult, ToDart(status));
228 }
229 zx_info_handle_basic_t info;
230 if (zx_status_t status = handle.get_info(ZX_INFO_HANDLE_BASIC, &info,
231 sizeof(info), nullptr, nullptr);
232 status != ZX_OK) {
233 return ConstructDartObject(kHandleResult, ToDart(status));
234 }
235 if (info.type != ZX_OBJ_TYPE_CHANNEL) {
236 return ConstructDartObject(kHandleResult, ToDart(ZX_ERR_WRONG_TYPE));
237 }
238
239 return ConstructDartObject(kHandleResult, ToDart(ZX_OK),
240 ToDart(Handle::Create(handle.release())));
241}
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 switch_defs.h:52

References zircon::dart::Handle::Create(), and fml::UniqueObject< T, Traits >::release().

◆ ChannelQueryAndRead()

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

Definition at line 304 of file system.cc.

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

References channel, and FML_DCHECK.

◆ ChannelQueryAndReadEtc()

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

Definition at line 344 of file system.cc.

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

References channel, and FML_DCHECK.

◆ ChannelWrite()

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

Definition at line 243 of file system.cc.

245 {
246 if (!channel || !channel->is_valid()) {
247 data.Release();
248 return ZX_ERR_BAD_HANDLE;
249 }
250
251 std::vector<zx_handle_t> zx_handles;
252 for (Handle* handle : handles) {
253 zx_handles.push_back(handle->handle());
254 }
255
256 zx_status_t status = zx_channel_write(channel->handle(), 0, data.data(),
257 data.length_in_bytes(),
258 zx_handles.data(), zx_handles.size());
259 // Handles are always consumed.
260 for (Handle* handle : handles) {
261 handle->ReleaseHandle();
262 }
263
264 data.Release();
265 return status;
266}
std::shared_ptr< const fml::Mapping > data

References channel, and data.

◆ 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 268 of file system.cc.

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

References channel, data, FML_DCHECK, and i.

◆ ClockGetMonotonic()

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

Definition at line 586 of file system.cc.

586 {
587 return zx_clock_get_monotonic();
588}

◆ ConnectToService()

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

Definition at line 211 of file system.cc.

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

References channel.

◆ EventpairCreate()

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

Definition at line 385 of file system.cc.

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

References zircon::dart::Handle::Create().

◆ IobWrite()

zx_status_t zircon::dart::System::IobWrite ( fml::RefPtr< Handle iob,
uint32_t  region_index,
const tonic::DartByteData data 
)
static

Definition at line 569 of file system.cc.

571 {
572 if (!iob || !iob->is_valid()) {
573 data.Release();
574 return ZX_ERR_BAD_HANDLE;
575 }
576
577 zx_iovec_t vector = {.buffer = const_cast<void*>(data.data()),
578 .capacity = data.length_in_bytes()};
579 zx_status_t status =
580 zx_iob_writev(iob->handle(), /*options=*/0, region_index, &vector, 1);
581
582 data.Release();
583 return status;
584}

References data.

◆ RegisterNatives()

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

Definition at line 622 of file system.cc.

622 {
624}
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

References DART_REGISTER_NATIVE_STATIC_, and FOR_EACH_STATIC_BINDING.

◆ SocketCreate()

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

Definition at line 397 of file system.cc.

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

References zircon::dart::Handle::Create().

◆ SocketRead()

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

Definition at line 424 of file system.cc.

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

References FML_DCHECK.

◆ SocketWrite()

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

Definition at line 409 of file system.cc.

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

References data.

◆ VmoCreate()

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

Definition at line 443 of file system.cc.

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

References zircon::dart::Handle::Create().

◆ VmoFromFile()

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

Definition at line 454 of file system.cc.

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

References zircon::dart::Handle::Create(), and fml::UniqueObject< T, Traits >::get().

◆ VmoGetSize()

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

Definition at line 477 of file system.cc.

477 {
478 if (!vmo || !vmo->is_valid()) {
479 return ConstructDartObject(kGetSizeResult, ToDart(ZX_ERR_BAD_HANDLE));
480 }
481
482 uint64_t size;
483 zx_status_t status = zx_vmo_get_size(vmo->handle(), &size);
484
485 return ConstructDartObject(kGetSizeResult, ToDart(status), ToDart(size));
486}
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all 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

◆ VmoMap()

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

Definition at line 541 of file system.cc.

541 {
542 if (!vmo || !vmo->is_valid())
543 return ConstructDartObject(kMapResult, ToDart(ZX_ERR_BAD_HANDLE));
544
545 uint64_t size;
546 zx_status_t status = zx_vmo_get_size(vmo->handle(), &size);
547 if (status != ZX_OK)
548 return ConstructDartObject(kMapResult, ToDart(status));
549
550 uintptr_t mapped_addr;
551 status = zx_vmar_map(zx_vmar_root_self(), ZX_VM_PERM_READ, 0, vmo->handle(),
552 0, size, &mapped_addr);
553 if (status != ZX_OK)
554 return ConstructDartObject(kMapResult, ToDart(status));
555
556 void* data = reinterpret_cast<void*>(mapped_addr);
557 Dart_Handle object = Dart_NewExternalTypedData(Dart_TypedData_kUint8, data,
558 static_cast<intptr_t>(size));
560
561 SizedRegion* r = new SizedRegion(data, size);
562 Dart_NewFinalizableHandle(object, reinterpret_cast<void*>(r),
563 static_cast<intptr_t>(size) + sizeof(*r),
564 System::VmoMapFinalizer);
565
566 return ConstructDartObject(kMapResult, ToDart(ZX_OK), object);
567}
bool CheckAndHandleError(Dart_Handle handle)
Definition dart_error.cc:33

References tonic::CheckAndHandleError(), data, and FML_DCHECK.

◆ VmoRead()

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

Definition at line 510 of file system.cc.

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

◆ VmoSetSize()

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

Definition at line 488 of file system.cc.

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

◆ VmoWrite()

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

Definition at line 495 of file system.cc.

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

References data.


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