Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
file_in_namespace_buffer.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#ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_FILE_IN_NAMESPACE_BUFFER_H_
5#define FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_FILE_IN_NAMESPACE_BUFFER_H_
6
7#include "flutter/fml/mapping.h"
8
9namespace flutter_runner {
10
11/// A mapping to a buffer for a file that has been loaded into a namespace.
12class FileInNamespaceBuffer final : public fml::Mapping {
13 public:
14 /// Loads the file at |path| into the namespace |namespace_fd|, creating
15 /// a mapping to the loaded buffer.
16 ///
17 /// The file will be loaded with the readable permission. If |executable| is
18 /// true, the file will also be loaded with the executable permission.
19 FileInNamespaceBuffer(int namespace_fd, const char* path, bool executable);
21
22 // |fml::Mapping|
23 const uint8_t* GetMapping() const override;
24
25 // |fml::Mapping|
26 size_t GetSize() const override;
27
28 // |fml::Mapping|
29 bool IsDontNeedSafe() const override;
30
31 private:
32 /// The address that was mapped to the buffer.
33 void* address_;
34
35 /// The size of the buffer.
36 size_t size_;
37
39};
40
41/// Loads a file from |file_path| into the namespace |namespace_fd|, returning
42/// the mapping for that file.
43///
44/// The file will be loaded with the readable permission. If |executable| is
45/// true, the file will be also be loaded with the executable permission.
46std::unique_ptr<fml::Mapping> LoadFile(int namespace_fd,
47 const char* path,
48 bool executable);
49
50/// Opens the file at |path| and creates a file mapping for the file.
51///
52/// The file will be opened with the readable permission. If |executable| is
53/// true, the file will also be opened with the executable permission.
54std::unique_ptr<fml::FileMapping> MakeFileMapping(const char* path,
55 bool executable);
56
57} // namespace flutter_runner
58
59#endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_FLUTTER_FILE_IN_NAMESPACE_BUFFER_H_
A mapping to a buffer for a file that has been loaded into a namespace.
const uint8_t * GetMapping() const override
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
std::unique_ptr< fml::FileMapping > MakeFileMapping(const char *path, bool executable)
std::unique_ptr< fml::Mapping > LoadFile(int namespace_fd, const char *path, bool executable)