Flutter Engine
The Flutter Engine
Static Public Member Functions | Friends | List of all members
dart::bin::VmService Class Reference

#include <vmservice_impl.h>

Static Public Member Functions

static bool Setup (const char *server_ip, intptr_t server_port, bool dev_mode_server, bool auth_codes_disabled, const char *write_service_info_filename, bool trace_loading, bool deterministic, bool enable_service_port_fallback, bool wait_for_dds_to_advertise_service, bool serve_devtools, bool serve_observatory, bool print_dtd)
 
static void SetNativeResolver ()
 
static const char * GetErrorMessage ()
 
static const char * GetServerAddress ()
 

Friends

void NotifyServerState (Dart_NativeArguments args)
 

Detailed Description

Definition at line 15 of file vmservice_impl.h.

Member Function Documentation

◆ GetErrorMessage()

const char * dart::bin::VmService::GetErrorMessage ( )
static

Definition at line 266 of file vmservice_impl.cc.

266 {
267 return (error_msg_ == nullptr) ? "No error." : error_msg_;
268}

◆ GetServerAddress()

static const char * dart::bin::VmService::GetServerAddress ( )
inlinestatic

Definition at line 64 of file vmservice_impl.h.

64{ return &server_uri_[0]; }

◆ SetNativeResolver()

void dart::bin::VmService::SetNativeResolver ( )
static

Definition at line 108 of file vmservice_impl.cc.

108 {
110 Dart_Handle library = Dart_LookupLibrary(url);
111 if (!Dart_IsError(library)) {
114 }
115}
static Dart_Handle NewString(const char *str)
Definition: dartutils.h:214
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
static Dart_NativeFunction VmServiceIONativeResolver(Dart_Handle name, int num_arguments, bool *auto_setup_scope)
const uint8_t * VmServiceIONativeSymbol(Dart_NativeFunction nf)
static constexpr const char * kVMServiceIOLibraryUri
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_SetNativeResolver(Dart_Handle library, Dart_NativeEntryResolver resolver, Dart_NativeEntrySymbol symbol)
DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url)

◆ Setup()

bool dart::bin::VmService::Setup ( const char *  server_ip,
intptr_t  server_port,
bool  dev_mode_server,
bool  auth_codes_disabled,
const char *  write_service_info_filename,
bool  trace_loading,
bool  deterministic,
bool  enable_service_port_fallback,
bool  wait_for_dds_to_advertise_service,
bool  serve_devtools,
bool  serve_observatory,
bool  print_dtd 
)
static

Definition at line 117 of file vmservice_impl.cc.

