Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
flutter_runner::FileInNamespaceBuffer Class Referencefinal

A mapping to a buffer for a file that has been loaded into a namespace. More...

#include <file_in_namespace_buffer.h>

Inheritance diagram for flutter_runner::FileInNamespaceBuffer:
fml::Mapping

Public Member Functions

 FileInNamespaceBuffer (int namespace_fd, const char *path, bool executable)
 
 ~FileInNamespaceBuffer ()
 
const uint8_t * GetMapping () const override
 
size_t GetSize () const override
 
bool IsDontNeedSafe () const override
 
- Public Member Functions inherited from fml::Mapping
 Mapping ()
 
virtual ~Mapping ()
 
virtual size_t GetSize () const =0
 
virtual const uint8_t * GetMapping () const =0
 
virtual bool IsDontNeedSafe () const =0
 

Detailed Description

A mapping to a buffer for a file that has been loaded into a namespace.

Definition at line 12 of file file_in_namespace_buffer.h.

Constructor & Destructor Documentation

◆ FileInNamespaceBuffer()

flutter_runner::FileInNamespaceBuffer::FileInNamespaceBuffer ( int  namespace_fd,
const char *  path,
bool  executable 
)

Loads the file at |path| into the namespace |namespace_fd|, creating a mapping to the loaded buffer.

The file will be loaded with the readable permission. If |executable| is true, the file will also be loaded with the executable permission.

Definition at line 20 of file file_in_namespace_buffer.cc.

23 : address_(nullptr), size_(0) {
24 fuchsia::mem::Buffer buffer;
25 if (!dart_utils::VmoFromFilenameAt(namespace_fd, path, executable, &buffer) ||
26 buffer.size == 0) {
27 return;
28 }
29
30 uint32_t flags = ZX_VM_PERM_READ;
31 if (executable) {
32 flags |= ZX_VM_PERM_EXECUTE;
33 }
34
35 uintptr_t addr;
36 const zx_status_t status =
37 zx::vmar::root_self()->map(flags, 0, buffer.vmo, 0, buffer.size, &addr);
38 if (status != ZX_OK) {
39 FML_LOG(FATAL) << "Failed to map " << path << ": "
40 << zx_status_get_string(status);
41 }
42
43 address_ = reinterpret_cast<void*>(addr);
44 size_ = buffer.size;
45}
#define FATAL(error)
FlutterSemanticsFlag flags
#define FML_LOG(severity)
Definition: logging.h:82
bool VmoFromFilenameAt(int dirfd, const std::string &filename, bool executable, fuchsia::mem::Buffer *buffer)
Definition: vmo.cc:82
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
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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ ~FileInNamespaceBuffer()

flutter_runner::FileInNamespaceBuffer::~FileInNamespaceBuffer ( )

Definition at line 47 of file file_in_namespace_buffer.cc.

47 {
48 if (address_ != nullptr) {
49 zx::vmar::root_self()->unmap(reinterpret_cast<uintptr_t>(address_), size_);
50 address_ = nullptr;
51 size_ = 0;
52 }
53}

Member Function Documentation

◆ GetMapping()

const uint8_t * flutter_runner::FileInNamespaceBuffer::GetMapping ( ) const
overridevirtual

Implements fml::Mapping.

Definition at line 55 of file file_in_namespace_buffer.cc.

55 {
56 return reinterpret_cast<const uint8_t*>(address_);
57}

◆ GetSize()

size_t flutter_runner::FileInNamespaceBuffer::GetSize ( ) const
overridevirtual

Implements fml::Mapping.

Definition at line 59 of file file_in_namespace_buffer.cc.

59 {
60 return size_;
61}

◆ IsDontNeedSafe()

bool flutter_runner::FileInNamespaceBuffer::IsDontNeedSafe ( ) const
overridevirtual

Implements fml::Mapping.

Definition at line 63 of file file_in_namespace_buffer.cc.

63 {
64 return true;
65}

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