Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
dart_io.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
8#include "third_party/dart/runtime/include/bin/dart_io_api.h"
9#include "third_party/dart/runtime/include/dart_api.h"
12
14using tonic::ToDart;
15
16namespace flutter {
17
18void DartIO::InitForIsolate(bool may_insecurely_connect_to_all_domains,
19 const std::string& domain_network_policy,
20 const std::string& script_uri) {
21 Dart_Handle ui_lib = Dart_LookupLibrary(ToDart("dart:ui"));
22 Dart_Handle dart_validate_args[1];
23 dart_validate_args[0] = ToDart(may_insecurely_connect_to_all_domains);
24 Dart_Handle http_connection_hook_closure =
25 Dart_Invoke(ui_lib, ToDart("_getHttpConnectionHookClosure"),
26 /*number_of_arguments=*/1, dart_validate_args);
27 FML_CHECK(!CheckAndHandleError(http_connection_hook_closure));
28
29 Dart_Handle /* _LocaleClosure? */ locale_closure =
30 Dart_Invoke(ui_lib, ToDart("_getLocaleClosure"), 0, nullptr);
31 FML_CHECK(!CheckAndHandleError(locale_closure));
32
33 Dart_Handle setup_result = dart::bin::SetupDartIoLibrary({
34 .http_connection_hook = http_connection_hook_closure,
35 .locale_name_callback = locale_closure,
36 .script_uri = !script_uri.empty() ? script_uri.c_str() : nullptr,
37 });
38 FML_CHECK(!CheckAndHandleError(setup_result));
39}
40
41} // namespace flutter
static void InitForIsolate(bool may_insecurely_connect_to_all_domains, const std::string &domain_network_policy, const std::string &script_uri)
Definition dart_io.cc:18
#define FML_CHECK(condition)
Definition logging.h:104
Dart_Handle ToDart(const T &object)
bool CheckAndHandleError(Dart_Handle handle)
Definition dart_error.cc:33