| Flutter Windows Embedder |

Public Member Functions | List of all members
flutter::FlutterProjectBundle Class Reference

`#include <flutter_project_bundle.h>`

## Public Member Functions
| FlutterProjectBundle (const FlutterDesktopEngineProperties &properties)
| ~FlutterProjectBundle ()
bool | HasValidPaths ()
const std::filesystem::path & | assets_path ()
const std::filesystem::path & | icu_path ()
const std::vector< std::string > | GetSwitches ()
void | SetSwitches (const std::vector< std::string > &switches)
UniqueAotDataPtr | LoadAotData (const FlutterEngineProcTable &engine_procs)
const std::string & | dart_entrypoint () const
const std::vector< std::string > & | dart_entrypoint_arguments () const
FlutterGpuPreference | gpu_preference () const
FlutterUIThreadPolicy | ui_thread_policy ()

## Detailed Description

Definition at line 32 of file flutter_project_bundle.h.

## Constructor & Destructor Documentation

## ◆ FlutterProjectBundle()

flutter::FlutterProjectBundle::FlutterProjectBundle | ( | const FlutterDesktopEngineProperties & | properties | ) |
| explicit

Definition at line 16 of file flutter_project_bundle.cc.

18 : assets_path_(properties.assets_path),
19 icu_path_(properties.icu_data_path) {
20 if (properties.aot_library_path != nullptr) {
21 aot_library_path_ = std::filesystem::path(properties.aot_library_path);
22 }
23
24 if (properties.dart_entrypoint && properties.dart_entrypoint[0] != '\0') {
25 dart_entrypoint_ = properties.dart_entrypoint;
26 }
27
28 for (int i = 0; i < properties.dart_entrypoint_argc; i++) {
29 dart_entrypoint_arguments_.push_back(
30 std::string(properties.dart_entrypoint_argv[i]));
31 }
32
33 gpu_preference_ =
34 static_cast<FlutterGpuPreference>(properties.gpu_preference);
35
36 ui_thread_policy_ =
37 static_cast<FlutterUIThreadPolicy>(properties.ui_thread_policy);
38
39 // Resolve any relative paths.
40 if (assets_path_.is_relative() || icu_path_.is_relative() ||
41 (!aot_library_path_.empty() && aot_library_path_.is_relative())) {
42 std::filesystem::path executable_location = GetExecutableDirectory();
43 if (executable_location.empty()) {
44 FML_LOG(ERROR)
45 << "Unable to find executable location to resolve resource paths.";
46 assets_path_ = std::filesystem::path();
47 icu_path_ = std::filesystem::path();
48 } else {
49 assets_path_ = std::filesystem::path(executable_location) / assets_path_;
50 icu_path_ = std::filesystem::path(executable_location) / icu_path_;
51 if (!aot_library_path_.empty()) {
52 aot_library_path_ =
53 std::filesystem::path(executable_location) / aot_library_path_;
54 }
55 }
56 }
57 }
flutter::FlutterUIThreadPolicy
FlutterUIThreadPolicy
Definition: flutter_project_bundle.h:25
flutter::GetExecutableDirectory
std::filesystem::path GetExecutableDirectory()
Definition: path_utils.cc:16
flutter::FlutterGpuPreference
FlutterGpuPreference
Definition: flutter_project_bundle.h:20
FlutterDesktopEngineProperties::dart_entrypoint
const char * dart_entrypoint
Definition: flutter_windows.h:83
FlutterDesktopEngineProperties::icu_data_path
const wchar_t * icu_data_path
Definition: flutter_windows.h:69
FlutterDesktopEngineProperties::dart_entrypoint_argc
int dart_entrypoint_argc
Definition: flutter_windows.h:86
FlutterDesktopEngineProperties::assets_path
const wchar_t * assets_path
Definition: flutter_windows.h:64
FlutterDesktopEngineProperties::dart_entrypoint_argv
const char ** dart_entrypoint_argv
Definition: flutter_windows.h:90
FlutterDesktopEngineProperties::ui_thread_policy
FlutterDesktopUIThreadPolicy ui_thread_policy
Definition: flutter_windows.h:96
FlutterDesktopEngineProperties::aot_library_path
const wchar_t * aot_library_path
Definition: flutter_windows.h:75
FlutterDesktopEngineProperties::gpu_preference
FlutterDesktopGpuPreference gpu_preference
Definition: flutter_windows.h:93

References FlutterDesktopEngineProperties::aot_library_path, FlutterDesktopEngineProperties::dart_entrypoint, FlutterDesktopEngineProperties::dart_entrypoint_argc, FlutterDesktopEngineProperties::dart_entrypoint_argv, flutter::GetExecutableDirectory(), FlutterDesktopEngineProperties::gpu_preference, and FlutterDesktopEngineProperties::ui_thread_policy.

## ◆ ~FlutterProjectBundle()

flutter::FlutterProjectBundle::~FlutterProjectBundle | ( |  | ) |

