Flutter Engine
 
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 // TODO(https://dartbug.com/61694): move this code into dart_io_api.h
21 Dart_Handle io_lib = Dart_LookupLibrary(ToDart("dart:io"));
22 Dart_Handle result = Dart_SetNativeResolver(io_lib, dart::bin::LookupIONative,
23 dart::bin::LookupIONativeSymbol);
24 FML_CHECK(!CheckAndHandleError(result));
25 result = Dart_SetFfiNativeResolver(io_lib, dart::bin::LookupIOFfiNative);
26 FML_CHECK(!CheckAndHandleError(result));
27
28 Dart_Handle ui_lib = Dart_LookupLibrary(ToDart("dart:ui"));
29 Dart_Handle dart_validate_args[1];
30 dart_validate_args[0] = ToDart(may_insecurely_connect_to_all_domains);
31 Dart_Handle http_connection_hook_closure =
32 Dart_Invoke(ui_lib, ToDart("_getHttpConnectionHookClosure"),
33 /*number_of_arguments=*/1, dart_validate_args);
34 FML_CHECK(!CheckAndHandleError(http_connection_hook_closure));
35 Dart_Handle http_lib = Dart_LookupLibrary(ToDart("dart:_http"));
36 FML_CHECK(!CheckAndHandleError(http_lib));
37 Dart_Handle set_http_connection_hook_result = Dart_SetField(
38 http_lib, ToDart("_httpConnectionHook"), http_connection_hook_closure);
39 FML_CHECK(!CheckAndHandleError(set_http_connection_hook_result));
40}
41
42} // namespace flutter
static void InitForIsolate(bool may_insecurely_connect_to_all_domains, const std::string &domain_network_policy)
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