Flutter Engine
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 30 of file file_in_namespace_buffer.cc.

33  : address_(nullptr), size_(0) {
34  fuchsia::mem::Buffer buffer;
35  if (!dart_utils::VmoFromFilenameAt(namespace_fd, path, executable, &buffer) ||
36  buffer.size == 0) {
37  return;
38  }
39 
40  uint32_t flags = ZX_VM_PERM_READ;
41  if (executable) {
42  flags |= ZX_VM_PERM_EXECUTE;
43  }
44 
45  uintptr_t addr;
46  const zx_status_t status =
47  zx::vmar::root_self()->map(flags, 0, buffer.vmo, 0, buffer.size, &addr);
48  if (status != ZX_OK) {
49  FML_LOG(FATAL) << "Failed to map " << path << ": "
50  << zx_status_get_string(status);
51  }
52 
53  address_ = reinterpret_cast<void*>(addr);
54  size_ = buffer.size;
55 }
#define FML_LOG(severity)
Definition: logging.h:65
bool VmoFromFilenameAt(int dirfd, const std::string &filename, bool executable, fuchsia::mem::Buffer *buffer)
Definition: vmo.cc:76
FlutterSemanticsFlag flags
static const uint8_t buffer[]
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 57 of file file_in_namespace_buffer.cc.

57  {
58  if (address_ != nullptr) {
59  zx::vmar::root_self()->unmap(reinterpret_cast<uintptr_t>(address_), size_);
60  address_ = nullptr;
61  size_ = 0;
62  }
63 }

Member Function Documentation

◆ GetMapping()

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

Implements fml::Mapping.

Definition at line 65 of file file_in_namespace_buffer.cc.

65  {
66  return reinterpret_cast<const uint8_t*>(address_);
67 }

◆ GetSize()

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

Implements fml::Mapping.

Definition at line 69 of file file_in_namespace_buffer.cc.

69  {
70  return size_;
71 }

◆ IsDontNeedSafe()

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

Implements fml::Mapping.

Definition at line 73 of file file_in_namespace_buffer.cc.

73  {
74  return true;
75 }

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