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 "handle_disposition.h"
12 #include "third_party/dart/runtime/include/dart_api.h"
16 
17 // TODO (kaushikiska): Once fuchsia adds fs to their sdk,
18 // use the rights macros from "fs/vfs.h"
19 
20 // Rights
21 // The file may be read.
22 #define ZX_FS_RIGHT_READABLE 0x00000001
23 // The file may be written.
24 #define ZX_FS_RIGHT_WRITABLE 0x00000002
25 
26 namespace zircon {
27 namespace dart {
28 
29 class System : public fml::RefCountedThreadSafe<System>,
30  public tonic::DartWrappable {
31  DEFINE_WRAPPERTYPEINFO();
32  FML_FRIEND_REF_COUNTED_THREAD_SAFE(System);
33  FML_FRIEND_MAKE_REF_COUNTED(System);
34 
35  public:
36  static Dart_Handle ChannelCreate(uint32_t options);
37  static Dart_Handle ChannelFromFile(std::string path);
38  static zx_status_t ChannelWrite(fml::RefPtr<Handle> channel,
39  const tonic::DartByteData& data,
40  std::vector<Handle*> handles);
41  static zx_status_t ChannelWriteEtc(
42  fml::RefPtr<Handle> channel,
43  const tonic::DartByteData& data,
44  std::vector<HandleDisposition*> handle_dispositions);
45  // TODO(ianloic): Add ChannelRead
46  static Dart_Handle ChannelQueryAndRead(fml::RefPtr<Handle> channel);
47  static Dart_Handle ChannelQueryAndReadEtc(fml::RefPtr<Handle> channel);
48 
49  static Dart_Handle EventpairCreate(uint32_t options);
50 
51  static Dart_Handle SocketCreate(uint32_t options);
52  static Dart_Handle SocketWrite(fml::RefPtr<Handle> socket,
53  const tonic::DartByteData& data,
54  int options);
55  static Dart_Handle SocketRead(fml::RefPtr<Handle> socket, size_t size);
56 
57  static Dart_Handle VmoCreate(uint64_t size, uint32_t options);
58  static Dart_Handle VmoFromFile(std::string path);
59  static Dart_Handle VmoGetSize(fml::RefPtr<Handle> vmo);
60  static zx_status_t VmoSetSize(fml::RefPtr<Handle> vmo, uint64_t size);
61  static zx_status_t VmoWrite(fml::RefPtr<Handle> vmo,
62  uint64_t offset,
63  const tonic::DartByteData& data);
64  static Dart_Handle VmoRead(fml::RefPtr<Handle> vmo,
65  uint64_t offset,
66  size_t size);
67 
68  static Dart_Handle VmoMap(fml::RefPtr<Handle> vmo);
69 
70  static uint64_t ClockGetMonotonic();
71 
72  static void RegisterNatives(tonic::DartLibraryNatives* natives);
73 
74  static zx_status_t ConnectToService(std::string path,
75  fml::RefPtr<Handle> channel);
76 
77  private:
78  static void VmoMapFinalizer(void* isolate_callback_data, void* peer);
79 
80  static zx::channel CloneChannelFromFileDescriptor(int fd);
81 };
82 
83 } // namespace dart
84 } // namespace zircon
85 
86 #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:243
DEF_SWITCHES_START snapshot asset path
Definition: switches.h:32
static Dart_Handle EventpairCreate(uint32_t options)
Definition: system.cc:385
Definition: handle.cc:14
static zx_status_t VmoWrite(fml::RefPtr< Handle > vmo, uint64_t offset, const tonic::DartByteData &data)
Definition: system.cc:490
static Dart_Handle SocketWrite(fml::RefPtr< Handle > socket, const tonic::DartByteData &data, int options)
Definition: system.cc:409
static Dart_Handle SocketCreate(uint32_t options)
Definition: system.cc:397
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13
static Dart_Handle VmoFromFile(std::string path)
Definition: system.cc:454
static Dart_Handle VmoCreate(uint64_t size, uint32_t options)
Definition: system.cc:443
static Dart_Handle ChannelQueryAndReadEtc(fml::RefPtr< Handle > channel)
Definition: system.cc:344
static uint64_t ClockGetMonotonic()
Definition: system.cc:564
Definition: dart_vm.cc:39
static Dart_Handle ChannelQueryAndRead(fml::RefPtr< Handle > channel)
Definition: system.cc:304
static zx_status_t ConnectToService(std::string path, fml::RefPtr< Handle > channel)
Definition: system.cc:204
static zx_status_t ChannelWriteEtc(fml::RefPtr< Handle > channel, const tonic::DartByteData &data, std::vector< HandleDisposition *> handle_dispositions)
Definition: system.cc:268
static Dart_Handle VmoMap(fml::RefPtr< Handle > vmo)
Definition: system.cc:536
static Dart_Handle SocketRead(fml::RefPtr< Handle > socket, size_t size)
Definition: system.cc:424
static Dart_Handle ChannelFromFile(std::string path)
Definition: system.cc:227
static Dart_Handle VmoGetSize(fml::RefPtr< Handle > vmo)
Definition: system.cc:472
static void RegisterNatives(tonic::DartLibraryNatives *natives)
Definition: system.cc:599
static Dart_Handle VmoRead(fml::RefPtr< Handle > vmo, uint64_t offset, size_t size)
Definition: system.cc:505
static Dart_Handle ChannelCreate(uint32_t options)
Definition: system.cc:192
static zx_status_t VmoSetSize(fml::RefPtr< Handle > vmo, uint64_t size)
Definition: system.cc:483