| 1 | // Copyright (c) 2015, the Dart project authors.  Please see the AUTHORS file | 
|---|
| 2 | // for details. All rights reserved. Use of this source code is governed by a | 
|---|
| 3 | // BSD-style license that can be found in the LICENSE file. | 
|---|
| 4 |  | 
|---|
| 5 | #include "include/bin/dart_io_api.h" | 
|---|
| 6 |  | 
|---|
| 7 | #include "bin/crypto.h" | 
|---|
| 8 | #include "bin/directory.h" | 
|---|
| 9 | #include "bin/eventhandler.h" | 
|---|
| 10 | #include "bin/io_natives.h" | 
|---|
| 11 | #include "bin/platform.h" | 
|---|
| 12 | #include "bin/process.h" | 
|---|
| 13 | #include "bin/secure_socket_filter.h" | 
|---|
| 14 | #include "bin/thread.h" | 
|---|
| 15 | #include "bin/utils.h" | 
|---|
| 16 |  | 
|---|
| 17 | namespace dart { | 
|---|
| 18 | namespace bin { | 
|---|
| 19 |  | 
|---|
| 20 | void BootstrapDartIo() { | 
|---|
| 21 | // Bootstrap 'dart:io' event handler. | 
|---|
| 22 | TimerUtils::InitOnce(); | 
|---|
| 23 | Process::Init(); | 
|---|
| 24 | #if !defined(DART_IO_SECURE_SOCKET_DISABLED) | 
|---|
| 25 | SSLFilter::Init(); | 
|---|
| 26 | #endif | 
|---|
| 27 | EventHandler::Start(); | 
|---|
| 28 | } | 
|---|
| 29 |  | 
|---|
| 30 | void CleanupDartIo() { | 
|---|
| 31 | EventHandler::Stop(); | 
|---|
| 32 | #if !defined(DART_IO_SECURE_SOCKET_DISABLED) | 
|---|
| 33 | SSLFilter::Cleanup(); | 
|---|
| 34 | #endif | 
|---|
| 35 | Process::Cleanup(); | 
|---|
| 36 | } | 
|---|
| 37 |  | 
|---|
| 38 | void SetSystemTempDirectory(const char* system_temp) { | 
|---|
| 39 | Directory::SetSystemTemp(system_temp); | 
|---|
| 40 | } | 
|---|
| 41 |  | 
|---|
| 42 | void SetExecutableName(const char* executable_name) { | 
|---|
| 43 | Platform::SetExecutableName(executable_name); | 
|---|
| 44 | } | 
|---|
| 45 |  | 
|---|
| 46 | void SetExecutableArguments(int script_index, char** argv) { | 
|---|
| 47 | Platform::SetExecutableArguments(script_index, argv); | 
|---|
| 48 | } | 
|---|
| 49 |  | 
|---|
| 50 | void GetIOEmbedderInformation(Dart_EmbedderInformation* info) { | 
|---|
| 51 | ASSERT(info != NULL); | 
|---|
| 52 | ASSERT(info->version == DART_EMBEDDER_INFORMATION_CURRENT_VERSION); | 
|---|
| 53 |  | 
|---|
| 54 | Process::GetRSSInformation(&(info->max_rss), &(info->current_rss)); | 
|---|
| 55 | } | 
|---|
| 56 |  | 
|---|
| 57 | bool GetEntropy(uint8_t* buffer, intptr_t length) { | 
|---|
| 58 | return Crypto::GetRandomBytes(length, buffer); | 
|---|
| 59 | } | 
|---|
| 60 |  | 
|---|
| 61 | Dart_NativeFunction LookupIONative(Dart_Handle name, | 
|---|
| 62 | int argument_count, | 
|---|
| 63 | bool* auto_setup_scope) { | 
|---|
| 64 | return IONativeLookup(name, argument_count, auto_setup_scope); | 
|---|
| 65 | } | 
|---|
| 66 |  | 
|---|
| 67 | const uint8_t* LookupIONativeSymbol(Dart_NativeFunction nf) { | 
|---|
| 68 | return IONativeSymbol(nf); | 
|---|
| 69 | } | 
|---|
| 70 |  | 
|---|
| 71 | }  // namespace bin | 
|---|
| 72 | }  // namespace dart | 
|---|
| 73 |  | 
|---|