Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
flutter::UIDartState Class Reference

#include <ui_dart_state.h>

Inheritance diagram for flutter::UIDartState:
tonic::DartState flutter::DartIsolate

Classes

struct  Context
 The subset of state which is owned by the shell or engine and passed through the RuntimeController into DartIsolates. If a shell-owned resource needs to be exposed to the framework via UIDartState, a pointer to the resource can be added to this struct with appropriate default construction. More...
 

Public Member Functions

Dart_Port main_port () const
 
bool IsRootIsolate () const
 
void SetDebugName (const std::string &name)
 
const std::string & debug_name () const
 
const std::string & logger_prefix () const
 
PlatformConfigurationplatform_configuration () const
 
void SetPlatformMessageHandler (std::weak_ptr< PlatformMessageHandler > handler)
 
Dart_Handle HandlePlatformMessage (std::unique_ptr< PlatformMessage > message)
 
const TaskRunnersGetTaskRunners () const
 
void ScheduleMicrotask (Dart_Handle handle)
 
void FlushMicrotasksNow ()
 
fml::WeakPtr< IOManagerGetIOManager () const
 
fml::RefPtr< flutter::SkiaUnrefQueueGetSkiaUnrefQueue () const
 
std::shared_ptr< VolatilePathTrackerGetVolatilePathTracker () const
 
std::shared_ptr< fml::ConcurrentTaskRunnerGetConcurrentTaskRunner () const
 
fml::TaskRunnerAffineWeakPtr< SnapshotDelegateGetSnapshotDelegate () const
 
fml::WeakPtr< ImageDecoderGetImageDecoder () const
 
fml::WeakPtr< ImageGeneratorRegistryGetImageGeneratorRegistry () const
 
std::shared_ptr< IsolateNameServerGetIsolateNameServer () const
 
tonic::DartErrorHandleType GetLastError ()
 
void LogMessage (const std::string &tag, const std::string &message) const
 
UnhandledExceptionCallback unhandled_exception_callback () const
 
int64_t GetRootIsolateToken () const
 
bool IsImpellerEnabled () const
 Whether Impeller is enabled for this application.
 
impeller::RuntimeStageBackend GetRuntimeStageBackend () const
 The expected type for runtime stage shaders.
 
virtual Dart_Isolate CreatePlatformIsolate (Dart_Handle entry_point, char **error)
 
- Public Member Functions inherited from tonic::DartState
 DartState (int dirfd=-1, std::function< void(Dart_Handle)> message_epilogue=nullptr)
 
virtual ~DartState ()
 
std::weak_ptr< DartStateGetWeakPtr ()
 
Dart_Isolate isolate ()
 
void SetIsolate (Dart_Isolate isolate)
 
Dart_PersistentHandle private_constructor_name ()
 
DartClassLibraryclass_library ()
 
DartMessageHandlermessage_handler ()
 
FileLoaderfile_loader ()
 
void MessageEpilogue (Dart_Handle message_result)
 
void SetReturnCode (uint32_t return_code)
 
void SetReturnCodeCallback (std::function< void(uint32_t)> callback)
 
bool has_set_return_code () const
 
void SetIsShuttingDown ()
 
bool IsShuttingDown ()
 

Static Public Member Functions

static UIDartStateCurrent ()
 
static void ThrowIfUIOperationsProhibited ()
 
- Static Public Member Functions inherited from tonic::DartState
static DartStateFrom (Dart_Isolate isolate)
 
static DartStateCurrent ()
 
static Dart_Handle HandleLibraryTag (Dart_LibraryTag tag, Dart_Handle library, Dart_Handle url)
 

Protected Member Functions

 UIDartState (TaskObserverAdd add_callback, TaskObserverRemove remove_callback, std::string logger_prefix, UnhandledExceptionCallback unhandled_exception_callback, LogMessageCallback log_message_callback, std::shared_ptr< IsolateNameServer > isolate_name_server, bool is_root_isolate_, const UIDartState::Context &context)
 
 ~UIDartState () override
 
void SetPlatformConfiguration (std::unique_ptr< PlatformConfiguration > platform_configuration)
 
const std::string & GetAdvisoryScriptURI () const
 
- Protected Member Functions inherited from tonic::DartState
Dart_Isolate isolate () const
 
 TONIC_DISALLOW_COPY_AND_ASSIGN (DartState)
 

Private Member Functions

void DidSetIsolate () override
 

Detailed Description

Definition at line 36 of file ui_dart_state.h.

