Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 ()
 

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
static const uint8_t buffer[]
#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

◆ ~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: