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 
14 using tonic::ToDart;
15 
16 namespace flutter {
17 
18 void DartIO::InitForIsolate(bool may_insecurely_connect_to_all_domains,
19  std::string domain_network_policy) {
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);
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"));
33  FML_CHECK(!CheckAndHandleError(http_lib));
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
GAsyncResult * result
bool CheckAndHandleError(Dart_Handle handle)
Definition: dart_error.cc:33
#define FML_CHECK(condition)
Definition: logging.h:68
static void InitForIsolate(bool may_insecurely_connect_to_all_domains, std::string domain_network_policy)
Definition: dart_io.cc:18
Dart_Handle ToDart(const T &object)