Flutter Engine
The Flutter Engine
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
5#include "flutter/lib/io/dart_io.h"
6
7#include "flutter/fml/logging.h"
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 Dart_Handle io_lib = Dart_LookupLibrary(ToDart("dart:io"));
24
25 Dart_Handle ui_lib = Dart_LookupLibrary(ToDart("dart:ui"));
26 Dart_Handle dart_validate_args[1];
27 dart_validate_args[0] = ToDart(may_insecurely_connect_to_all_domains);
28 Dart_Handle http_connection_hook_closure =
29 Dart_Invoke(ui_lib, ToDart("_getHttpConnectionHookClosure"),
30 /*number_of_arguments=*/1, dart_validate_args);
31 FML_CHECK(!CheckAndHandleError(http_connection_hook_closure));
32 Dart_Handle http_lib = Dart_LookupLibrary(ToDart("dart:_http"));
34 Dart_Handle set_http_connection_hook_result = Dart_SetField(
35 http_lib, ToDart("_httpConnectionHook"), http_connection_hook_closure);
36 FML_CHECK(!CheckAndHandleError(set_http_connection_hook_result));
37}
38
39} // namespace flutter
static void InitForIsolate(bool may_insecurely_connect_to_all_domains, const std::string &domain_network_policy)
Definition: dart_io.cc:18
DART_EXPORT Dart_Handle Dart_SetNativeResolver(Dart_Handle library, Dart_NativeEntryResolver resolver, Dart_NativeEntrySymbol symbol)
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_Invoke(Dart_Handle target, Dart_Handle name, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_SetField(Dart_Handle container, Dart_Handle name, Dart_Handle value)
GAsyncResult * result
#define FML_CHECK(condition)
Definition: logging.h:85
Dart_NativeFunction LookupIONative(Dart_Handle name, int argument_count, bool *auto_setup_scope)
const uint8_t * LookupIONativeSymbol(Dart_NativeFunction nf)
Dart_Handle ToDart(const T &object)
bool CheckAndHandleError(Dart_Handle handle)
Definition: dart_error.cc:33