Constructor & Destructor Documentation

◆ UIDartState()

flutter::UIDartState::UIDartState ( TaskObserverAdd  add_callback,
TaskObserverRemove  remove_callback,
std::string  logger_prefix,
UnhandledExceptionCallback  unhandled_exception_callback,
LogMessageCallback  log_message_callback,
std::shared_ptr< IsolateNameServer isolate_name_server,
bool  is_root_isolate_,
const UIDartState::Context context 
)
protected

Definition at line 58 of file ui_dart_state.cc.

67 : add_callback_(std::move(add_callback)),
68 remove_callback_(std::move(remove_callback)),
69 logger_prefix_(std::move(logger_prefix)),
70 is_root_isolate_(is_root_isolate),
71 unhandled_exception_callback_(std::move(unhandled_exception_callback)),
72 log_message_callback_(std::move(log_message_callback)),
73 isolate_name_server_(std::move(isolate_name_server)),
74 context_(context) {
75 AddOrRemoveTaskObserver(true /* add */);
76}
UnhandledExceptionCallback unhandled_exception_callback() const
const std::string & logger_prefix() const

◆ ~UIDartState()

flutter::UIDartState::~UIDartState ( )
overrideprotected

Definition at line 78 of file ui_dart_state.cc.

78 {
79 AddOrRemoveTaskObserver(false /* remove */);
80}

Member Function Documentation

◆ CreatePlatformIsolate()

Dart_Isolate flutter::UIDartState::CreatePlatformIsolate ( Dart_Handle  entry_point,
char **  error 
)
virtual

Reimplemented in flutter::DartIsolate.

Definition at line 265 of file ui_dart_state.cc.

266 {
268 return nullptr;
269}
#define FML_UNREACHABLE()
Definition logging.h:109

◆ Current()

UIDartState * flutter::UIDartState::Current ( )
static

Definition at line 119 of file ui_dart_state.cc.

119 {
120 return static_cast<UIDartState*>(DartState::Current());
121}
UIDartState(TaskObserverAdd add_callback, TaskObserverRemove remove_callback, std::string logger_prefix, UnhandledExceptionCallback unhandled_exception_callback, LogMessageCallback log_message_callback, std::shared_ptr< IsolateNameServer > isolate_name_server, bool is_root_isolate_, const UIDartState::Context &context)

◆ debug_name()

const std::string & flutter::UIDartState::debug_name ( ) const
inline

Definition at line 116 of file ui_dart_state.h.

116{ return debug_name_; }

◆ DidSetIsolate()

void flutter::UIDartState::DidSetIsolate ( )
overrideprivatevirtual

Reimplemented from tonic::DartState.

Definition at line 94 of file ui_dart_state.cc.

94 {
95 main_port_ = Dart_GetMainPortId();
96 std::ostringstream debug_name;
97 // main.dart$main-1234
98 debug_name << context_.advisory_script_uri << "$"
99 << context_.advisory_script_entrypoint << "-" << main_port_;
101}
void SetDebugName(const std::string &name)
const std::string & debug_name() const
DART_EXPORT Dart_Port Dart_GetMainPortId(void)

◆ FlushMicrotasksNow()

void flutter::UIDartState::FlushMicrotasksNow ( )

Definition at line 169 of file ui_dart_state.cc.

169 {
170 microtask_queue_.RunMicrotasks();
171}

◆ GetAdvisoryScriptURI()

const std::string & flutter::UIDartState::GetAdvisoryScriptURI ( ) const
protected

Definition at line 82 of file ui_dart_state.cc.

82 {
83 return context_.advisory_script_uri;
84}

◆ GetConcurrentTaskRunner()

std::shared_ptr< fml::ConcurrentTaskRunner > flutter::UIDartState::GetConcurrentTaskRunner ( ) const

Definition at line 157 of file ui_dart_state.cc.

157 {
158 return context_.concurrent_task_runner;
159}
std::shared_ptr< fml::ConcurrentTaskRunner > concurrent_task_runner

◆ GetImageDecoder()

fml::WeakPtr< ImageDecoder > flutter::UIDartState::GetImageDecoder ( ) const

Definition at line 194 of file ui_dart_state.cc.

194 {
195 return context_.image_decoder;
196}
fml::WeakPtr< ImageDecoder > image_decoder
The image decoder.

◆ GetImageGeneratorRegistry()

fml::WeakPtr< ImageGeneratorRegistry > flutter::UIDartState::GetImageGeneratorRegistry ( ) const

