Flutter Engine
 
Loading...
Searching...
No Matches
native_assets.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 FLUTTER_ASSETS_NATIVE_ASSETS_H_
6#define FLUTTER_ASSETS_NATIVE_ASSETS_H_
7
8#include <memory>
9#include <vector>
10
12
13namespace flutter {
14
15// Parses the `NativeAssetsManifest.json` and provides a way to look up assets
16// and the available assets for the callbacks that are registered to the Dart VM
17// via the dart_api.h.
18//
19// The engine eagerly populates a native assets manager on startup. This native
20// assets manager is stored in the `IsolateGroupData` so it can be accessed on
21// the native assets callbacks registered in `InitDartFFIForIsolateGroup`.
23 public:
26
27 // Reads the `NativeAssetsManifest.json` bundled in the Flutter application.
28 void RegisterNativeAssets(const uint8_t* manifest, size_t manifest_size);
29 void RegisterNativeAssets(const std::shared_ptr<AssetManager>& asset_manager);
30
31 // Looks up the asset path for [asset_id].
32 //
33 // The asset path consists of a type, and an optional path. For example:
34 // `["system", "libsqlite3.so"]`.
35 std::vector<std::string> LookupNativeAsset(std::string_view asset_id);
36
37 // Lists the available asset ids.
38 //
39 // Used when a user tries to look up an asset with an ID that does not exist
40 // to report the list of available asset ids.
41 std::string AvailableNativeAssets();
42
43 private:
44 std::unordered_map<std::string, std::vector<std::string>> parsed_mapping_;
45
48 NativeAssetsManager& operator=(const NativeAssetsManager&) = delete;
49 NativeAssetsManager& operator=(NativeAssetsManager&&) = delete;
50};
51
52} // namespace flutter
53
54#endif // FLUTTER_ASSETS_NATIVE_ASSETS_H_
void RegisterNativeAssets(const uint8_t *manifest, size_t manifest_size)
std::vector< std::string > LookupNativeAsset(std::string_view asset_id)