Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
dart_utils::MappedResource Class Reference

#include <mapped_resource.h>

Public Member Functions

 MappedResource ()
 
 MappedResource (MappedResource &&other)
 
MappedResourceoperator= (MappedResource &&other)
 
 ~MappedResource ()
 
const uint8_t * address () const
 
size_t size () const
 

Static Public Member Functions

static bool LoadFromNamespace (fdio_ns_t *namespc, const std::string &path, MappedResource &resource, bool executable=false)
 
static bool LoadFromDir (int dirfd, const std::string &path, MappedResource &resource, bool executable=false)
 
static bool LoadFromVmo (const std::string &path, fuchsia::mem::Buffer resource_vmo, MappedResource &resource, bool executable=false)
 

Detailed Description

Definition at line 50 of file mapped_resource.h.

Constructor & Destructor Documentation

◆ MappedResource() [1/2]

dart_utils::MappedResource::MappedResource ( )
inline

Definition at line 52 of file mapped_resource.h.

52: address_(nullptr), size_(0) {}

◆ MappedResource() [2/2]

dart_utils::MappedResource::MappedResource ( MappedResource &&  other)
inline

Definition at line 53 of file mapped_resource.h.

54 : address_(other.address_), size_(other.size_) {
55 other.address_ = nullptr;
56 other.size_ = 0;
57 }

◆ ~MappedResource()

dart_utils::MappedResource::~MappedResource ( )

Definition at line 96 of file mapped_resource.cc.

96 {
97 if (address_ != nullptr) {
98 zx::vmar::root_self()->unmap(reinterpret_cast<uintptr_t>(address_), size_);
99 address_ = nullptr;
100 size_ = 0;
101 }
102}

Member Function Documentation

◆ address()

const uint8_t * dart_utils::MappedResource::address ( ) const
inline

Definition at line 92 of file mapped_resource.h.

92 {
93 return reinterpret_cast<const uint8_t*>(address_);
94 }

◆ LoadFromDir()

static bool dart_utils::MappedResource::LoadFromDir ( int  dirfd,
const std::string &  path,
MappedResource resource,
bool  executable = false 
)
static

◆ LoadFromNamespace()

bool dart_utils::MappedResource::LoadFromNamespace ( fdio_ns_t *  namespc,
const std::string &  path,
MappedResource resource,
bool  executable = false 
)
static

Definition at line 62 of file mapped_resource.cc.

65 {
66 fuchsia::mem::Buffer resource_vmo;
67 return OpenVmo(&resource_vmo, namespc, path, executable) &&
68 LoadFromVmo(path, std::move(resource_vmo), resource, executable);
69}
static bool LoadFromVmo(const std::string &path, fuchsia::mem::Buffer resource_vmo, MappedResource &resource, bool executable=false)
static bool OpenVmo(fuchsia::mem::Buffer *resource_vmo, fdio_ns_t *namespc, const std::string &path, bool executable)

◆ LoadFromVmo()

bool dart_utils::MappedResource::LoadFromVmo ( const std::string &  path,
fuchsia::mem::Buffer  resource_vmo,
MappedResource resource,
bool  executable = false 
)
static

Definition at line 71 of file mapped_resource.cc.

74 {
75 if (resource_vmo.size == 0) {
76 return true;
77 }
78
79 uint32_t flags = ZX_VM_PERM_READ;
80 if (executable) {
81 flags |= ZX_VM_PERM_EXECUTE;
82 }
83 uintptr_t addr;
84 zx_status_t status = zx::vmar::root_self()->map(flags, 0, resource_vmo.vmo, 0,
85 resource_vmo.size, &addr);
86 if (status != ZX_OK) {
87 FML_LOG(ERROR) << "Failed to map: " << zx_status_get_string(status);
88 return false;
89 }
90
91 resource.address_ = reinterpret_cast<void*>(addr);
92 resource.size_ = resource_vmo.size;
93 return true;
94}
FlutterSemanticsFlag flags
#define FML_LOG(severity)
Definition logging.h:82
#define ERROR(message)

◆ operator=()

MappedResource & dart_utils::MappedResource::operator= ( MappedResource &&  other)
inline

Definition at line 58 of file mapped_resource.h.

58 {
59 address_ = other.address_;
60 size_ = other.size_;
61 other.address_ = nullptr;
62 other.size_ = 0;
63 return *this;
64 }

◆ size()

size_t dart_utils::MappedResource::size ( ) const
inline

Definition at line 95 of file mapped_resource.h.

95{ return size_; }

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