Flutter Engine
The Flutter Engine
file_loader.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
5#ifndef LIB_TONIC_FILE_LOADER_FILE_LOADER_H_
6#define LIB_TONIC_FILE_LOADER_FILE_LOADER_H_
7
8#include <memory>
9#include <set>
10#include <string>
11#include <vector>
12
13#include "third_party/dart/runtime/include/dart_api.h"
14#include "tonic/common/macros.h"
16
17namespace tonic {
18
20 public:
21 explicit FileLoader(int dirfd = -1);
23
24 bool LoadPackagesMap(const std::string& packages);
25
26 // The path to the `.packages` file the packages map was loaded from.
27 const std::string& packages() const { return packages_; }
28
30 Dart_Handle library,
31 Dart_Handle url);
32
37
38 Dart_Handle FetchBytes(const std::string& url,
39 uint8_t*& buffer,
40 intptr_t& buffer_size);
41
42 static const char kFileURLPrefix[];
43 static const size_t kFileURLPrefixLength;
44 static const std::string kPathSeparator;
45
46 private:
47 static std::string SanitizeURIEscapedCharacters(const std::string& str);
48 static std::string SanitizePath(const std::string& path);
49
50 std::string GetFilePathForURL(std::string url);
51 std::string GetFilePathForPackageURL(std::string url);
52 std::string GetFilePathForFileURL(std::string url);
53
54 std::string GetFileURLForPath(const std::string& path);
55
56 bool ReadFileToString(const std::string& path, std::string* result);
57 std::pair<uint8_t*, intptr_t> ReadFileToBytes(const std::string& path);
58
59 int dirfd_;
60 std::string packages_;
61 std::unique_ptr<PackagesMap> packages_map_;
62 std::vector<uint8_t*> kernel_buffers_;
63
64 TONIC_DISALLOW_COPY_AND_ASSIGN(FileLoader);
65};
66
67} // namespace tonic
68
69#endif // LIB_TONIC_FILE_LOADER_FILE_LOADER_H_
static uint32_t buffer_size(uint32_t offset, uint32_t maxAlignment)
const std::string & packages() const
Definition: file_loader.h:27
FileLoader(int dirfd=-1)
Definition: file_loader.cc:49
Dart_Handle Import(Dart_Handle url)
Definition: file_loader.cc:186
void SetPackagesUrl(Dart_Handle url)
Definition: file_loader.cc:220
static const char kFileURLPrefix[]
Definition: file_loader.h:42
bool LoadPackagesMap(const std::string &packages)
Definition: file_loader.cc:79
Dart_Handle HandleLibraryTag(Dart_LibraryTag tag, Dart_Handle library, Dart_Handle url)
Definition: file_loader.cc:118
static const size_t kFileURLPrefixLength
Definition: file_loader.h:43
Dart_Handle CanonicalizeURL(Dart_Handle library, Dart_Handle url)
Definition: file_loader.cc:133
Dart_Handle Kernel(Dart_Handle url)
Definition: file_loader.cc:205
Dart_Handle FetchBytes(const std::string &url, uint8_t *&buffer, intptr_t &buffer_size)
Definition: file_loader.cc:161
static const std::string kPathSeparator
Definition: file_loader.h:44
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
Dart_LibraryTag
Definition: dart_api.h:3419
GAsyncResult * result
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