Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
flutter::ScriptCompletionTaskObserver Class Reference

Public Member Functions

 ScriptCompletionTaskObserver (Shell &shell, fml::RefPtr< fml::TaskRunner > main_task_runner, fml::RefPtr< fml::TaskRunner > ui_task_runner, bool run_forever)
 
int GetExitCodeForLastError () const
 
void DidProcessTask ()
 

Detailed Description

Definition at line 215 of file tester_main.cc.

Constructor & Destructor Documentation

◆ ScriptCompletionTaskObserver()

flutter::ScriptCompletionTaskObserver::ScriptCompletionTaskObserver ( Shell shell,
fml::RefPtr< fml::TaskRunner main_task_runner,
fml::RefPtr< fml::TaskRunner ui_task_runner,
bool  run_forever 
)
inline

Definition at line 217 of file tester_main.cc.

221 : shell_(shell),
222 main_task_runner_(std::move(main_task_runner)),
223 ui_task_runner_(std::move(ui_task_runner)),
224 run_forever_(run_forever) {}

Member Function Documentation

◆ DidProcessTask()

void flutter::ScriptCompletionTaskObserver::DidProcessTask ( )
inline

Definition at line 230 of file tester_main.cc.

230 {
231 last_error_ = shell_.GetUIIsolateLastError();
232 if (shell_.EngineHasLivePorts()) {
233 // The UI isolate still has live ports and is running. Nothing to do
234 // just yet.
235 return;
236 }
237 if (shell_.EngineHasPendingMicrotasks()) {
238 // Post an empty task to force a run of the engine task observer that
239 // drains the microtask queue.
240 ui_task_runner_->PostTask([] {});
241 return;
242 }
243
244 if (run_forever_) {
245 // We need this script to run forever. We have already recorded the last
246 // error. Keep going.
247 return;
248 }
249
250 if (!has_terminated_) {
251 // Only try to terminate the loop once.
252 has_terminated_ = true;
253 fml::TaskRunner::RunNowOrPostTask(main_task_runner_, []() {
255 });
256 }
257 }
std::optional< DartErrorCode > GetUIIsolateLastError() const
Used by embedders to get the last error from the Dart UI Isolate, if one exists.
Definition shell.cc:797
bool EngineHasLivePorts() const
Used by embedders to check if the Engine is running and has any live ports remaining....
Definition shell.cc:817
bool EngineHasPendingMicrotasks() const
Used by embedders to check if the Engine is running and has any microtasks that have been queued but ...
Definition shell.cc:828
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
static void RunNowOrPostTask(const fml::RefPtr< fml::TaskRunner > &runner, const fml::closure &task)
virtual void PostTask(const fml::closure &task) override

References flutter::Shell::EngineHasLivePorts(), flutter::Shell::EngineHasPendingMicrotasks(), fml::MessageLoop::GetCurrent(), flutter::Shell::GetUIIsolateLastError(), fml::TaskRunner::PostTask(), fml::TaskRunner::RunNowOrPostTask(), and fml::MessageLoop::Terminate().

Referenced by flutter::RunTester().

◆ GetExitCodeForLastError()

int flutter::ScriptCompletionTaskObserver::GetExitCodeForLastError ( ) const
inline

Definition at line 226 of file tester_main.cc.

226 {
227 return static_cast<int>(last_error_.value_or(DartErrorCode::NoError));
228 }
@ NoError
No error has occurred.

References flutter::NoError.

Referenced by flutter::RunTester().


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