Definition at line 90 of file flutter_project_bundle.cc.

90 {}

## Member Function Documentation

## ◆ assets_path()

const std::filesystem::path& flutter::FlutterProjectBundle::assets_path | ( |  | ) |
| inline

Definition at line 47 of file flutter_project_bundle.h.

47 { return assets_path_; }

Referenced by flutter::testing::TEST().

## ◆ dart_entrypoint()

const std::string& flutter::FlutterProjectBundle::dart_entrypoint | ( |  | ) | const
| inline

Definition at line 65 of file flutter_project_bundle.h.

65 { return dart_entrypoint_; }

## ◆ dart_entrypoint_arguments()

const std::vector<std::string>& flutter::FlutterProjectBundle::dart_entrypoint_arguments | ( |  | ) | const
| inline

Definition at line 69 of file flutter_project_bundle.h.

69 {
70 return dart_entrypoint_arguments_;
71 }

Referenced by flutter::testing::TEST().

## ◆ GetSwitches()

const std::vector< std::string > flutter::FlutterProjectBundle::GetSwitches | ( |  | ) |

Definition at line 97 of file flutter_project_bundle.cc.

97 {
98 if (engine_switches_.size() == 0) {
99 return GetSwitchesFromEnvironment();
100 }
101 std::vector<std::string> switches;
102 switches.insert(switches.end(), engine_switches_.begin(),
103 engine_switches_.end());
104
105 auto env_switches = GetSwitchesFromEnvironment();
106 switches.insert(switches.end(), env_switches.begin(), env_switches.end());
107
108 return switches;
109 }
flutter::GetSwitchesFromEnvironment
std::vector< std::string > GetSwitchesFromEnvironment()
Definition: engine_switches.cc:14

References flutter::GetSwitchesFromEnvironment().

Referenced by flutter::testing::TEST().

## ◆ gpu_preference()

FlutterGpuPreference flutter::FlutterProjectBundle::gpu_preference | ( |  | ) | const
| inline

Definition at line 74 of file flutter_project_bundle.h.

74 { return gpu_preference_; }

## ◆ HasValidPaths()

bool flutter::FlutterProjectBundle::HasValidPaths | ( |  | ) |

Definition at line 59 of file flutter_project_bundle.cc.

59 {
60 return !assets_path_.empty() && !icu_path_.empty();
61 }

Referenced by flutter::testing::TEST().

## ◆ icu_path()

const std::filesystem::path& flutter::FlutterProjectBundle::icu_path | ( |  | ) |
| inline

Definition at line 50 of file flutter_project_bundle.h.

50 { return icu_path_; }

Referenced by flutter::testing::TEST().

## ◆ LoadAotData()

UniqueAotDataPtr flutter::FlutterProjectBundle::LoadAotData | ( | const FlutterEngineProcTable & | engine_procs | ) |

Definition at line 65 of file flutter_project_bundle.cc.

66 {
67 if (aot_library_path_.empty()) {
68 FML_LOG(ERROR)
69 << "Attempted to load AOT data, but no aot_library_path was provided.";
70 return UniqueAotDataPtr(nullptr, nullptr);
71 }
72 if (!std::filesystem::exists(aot_library_path_)) {
73 FML_LOG(ERROR) << "Can't load AOT data from " << aot_library_path_
74 << "; no such file.";
75 return UniqueAotDataPtr(nullptr, nullptr);
76 }
77 std::string path_string = fml::PathToUtf8(aot_library_path_);
78 FlutterEngineAOTDataSource source = {};
79 source.type = kFlutterEngineAOTDataSourceTypeElfPath;
80 source.elf_path = path_string.c_str();
81 FlutterEngineAOTData data = nullptr;
82 auto result = engine_procs.CreateAOTData(&source, &data);
83 if (result != kSuccess) {
84 FML_LOG(ERROR) << "Failed to load AOT data from: " << path_string;
85 return UniqueAotDataPtr(nullptr, nullptr);
86 }
87 return UniqueAotDataPtr(data, engine_procs.CollectAOTData);
88 }
flutter::UniqueAotDataPtr
std::unique_ptr< _FlutterEngineAOTData, FlutterEngineCollectAOTDataFnPtr > UniqueAotDataPtr
Definition: flutter_project_bundle.h:18

## ◆ SetSwitches()

void flutter::FlutterProjectBundle::SetSwitches | ( | const std::vector< std::string > & | switches | ) |

Definition at line 92 of file flutter_project_bundle.cc.

93 {
94 engine_switches_ = switches;
95 }

## ◆ ui_thread_policy()

FlutterUIThreadPolicy flutter::FlutterProjectBundle::ui_thread_policy | ( |  | ) |
| inline

Definition at line 77 of file flutter_project_bundle.h.

77 { return ui_thread_policy_; }

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

- shell/platform/windows/flutter_project_bundle.h
- shell/platform/windows/flutter_project_bundle.cc