Flutter Engine
 
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 274 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 276 of file tester_main.cc.

280 : shell_(shell),
281 main_task_runner_(std::move(main_task_runner)),
282 ui_task_runner_(std::move(ui_task_runner)),
283 run_forever_(run_forever) {}

Member Function Documentation

◆ DidProcessTask()

void flutter::ScriptCompletionTaskObserver::DidProcessTask ( )
inline

Definition at line 289 of file tester_main.cc.

289 {
290 last_error_ = shell_.GetUIIsolateLastError();
291 if (shell_.EngineHasLivePorts()) {
292 // The UI isolate still has live ports and is running. Nothing to do
293 // just yet.
294 return;
295 }
296 if (shell_.EngineHasPendingMicrotasks()) {
297 // Post an empty task to force a run of the engine task observer that
298 // drains the microtask queue.
299 ui_task_runner_->PostTask([] {});
300 return;
301 }
302
303 if (run_forever_) {
304 // We need this script to run forever. We have already recorded the last
305 // error. Keep going.
306 return;
307 }
308
309 if (!has_terminated_) {
310 // Only try to terminate the loop once.
311 has_terminated_ = true;
312 fml::TaskRunner::RunNowOrPostTask(main_task_runner_, []() {
314 });
315 }
316 }
std::optional< DartErrorCode > GetUIIsolateLastError() const
Used by embedders to get the last error from the Dart UI Isolate, if one exists.
Definition shell.cc:792
bool EngineHasLivePorts() const
Used by embedders to check if the Engine is running and has any live ports remaining....
Definition shell.cc:812
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:823
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 285 of file tester_main.cc.

285 {
286 return static_cast<int>(last_error_.value_or(DartErrorCode::NoError));
287 }
@ NoError
No error has occurred.

References flutter::NoError.

Referenced by flutter::RunTester().


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