128 {
130 ASSERT(isolate != nullptr);
131 SetServerAddress("");
132
134
135 // Prepare builtin and its dependent libraries for use to resolve URIs.
136 // Set up various closures, e.g: printing, timers etc.
137 // Set up 'package root' for URI resolution.
138 result = DartUtils::PrepareForScriptLoading(/*is_service_isolate=*/true,
139 trace_loading);
141
143 Dart_Handle library = Dart_LookupLibrary(url);
144 SHUTDOWN_ON_ERROR(library);
145 result = Dart_SetRootLibrary(library);
146 SHUTDOWN_ON_ERROR(library);
150
151 // Make runnable.
154 error_msg_ = Dart_IsolateMakeRunnable(isolate);
155 if (error_msg_ != nullptr) {
156 Dart_EnterIsolate(isolate);
158 return false;
159 }
160 Dart_EnterIsolate(isolate);
162
163 library = Dart_RootLibrary();
164 SHUTDOWN_ON_ERROR(library);
165
166 // Set HTTP server state.
167 // If we have a port specified, start the server immediately.
168 bool auto_start = server_port >= 0;
169 if (server_port < 0) {
170 // Adjust server_port to port 0 which will result in the first available
171 // port when the HTTP server is started.
172 server_port = 0;
173 }
174 if (wait_for_dds_to_advertise_service) {
175 result = DartUtils::SetStringField(library, "_ddsIP", server_ip);
177 result = DartUtils::SetIntegerField(library, "_ddsPort", server_port);
179 result =
182 result = DartUtils::SetIntegerField(library, "_port", 0);
184 } else {
185 result = DartUtils::SetStringField(library, "_ip", server_ip);
187 result = DartUtils::SetIntegerField(library, "_port", server_port);
189 }
190 result = Dart_SetField(library, DartUtils::NewString("_autoStart"),
191 Dart_NewBoolean(auto_start));
193 result = Dart_SetField(library, DartUtils::NewString("_originCheckDisabled"),
194 Dart_NewBoolean(dev_mode_server));
196
197 result = Dart_SetField(library, DartUtils::NewString("_authCodesDisabled"),
198 Dart_NewBoolean(auth_codes_disabled));
200
201 result =
202 Dart_SetField(library, DartUtils::NewString("_enableServicePortFallback"),
203 Dart_NewBoolean(enable_service_port_fallback));
205
206 if (write_service_info_filename != nullptr) {
207 result = DartUtils::SetStringField(library, "_serviceInfoFilename",
208 write_service_info_filename);
210 }
211
212 result = Dart_SetField(library,
213 DartUtils::NewString("_waitForDdsToAdvertiseService"),
214 Dart_NewBoolean(wait_for_dds_to_advertise_service));
216
217 result = Dart_SetField(library, DartUtils::NewString("_serveDevtools"),
218 serve_devtools ? Dart_True() : Dart_False());
220
221 result = Dart_SetField(library, DartUtils::NewString("_serveObservatory"),
222 serve_observatory ? Dart_True() : Dart_False());
224
225 result = Dart_SetField(library, DartUtils::NewString("_printDtd"),
226 print_dtd ? Dart_True() : Dart_False());
228
229// Are we running on Windows?
230#if defined(DART_HOST_OS_WINDOWS)
232#else
234#endif
235 result =
236 Dart_SetField(library, DartUtils::NewString("_isWindows"), is_windows);
238
239// Are we running on Fuchsia?
240#if defined(DART_HOST_OS_FUCHSIA)
241 Dart_Handle is_fuchsia = Dart_True();
242#else
243 Dart_Handle is_fuchsia = Dart_False();
244#endif
245 result =
246 Dart_SetField(library, DartUtils::NewString("_isFuchsia"), is_fuchsia);
248
249 // Get _getWatchSignalInternal from dart:io.
251 SHUTDOWN_ON_ERROR(dart_io_str);
252 Dart_Handle io_lib = Dart_LookupLibrary(dart_io_str);
253 SHUTDOWN_ON_ERROR(io_lib);
255 Dart_NewStringFromCString("_getWatchSignalInternal");
257 Dart_Handle signal_watch = Dart_Invoke(io_lib, function_name, 0, nullptr);
258 SHUTDOWN_ON_ERROR(signal_watch);
259 Dart_Handle field_name = Dart_NewStringFromCString("_signalWatch");
260 SHUTDOWN_ON_ERROR(field_name);
261 result = Dart_SetField(library, field_name, signal_watch);
262 SHUTDOWN_ON_ERROR(field_name);
263 return true;
264}
static constexpr const char * kIOLibURL
Definition: dartutils.h:297
static Dart_Handle PrepareForScriptLoading(bool is_service_isolate, bool trace_loading)
Definition: dartutils.cc:570
static Dart_Handle SetIntegerField(Dart_Handle handle, const char *name, int64_t val)
Definition: dartutils.cc:203
static Dart_Handle SetStringField(Dart_Handle handle, const char *name, const char *val)
Definition: dartutils.cc:209
struct _Dart_Isolate * Dart_Isolate
Definition: dart_api.h:88
#define ASSERT(E)
GAsyncResult * result
static constexpr const char * DEFAULT_VM_SERVICE_SERVER_IP
Definition: main_options.h:97
Dart_ShutdownIsolate()
DART_EXPORT void Dart_EnterScope()
DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate)
DART_EXPORT Dart_Handle Dart_False()
DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target, Dart_Handle name, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT Dart_Handle Dart_True()
DART_EXPORT Dart_Handle Dart_RootLibrary()
DART_EXPORT Dart_Isolate Dart_CurrentIsolate()
DART_EXPORT Dart_Handle Dart_NewBoolean(bool value)
DART_EXPORT void Dart_ExitIsolate()
DART_EXPORT char * Dart_IsolateMakeRunnable(Dart_Isolate isolate)
DART_EXPORT Dart_Handle Dart_SetField(Dart_Handle container, Dart_Handle name, Dart_Handle value)
const char *const function_name
DART_EXPORT Dart_Handle Dart_SetRootLibrary(Dart_Handle library)
DART_EXPORT Dart_Handle Dart_NewStringFromCString(const char *str)
def is_windows()
Definition: git_revision.py:15
#define SHUTDOWN_ON_ERROR(handle)

Friends And Related Function Documentation

◆ NotifyServerState

void NotifyServerState ( Dart_NativeArguments  args)
friend

Definition at line 39 of file vmservice_impl.cc.

39 {
41 const char* uri_chars;
43 if (Dart_IsError(uri_arg)) {
44 VmService::SetServerAddress("");
46 return;
47 }
48 Dart_Handle result = Dart_StringToCString(uri_arg, &uri_chars);
49 if (Dart_IsError(result)) {
50 VmService::SetServerAddress("");
52 return;
53 }
54 VmService::SetServerAddress(uri_chars);
56}
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, int index)
DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle object, const char **cstr)

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