Flutter Engine
flutter::DartIO Class Reference

#include <dart_io.h>

Static Public Member Functions

static void InitForIsolate (bool may_insecurely_connect_to_all_domains, std::string domain_network_policy)
 

Detailed Description

Definition at line 15 of file dart_io.h.

Member Function Documentation

◆ InitForIsolate()

void flutter::DartIO::InitForIsolate ( bool  may_insecurely_connect_to_all_domains,
std::string  domain_network_policy 
)
static

Definition at line 18 of file dart_io.cc.

References FML_CHECK, tonic::LogIfError(), result, and tonic::ToDart().

Referenced by flutter::DartIsolate::LoadLoadingUnitError().

19  {
20  Dart_Handle io_lib = Dart_LookupLibrary(ToDart("dart:io"));
21  Dart_Handle result = Dart_SetNativeResolver(io_lib, dart::bin::LookupIONative,
22  dart::bin::LookupIONativeSymbol);
23  FML_CHECK(!LogIfError(result));
24 
25  Dart_Handle embedder_config_type =
26  Dart_GetNonNullableType(io_lib, ToDart("_EmbedderConfig"), 0, nullptr);
27  FML_CHECK(!LogIfError(embedder_config_type));
28 
29  Dart_Handle allow_insecure_connections_result = Dart_SetField(
30  embedder_config_type, ToDart("_mayInsecurelyConnectToAllDomains"),
31  ToDart(may_insecurely_connect_to_all_domains));
32  FML_CHECK(!LogIfError(allow_insecure_connections_result));
33 
34  Dart_Handle dart_args[1];
35  dart_args[0] = ToDart(domain_network_policy);
36  Dart_Handle set_domain_network_policy_result = Dart_Invoke(
37  embedder_config_type, ToDart("_setDomainPolicies"), 1, dart_args);
38  FML_CHECK(!LogIfError(set_domain_network_policy_result));
39 
40  Dart_Handle ui_lib = Dart_LookupLibrary(ToDart("dart:ui"));
41  Dart_Handle dart_validate_args[1];
42  dart_validate_args[0] = ToDart(may_insecurely_connect_to_all_domains);
43  Dart_Handle http_connection_hook_closure =
44  Dart_Invoke(ui_lib, ToDart("_getHttpConnectionHookClosure"),
45  /*number_of_arguments=*/1, dart_validate_args);
46  FML_CHECK(!LogIfError(http_connection_hook_closure));
47  Dart_Handle http_lib = Dart_LookupLibrary(ToDart("dart:_http"));
48  FML_CHECK(!LogIfError(http_lib));
49  Dart_Handle set_http_connection_hook_result = Dart_SetField(
50  http_lib, ToDart("_httpConnectionHook"), http_connection_hook_closure);
51  FML_CHECK(!LogIfError(set_http_connection_hook_result));
52 }
GAsyncResult * result
#define FML_CHECK(condition)
Definition: logging.h:68
Dart_Handle ToDart(const T &object)
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15

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