Flutter Engine
 
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 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 198 of file system.cc.

198 {
199 zx_handle_t out0 = 0, out1 = 0;
200 zx_status_t status = zx_channel_create(options, &out0, &out1);
201 if (status != ZX_OK) {
202 return ConstructDartObject(kHandlePairResult, ToDart(status));
203 } else {
204 return ConstructDartObject(kHandlePairResult, ToDart(status),
205 ToDart(Handle::Create(out0)),
206 ToDart(Handle::Create(out1)));
207 }
208}
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 216 of file system.cc.

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

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

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

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

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

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

References channel, data, FML_DCHECK, and i.

◆ ClockGetMonotonic()

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

Definition at line 568 of file system.cc.

568 {
569 return zx_clock_get_monotonic();
570}

◆ ConnectToService()

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

Definition at line 210 of file system.cc.

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

References channel.

◆ EventpairCreate()

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

Definition at line 384 of file system.cc.

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

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

◆ RegisterNatives()

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

Definition at line 603 of file system.cc.

603 {
605}
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 396 of file system.cc.

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

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

◆ SocketRead()

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

Definition at line 423 of file system.cc.

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

References FML_DCHECK.

◆ SocketWrite()

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

Definition at line 408 of file system.cc.

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

References data.

◆ VmoCreate()

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

Definition at line 442 of file system.cc.

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

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

◆ VmoFromFile()

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

Definition at line 453 of file system.cc.

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

476 {
477 if (!vmo || !vmo->is_valid()) {
478 return ConstructDartObject(kGetSizeResult, ToDart(ZX_ERR_BAD_HANDLE));
479 }
480
481 uint64_t size;
482 zx_status_t status = zx_vmo_get_size(vmo->handle(), &size);
483
484 return ConstructDartObject(kGetSizeResult, ToDart(status), ToDart(size));
485}
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 540 of file system.cc.

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

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

◆ VmoSetSize()

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

Definition at line 487 of file system.cc.

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

◆ VmoWrite()

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

Definition at line 494 of file system.cc.

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

References data.


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