Definition at line 198 of file ui_dart_state.cc.

199 {
200 return context_.image_generator_registry;
201}
fml::WeakPtr< ImageGeneratorRegistry > image_generator_registry

◆ GetIOManager()

fml::WeakPtr< IOManager > flutter::UIDartState::GetIOManager ( ) const

Definition at line 143 of file ui_dart_state.cc.

143 {
144 return context_.io_manager;
145}
fml::WeakPtr< IOManager > io_manager
The IO manager used by the isolate for asynchronous texture uploads.

◆ GetIsolateNameServer()

std::shared_ptr< IsolateNameServer > flutter::UIDartState::GetIsolateNameServer ( ) const

Definition at line 203 of file ui_dart_state.cc.

203 {
204 return isolate_name_server_;
205}

◆ GetLastError()

tonic::DartErrorHandleType flutter::UIDartState::GetLastError ( )

Definition at line 207 of file ui_dart_state.cc.

207 {
209 if (error == tonic::kNoError) {
210 error = microtask_queue_.GetLastError();
211 }
212 return error;
213}
DartErrorHandleType isolate_last_error() const
DartErrorHandleType GetLastError()
DartMessageHandler & message_handler()
Definition dart_state.h:61
const uint8_t uint32_t uint32_t GError ** error
DartErrorHandleType
Definition dart_error.h:67
@ kNoError
Definition dart_error.h:68

◆ GetRootIsolateToken()

int64_t flutter::UIDartState::GetRootIsolateToken ( ) const

Returns a enumeration that uniquely represents this root isolate. Returns 0 if called from a non-root isolate.

Definition at line 261 of file ui_dart_state.cc.

261 {
262 return IsRootIsolate() ? reinterpret_cast<int64_t>(this) : 0;
263}
bool IsRootIsolate() const

◆ GetRuntimeStageBackend()

impeller::RuntimeStageBackend flutter::UIDartState::GetRuntimeStageBackend ( ) const

The expected type for runtime stage shaders.

Definition at line 90 of file ui_dart_state.cc.

90 {
91 return context_.runtime_stage_backend;
92}
impeller::RuntimeStageBackend runtime_stage_backend
The expected backend for runtime stage shaders.

◆ GetSkiaUnrefQueue()

fml::RefPtr< flutter::SkiaUnrefQueue > flutter::UIDartState::GetSkiaUnrefQueue ( ) const

Definition at line 147 of file ui_dart_state.cc.

147 {
148 return context_.unref_queue;
149}
fml::RefPtr< SkiaUnrefQueue > unref_queue

◆ GetSnapshotDelegate()

fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > flutter::UIDartState::GetSnapshotDelegate ( ) const

Definition at line 190 of file ui_dart_state.cc.

190 {
191 return context_.snapshot_delegate;
192}
fml::TaskRunnerAffineWeakPtr< SnapshotDelegate > snapshot_delegate

◆ GetTaskRunners()

const TaskRunners & flutter::UIDartState::GetTaskRunners ( ) const

Definition at line 139 of file ui_dart_state.cc.

139 {
140 return context_.task_runners;
141}
const TaskRunners task_runners

◆ GetVolatilePathTracker()

std::shared_ptr< VolatilePathTracker > flutter::UIDartState::GetVolatilePathTracker ( ) const

Definition at line 151 of file ui_dart_state.cc.

152 {
153 return context_.volatile_path_tracker;
154}
std::shared_ptr< VolatilePathTracker > volatile_path_tracker
Cache for tracking path volatility.

◆ HandlePlatformMessage()

Dart_Handle flutter::UIDartState::HandlePlatformMessage ( std::unique_ptr< PlatformMessage message)

Definition at line 242 of file ui_dart_state.cc.

243 {
244 if (platform_configuration_) {
245 platform_configuration_->client()->HandlePlatformMessage(
246 std::move(message));
247 } else {
248 std::shared_ptr<PlatformMessageHandler> handler =
249 platform_message_handler_.lock();
250 if (handler) {
251 handler->HandlePlatformMessage(std::move(message));
252 } else {
253 return tonic::ToDart(
254 "No platform channel handler registered for background isolate.");
255 }
256 }
257
258 return Dart_Null();
259}
DART_EXPORT Dart_Handle Dart_Null(void)
Win32Message message
Dart_Handle ToDart(const T &object)

◆ IsImpellerEnabled()

bool flutter::UIDartState::IsImpellerEnabled ( ) const

