Flutter Engine
system.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_DART_PKG_ZIRCON_SDK_EXT_SYSTEM_H_
6 #define FLUTTER_SHELL_PLATFORM_FUCHSIA_DART_PKG_ZIRCON_SDK_EXT_SYSTEM_H_
7 
8 #include <zircon/syscalls.h>
9 
10 #include "handle.h"
11 #include "third_party/dart/runtime/include/dart_api.h"
15 
16 // TODO (kaushikiska): Once fuchsia adds fs to their sdk,
17 // use the rights macros from "fs/vfs.h"
18 
19 // Rights
20 // The file may be read.
21 #define ZX_FS_RIGHT_READABLE 0x00000001
22 // The file may be written.
23 #define ZX_FS_RIGHT_WRITABLE 0x00000002
24 
25 namespace zircon {
26 namespace dart {
27 
28 class System : public fml::RefCountedThreadSafe<System>,
29  public tonic::DartWrappable {
30  DEFINE_WRAPPERTYPEINFO();
31  FML_FRIEND_REF_COUNTED_THREAD_SAFE(System);
32  FML_FRIEND_MAKE_REF_COUNTED(System);
33 
34  public:
35  static Dart_Handle ChannelCreate(uint32_t options);
36  static Dart_Handle ChannelFromFile(std::string path);
37  static zx_status_t ChannelWrite(fml::RefPtr<Handle> channel,
38  const tonic::DartByteData& data,
39  std::vector<Handle*> handles);
40  // TODO(ianloic): Add ChannelRead
41  static Dart_Handle ChannelQueryAndRead(fml::RefPtr<Handle> channel);
42 
43  static Dart_Handle EventpairCreate(uint32_t options);
44 
45  static Dart_Handle SocketCreate(uint32_t options);
46  static Dart_Handle SocketWrite(fml::RefPtr<Handle> socket,
47  const tonic::DartByteData& data,
48  int options);
49  static Dart_Handle SocketRead(fml::RefPtr<Handle> socket, size_t size);
50 
51  static Dart_Handle VmoCreate(uint64_t size, uint32_t options);
52  static Dart_Handle VmoFromFile(std::string path);
53  static Dart_Handle VmoGetSize(fml::RefPtr<Handle> vmo);
54  static zx_status_t VmoSetSize(fml::RefPtr<Handle> vmo, uint64_t size);
55  static zx_status_t VmoWrite(fml::RefPtr<Handle> vmo,
56  uint64_t offset,
57  const tonic::DartByteData& data);
58  static Dart_Handle VmoRead(fml::RefPtr<Handle> vmo,
59  uint64_t offset,
60  size_t size);
61 
62  static Dart_Handle VmoMap(fml::RefPtr<Handle> vmo);
63 
64  static uint64_t ClockGet(uint32_t clock_id);
65 
66  static void RegisterNatives(tonic::DartLibraryNatives* natives);
67 
68  static zx_status_t ConnectToService(std::string path,
69  fml::RefPtr<Handle> channel);
70 
71  private:
72  static void VmoMapFinalizer(void* isolate_callback_data, void* peer);
73 
74  static zx::channel CloneChannelFromFileDescriptor(int fd);
75 };
76 
77 } // namespace dart
78 } // namespace zircon
79 
80 #endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_DART_PKG_ZIRCON_SDK_EXT_SYSTEM_H_
static zx_status_t ChannelWrite(fml::RefPtr< Handle > channel, const tonic::DartByteData &data, std::vector< Handle *> handles)
Definition: system.cc:218
DEF_SWITCHES_START snapshot asset path
Definition: switches.h:32
static Dart_Handle EventpairCreate(uint32_t options)
Definition: system.cc:283
Definition: handle.cc:14
static zx_status_t VmoWrite(fml::RefPtr< Handle > vmo, uint64_t offset, const tonic::DartByteData &data)
Definition: system.cc:388
static Dart_Handle SocketWrite(fml::RefPtr< Handle > socket, const tonic::DartByteData &data, int options)
Definition: system.cc:307
static Dart_Handle SocketCreate(uint32_t options)
Definition: system.cc:295
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13
static Dart_Handle VmoFromFile(std::string path)
Definition: system.cc:352
static Dart_Handle VmoCreate(uint64_t size, uint32_t options)
Definition: system.cc:341
Definition: dart_vm.cc:38
static Dart_Handle ChannelQueryAndRead(fml::RefPtr< Handle > channel)
Definition: system.cc:243
static zx_status_t ConnectToService(std::string path, fml::RefPtr< Handle > channel)
Definition: system.cc:179
static Dart_Handle VmoMap(fml::RefPtr< Handle > vmo)
Definition: system.cc:434
static Dart_Handle SocketRead(fml::RefPtr< Handle > socket, size_t size)
Definition: system.cc:322
static Dart_Handle ChannelFromFile(std::string path)
Definition: system.cc:202
static Dart_Handle VmoGetSize(fml::RefPtr< Handle > vmo)
Definition: system.cc:370
static void RegisterNatives(tonic::DartLibraryNatives *natives)
Definition: system.cc:497
static Dart_Handle VmoRead(fml::RefPtr< Handle > vmo, uint64_t offset, size_t size)
Definition: system.cc:403
static Dart_Handle ChannelCreate(uint32_t options)
Definition: system.cc:167
static uint64_t ClockGet(uint32_t clock_id)
Definition: system.cc:462
static zx_status_t VmoSetSize(fml::RefPtr< Handle > vmo, uint64_t size)
Definition: system.cc:381