Whether Impeller is enabled for this application.

Definition at line 86 of file ui_dart_state.cc.

86 {
87 return context_.enable_impeller;
88}
bool enable_impeller
Whether Impeller is enabled or not.

◆ IsRootIsolate()

bool flutter::UIDartState::IsRootIsolate ( ) const
inline

Definition at line 111 of file ui_dart_state.h.

111{ return is_root_isolate_; }

◆ logger_prefix()

const std::string & flutter::UIDartState::logger_prefix ( ) const
inline

Definition at line 118 of file ui_dart_state.h.

118{ return logger_prefix_; }

◆ LogMessage()

void flutter::UIDartState::LogMessage ( const std::string &  tag,
const std::string &  message 
) const

Definition at line 215 of file ui_dart_state.cc.

216 {
217 if (log_message_callback_) {
218 log_message_callback_(tag, message);
219 } else {
220 // Fall back to previous behavior if unspecified.
221#if defined(FML_OS_ANDROID)
222 __android_log_print(ANDROID_LOG_INFO, tag.c_str(), "%.*s",
223 static_cast<int>(message.size()), message.c_str());
224#elif defined(FML_OS_IOS)
225 std::stringstream stream;
226 if (!tag.empty()) {
227 stream << tag << ": ";
228 }
229 stream << message;
230 std::string log = stream.str();
231 syslog(1 /* LOG_ALERT */, "%.*s", static_cast<int>(log.size()),
232 log.c_str());
233#else
234 if (!tag.empty()) {
235 std::cout << tag << ": ";
236 }
237 std::cout << message << std::endl;
238#endif
239 }
240}

◆ main_port()

Dart_Port flutter::UIDartState::main_port ( ) const
inline

Definition at line 109 of file ui_dart_state.h.

109{ return main_port_; }

◆ platform_configuration()

PlatformConfiguration * flutter::UIDartState::platform_configuration ( ) const
inline

Definition at line 120 of file ui_dart_state.h.

120 {
121 return platform_configuration_.get();
122 }

◆ ScheduleMicrotask()

void flutter::UIDartState::ScheduleMicrotask ( Dart_Handle  handle)

Definition at line 161 of file ui_dart_state.cc.

161 {
162 if (tonic::CheckAndHandleError(closure) || !Dart_IsClosure(closure)) {
163 return;
164 }
165
166 microtask_queue_.ScheduleMicrotask(closure);
167}
void ScheduleMicrotask(Dart_Handle callback)
DART_EXPORT bool Dart_IsClosure(Dart_Handle object)
bool CheckAndHandleError(Dart_Handle handle)
Definition dart_error.cc:33

◆ SetDebugName()

void flutter::UIDartState::SetDebugName ( const std::string &  name)

Definition at line 111 of file ui_dart_state.cc.

111 {
112 debug_name_ = debug_name;
113 if (platform_configuration_) {
114 platform_configuration_->client()->UpdateIsolateDescription(debug_name_,
115 main_port_);
116 }
117}

◆ SetPlatformConfiguration()

void flutter::UIDartState::SetPlatformConfiguration ( std::unique_ptr< PlatformConfiguration platform_configuration)
protected

Definition at line 123 of file ui_dart_state.cc.

124 {
126 platform_configuration_ = std::move(platform_configuration);
127 if (platform_configuration_) {
128 platform_configuration_->client()->UpdateIsolateDescription(debug_name_,
129 main_port_);
130 }
131}
PlatformConfiguration * platform_configuration() const
#define FML_DCHECK(condition)
Definition logging.h:103

◆ SetPlatformMessageHandler()

void flutter::UIDartState::SetPlatformMessageHandler ( std::weak_ptr< PlatformMessageHandler handler)

Definition at line 133 of file ui_dart_state.cc.

134 {
136 platform_message_handler_ = std::move(handler);
137}

◆ ThrowIfUIOperationsProhibited()

void flutter::UIDartState::ThrowIfUIOperationsProhibited ( )
static

Definition at line 103 of file ui_dart_state.cc.

103 {
107 tonic::ToDart("UI actions are only available on root isolate."));
108 }
109}
static UIDartState * Current()
DART_EXPORT void Dart_EnterScope(void)
DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception)

◆ unhandled_exception_callback()

UnhandledExceptionCallback flutter::UIDartState::unhandled_exception_callback ( ) const
inline

Definition at line 160 of file ui_dart_state.h.

160 {
161 return unhandled_exception_callback_;
162 }

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