From d96f23547796eafdf2fd461aaea4022cdd57be8f Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Fri, 11 Jun 2021 21:31:48 +0530 Subject: [PATCH 01/42] adding dependencies, generated_bindings and android support --- .gitignore | 51 +- .metadata | 10 + .pubignore | 59 + CHANGELOG.md | 3 + analysis_options.yaml | 9 + android/.gitignore | 8 + android/build.gradle | 40 + android/gradle.properties | 3 + .../gradle/wrapper/gradle-wrapper.properties | 5 + android/settings.gradle | 1 + android/src/main/AndroidManifest.xml | 3 + .../kotlin/com/example/cronet/CronetPlugin.kt | 36 + cronet.iml | 19 + example/.gitignore | 46 + example/.metadata | 10 + example/README.md | 16 + example/android/.gitignore | 11 + example/android/app/build.gradle | 59 + .../android/app/src/debug/AndroidManifest.xml | 7 + .../android/app/src/main/AndroidManifest.xml | 41 + .../example/cronet_example/MainActivity.kt | 6 + .../res/drawable-v21/launch_background.xml | 12 + .../main/res/drawable/launch_background.xml | 12 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 544 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 442 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 721 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 1031 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 1443 bytes .../app/src/main/res/values-night/styles.xml | 18 + .../app/src/main/res/values/styles.xml | 18 + .../app/src/profile/AndroidManifest.xml | 7 + example/android/build.gradle | 31 + example/android/gradle.properties | 3 + .../gradle/wrapper/gradle-wrapper.properties | 6 + example/android/settings.gradle | 11 + example/lib/main.dart | 58 + example/pubspec.yaml | 71 + lib/src/generated_bindings.dart | 1377 ++++++ .../include/cronet/bidirectional_stream_c.h | 245 + lib/src/native/include/cronet/cronet.idl_c.h | 1284 ++++++ lib/src/native/include/cronet/cronet_c.h | 38 + lib/src/native/include/cronet/cronet_export.h | 14 + lib/src/native/include/dart/dart_api.h | 3953 +++++++++++++++++ lib/src/native/include/dart/dart_api_dl.c | 59 + lib/src/native/include/dart/dart_api_dl.h | 127 + lib/src/native/include/dart/dart_native_api.h | 191 + lib/src/native/include/dart/dart_tools_api.h | 499 +++ lib/src/native/include/dart/dart_version.h | 16 + .../include/dart/runtime/dart_api_dl_impl.h | 21 + lib/src/native/wrapper/CMakeLists.txt | 46 + lib/src/native/wrapper/build.sh | 8 + lib/src/native/wrapper/sample_executor.cc | 119 + lib/src/native/wrapper/sample_executor.h | 45 + lib/src/native/wrapper/wrapper.cc | 426 ++ lib/src/native/wrapper/wrapper.h | 395 ++ lib/src/native/wrapper/wrapper_export.h | 10 + pubspec.yaml | 72 + 57 files changed, 9620 insertions(+), 15 deletions(-) create mode 100644 .metadata create mode 100644 .pubignore create mode 100644 CHANGELOG.md create mode 100644 android/.gitignore create mode 100644 android/build.gradle create mode 100644 android/gradle.properties create mode 100644 android/gradle/wrapper/gradle-wrapper.properties create mode 100644 android/settings.gradle create mode 100644 android/src/main/AndroidManifest.xml create mode 100644 android/src/main/kotlin/com/example/cronet/CronetPlugin.kt create mode 100644 cronet.iml create mode 100644 example/.gitignore create mode 100644 example/.metadata create mode 100644 example/README.md create mode 100644 example/android/.gitignore create mode 100644 example/android/app/build.gradle create mode 100644 example/android/app/src/debug/AndroidManifest.xml create mode 100644 example/android/app/src/main/AndroidManifest.xml create mode 100644 example/android/app/src/main/kotlin/com/example/cronet_example/MainActivity.kt create mode 100644 example/android/app/src/main/res/drawable-v21/launch_background.xml create mode 100644 example/android/app/src/main/res/drawable/launch_background.xml create mode 100644 example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 example/android/app/src/main/res/values-night/styles.xml create mode 100644 example/android/app/src/main/res/values/styles.xml create mode 100644 example/android/app/src/profile/AndroidManifest.xml create mode 100644 example/android/build.gradle create mode 100644 example/android/gradle.properties create mode 100644 example/android/gradle/wrapper/gradle-wrapper.properties create mode 100644 example/android/settings.gradle create mode 100644 example/lib/main.dart create mode 100644 example/pubspec.yaml create mode 100644 lib/src/generated_bindings.dart create mode 100644 lib/src/native/include/cronet/bidirectional_stream_c.h create mode 100644 lib/src/native/include/cronet/cronet.idl_c.h create mode 100644 lib/src/native/include/cronet/cronet_c.h create mode 100644 lib/src/native/include/cronet/cronet_export.h create mode 100644 lib/src/native/include/dart/dart_api.h create mode 100644 lib/src/native/include/dart/dart_api_dl.c create mode 100644 lib/src/native/include/dart/dart_api_dl.h create mode 100644 lib/src/native/include/dart/dart_native_api.h create mode 100644 lib/src/native/include/dart/dart_tools_api.h create mode 100644 lib/src/native/include/dart/dart_version.h create mode 100644 lib/src/native/include/dart/runtime/dart_api_dl_impl.h create mode 100644 lib/src/native/wrapper/CMakeLists.txt create mode 100644 lib/src/native/wrapper/build.sh create mode 100644 lib/src/native/wrapper/sample_executor.cc create mode 100644 lib/src/native/wrapper/sample_executor.h create mode 100644 lib/src/native/wrapper/wrapper.cc create mode 100644 lib/src/native/wrapper/wrapper.h create mode 100644 lib/src/native/wrapper/wrapper_export.h diff --git a/.gitignore b/.gitignore index 93533a5..524ce93 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,22 @@ -# See https://www.dartlang.org/guides/libraries/private-files +# See https://dart.dev/guides/libraries/private-files # Files and directories created by pub. .dart_tool/ -.packages build/ +# wrapper build directory +lib/src/native/wrapper/out +.packages pubspec.lock +# IDE and debugger files. +.clangd +.gdb_history +.history +.vscode +compile_commands.json + # Directory created by dartdoc. +# If you don't generate documentation locally you can remove this line. doc/api/ # Avoid committing generated Javascript files: @@ -18,18 +28,29 @@ doc/api/ *.js.deps *.js.map -# IDE and debugger files. -.clangd -.gdb_history -.history -.vscode -compile_commands.json +# Cronet pre-built binaries +cronet_binaries/ + +# Generated shared libraries. +*.so +*.so.* +*.dylib +*.dll + +# AOT compiled files. +*.exe + +*.jar +*.cxx + +*.flutter-plugins +*.flutter-plugins-dependencies + +*.idea -# IntelliJ -*.iml -*.ipr -*.iws -.idea/ +# Directory for quick experiments. +experiments/ -# Mac -.DS_Store +# Files generated by tests for debugging purposes. +test/debug_generated/* +!test/debug_generated/readme.md diff --git a/.metadata b/.metadata new file mode 100644 index 0000000..0d35783 --- /dev/null +++ b/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 1d9032c7e1d867f071f2277eb1673e8f9b0274e3 + channel: stable + +project_type: plugin diff --git a/.pubignore b/.pubignore new file mode 100644 index 0000000..24e181a --- /dev/null +++ b/.pubignore @@ -0,0 +1,59 @@ +# See https://dart.dev/guides/libraries/private-files + +# Files and directories created by pub. +.dart_tool/ +.packages +pubspec.lock + +# IDE and debugger files. +.clangd +.gdb_history +.history +.vscode +compile_commands.json + +# Directory created by dartdoc. +# If you don't generate documentation locally you can remove this line. +doc/api/ + +# Avoid committing generated Javascript files: +*.dart.js +*.info.json # Produced by the --dump-info flag. +*.js # When generated by dart2js. Don't specify *.js if your + # project includes source files written in JavaScript. +*.js_ +*.js.deps +*.js.map + +# Cronet pre-built binaries +cronet_binaries/ + +# Generated shared libraries. +*.so +*.so.* +*.dylib +*.dll + +# AOT compiled files. +*.exe + +*.jar +*.cxx + +# Jar dependencies should be published to pub +!android/libs/* + +# Cronet binaries for android should be published to pub +!android/src/main/jniLibs/** + +*.flutter-plugins +*.flutter-plugins-dependencies + +*.idea + +# Directory for quick experiments. +experiments/ + +# Files generated by tests for debugging purposes. +test/debug_generated/* +!test/debug_generated/readme.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..41cc7d8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +* TODO: Describe initial release. diff --git a/analysis_options.yaml b/analysis_options.yaml index 27972b8..7944a89 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -3,3 +3,12 @@ # BSD-style license that can be found in the LICENSE file. include: package:lints/recommended.yaml + +analyzer: + strong-mode: + implicit-casts: false + implicit-dynamic: false + exclude: + - example/** + - lib/third_party/** # may not be fully migrated + - lib/src/generated_bindings.dart # ignore generated files diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 0000000..c6cbe56 --- /dev/null +++ b/android/.gitignore @@ -0,0 +1,8 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 0000000..03c1436 --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,40 @@ +group 'com.example.cronet' +version '1.0-SNAPSHOT' + +buildscript { + ext.kotlin_version = '1.3.50' + repositories { + google() + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:4.1.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +rootProject.allprojects { + repositories { + google() + jcenter() + } +} + +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' + +android { + compileSdkVersion 30 + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + defaultConfig { + minSdkVersion 16 + } +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 0000000..94adc3a --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..3c9d085 --- /dev/null +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/android/settings.gradle b/android/settings.gradle new file mode 100644 index 0000000..43fd67c --- /dev/null +++ b/android/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'cronet' diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml new file mode 100644 index 0000000..1f43b5d --- /dev/null +++ b/android/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + diff --git a/android/src/main/kotlin/com/example/cronet/CronetPlugin.kt b/android/src/main/kotlin/com/example/cronet/CronetPlugin.kt new file mode 100644 index 0000000..fa41764 --- /dev/null +++ b/android/src/main/kotlin/com/example/cronet/CronetPlugin.kt @@ -0,0 +1,36 @@ +package com.example.cronet + +import androidx.annotation.NonNull + +import io.flutter.embedding.engine.plugins.FlutterPlugin +import io.flutter.plugin.common.MethodCall +import io.flutter.plugin.common.MethodChannel +import io.flutter.plugin.common.MethodChannel.MethodCallHandler +import io.flutter.plugin.common.MethodChannel.Result +import io.flutter.plugin.common.PluginRegistry.Registrar + +/** CronetPlugin */ +class CronetPlugin: FlutterPlugin, MethodCallHandler { + /// The MethodChannel that will the communication between Flutter and native Android + /// + /// This local reference serves to register the plugin with the Flutter Engine and unregister it + /// when the Flutter Engine is detached from the Activity + private lateinit var channel : MethodChannel + + override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { + channel = MethodChannel(flutterPluginBinding.binaryMessenger, "cronet") + channel.setMethodCallHandler(this) + } + + override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { + if (call.method == "getPlatformVersion") { + result.success("Android ${android.os.Build.VERSION.RELEASE}") + } else { + result.notImplemented() + } + } + + override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { + channel.setMethodCallHandler(null) + } +} diff --git a/cronet.iml b/cronet.iml new file mode 100644 index 0000000..429df7d --- /dev/null +++ b/cronet.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..0fa6b67 --- /dev/null +++ b/example/.gitignore @@ -0,0 +1,46 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Web related +lib/generated_plugin_registrant.dart + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/example/.metadata b/example/.metadata new file mode 100644 index 0000000..c1ee81b --- /dev/null +++ b/example/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 1d9032c7e1d867f071f2277eb1673e8f9b0274e3 + channel: stable + +project_type: app diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..aabdd9a --- /dev/null +++ b/example/README.md @@ -0,0 +1,16 @@ +# cronet_example + +Demonstrates how to use the cronet plugin. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) + +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/example/android/.gitignore b/example/android/.gitignore new file mode 100644 index 0000000..0a741cb --- /dev/null +++ b/example/android/.gitignore @@ -0,0 +1,11 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle new file mode 100644 index 0000000..1c9a77f --- /dev/null +++ b/example/android/app/build.gradle @@ -0,0 +1,59 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion 30 + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.example.cronet_example" + minSdkVersion 16 + targetSdkVersion 30 + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..7fb7fb9 --- /dev/null +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..40925f7 --- /dev/null +++ b/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + diff --git a/example/android/app/src/main/kotlin/com/example/cronet_example/MainActivity.kt b/example/android/app/src/main/kotlin/com/example/cronet_example/MainActivity.kt new file mode 100644 index 0000000..113f321 --- /dev/null +++ b/example/android/app/src/main/kotlin/com/example/cronet_example/MainActivity.kt @@ -0,0 +1,6 @@ +package com.example.cronet_example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/example/android/app/src/main/res/drawable-v21/launch_background.xml b/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/example/android/app/src/main/res/drawable/launch_background.xml b/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAj~WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8bpbvhu0Wd6uZuB!w&u2PAxD2eNXD>P5D~Wn-+_Wa#27Xc zC?Zj|6r#X(-D3u$NCt}(Ms06KgJ4FxJVv{GM)!I~&n8Bnc94O7-Hd)cjDZswgC;Qs zO=b+9!WcT8F?0rF7!Uys2bs@gozCP?z~o%U|N3vA*22NaGQG zlg@K`O_XuxvZ&Ks^m&R!`&1=spLvfx7oGDKDwpwW`#iqdw@AL`7MR}m`rwr|mZgU`8P7SBkL78fFf!WnuYWm$5Z0 zNXhDbCv&49sM544K|?c)WrFfiZvCi9h0O)B3Pgg&ebxsLQ05GG~ AQ2+n{ literal 0 HcmV?d00001 diff --git a/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xx&nMcT!A!W`0S9QKQy;}1Cl^CgaH=;G9cpY;r$Q>i*pfB zP2drbID<_#qf;rPZx^FqH)F_D#*k@@q03KywUtLX8Ua?`H+NMzkczFPK3lFz@i_kW%1NOn0|D2I9n9wzH8m|-tHjsw|9>@K=iMBhxvkv6m8Y-l zytQ?X=U+MF$@3 zt`~i=@j|6y)RWMK--}M|=T`o&^Ni>IoWKHEbBXz7?A@mgWoL>!*SXo`SZH-*HSdS+ yn*9;$7;m`l>wYBC5bq;=U}IMqLzqbYCidGC!)_gkIk_C@Uy!y&wkt5C($~2D>~)O*cj@FGjOCM)M>_ixfudOh)?xMu#Fs z#}Y=@YDTwOM)x{K_j*Q;dPdJ?Mz0n|pLRx{4n|)f>SXlmV)XB04CrSJn#dS5nK2lM zrZ9#~WelCp7&e13Y$jvaEXHskn$2V!!DN-nWS__6T*l;H&Fopn?A6HZ-6WRLFP=R` zqG+CE#d4|IbyAI+rJJ`&x9*T`+a=p|0O(+s{UBcyZdkhj=yS1>AirP+0R;mf2uMgM zC}@~JfByORAh4SyRgi&!(cja>F(l*O+nd+@4m$|6K6KDn_&uvCpV23&>G9HJp{xgg zoq1^2_p9@|WEo z*X_Uko@K)qYYv~>43eQGMdbiGbo>E~Q& zrYBH{QP^@Sti!`2)uG{irBBq@y*$B zi#&(U-*=fp74j)RyIw49+0MRPMRU)+a2r*PJ$L5roHt2$UjExCTZSbq%V!HeS7J$N zdG@vOZB4v_lF7Plrx+hxo7(fCV&}fHq)$ literal 0 HcmV?d00001 diff --git a/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c GIT binary patch literal 1031 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q8Ax83A=Cw=BuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFa`(sgt!6~Yi|1%a`XoT0ojZ}lNrNjb9xjc(B0U1_% zz5^97Xt*%oq$rQy4?0GKNfJ44uvxI)gC`h-NZ|&0-7(qS@?b!5r36oQ}zyZrNO3 zMO=Or+<~>+A&uN&E!^Sl+>xE!QC-|oJv`ApDhqC^EWD|@=#J`=d#Xzxs4ah}w&Jnc z$|q_opQ^2TrnVZ0o~wh<3t%W&flvYGe#$xqda2bR_R zvPYgMcHgjZ5nSA^lJr%;<&0do;O^tDDh~=pIxA#coaCY>&N%M2^tq^U%3DB@ynvKo}b?yu-bFc-u0JHzced$sg7S3zqI(2 z#Km{dPr7I=pQ5>FuK#)QwK?Y`E`B?nP+}U)I#c1+FM*1kNvWG|a(TpksZQ3B@sD~b zpQ2)*V*TdwjFOtHvV|;OsiDqHi=6%)o4b!)x$)%9pGTsE z-JL={-Ffv+T87W(Xpooq<`r*VzWQcgBN$$`u}f>-ZQI1BB8ykN*=e4rIsJx9>z}*o zo~|9I;xof literal 0 HcmV?d00001 diff --git a/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 GIT binary patch literal 1443 zcmb`G{WsKk6vsdJTdFg%tJav9_E4vzrOaqkWF|A724Nly!y+?N9`YV6wZ}5(X(D_N(?!*n3`|_r0Hc?=PQw&*vnU?QTFY zB_MsH|!j$PP;I}?dppoE_gA(4uc!jV&0!l7_;&p2^pxNo>PEcNJv za5_RT$o2Mf!<+r?&EbHH6nMoTsDOa;mN(wv8RNsHpG)`^ymG-S5By8=l9iVXzN_eG%Xg2@Xeq76tTZ*dGh~Lo9vl;Zfs+W#BydUw zCkZ$o1LqWQO$FC9aKlLl*7x9^0q%0}$OMlp@Kk_jHXOjofdePND+j!A{q!8~Jn+s3 z?~~w@4?egS02}8NuulUA=L~QQfm;MzCGd)XhiftT;+zFO&JVyp2mBww?;QByS_1w! zrQlx%{^cMj0|Bo1FjwY@Q8?Hx0cIPF*@-ZRFpPc#bBw{5@tD(5%sClzIfl8WU~V#u zm5Q;_F!wa$BSpqhN>W@2De?TKWR*!ujY;Yylk_X5#~V!L*Gw~;$%4Q8~Mad z@`-kG?yb$a9cHIApZDVZ^U6Xkp<*4rU82O7%}0jjHlK{id@?-wpN*fCHXyXh(bLt* zPc}H-x0e4E&nQ>y%B-(EL=9}RyC%MyX=upHuFhAk&MLbsF0LP-q`XnH78@fT+pKPW zu72MW`|?8ht^tz$iC}ZwLp4tB;Q49K!QCF3@!iB1qOI=?w z7In!}F~ij(18UYUjnbmC!qKhPo%24?8U1x{7o(+?^Zu0Hx81|FuS?bJ0jgBhEMzf< zCgUq7r2OCB(`XkKcN-TL>u5y#dD6D!)5W?`O5)V^>jb)P)GBdy%t$uUMpf$SNV31$ zb||OojAbvMP?T@$h_ZiFLFVHDmbyMhJF|-_)HX3%m=CDI+ID$0^C>kzxprBW)hw(v zr!Gmda);ICoQyhV_oP5+C%?jcG8v+D@9f?Dk*!BxY}dazmrT@64UrP3hlslANK)bq z$67n83eh}OeW&SV@HG95P|bjfqJ7gw$e+`Hxo!4cx`jdK1bJ>YDSpGKLPZ^1cv$ek zIB?0S<#tX?SJCLWdMd{-ME?$hc7A$zBOdIJ)4!KcAwb=VMov)nK;9z>x~rfT1>dS+ zZ6#`2v@`jgbqq)P22H)Tx2CpmM^o1$B+xT6`(v%5xJ(?j#>Q$+rx_R|7TzDZe{J6q zG1*EcU%tE?!kO%^M;3aM6JN*LAKUVb^xz8-Pxo#jR5(-KBeLJvA@-gxNHx0M-ZJLl z;#JwQoh~9V?`UVo#}{6ka@II>++D@%KqGpMdlQ}?9E*wFcf5(#XQnP$Dk5~%iX^>f z%$y;?M0BLp{O3a(-4A?ewryHrrD%cx#Q^%KY1H zNre$ve+vceSLZcNY4U(RBX&)oZn*Py()h)XkE?PL$!bNb{N5FVI2Y%LKEm%yvpyTP z(1P?z~7YxD~Rf<(a@_y` literal 0 HcmV?d00001 diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..449a9f9 --- /dev/null +++ b/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..d74aa35 --- /dev/null +++ b/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..7fb7fb9 --- /dev/null +++ b/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/example/android/build.gradle b/example/android/build.gradle new file mode 100644 index 0000000..c505a86 --- /dev/null +++ b/example/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + ext.kotlin_version = '1.3.50' + repositories { + google() + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:4.1.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/example/android/gradle.properties b/example/android/gradle.properties new file mode 100644 index 0000000..94adc3a --- /dev/null +++ b/example/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..bc6a58a --- /dev/null +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle new file mode 100644 index 0000000..44e62bc --- /dev/null +++ b/example/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/example/lib/main.dart b/example/lib/main.dart new file mode 100644 index 0000000..9e86bdb --- /dev/null +++ b/example/lib/main.dart @@ -0,0 +1,58 @@ +import 'package:flutter/material.dart'; +import 'dart:async'; + +import 'package:flutter/services.dart'; +import 'package:cronet/cronet.dart'; + +void main() { + runApp(MyApp()); +} + +class MyApp extends StatefulWidget { + @override + _MyAppState createState() => _MyAppState(); +} + +class _MyAppState extends State { + String _platformVersion = 'Unknown'; + + @override + void initState() { + super.initState(); + initPlatformState(); + } + + // Platform messages are asynchronous, so we initialize in an async method. + Future initPlatformState() async { + String platformVersion; + // Platform messages may fail, so we use a try/catch PlatformException. + try { + platformVersion = await Cronet.platformVersion; + } on PlatformException { + platformVersion = 'Failed to get platform version.'; + } + + // If the widget was removed from the tree while the asynchronous platform + // message was in flight, we want to discard the reply rather than calling + // setState to update our non-existent appearance. + if (!mounted) return; + + setState(() { + _platformVersion = platformVersion; + }); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Plugin example app'), + ), + body: Center( + child: Text('Running on: $_platformVersion\n'), + ), + ), + ); + } +} diff --git a/example/pubspec.yaml b/example/pubspec.yaml new file mode 100644 index 0000000..4061a12 --- /dev/null +++ b/example/pubspec.yaml @@ -0,0 +1,71 @@ +name: cronet_example +description: Demonstrates how to use the cronet plugin. + +# The following line prevents the package from being accidentally published to +# pub.dev using `pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +environment: + sdk: ">=2.7.0 <3.0.0" + +dependencies: + flutter: + sdk: flutter + + cronet: + # When depending on this package from a real application you should use: + # cronet: ^x.y.z + # See https://dart.dev/tools/pub/dependencies#version-constraints + # The example app is bundled with the plugin so we use a path dependency on + # the parent directory to use the current plugin's version. + path: ../ + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware. + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/lib/src/generated_bindings.dart b/lib/src/generated_bindings.dart new file mode 100644 index 0000000..876da12 --- /dev/null +++ b/lib/src/generated_bindings.dart @@ -0,0 +1,1377 @@ +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +import 'dart:ffi' as ffi; + +/// Bindings to Cronet +class Cronet { + /// Holds the symbol lookup function. + final ffi.Pointer Function(String symbolName) + _lookup; + + /// The symbols are looked up in [dynamicLibrary]. + Cronet(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; + + /// The symbols are looked up with [lookup]. + Cronet.fromLookup( + ffi.Pointer Function(String symbolName) + lookup) + : _lookup = lookup; + + void dispatchCallback( + ffi.Pointer methodname, + ) { + return _dispatchCallback( + methodname, + ); + } + + late final _dispatchCallback_ptr = + _lookup>('dispatchCallback'); + late final _dart_dispatchCallback _dispatchCallback = + _dispatchCallback_ptr.asFunction<_dart_dispatchCallback>(); + + int InitDartApiDL( + ffi.Pointer data, + ) { + return _InitDartApiDL( + data, + ); + } + + late final _InitDartApiDL_ptr = + _lookup>('InitDartApiDL'); + late final _dart_InitDartApiDL _InitDartApiDL = + _InitDartApiDL_ptr.asFunction<_dart_InitDartApiDL>(); + + void unloadCronet() { + return _unloadCronet(); + } + + late final _unloadCronet_ptr = + _lookup>('unloadCronet'); + late final _dart_unloadCronet _unloadCronet = + _unloadCronet_ptr.asFunction<_dart_unloadCronet>(); + + ffi.Pointer Create_Executor() { + return _Create_Executor(); + } + + late final _Create_Executor_ptr = + _lookup>('Create_Executor'); + late final _dart_Create_Executor _Create_Executor = + _Create_Executor_ptr.asFunction<_dart_Create_Executor>(); + + void Destroy_Executor( + ffi.Pointer executor, + ) { + return _Destroy_Executor( + executor, + ); + } + + late final _Destroy_Executor_ptr = + _lookup>('Destroy_Executor'); + late final _dart_Destroy_Executor _Destroy_Executor = + _Destroy_Executor_ptr.asFunction<_dart_Destroy_Executor>(); + + void registerHttpClient( + Object h, + ffi.Pointer ce, + ) { + return _registerHttpClient( + h, + ce, + ); + } + + late final _registerHttpClient_ptr = + _lookup>('registerHttpClient'); + late final _dart_registerHttpClient _registerHttpClient = + _registerHttpClient_ptr.asFunction<_dart_registerHttpClient>(); + + void registerCallbackHandler( + int nativePort, + ffi.Pointer rp, + ) { + return _registerCallbackHandler( + nativePort, + rp, + ); + } + + late final _registerCallbackHandler_ptr = + _lookup>( + 'registerCallbackHandler'); + late final _dart_registerCallbackHandler _registerCallbackHandler = + _registerCallbackHandler_ptr.asFunction<_dart_registerCallbackHandler>(); + + void removeRequest( + ffi.Pointer rp, + ) { + return _removeRequest( + rp, + ); + } + + late final _removeRequest_ptr = + _lookup>('removeRequest'); + late final _dart_removeRequest _removeRequest = + _removeRequest_ptr.asFunction<_dart_removeRequest>(); + + /// //////////////////// + ffi.Pointer Cronet_QuicHint_Create() { + return _Cronet_QuicHint_Create(); + } + + late final _Cronet_QuicHint_Create_ptr = + _lookup>( + 'Cronet_QuicHint_Create'); + late final _dart_Cronet_QuicHint_Create _Cronet_QuicHint_Create = + _Cronet_QuicHint_Create_ptr.asFunction<_dart_Cronet_QuicHint_Create>(); + + void Cronet_QuicHint_Destroy( + ffi.Pointer self, + ) { + return _Cronet_QuicHint_Destroy( + self, + ); + } + + late final _Cronet_QuicHint_Destroy_ptr = + _lookup>( + 'Cronet_QuicHint_Destroy'); + late final _dart_Cronet_QuicHint_Destroy _Cronet_QuicHint_Destroy = + _Cronet_QuicHint_Destroy_ptr.asFunction<_dart_Cronet_QuicHint_Destroy>(); + + void Cronet_QuicHint_host_set( + ffi.Pointer self, + ffi.Pointer host, + ) { + return _Cronet_QuicHint_host_set( + self, + host, + ); + } + + late final _Cronet_QuicHint_host_set_ptr = + _lookup>( + 'Cronet_QuicHint_host_set'); + late final _dart_Cronet_QuicHint_host_set _Cronet_QuicHint_host_set = + _Cronet_QuicHint_host_set_ptr.asFunction< + _dart_Cronet_QuicHint_host_set>(); + + void Cronet_QuicHint_port_set( + ffi.Pointer self, + int port, + ) { + return _Cronet_QuicHint_port_set( + self, + port, + ); + } + + late final _Cronet_QuicHint_port_set_ptr = + _lookup>( + 'Cronet_QuicHint_port_set'); + late final _dart_Cronet_QuicHint_port_set _Cronet_QuicHint_port_set = + _Cronet_QuicHint_port_set_ptr.asFunction< + _dart_Cronet_QuicHint_port_set>(); + + void Cronet_QuicHint_alternate_port_set( + ffi.Pointer self, + int alternate_port, + ) { + return _Cronet_QuicHint_alternate_port_set( + self, + alternate_port, + ); + } + + late final _Cronet_QuicHint_alternate_port_set_ptr = + _lookup>( + 'Cronet_QuicHint_alternate_port_set'); + late final _dart_Cronet_QuicHint_alternate_port_set + _Cronet_QuicHint_alternate_port_set = + _Cronet_QuicHint_alternate_port_set_ptr.asFunction< + _dart_Cronet_QuicHint_alternate_port_set>(); + + ffi.Pointer Cronet_Engine_Create() { + return _Cronet_Engine_Create(); + } + + late final _Cronet_Engine_Create_ptr = + _lookup>( + 'Cronet_Engine_Create'); + late final _dart_Cronet_Engine_Create _Cronet_Engine_Create = + _Cronet_Engine_Create_ptr.asFunction<_dart_Cronet_Engine_Create>(); + + ffi.Pointer Cronet_Engine_GetVersionString( + ffi.Pointer self, + ) { + return _Cronet_Engine_GetVersionString( + self, + ); + } + + late final _Cronet_Engine_GetVersionString_ptr = + _lookup>( + 'Cronet_Engine_GetVersionString'); + late final _dart_Cronet_Engine_GetVersionString + _Cronet_Engine_GetVersionString = _Cronet_Engine_GetVersionString_ptr + .asFunction<_dart_Cronet_Engine_GetVersionString>(); + + ffi.Pointer Cronet_EngineParams_Create() { + return _Cronet_EngineParams_Create(); + } + + late final _Cronet_EngineParams_Create_ptr = + _lookup>( + 'Cronet_EngineParams_Create'); + late final _dart_Cronet_EngineParams_Create _Cronet_EngineParams_Create = + _Cronet_EngineParams_Create_ptr.asFunction< + _dart_Cronet_EngineParams_Create>(); + + void Cronet_EngineParams_Destroy( + ffi.Pointer self, + ) { + return _Cronet_EngineParams_Destroy( + self, + ); + } + + late final _Cronet_EngineParams_Destroy_ptr = + _lookup>( + 'Cronet_EngineParams_Destroy'); + late final _dart_Cronet_EngineParams_Destroy _Cronet_EngineParams_Destroy = + _Cronet_EngineParams_Destroy_ptr.asFunction< + _dart_Cronet_EngineParams_Destroy>(); + + void Cronet_EngineParams_user_agent_set( + ffi.Pointer self, + ffi.Pointer user_agent, + ) { + return _Cronet_EngineParams_user_agent_set( + self, + user_agent, + ); + } + + late final _Cronet_EngineParams_user_agent_set_ptr = + _lookup>( + 'Cronet_EngineParams_user_agent_set'); + late final _dart_Cronet_EngineParams_user_agent_set + _Cronet_EngineParams_user_agent_set = + _Cronet_EngineParams_user_agent_set_ptr.asFunction< + _dart_Cronet_EngineParams_user_agent_set>(); + + void Cronet_EngineParams_enable_quic_set( + ffi.Pointer self, + bool enable_quic, + ) { + return _Cronet_EngineParams_enable_quic_set( + self, + enable_quic ? 1 : 0, + ); + } + + late final _Cronet_EngineParams_enable_quic_set_ptr = + _lookup>( + 'Cronet_EngineParams_enable_quic_set'); + late final _dart_Cronet_EngineParams_enable_quic_set + _Cronet_EngineParams_enable_quic_set = + _Cronet_EngineParams_enable_quic_set_ptr.asFunction< + _dart_Cronet_EngineParams_enable_quic_set>(); + + void Cronet_EngineParams_quic_hints_add( + ffi.Pointer self, + ffi.Pointer element, + ) { + return _Cronet_EngineParams_quic_hints_add( + self, + element, + ); + } + + late final _Cronet_EngineParams_quic_hints_add_ptr = + _lookup>( + 'Cronet_EngineParams_quic_hints_add'); + late final _dart_Cronet_EngineParams_quic_hints_add + _Cronet_EngineParams_quic_hints_add = + _Cronet_EngineParams_quic_hints_add_ptr.asFunction< + _dart_Cronet_EngineParams_quic_hints_add>(); + + void Cronet_EngineParams_accept_language_set( + ffi.Pointer self, + ffi.Pointer accept_language, + ) { + return _Cronet_EngineParams_accept_language_set( + self, + accept_language, + ); + } + + late final _Cronet_EngineParams_accept_language_set_ptr = + _lookup>( + 'Cronet_EngineParams_accept_language_set'); + late final _dart_Cronet_EngineParams_accept_language_set + _Cronet_EngineParams_accept_language_set = + _Cronet_EngineParams_accept_language_set_ptr.asFunction< + _dart_Cronet_EngineParams_accept_language_set>(); + + void Cronet_EngineParams_storage_path_set( + ffi.Pointer self, + ffi.Pointer storage_path, + ) { + return _Cronet_EngineParams_storage_path_set( + self, + storage_path, + ); + } + + late final _Cronet_EngineParams_storage_path_set_ptr = + _lookup>( + 'Cronet_EngineParams_storage_path_set'); + late final _dart_Cronet_EngineParams_storage_path_set + _Cronet_EngineParams_storage_path_set = + _Cronet_EngineParams_storage_path_set_ptr.asFunction< + _dart_Cronet_EngineParams_storage_path_set>(); + + void Cronet_EngineParams_enable_http2_set( + ffi.Pointer self, + bool enable_http2, + ) { + return _Cronet_EngineParams_enable_http2_set( + self, + enable_http2 ? 1 : 0, + ); + } + + late final _Cronet_EngineParams_enable_http2_set_ptr = + _lookup>( + 'Cronet_EngineParams_enable_http2_set'); + late final _dart_Cronet_EngineParams_enable_http2_set + _Cronet_EngineParams_enable_http2_set = + _Cronet_EngineParams_enable_http2_set_ptr.asFunction< + _dart_Cronet_EngineParams_enable_http2_set>(); + + void Cronet_EngineParams_enable_brotli_set( + ffi.Pointer self, + bool enable_brotli, + ) { + return _Cronet_EngineParams_enable_brotli_set( + self, + enable_brotli ? 1 : 0, + ); + } + + late final _Cronet_EngineParams_enable_brotli_set_ptr = + _lookup>( + 'Cronet_EngineParams_enable_brotli_set'); + late final _dart_Cronet_EngineParams_enable_brotli_set + _Cronet_EngineParams_enable_brotli_set = + _Cronet_EngineParams_enable_brotli_set_ptr.asFunction< + _dart_Cronet_EngineParams_enable_brotli_set>(); + + void Cronet_EngineParams_http_cache_mode_set( + ffi.Pointer self, + int http_cache_mode, + ) { + return _Cronet_EngineParams_http_cache_mode_set( + self, + http_cache_mode, + ); + } + + late final _Cronet_EngineParams_http_cache_mode_set_ptr = + _lookup>( + 'Cronet_EngineParams_http_cache_mode_set'); + late final _dart_Cronet_EngineParams_http_cache_mode_set + _Cronet_EngineParams_http_cache_mode_set = + _Cronet_EngineParams_http_cache_mode_set_ptr.asFunction< + _dart_Cronet_EngineParams_http_cache_mode_set>(); + + void Cronet_EngineParams_http_cache_max_size_set( + ffi.Pointer self, + int http_cache_max_size, + ) { + return _Cronet_EngineParams_http_cache_max_size_set( + self, + http_cache_max_size, + ); + } + + late final _Cronet_EngineParams_http_cache_max_size_set_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_EngineParams_http_cache_max_size_set>>( + 'Cronet_EngineParams_http_cache_max_size_set'); + late final _dart_Cronet_EngineParams_http_cache_max_size_set + _Cronet_EngineParams_http_cache_max_size_set = + _Cronet_EngineParams_http_cache_max_size_set_ptr.asFunction< + _dart_Cronet_EngineParams_http_cache_max_size_set>(); + + int Cronet_Engine_StartWithParams( + ffi.Pointer self, + ffi.Pointer params, + ) { + return _Cronet_Engine_StartWithParams( + self, + params, + ); + } + + late final _Cronet_Engine_StartWithParams_ptr = + _lookup>( + 'Cronet_Engine_StartWithParams'); + late final _dart_Cronet_Engine_StartWithParams + _Cronet_Engine_StartWithParams = _Cronet_Engine_StartWithParams_ptr + .asFunction<_dart_Cronet_Engine_StartWithParams>(); + + int Cronet_Engine_Shutdown( + ffi.Pointer self, + ) { + return _Cronet_Engine_Shutdown( + self, + ); + } + + late final _Cronet_Engine_Shutdown_ptr = + _lookup>( + 'Cronet_Engine_Shutdown'); + late final _dart_Cronet_Engine_Shutdown _Cronet_Engine_Shutdown = + _Cronet_Engine_Shutdown_ptr.asFunction<_dart_Cronet_Engine_Shutdown>(); + + ffi.Pointer Cronet_UrlRequest_Create() { + return _Cronet_UrlRequest_Create(); + } + + late final _Cronet_UrlRequest_Create_ptr = + _lookup>( + 'Cronet_UrlRequest_Create'); + late final _dart_Cronet_UrlRequest_Create _Cronet_UrlRequest_Create = + _Cronet_UrlRequest_Create_ptr.asFunction< + _dart_Cronet_UrlRequest_Create>(); + + void Cronet_UrlRequest_Destroy( + ffi.Pointer self, + ) { + return _Cronet_UrlRequest_Destroy( + self, + ); + } + + late final _Cronet_UrlRequest_Destroy_ptr = + _lookup>( + 'Cronet_UrlRequest_Destroy'); + late final _dart_Cronet_UrlRequest_Destroy _Cronet_UrlRequest_Destroy = + _Cronet_UrlRequest_Destroy_ptr.asFunction< + _dart_Cronet_UrlRequest_Destroy>(); + + void Cronet_UrlRequest_Cancel( + ffi.Pointer self, + ) { + return _Cronet_UrlRequest_Cancel( + self, + ); + } + + late final _Cronet_UrlRequest_Cancel_ptr = + _lookup>( + 'Cronet_UrlRequest_Cancel'); + late final _dart_Cronet_UrlRequest_Cancel _Cronet_UrlRequest_Cancel = + _Cronet_UrlRequest_Cancel_ptr.asFunction< + _dart_Cronet_UrlRequest_Cancel>(); + + void Cronet_UrlRequest_SetClientContext( + ffi.Pointer self, + ffi.Pointer client_context, + ) { + return _Cronet_UrlRequest_SetClientContext( + self, + client_context, + ); + } + + late final _Cronet_UrlRequest_SetClientContext_ptr = + _lookup>( + 'Cronet_UrlRequest_SetClientContext'); + late final _dart_Cronet_UrlRequest_SetClientContext + _Cronet_UrlRequest_SetClientContext = + _Cronet_UrlRequest_SetClientContext_ptr.asFunction< + _dart_Cronet_UrlRequest_SetClientContext>(); + + ffi.Pointer Cronet_UrlRequest_GetClientContext( + ffi.Pointer self, + ) { + return _Cronet_UrlRequest_GetClientContext( + self, + ); + } + + late final _Cronet_UrlRequest_GetClientContext_ptr = + _lookup>( + 'Cronet_UrlRequest_GetClientContext'); + late final _dart_Cronet_UrlRequest_GetClientContext + _Cronet_UrlRequest_GetClientContext = + _Cronet_UrlRequest_GetClientContext_ptr.asFunction< + _dart_Cronet_UrlRequest_GetClientContext>(); + + ffi.Pointer Cronet_UrlRequestParams_Create() { + return _Cronet_UrlRequestParams_Create(); + } + + late final _Cronet_UrlRequestParams_Create_ptr = + _lookup>( + 'Cronet_UrlRequestParams_Create'); + late final _dart_Cronet_UrlRequestParams_Create + _Cronet_UrlRequestParams_Create = _Cronet_UrlRequestParams_Create_ptr + .asFunction<_dart_Cronet_UrlRequestParams_Create>(); + + void Cronet_UrlRequestParams_http_method_set( + ffi.Pointer self, + ffi.Pointer http_method, + ) { + return _Cronet_UrlRequestParams_http_method_set( + self, + http_method, + ); + } + + late final _Cronet_UrlRequestParams_http_method_set_ptr = + _lookup>( + 'Cronet_UrlRequestParams_http_method_set'); + late final _dart_Cronet_UrlRequestParams_http_method_set + _Cronet_UrlRequestParams_http_method_set = + _Cronet_UrlRequestParams_http_method_set_ptr.asFunction< + _dart_Cronet_UrlRequestParams_http_method_set>(); + + void Cronet_UrlRequestParams_request_headers_add( + ffi.Pointer self, + ffi.Pointer element, + ) { + return _Cronet_UrlRequestParams_request_headers_add( + self, + element, + ); + } + + late final _Cronet_UrlRequestParams_request_headers_add_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlRequestParams_request_headers_add>>( + 'Cronet_UrlRequestParams_request_headers_add'); + late final _dart_Cronet_UrlRequestParams_request_headers_add + _Cronet_UrlRequestParams_request_headers_add = + _Cronet_UrlRequestParams_request_headers_add_ptr.asFunction< + _dart_Cronet_UrlRequestParams_request_headers_add>(); + + int Cronet_UrlRequest_Start( + ffi.Pointer self, + ) { + return _Cronet_UrlRequest_Start( + self, + ); + } + + late final _Cronet_UrlRequest_Start_ptr = + _lookup>( + 'Cronet_UrlRequest_Start'); + late final _dart_Cronet_UrlRequest_Start _Cronet_UrlRequest_Start = + _Cronet_UrlRequest_Start_ptr.asFunction<_dart_Cronet_UrlRequest_Start>(); + + int Cronet_UrlRequest_FollowRedirect( + ffi.Pointer self, + ) { + return _Cronet_UrlRequest_FollowRedirect( + self, + ); + } + + late final _Cronet_UrlRequest_FollowRedirect_ptr = + _lookup>( + 'Cronet_UrlRequest_FollowRedirect'); + late final _dart_Cronet_UrlRequest_FollowRedirect + _Cronet_UrlRequest_FollowRedirect = _Cronet_UrlRequest_FollowRedirect_ptr + .asFunction<_dart_Cronet_UrlRequest_FollowRedirect>(); + + int Cronet_UrlRequest_Read( + ffi.Pointer self, + ffi.Pointer buffer, + ) { + return _Cronet_UrlRequest_Read( + self, + buffer, + ); + } + + late final _Cronet_UrlRequest_Read_ptr = + _lookup>( + 'Cronet_UrlRequest_Read'); + late final _dart_Cronet_UrlRequest_Read _Cronet_UrlRequest_Read = + _Cronet_UrlRequest_Read_ptr.asFunction<_dart_Cronet_UrlRequest_Read>(); + + int Cronet_UrlRequest_Init( + ffi.Pointer self, + ffi.Pointer engine, + ffi.Pointer url, + ffi.Pointer params, + ffi.Pointer _executor, + ) { + return _Cronet_UrlRequest_Init( + self, + engine, + url, + params, + _executor, + ); + } + + late final _Cronet_UrlRequest_Init_ptr = + _lookup>( + 'Cronet_UrlRequest_Init'); + late final _dart_Cronet_UrlRequest_Init _Cronet_UrlRequest_Init = + _Cronet_UrlRequest_Init_ptr.asFunction<_dart_Cronet_UrlRequest_Init>(); + + ffi.Pointer Cronet_HttpHeader_Create() { + return _Cronet_HttpHeader_Create(); + } + + late final _Cronet_HttpHeader_Create_ptr = + _lookup>( + 'Cronet_HttpHeader_Create'); + late final _dart_Cronet_HttpHeader_Create _Cronet_HttpHeader_Create = + _Cronet_HttpHeader_Create_ptr.asFunction< + _dart_Cronet_HttpHeader_Create>(); + + void Cronet_HttpHeader_Destroy( + ffi.Pointer self, + ) { + return _Cronet_HttpHeader_Destroy( + self, + ); + } + + late final _Cronet_HttpHeader_Destroy_ptr = + _lookup>( + 'Cronet_HttpHeader_Destroy'); + late final _dart_Cronet_HttpHeader_Destroy _Cronet_HttpHeader_Destroy = + _Cronet_HttpHeader_Destroy_ptr.asFunction< + _dart_Cronet_HttpHeader_Destroy>(); + + void Cronet_HttpHeader_name_set( + ffi.Pointer self, + ffi.Pointer name, + ) { + return _Cronet_HttpHeader_name_set( + self, + name, + ); + } + + late final _Cronet_HttpHeader_name_set_ptr = + _lookup>( + 'Cronet_HttpHeader_name_set'); + late final _dart_Cronet_HttpHeader_name_set _Cronet_HttpHeader_name_set = + _Cronet_HttpHeader_name_set_ptr.asFunction< + _dart_Cronet_HttpHeader_name_set>(); + + void Cronet_HttpHeader_value_set( + ffi.Pointer self, + ffi.Pointer value, + ) { + return _Cronet_HttpHeader_value_set( + self, + value, + ); + } + + late final _Cronet_HttpHeader_value_set_ptr = + _lookup>( + 'Cronet_HttpHeader_value_set'); + late final _dart_Cronet_HttpHeader_value_set _Cronet_HttpHeader_value_set = + _Cronet_HttpHeader_value_set_ptr.asFunction< + _dart_Cronet_HttpHeader_value_set>(); + + int Cronet_UrlResponseInfo_http_status_code_get( + ffi.Pointer self, + ) { + return _Cronet_UrlResponseInfo_http_status_code_get( + self, + ); + } + + late final _Cronet_UrlResponseInfo_http_status_code_get_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlResponseInfo_http_status_code_get>>( + 'Cronet_UrlResponseInfo_http_status_code_get'); + late final _dart_Cronet_UrlResponseInfo_http_status_code_get + _Cronet_UrlResponseInfo_http_status_code_get = + _Cronet_UrlResponseInfo_http_status_code_get_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_http_status_code_get>(); + + ffi.Pointer Cronet_UrlResponseInfo_http_status_text_get( + ffi.Pointer self, + ) { + return _Cronet_UrlResponseInfo_http_status_text_get( + self, + ); + } + + late final _Cronet_UrlResponseInfo_http_status_text_get_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlResponseInfo_http_status_text_get>>( + 'Cronet_UrlResponseInfo_http_status_text_get'); + late final _dart_Cronet_UrlResponseInfo_http_status_text_get + _Cronet_UrlResponseInfo_http_status_text_get = + _Cronet_UrlResponseInfo_http_status_text_get_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_http_status_text_get>(); + + int Cronet_Buffer_GetSize( + ffi.Pointer self, + ) { + return _Cronet_Buffer_GetSize( + self, + ); + } + + late final _Cronet_Buffer_GetSize_ptr = + _lookup>( + 'Cronet_Buffer_GetSize'); + late final _dart_Cronet_Buffer_GetSize _Cronet_Buffer_GetSize = + _Cronet_Buffer_GetSize_ptr.asFunction<_dart_Cronet_Buffer_GetSize>(); + + ffi.Pointer Cronet_Buffer_GetData( + ffi.Pointer self, + ) { + return _Cronet_Buffer_GetData( + self, + ); + } + + late final _Cronet_Buffer_GetData_ptr = + _lookup>( + 'Cronet_Buffer_GetData'); + late final _dart_Cronet_Buffer_GetData _Cronet_Buffer_GetData = + _Cronet_Buffer_GetData_ptr.asFunction<_dart_Cronet_Buffer_GetData>(); + + bool Cronet_Engine_StartNetLogToFile( + ffi.Pointer self, + ffi.Pointer file_name, + bool log_all, + ) { + return _Cronet_Engine_StartNetLogToFile( + self, + file_name, + log_all ? 1 : 0, + ) != + 0; + } + + late final _Cronet_Engine_StartNetLogToFile_ptr = + _lookup>( + 'Cronet_Engine_StartNetLogToFile'); + late final _dart_Cronet_Engine_StartNetLogToFile + _Cronet_Engine_StartNetLogToFile = _Cronet_Engine_StartNetLogToFile_ptr + .asFunction<_dart_Cronet_Engine_StartNetLogToFile>(); + + void Cronet_Engine_StopNetLog( + ffi.Pointer self, + ) { + return _Cronet_Engine_StopNetLog( + self, + ); + } + + late final _Cronet_Engine_StopNetLog_ptr = + _lookup>( + 'Cronet_Engine_StopNetLog'); + late final _dart_Cronet_Engine_StopNetLog _Cronet_Engine_StopNetLog = + _Cronet_Engine_StopNetLog_ptr.asFunction< + _dart_Cronet_Engine_StopNetLog>(); +} + +class Cronet_Buffer extends ffi.Opaque {} + +class Cronet_BufferCallback extends ffi.Opaque {} + +class Cronet_Runnable extends ffi.Opaque {} + +class Cronet_Executor extends ffi.Opaque {} + +class Cronet_Engine extends ffi.Opaque {} + +class Cronet_UrlRequestStatusListener extends ffi.Opaque {} + +class Cronet_UrlRequestCallback extends ffi.Opaque {} + +class Cronet_UploadDataSink extends ffi.Opaque {} + +class Cronet_UploadDataProvider extends ffi.Opaque {} + +class Cronet_UrlRequest extends ffi.Opaque {} + +class Cronet_RequestFinishedInfoListener extends ffi.Opaque {} + +class Cronet_Error extends ffi.Opaque {} + +class Cronet_QuicHint extends ffi.Opaque {} + +class Cronet_PublicKeyPins extends ffi.Opaque {} + +class Cronet_EngineParams extends ffi.Opaque {} + +class Cronet_HttpHeader extends ffi.Opaque {} + +class Cronet_UrlResponseInfo extends ffi.Opaque {} + +class Cronet_UrlRequestParams extends ffi.Opaque {} + +class Cronet_DateTime extends ffi.Opaque {} + +class Cronet_Metrics extends ffi.Opaque {} + +class Cronet_RequestFinishedInfo extends ffi.Opaque {} + +abstract class Cronet_RESULT { + static const int Cronet_RESULT_SUCCESS = 0; + static const int Cronet_RESULT_ILLEGAL_ARGUMENT = -100; + static const int Cronet_RESULT_ILLEGAL_ARGUMENT_STORAGE_PATH_MUST_EXIST = + -101; + static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_PIN = -102; + static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HOSTNAME = -103; + static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HTTP_METHOD = -104; + static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HTTP_HEADER = -105; + static const int Cronet_RESULT_ILLEGAL_STATE = -200; + static const int Cronet_RESULT_ILLEGAL_STATE_STORAGE_PATH_IN_USE = -201; + static const int + Cronet_RESULT_ILLEGAL_STATE_CANNOT_SHUTDOWN_ENGINE_FROM_NETWORK_THREAD = + -202; + static const int Cronet_RESULT_ILLEGAL_STATE_ENGINE_ALREADY_STARTED = -203; + static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_ALREADY_STARTED = -204; + static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_NOT_INITIALIZED = -205; + static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_ALREADY_INITIALIZED = + -206; + static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_NOT_STARTED = -207; + static const int Cronet_RESULT_ILLEGAL_STATE_UNEXPECTED_REDIRECT = -208; + static const int Cronet_RESULT_ILLEGAL_STATE_UNEXPECTED_READ = -209; + static const int Cronet_RESULT_ILLEGAL_STATE_READ_FAILED = -210; + static const int Cronet_RESULT_NULL_POINTER = -300; + static const int Cronet_RESULT_NULL_POINTER_HOSTNAME = -301; + static const int Cronet_RESULT_NULL_POINTER_SHA256_PINS = -302; + static const int Cronet_RESULT_NULL_POINTER_EXPIRATION_DATE = -303; + static const int Cronet_RESULT_NULL_POINTER_ENGINE = -304; + static const int Cronet_RESULT_NULL_POINTER_URL = -305; + static const int Cronet_RESULT_NULL_POINTER_CALLBACK = -306; + static const int Cronet_RESULT_NULL_POINTER_EXECUTOR = -307; + static const int Cronet_RESULT_NULL_POINTER_METHOD = -308; + static const int Cronet_RESULT_NULL_POINTER_HEADER_NAME = -309; + static const int Cronet_RESULT_NULL_POINTER_HEADER_VALUE = -310; + static const int Cronet_RESULT_NULL_POINTER_PARAMS = -311; + static const int + Cronet_RESULT_NULL_POINTER_REQUEST_FINISHED_INFO_LISTENER_EXECUTOR = -312; +} + +abstract class Cronet_Error_ERROR_CODE { + static const int Cronet_Error_ERROR_CODE_ERROR_CALLBACK = 0; + static const int Cronet_Error_ERROR_CODE_ERROR_HOSTNAME_NOT_RESOLVED = 1; + static const int Cronet_Error_ERROR_CODE_ERROR_INTERNET_DISCONNECTED = 2; + static const int Cronet_Error_ERROR_CODE_ERROR_NETWORK_CHANGED = 3; + static const int Cronet_Error_ERROR_CODE_ERROR_TIMED_OUT = 4; + static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_CLOSED = 5; + static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_TIMED_OUT = 6; + static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_REFUSED = 7; + static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_RESET = 8; + static const int Cronet_Error_ERROR_CODE_ERROR_ADDRESS_UNREACHABLE = 9; + static const int Cronet_Error_ERROR_CODE_ERROR_QUIC_PROTOCOL_FAILED = 10; + static const int Cronet_Error_ERROR_CODE_ERROR_OTHER = 11; +} + +abstract class Cronet_EngineParams_HTTP_CACHE_MODE { + static const int Cronet_EngineParams_HTTP_CACHE_MODE_DISABLED = 0; + static const int Cronet_EngineParams_HTTP_CACHE_MODE_IN_MEMORY = 1; + static const int Cronet_EngineParams_HTTP_CACHE_MODE_DISK_NO_HTTP = 2; + static const int Cronet_EngineParams_HTTP_CACHE_MODE_DISK = 3; +} + +abstract class Cronet_UrlRequestParams_REQUEST_PRIORITY { + static const int + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_IDLE = 0; + static const int + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_LOWEST = 1; + static const int + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_LOW = 2; + static const int + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_MEDIUM = 3; + static const int + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_HIGHEST = 4; +} + +abstract class Cronet_UrlRequestParams_IDEMPOTENCY { + static const int Cronet_UrlRequestParams_IDEMPOTENCY_DEFAULT_IDEMPOTENCY = 0; + static const int Cronet_UrlRequestParams_IDEMPOTENCY_IDEMPOTENT = 1; + static const int Cronet_UrlRequestParams_IDEMPOTENCY_NOT_IDEMPOTENT = 2; +} + +abstract class Cronet_RequestFinishedInfo_FINISHED_REASON { + static const int Cronet_RequestFinishedInfo_FINISHED_REASON_SUCCEEDED = 0; + static const int Cronet_RequestFinishedInfo_FINISHED_REASON_FAILED = 1; + static const int Cronet_RequestFinishedInfo_FINISHED_REASON_CANCELED = 2; +} + +abstract class Cronet_UrlRequestStatusListener_Status { + static const int Cronet_UrlRequestStatusListener_Status_INVALID = -1; + static const int Cronet_UrlRequestStatusListener_Status_IDLE = 0; + static const int + Cronet_UrlRequestStatusListener_Status_WAITING_FOR_STALLED_SOCKET_POOL = + 1; + static const int + Cronet_UrlRequestStatusListener_Status_WAITING_FOR_AVAILABLE_SOCKET = 2; + static const int Cronet_UrlRequestStatusListener_Status_WAITING_FOR_DELEGATE = + 3; + static const int Cronet_UrlRequestStatusListener_Status_WAITING_FOR_CACHE = 4; + static const int Cronet_UrlRequestStatusListener_Status_DOWNLOADING_PAC_FILE = + 5; + static const int + Cronet_UrlRequestStatusListener_Status_RESOLVING_PROXY_FOR_URL = 6; + static const int + Cronet_UrlRequestStatusListener_Status_RESOLVING_HOST_IN_PAC_FILE = 7; + static const int + Cronet_UrlRequestStatusListener_Status_ESTABLISHING_PROXY_TUNNEL = 8; + static const int Cronet_UrlRequestStatusListener_Status_RESOLVING_HOST = 9; + static const int Cronet_UrlRequestStatusListener_Status_CONNECTING = 10; + static const int Cronet_UrlRequestStatusListener_Status_SSL_HANDSHAKE = 11; + static const int Cronet_UrlRequestStatusListener_Status_SENDING_REQUEST = 12; + static const int Cronet_UrlRequestStatusListener_Status_WAITING_FOR_RESPONSE = + 13; + static const int Cronet_UrlRequestStatusListener_Status_READING_RESPONSE = 14; +} + +const String CRONET_LIB_PREFIX = 'libcronet'; + +const String CRONET_LIB_EXTENSION = '.so'; + +typedef _c_dispatchCallback = ffi.Void Function( + ffi.Pointer methodname, +); + +typedef _dart_dispatchCallback = void Function( + ffi.Pointer methodname, +); + +typedef _c_InitDartApiDL = ffi.IntPtr Function( + ffi.Pointer data, +); + +typedef _dart_InitDartApiDL = int Function( + ffi.Pointer data, +); + +typedef _c_unloadCronet = ffi.Void Function(); + +typedef _dart_unloadCronet = void Function(); + +typedef _c_Create_Executor = ffi.Pointer Function(); + +typedef _dart_Create_Executor = ffi.Pointer Function(); + +typedef _c_Destroy_Executor = ffi.Void Function( + ffi.Pointer executor, +); + +typedef _dart_Destroy_Executor = void Function( + ffi.Pointer executor, +); + +typedef _c_registerHttpClient = ffi.Void Function( + ffi.Handle h, + ffi.Pointer ce, +); + +typedef _dart_registerHttpClient = void Function( + Object h, + ffi.Pointer ce, +); + +typedef _c_registerCallbackHandler = ffi.Void Function( + ffi.Int64 nativePort, + ffi.Pointer rp, +); + +typedef _dart_registerCallbackHandler = void Function( + int nativePort, + ffi.Pointer rp, +); + +typedef _c_removeRequest = ffi.Void Function( + ffi.Pointer rp, +); + +typedef _dart_removeRequest = void Function( + ffi.Pointer rp, +); + +typedef _c_Cronet_QuicHint_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_QuicHint_Create = ffi.Pointer Function(); + +typedef _c_Cronet_QuicHint_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_QuicHint_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_QuicHint_host_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer host, +); + +typedef _dart_Cronet_QuicHint_host_set = void Function( + ffi.Pointer self, + ffi.Pointer host, +); + +typedef _c_Cronet_QuicHint_port_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int32 port, +); + +typedef _dart_Cronet_QuicHint_port_set = void Function( + ffi.Pointer self, + int port, +); + +typedef _c_Cronet_QuicHint_alternate_port_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int32 alternate_port, +); + +typedef _dart_Cronet_QuicHint_alternate_port_set = void Function( + ffi.Pointer self, + int alternate_port, +); + +typedef _c_Cronet_Engine_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_Engine_Create = ffi.Pointer Function(); + +typedef _c_Cronet_Engine_GetVersionString = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Engine_GetVersionString = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_Create = ffi.Pointer + Function(); + +typedef _dart_Cronet_EngineParams_Create = ffi.Pointer + Function(); + +typedef _c_Cronet_EngineParams_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_user_agent_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer user_agent, +); + +typedef _dart_Cronet_EngineParams_user_agent_set = void Function( + ffi.Pointer self, + ffi.Pointer user_agent, +); + +typedef _c_Cronet_EngineParams_enable_quic_set = ffi.Void Function( + ffi.Pointer self, + ffi.Uint8 enable_quic, +); + +typedef _dart_Cronet_EngineParams_enable_quic_set = void Function( + ffi.Pointer self, + int enable_quic, +); + +typedef _c_Cronet_EngineParams_quic_hints_add = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _dart_Cronet_EngineParams_quic_hints_add = void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _c_Cronet_EngineParams_accept_language_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer accept_language, +); + +typedef _dart_Cronet_EngineParams_accept_language_set = void Function( + ffi.Pointer self, + ffi.Pointer accept_language, +); + +typedef _c_Cronet_EngineParams_storage_path_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer storage_path, +); + +typedef _dart_Cronet_EngineParams_storage_path_set = void Function( + ffi.Pointer self, + ffi.Pointer storage_path, +); + +typedef _c_Cronet_EngineParams_enable_http2_set = ffi.Void Function( + ffi.Pointer self, + ffi.Uint8 enable_http2, +); + +typedef _dart_Cronet_EngineParams_enable_http2_set = void Function( + ffi.Pointer self, + int enable_http2, +); + +typedef _c_Cronet_EngineParams_enable_brotli_set = ffi.Void Function( + ffi.Pointer self, + ffi.Uint8 enable_brotli, +); + +typedef _dart_Cronet_EngineParams_enable_brotli_set = void Function( + ffi.Pointer self, + int enable_brotli, +); + +typedef _c_Cronet_EngineParams_http_cache_mode_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int32 http_cache_mode, +); + +typedef _dart_Cronet_EngineParams_http_cache_mode_set = void Function( + ffi.Pointer self, + int http_cache_mode, +); + +typedef _c_Cronet_EngineParams_http_cache_max_size_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int64 http_cache_max_size, +); + +typedef _dart_Cronet_EngineParams_http_cache_max_size_set = void Function( + ffi.Pointer self, + int http_cache_max_size, +); + +typedef _c_Cronet_Engine_StartWithParams = ffi.Int32 Function( + ffi.Pointer self, + ffi.Pointer params, +); + +typedef _dart_Cronet_Engine_StartWithParams = int Function( + ffi.Pointer self, + ffi.Pointer params, +); + +typedef _c_Cronet_Engine_Shutdown = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Engine_Shutdown = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequest_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_UrlRequest_Create = ffi.Pointer + Function(); + +typedef _c_Cronet_UrlRequest_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequest_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequest_Cancel = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequest_Cancel = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequest_SetClientContext = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _dart_Cronet_UrlRequest_SetClientContext = void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _c_Cronet_UrlRequest_GetClientContext = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequest_GetClientContext = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequestParams_Create = ffi.Pointer + Function(); + +typedef _dart_Cronet_UrlRequestParams_Create + = ffi.Pointer Function(); + +typedef _c_Cronet_UrlRequestParams_http_method_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer http_method, +); + +typedef _dart_Cronet_UrlRequestParams_http_method_set = void Function( + ffi.Pointer self, + ffi.Pointer http_method, +); + +typedef _c_Cronet_UrlRequestParams_request_headers_add = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _dart_Cronet_UrlRequestParams_request_headers_add = void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _c_Cronet_UrlRequest_Start = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequest_Start = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequest_FollowRedirect = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequest_FollowRedirect = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequest_Read = ffi.Int32 Function( + ffi.Pointer self, + ffi.Pointer buffer, +); + +typedef _dart_Cronet_UrlRequest_Read = int Function( + ffi.Pointer self, + ffi.Pointer buffer, +); + +typedef _c_Cronet_UrlRequest_Init = ffi.Int32 Function( + ffi.Pointer self, + ffi.Pointer engine, + ffi.Pointer url, + ffi.Pointer params, + ffi.Pointer _executor, +); + +typedef _dart_Cronet_UrlRequest_Init = int Function( + ffi.Pointer self, + ffi.Pointer engine, + ffi.Pointer url, + ffi.Pointer params, + ffi.Pointer _executor, +); + +typedef _c_Cronet_HttpHeader_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_HttpHeader_Create = ffi.Pointer + Function(); + +typedef _c_Cronet_HttpHeader_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_HttpHeader_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_HttpHeader_name_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer name, +); + +typedef _dart_Cronet_HttpHeader_name_set = void Function( + ffi.Pointer self, + ffi.Pointer name, +); + +typedef _c_Cronet_HttpHeader_value_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer value, +); + +typedef _dart_Cronet_HttpHeader_value_set = void Function( + ffi.Pointer self, + ffi.Pointer value, +); + +typedef _c_Cronet_UrlResponseInfo_http_status_code_get = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlResponseInfo_http_status_code_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlResponseInfo_http_status_text_get = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlResponseInfo_http_status_text_get + = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Buffer_GetSize = ffi.Uint64 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Buffer_GetSize = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Buffer_GetData = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Buffer_GetData = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Engine_StartNetLogToFile = ffi.Uint8 Function( + ffi.Pointer self, + ffi.Pointer file_name, + ffi.Uint8 log_all, +); + +typedef _dart_Cronet_Engine_StartNetLogToFile = int Function( + ffi.Pointer self, + ffi.Pointer file_name, + int log_all, +); + +typedef _c_Cronet_Engine_StopNetLog = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Engine_StopNetLog = void Function( + ffi.Pointer self, +); diff --git a/lib/src/native/include/cronet/bidirectional_stream_c.h b/lib/src/native/include/cronet/bidirectional_stream_c.h new file mode 100644 index 0000000..3a6fae8 --- /dev/null +++ b/lib/src/native/include/cronet/bidirectional_stream_c.h @@ -0,0 +1,245 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_GRPC_SUPPORT_INCLUDE_BIDIRECTIONAL_STREAM_C_H_ +#define COMPONENTS_GRPC_SUPPORT_INCLUDE_BIDIRECTIONAL_STREAM_C_H_ + +#if defined(WIN32) +#define GRPC_SUPPORT_EXPORT __declspec(dllexport) +#else +#define GRPC_SUPPORT_EXPORT __attribute__((visibility("default"))) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* Engine API. */ + +/* Opaque object representing a Bidirectional stream creating engine. Created + * and configured outside of this API to facilitate sharing with other + * components */ +typedef struct stream_engine { + void* obj; + void* annotation; +} stream_engine; + +/* Bidirectional Stream API */ + +/* Opaque object representing Bidirectional Stream. */ +typedef struct bidirectional_stream { + void* obj; + void* annotation; +} bidirectional_stream; + +/* A single request or response header element. */ +typedef struct bidirectional_stream_header { + const char* key; + const char* value; +} bidirectional_stream_header; + +/* Array of request or response headers or trailers. */ +typedef struct bidirectional_stream_header_array { + size_t count; + size_t capacity; + bidirectional_stream_header* headers; +} bidirectional_stream_header_array; + +/* Set of callbacks used to receive callbacks from bidirectional stream. */ +typedef struct bidirectional_stream_callback { + /* Invoked when the stream is ready for reading and writing. + * Consumer may call bidirectional_stream_read() to start reading data. + * Consumer may call bidirectional_stream_write() to start writing + * data. + */ + void (*on_stream_ready)(bidirectional_stream* stream); + + /* Invoked when initial response headers are received. + * Consumer must call bidirectional_stream_read() to start reading. + * Consumer may call bidirectional_stream_write() to start writing or + * close the stream. Contents of |headers| is valid for duration of the call. + */ + void (*on_response_headers_received)( + bidirectional_stream* stream, + const bidirectional_stream_header_array* headers, + const char* negotiated_protocol); + + /* Invoked when data is read into the buffer passed to + * bidirectional_stream_read(). Only part of the buffer may be + * populated. To continue reading, call bidirectional_stream_read(). + * It may be invoked after on_response_trailers_received()}, if there was + * pending read data before trailers were received. + * + * If |bytes_read| is 0, it means the remote side has signaled that it will + * send no more data; future calls to bidirectional_stream_read() + * will result in the on_data_read() callback or on_succeded() callback if + * bidirectional_stream_write() was invoked with end_of_stream set to + * true. + */ + void (*on_read_completed)(bidirectional_stream* stream, + char* data, + int bytes_read); + + /** + * Invoked when all data passed to bidirectional_stream_write() is + * sent. To continue writing, call bidirectional_stream_write(). + */ + void (*on_write_completed)(bidirectional_stream* stream, const char* data); + + /* Invoked when trailers are received before closing the stream. Only invoked + * when server sends trailers, which it may not. May be invoked while there is + * read data remaining in local buffer. Contents of |trailers| is valid for + * duration of the call. + */ + void (*on_response_trailers_received)( + bidirectional_stream* stream, + const bidirectional_stream_header_array* trailers); + + /** + * Invoked when there is no data to be read or written and the stream is + * closed successfully remotely and locally. Once invoked, no further callback + * methods will be invoked. + */ + void (*on_succeded)(bidirectional_stream* stream); + + /** + * Invoked if the stream failed for any reason after + * bidirectional_stream_start(). HTTP/2 error codes are + * mapped to chrome net error codes. Once invoked, no further callback methods + * will be invoked. + */ + void (*on_failed)(bidirectional_stream* stream, int net_error); + + /** + * Invoked if the stream was canceled via + * bidirectional_stream_cancel(). Once invoked, no further callback + * methods will be invoked. + */ + void (*on_canceled)(bidirectional_stream* stream); +} bidirectional_stream_callback; + +/* Creates a new stream object that uses |engine| and |callback|. All stream + * tasks are performed asynchronously on the |engine| network thread. |callback| + * methods are invoked synchronously on the |engine| network thread, but must + * not run tasks on the current thread to prevent blocking networking operations + * and causing exceptions during shutdown. The |annotation| is stored in + * bidirectional stream for arbitrary use by application. + * + * Returned |bidirectional_stream*| is owned by the caller, and must be + * destroyed using |bidirectional_stream_destroy|. + * + * Both |calback| and |engine| must remain valid until stream is destroyed. + */ +GRPC_SUPPORT_EXPORT +bidirectional_stream* bidirectional_stream_create( + stream_engine* engine, + void* annotation, + bidirectional_stream_callback* callback); + +/* TBD: The following methods return int. Should it be a custom type? */ + +/* Destroys stream object. Destroy could be called from any thread, including + * network thread, but is posted, so |stream| is valid until calling task is + * complete. + */ +GRPC_SUPPORT_EXPORT +int bidirectional_stream_destroy(bidirectional_stream* stream); + +/** + * Disables or enables auto flush. By default, data is flushed after + * every bidirectional_stream_write(). If the auto flush is disabled, + * the client should explicitly call bidirectional_stream_flush to flush + * the data. + */ +GRPC_SUPPORT_EXPORT void bidirectional_stream_disable_auto_flush( + bidirectional_stream* stream, + bool disable_auto_flush); + +/** + * Delays sending request headers until bidirectional_stream_flush() + * is called. This flag is currently only respected when QUIC is negotiated. + * When true, QUIC will send request header frame along with data frame(s) + * as a single packet when possible. + */ +GRPC_SUPPORT_EXPORT +void bidirectional_stream_delay_request_headers_until_flush( + bidirectional_stream* stream, + bool delay_headers_until_flush); + +/* Starts the stream by sending request to |url| using |method| and |headers|. + * If |end_of_stream| is true, then no data is expected to be written. The + * |method| is HTTP verb. + */ +GRPC_SUPPORT_EXPORT +int bidirectional_stream_start(bidirectional_stream* stream, + const char* url, + int priority, + const char* method, + const bidirectional_stream_header_array* headers, + bool end_of_stream); + +/* Reads response data into |buffer| of |capacity| length. Must only be called + * at most once in response to each invocation of the + * on_stream_ready()/on_response_headers_received() and on_read_completed() + * methods of the bidirectional_stream_callback. + * Each call will result in an invocation of the callback's + * on_read_completed() method if data is read, or its on_failed() method if + * there's an error. The callback's on_succeeded() method is also invoked if + * there is no more data to read and |end_of_stream| was previously sent. + */ +GRPC_SUPPORT_EXPORT +int bidirectional_stream_read(bidirectional_stream* stream, + char* buffer, + int capacity); + +/* Writes request data from |buffer| of |buffer_length| length. If auto flush is + * disabled, data will be sent only after bidirectional_stream_flush() is + * called. + * Each call will result in an invocation the callback's on_write_completed() + * method if data is sent, or its on_failed() method if there's an error. + * The callback's on_succeeded() method is also invoked if |end_of_stream| is + * set and all response data has been read. + */ +GRPC_SUPPORT_EXPORT +int bidirectional_stream_write(bidirectional_stream* stream, + const char* buffer, + int buffer_length, + bool end_of_stream); + +/** + * Flushes pending writes. This method should not be called before invocation of + * on_stream_ready() method of the bidirectional_stream_callback. + * For each previously called bidirectional_stream_write() + * a corresponding on_write_completed() callback will be invoked when the buffer + * is sent. + */ +GRPC_SUPPORT_EXPORT +void bidirectional_stream_flush(bidirectional_stream* stream); + +/* Cancels the stream. Can be called at any time after + * bidirectional_stream_start(). The on_canceled() method of + * bidirectional_stream_callback will be invoked when cancelation + * is complete and no further callback methods will be invoked. If the + * stream has completed or has not started, calling + * bidirectional_stream_cancel() has no effect and on_canceled() will not + * be invoked. At most one callback method may be invoked after + * bidirectional_stream_cancel() has completed. + */ +GRPC_SUPPORT_EXPORT +void bidirectional_stream_cancel(bidirectional_stream* stream); + +/* Returns true if the |stream| was successfully started and is now done + * (succeeded, canceled, or failed). + * Returns false if the |stream| stream is not yet started or is in progress. + */ +GRPC_SUPPORT_EXPORT +bool bidirectional_stream_is_done(bidirectional_stream* stream); + +#ifdef __cplusplus +} +#endif + +#endif // COMPONENTS_GRPC_SUPPORT_INCLUDE_BIDIRECTIONAL_STREAM_C_H_ diff --git a/lib/src/native/include/cronet/cronet.idl_c.h b/lib/src/native/include/cronet/cronet.idl_c.h new file mode 100644 index 0000000..041fd8f --- /dev/null +++ b/lib/src/native/include/cronet/cronet.idl_c.h @@ -0,0 +1,1284 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/* DO NOT EDIT. Generated from components/cronet/native/generated/cronet.idl */ + +#ifndef COMPONENTS_CRONET_NATIVE_GENERATED_CRONET_IDL_C_H_ +#define COMPONENTS_CRONET_NATIVE_GENERATED_CRONET_IDL_C_H_ +#include "cronet_export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef const char* Cronet_String; +typedef void* Cronet_RawDataPtr; +typedef void* Cronet_ClientContext; + +// Forward declare interfaces. +typedef struct Cronet_Buffer Cronet_Buffer; +typedef struct Cronet_Buffer* Cronet_BufferPtr; +typedef struct Cronet_BufferCallback Cronet_BufferCallback; +typedef struct Cronet_BufferCallback* Cronet_BufferCallbackPtr; +typedef struct Cronet_Runnable Cronet_Runnable; +typedef struct Cronet_Runnable* Cronet_RunnablePtr; +typedef struct Cronet_Executor Cronet_Executor; +typedef struct Cronet_Executor* Cronet_ExecutorPtr; +typedef struct Cronet_Engine Cronet_Engine; +typedef struct Cronet_Engine* Cronet_EnginePtr; +typedef struct Cronet_UrlRequestStatusListener Cronet_UrlRequestStatusListener; +typedef struct Cronet_UrlRequestStatusListener* + Cronet_UrlRequestStatusListenerPtr; +typedef struct Cronet_UrlRequestCallback Cronet_UrlRequestCallback; +typedef struct Cronet_UrlRequestCallback* Cronet_UrlRequestCallbackPtr; +typedef struct Cronet_UploadDataSink Cronet_UploadDataSink; +typedef struct Cronet_UploadDataSink* Cronet_UploadDataSinkPtr; +typedef struct Cronet_UploadDataProvider Cronet_UploadDataProvider; +typedef struct Cronet_UploadDataProvider* Cronet_UploadDataProviderPtr; +typedef struct Cronet_UrlRequest Cronet_UrlRequest; +typedef struct Cronet_UrlRequest* Cronet_UrlRequestPtr; +typedef struct Cronet_RequestFinishedInfoListener + Cronet_RequestFinishedInfoListener; +typedef struct Cronet_RequestFinishedInfoListener* + Cronet_RequestFinishedInfoListenerPtr; + +// Forward declare structs. +typedef struct Cronet_Error Cronet_Error; +typedef struct Cronet_Error* Cronet_ErrorPtr; +typedef struct Cronet_QuicHint Cronet_QuicHint; +typedef struct Cronet_QuicHint* Cronet_QuicHintPtr; +typedef struct Cronet_PublicKeyPins Cronet_PublicKeyPins; +typedef struct Cronet_PublicKeyPins* Cronet_PublicKeyPinsPtr; +typedef struct Cronet_EngineParams Cronet_EngineParams; +typedef struct Cronet_EngineParams* Cronet_EngineParamsPtr; +typedef struct Cronet_HttpHeader Cronet_HttpHeader; +typedef struct Cronet_HttpHeader* Cronet_HttpHeaderPtr; +typedef struct Cronet_UrlResponseInfo Cronet_UrlResponseInfo; +typedef struct Cronet_UrlResponseInfo* Cronet_UrlResponseInfoPtr; +typedef struct Cronet_UrlRequestParams Cronet_UrlRequestParams; +typedef struct Cronet_UrlRequestParams* Cronet_UrlRequestParamsPtr; +typedef struct Cronet_DateTime Cronet_DateTime; +typedef struct Cronet_DateTime* Cronet_DateTimePtr; +typedef struct Cronet_Metrics Cronet_Metrics; +typedef struct Cronet_Metrics* Cronet_MetricsPtr; +typedef struct Cronet_RequestFinishedInfo Cronet_RequestFinishedInfo; +typedef struct Cronet_RequestFinishedInfo* Cronet_RequestFinishedInfoPtr; + +// Declare enums +typedef enum Cronet_RESULT { + Cronet_RESULT_SUCCESS = 0, + Cronet_RESULT_ILLEGAL_ARGUMENT = -100, + Cronet_RESULT_ILLEGAL_ARGUMENT_STORAGE_PATH_MUST_EXIST = -101, + Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_PIN = -102, + Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HOSTNAME = -103, + Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HTTP_METHOD = -104, + Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HTTP_HEADER = -105, + Cronet_RESULT_ILLEGAL_STATE = -200, + Cronet_RESULT_ILLEGAL_STATE_STORAGE_PATH_IN_USE = -201, + Cronet_RESULT_ILLEGAL_STATE_CANNOT_SHUTDOWN_ENGINE_FROM_NETWORK_THREAD = -202, + Cronet_RESULT_ILLEGAL_STATE_ENGINE_ALREADY_STARTED = -203, + Cronet_RESULT_ILLEGAL_STATE_REQUEST_ALREADY_STARTED = -204, + Cronet_RESULT_ILLEGAL_STATE_REQUEST_NOT_INITIALIZED = -205, + Cronet_RESULT_ILLEGAL_STATE_REQUEST_ALREADY_INITIALIZED = -206, + Cronet_RESULT_ILLEGAL_STATE_REQUEST_NOT_STARTED = -207, + Cronet_RESULT_ILLEGAL_STATE_UNEXPECTED_REDIRECT = -208, + Cronet_RESULT_ILLEGAL_STATE_UNEXPECTED_READ = -209, + Cronet_RESULT_ILLEGAL_STATE_READ_FAILED = -210, + Cronet_RESULT_NULL_POINTER = -300, + Cronet_RESULT_NULL_POINTER_HOSTNAME = -301, + Cronet_RESULT_NULL_POINTER_SHA256_PINS = -302, + Cronet_RESULT_NULL_POINTER_EXPIRATION_DATE = -303, + Cronet_RESULT_NULL_POINTER_ENGINE = -304, + Cronet_RESULT_NULL_POINTER_URL = -305, + Cronet_RESULT_NULL_POINTER_CALLBACK = -306, + Cronet_RESULT_NULL_POINTER_EXECUTOR = -307, + Cronet_RESULT_NULL_POINTER_METHOD = -308, + Cronet_RESULT_NULL_POINTER_HEADER_NAME = -309, + Cronet_RESULT_NULL_POINTER_HEADER_VALUE = -310, + Cronet_RESULT_NULL_POINTER_PARAMS = -311, + Cronet_RESULT_NULL_POINTER_REQUEST_FINISHED_INFO_LISTENER_EXECUTOR = -312, +} Cronet_RESULT; + +typedef enum Cronet_Error_ERROR_CODE { + Cronet_Error_ERROR_CODE_ERROR_CALLBACK = 0, + Cronet_Error_ERROR_CODE_ERROR_HOSTNAME_NOT_RESOLVED = 1, + Cronet_Error_ERROR_CODE_ERROR_INTERNET_DISCONNECTED = 2, + Cronet_Error_ERROR_CODE_ERROR_NETWORK_CHANGED = 3, + Cronet_Error_ERROR_CODE_ERROR_TIMED_OUT = 4, + Cronet_Error_ERROR_CODE_ERROR_CONNECTION_CLOSED = 5, + Cronet_Error_ERROR_CODE_ERROR_CONNECTION_TIMED_OUT = 6, + Cronet_Error_ERROR_CODE_ERROR_CONNECTION_REFUSED = 7, + Cronet_Error_ERROR_CODE_ERROR_CONNECTION_RESET = 8, + Cronet_Error_ERROR_CODE_ERROR_ADDRESS_UNREACHABLE = 9, + Cronet_Error_ERROR_CODE_ERROR_QUIC_PROTOCOL_FAILED = 10, + Cronet_Error_ERROR_CODE_ERROR_OTHER = 11, +} Cronet_Error_ERROR_CODE; + +typedef enum Cronet_EngineParams_HTTP_CACHE_MODE { + Cronet_EngineParams_HTTP_CACHE_MODE_DISABLED = 0, + Cronet_EngineParams_HTTP_CACHE_MODE_IN_MEMORY = 1, + Cronet_EngineParams_HTTP_CACHE_MODE_DISK_NO_HTTP = 2, + Cronet_EngineParams_HTTP_CACHE_MODE_DISK = 3, +} Cronet_EngineParams_HTTP_CACHE_MODE; + +typedef enum Cronet_UrlRequestParams_REQUEST_PRIORITY { + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_IDLE = 0, + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_LOWEST = 1, + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_LOW = 2, + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_MEDIUM = 3, + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_HIGHEST = 4, +} Cronet_UrlRequestParams_REQUEST_PRIORITY; + +typedef enum Cronet_UrlRequestParams_IDEMPOTENCY { + Cronet_UrlRequestParams_IDEMPOTENCY_DEFAULT_IDEMPOTENCY = 0, + Cronet_UrlRequestParams_IDEMPOTENCY_IDEMPOTENT = 1, + Cronet_UrlRequestParams_IDEMPOTENCY_NOT_IDEMPOTENT = 2, +} Cronet_UrlRequestParams_IDEMPOTENCY; + +typedef enum Cronet_RequestFinishedInfo_FINISHED_REASON { + Cronet_RequestFinishedInfo_FINISHED_REASON_SUCCEEDED = 0, + Cronet_RequestFinishedInfo_FINISHED_REASON_FAILED = 1, + Cronet_RequestFinishedInfo_FINISHED_REASON_CANCELED = 2, +} Cronet_RequestFinishedInfo_FINISHED_REASON; + +typedef enum Cronet_UrlRequestStatusListener_Status { + Cronet_UrlRequestStatusListener_Status_INVALID = -1, + Cronet_UrlRequestStatusListener_Status_IDLE = 0, + Cronet_UrlRequestStatusListener_Status_WAITING_FOR_STALLED_SOCKET_POOL = 1, + Cronet_UrlRequestStatusListener_Status_WAITING_FOR_AVAILABLE_SOCKET = 2, + Cronet_UrlRequestStatusListener_Status_WAITING_FOR_DELEGATE = 3, + Cronet_UrlRequestStatusListener_Status_WAITING_FOR_CACHE = 4, + Cronet_UrlRequestStatusListener_Status_DOWNLOADING_PAC_FILE = 5, + Cronet_UrlRequestStatusListener_Status_RESOLVING_PROXY_FOR_URL = 6, + Cronet_UrlRequestStatusListener_Status_RESOLVING_HOST_IN_PAC_FILE = 7, + Cronet_UrlRequestStatusListener_Status_ESTABLISHING_PROXY_TUNNEL = 8, + Cronet_UrlRequestStatusListener_Status_RESOLVING_HOST = 9, + Cronet_UrlRequestStatusListener_Status_CONNECTING = 10, + Cronet_UrlRequestStatusListener_Status_SSL_HANDSHAKE = 11, + Cronet_UrlRequestStatusListener_Status_SENDING_REQUEST = 12, + Cronet_UrlRequestStatusListener_Status_WAITING_FOR_RESPONSE = 13, + Cronet_UrlRequestStatusListener_Status_READING_RESPONSE = 14, +} Cronet_UrlRequestStatusListener_Status; + +// Declare constants + +/////////////////////// +// Concrete interface Cronet_Buffer. + +// Create an instance of Cronet_Buffer. +CRONET_EXPORT Cronet_BufferPtr Cronet_Buffer_Create(void); +// Destroy an instance of Cronet_Buffer. +CRONET_EXPORT void Cronet_Buffer_Destroy(Cronet_BufferPtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_Buffer_SetClientContext( + Cronet_BufferPtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_Buffer_GetClientContext(Cronet_BufferPtr self); +// Concrete methods of Cronet_Buffer implemented by Cronet. +// The app calls them to manipulate Cronet_Buffer. +CRONET_EXPORT +void Cronet_Buffer_InitWithDataAndCallback(Cronet_BufferPtr self, + Cronet_RawDataPtr data, + uint64_t size, + Cronet_BufferCallbackPtr callback); +CRONET_EXPORT +void Cronet_Buffer_InitWithAlloc(Cronet_BufferPtr self, uint64_t size); +CRONET_EXPORT +uint64_t Cronet_Buffer_GetSize(Cronet_BufferPtr self); +CRONET_EXPORT +Cronet_RawDataPtr Cronet_Buffer_GetData(Cronet_BufferPtr self); +// Concrete interface Cronet_Buffer is implemented by Cronet. +// The app can implement these for testing / mocking. +typedef void (*Cronet_Buffer_InitWithDataAndCallbackFunc)( + Cronet_BufferPtr self, + Cronet_RawDataPtr data, + uint64_t size, + Cronet_BufferCallbackPtr callback); +typedef void (*Cronet_Buffer_InitWithAllocFunc)(Cronet_BufferPtr self, + uint64_t size); +typedef uint64_t (*Cronet_Buffer_GetSizeFunc)(Cronet_BufferPtr self); +typedef Cronet_RawDataPtr (*Cronet_Buffer_GetDataFunc)(Cronet_BufferPtr self); +// Concrete interface Cronet_Buffer is implemented by Cronet. +// The app can use this for testing / mocking. +CRONET_EXPORT Cronet_BufferPtr Cronet_Buffer_CreateWith( + Cronet_Buffer_InitWithDataAndCallbackFunc InitWithDataAndCallbackFunc, + Cronet_Buffer_InitWithAllocFunc InitWithAllocFunc, + Cronet_Buffer_GetSizeFunc GetSizeFunc, + Cronet_Buffer_GetDataFunc GetDataFunc); + +/////////////////////// +// Abstract interface Cronet_BufferCallback is implemented by the app. + +// There is no method to create a concrete implementation. + +// Destroy an instance of Cronet_BufferCallback. +CRONET_EXPORT void Cronet_BufferCallback_Destroy(Cronet_BufferCallbackPtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_BufferCallback_SetClientContext( + Cronet_BufferCallbackPtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_BufferCallback_GetClientContext(Cronet_BufferCallbackPtr self); +// Abstract interface Cronet_BufferCallback is implemented by the app. +// The following concrete methods forward call to app implementation. +// The app doesn't normally call them. +CRONET_EXPORT +void Cronet_BufferCallback_OnDestroy(Cronet_BufferCallbackPtr self, + Cronet_BufferPtr buffer); +// The app implements abstract interface Cronet_BufferCallback by defining +// custom functions for each method. +typedef void (*Cronet_BufferCallback_OnDestroyFunc)( + Cronet_BufferCallbackPtr self, + Cronet_BufferPtr buffer); +// The app creates an instance of Cronet_BufferCallback by providing custom +// functions for each method. +CRONET_EXPORT Cronet_BufferCallbackPtr Cronet_BufferCallback_CreateWith( + Cronet_BufferCallback_OnDestroyFunc OnDestroyFunc); + +/////////////////////// +// Abstract interface Cronet_Runnable is implemented by the app. + +// There is no method to create a concrete implementation. + +// Destroy an instance of Cronet_Runnable. +CRONET_EXPORT void Cronet_Runnable_Destroy(Cronet_RunnablePtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_Runnable_SetClientContext( + Cronet_RunnablePtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_Runnable_GetClientContext(Cronet_RunnablePtr self); +// Abstract interface Cronet_Runnable is implemented by the app. +// The following concrete methods forward call to app implementation. +// The app doesn't normally call them. +CRONET_EXPORT +void Cronet_Runnable_Run(Cronet_RunnablePtr self); +// The app implements abstract interface Cronet_Runnable by defining custom +// functions for each method. +typedef void (*Cronet_Runnable_RunFunc)(Cronet_RunnablePtr self); +// The app creates an instance of Cronet_Runnable by providing custom functions +// for each method. +CRONET_EXPORT Cronet_RunnablePtr +Cronet_Runnable_CreateWith(Cronet_Runnable_RunFunc RunFunc); + +/////////////////////// +// Abstract interface Cronet_Executor is implemented by the app. + +// There is no method to create a concrete implementation. + +// Destroy an instance of Cronet_Executor. +CRONET_EXPORT void Cronet_Executor_Destroy(Cronet_ExecutorPtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_Executor_SetClientContext( + Cronet_ExecutorPtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_Executor_GetClientContext(Cronet_ExecutorPtr self); +// Abstract interface Cronet_Executor is implemented by the app. +// The following concrete methods forward call to app implementation. +// The app doesn't normally call them. +CRONET_EXPORT +void Cronet_Executor_Execute(Cronet_ExecutorPtr self, + Cronet_RunnablePtr command); +// The app implements abstract interface Cronet_Executor by defining custom +// functions for each method. +typedef void (*Cronet_Executor_ExecuteFunc)(Cronet_ExecutorPtr self, + Cronet_RunnablePtr command); +// The app creates an instance of Cronet_Executor by providing custom functions +// for each method. +CRONET_EXPORT Cronet_ExecutorPtr +Cronet_Executor_CreateWith(Cronet_Executor_ExecuteFunc ExecuteFunc); + +/////////////////////// +// Concrete interface Cronet_Engine. + +// Create an instance of Cronet_Engine. +CRONET_EXPORT Cronet_EnginePtr Cronet_Engine_Create(void); +// Destroy an instance of Cronet_Engine. +CRONET_EXPORT void Cronet_Engine_Destroy(Cronet_EnginePtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_Engine_SetClientContext( + Cronet_EnginePtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_Engine_GetClientContext(Cronet_EnginePtr self); +// Concrete methods of Cronet_Engine implemented by Cronet. +// The app calls them to manipulate Cronet_Engine. +CRONET_EXPORT +Cronet_RESULT Cronet_Engine_StartWithParams(Cronet_EnginePtr self, + Cronet_EngineParamsPtr params); +CRONET_EXPORT +bool Cronet_Engine_StartNetLogToFile(Cronet_EnginePtr self, + Cronet_String file_name, + bool log_all); +CRONET_EXPORT +void Cronet_Engine_StopNetLog(Cronet_EnginePtr self); +CRONET_EXPORT +Cronet_RESULT Cronet_Engine_Shutdown(Cronet_EnginePtr self); +CRONET_EXPORT +Cronet_String Cronet_Engine_GetVersionString(Cronet_EnginePtr self); +CRONET_EXPORT +Cronet_String Cronet_Engine_GetDefaultUserAgent(Cronet_EnginePtr self); +CRONET_EXPORT +void Cronet_Engine_AddRequestFinishedListener( + Cronet_EnginePtr self, + Cronet_RequestFinishedInfoListenerPtr listener, + Cronet_ExecutorPtr executor); +CRONET_EXPORT +void Cronet_Engine_RemoveRequestFinishedListener( + Cronet_EnginePtr self, + Cronet_RequestFinishedInfoListenerPtr listener); +// Concrete interface Cronet_Engine is implemented by Cronet. +// The app can implement these for testing / mocking. +typedef Cronet_RESULT (*Cronet_Engine_StartWithParamsFunc)( + Cronet_EnginePtr self, + Cronet_EngineParamsPtr params); +typedef bool (*Cronet_Engine_StartNetLogToFileFunc)(Cronet_EnginePtr self, + Cronet_String file_name, + bool log_all); +typedef void (*Cronet_Engine_StopNetLogFunc)(Cronet_EnginePtr self); +typedef Cronet_RESULT (*Cronet_Engine_ShutdownFunc)(Cronet_EnginePtr self); +typedef Cronet_String (*Cronet_Engine_GetVersionStringFunc)( + Cronet_EnginePtr self); +typedef Cronet_String (*Cronet_Engine_GetDefaultUserAgentFunc)( + Cronet_EnginePtr self); +typedef void (*Cronet_Engine_AddRequestFinishedListenerFunc)( + Cronet_EnginePtr self, + Cronet_RequestFinishedInfoListenerPtr listener, + Cronet_ExecutorPtr executor); +typedef void (*Cronet_Engine_RemoveRequestFinishedListenerFunc)( + Cronet_EnginePtr self, + Cronet_RequestFinishedInfoListenerPtr listener); +// Concrete interface Cronet_Engine is implemented by Cronet. +// The app can use this for testing / mocking. +CRONET_EXPORT Cronet_EnginePtr Cronet_Engine_CreateWith( + Cronet_Engine_StartWithParamsFunc StartWithParamsFunc, + Cronet_Engine_StartNetLogToFileFunc StartNetLogToFileFunc, + Cronet_Engine_StopNetLogFunc StopNetLogFunc, + Cronet_Engine_ShutdownFunc ShutdownFunc, + Cronet_Engine_GetVersionStringFunc GetVersionStringFunc, + Cronet_Engine_GetDefaultUserAgentFunc GetDefaultUserAgentFunc, + Cronet_Engine_AddRequestFinishedListenerFunc AddRequestFinishedListenerFunc, + Cronet_Engine_RemoveRequestFinishedListenerFunc + RemoveRequestFinishedListenerFunc); + +/////////////////////// +// Abstract interface Cronet_UrlRequestStatusListener is implemented by the app. + +// There is no method to create a concrete implementation. + +// Destroy an instance of Cronet_UrlRequestStatusListener. +CRONET_EXPORT void Cronet_UrlRequestStatusListener_Destroy( + Cronet_UrlRequestStatusListenerPtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_UrlRequestStatusListener_SetClientContext( + Cronet_UrlRequestStatusListenerPtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_UrlRequestStatusListener_GetClientContext( + Cronet_UrlRequestStatusListenerPtr self); +// Abstract interface Cronet_UrlRequestStatusListener is implemented by the app. +// The following concrete methods forward call to app implementation. +// The app doesn't normally call them. +CRONET_EXPORT +void Cronet_UrlRequestStatusListener_OnStatus( + Cronet_UrlRequestStatusListenerPtr self, + Cronet_UrlRequestStatusListener_Status status); +// The app implements abstract interface Cronet_UrlRequestStatusListener by +// defining custom functions for each method. +typedef void (*Cronet_UrlRequestStatusListener_OnStatusFunc)( + Cronet_UrlRequestStatusListenerPtr self, + Cronet_UrlRequestStatusListener_Status status); +// The app creates an instance of Cronet_UrlRequestStatusListener by providing +// custom functions for each method. +CRONET_EXPORT Cronet_UrlRequestStatusListenerPtr +Cronet_UrlRequestStatusListener_CreateWith( + Cronet_UrlRequestStatusListener_OnStatusFunc OnStatusFunc); + +/////////////////////// +// Abstract interface Cronet_UrlRequestCallback is implemented by the app. + +// There is no method to create a concrete implementation. + +// Destroy an instance of Cronet_UrlRequestCallback. +CRONET_EXPORT void Cronet_UrlRequestCallback_Destroy( + Cronet_UrlRequestCallbackPtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_UrlRequestCallback_SetClientContext( + Cronet_UrlRequestCallbackPtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_UrlRequestCallback_GetClientContext(Cronet_UrlRequestCallbackPtr self); +// Abstract interface Cronet_UrlRequestCallback is implemented by the app. +// The following concrete methods forward call to app implementation. +// The app doesn't normally call them. +CRONET_EXPORT +void Cronet_UrlRequestCallback_OnRedirectReceived( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_String new_location_url); +CRONET_EXPORT +void Cronet_UrlRequestCallback_OnResponseStarted( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); +CRONET_EXPORT +void Cronet_UrlRequestCallback_OnReadCompleted( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_BufferPtr buffer, + uint64_t bytes_read); +CRONET_EXPORT +void Cronet_UrlRequestCallback_OnSucceeded(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); +CRONET_EXPORT +void Cronet_UrlRequestCallback_OnFailed(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_ErrorPtr error); +CRONET_EXPORT +void Cronet_UrlRequestCallback_OnCanceled(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); +// The app implements abstract interface Cronet_UrlRequestCallback by defining +// custom functions for each method. +typedef void (*Cronet_UrlRequestCallback_OnRedirectReceivedFunc)( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_String new_location_url); +typedef void (*Cronet_UrlRequestCallback_OnResponseStartedFunc)( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); +typedef void (*Cronet_UrlRequestCallback_OnReadCompletedFunc)( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_BufferPtr buffer, + uint64_t bytes_read); +typedef void (*Cronet_UrlRequestCallback_OnSucceededFunc)( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); +typedef void (*Cronet_UrlRequestCallback_OnFailedFunc)( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_ErrorPtr error); +typedef void (*Cronet_UrlRequestCallback_OnCanceledFunc)( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); +// The app creates an instance of Cronet_UrlRequestCallback by providing custom +// functions for each method. +CRONET_EXPORT Cronet_UrlRequestCallbackPtr Cronet_UrlRequestCallback_CreateWith( + Cronet_UrlRequestCallback_OnRedirectReceivedFunc OnRedirectReceivedFunc, + Cronet_UrlRequestCallback_OnResponseStartedFunc OnResponseStartedFunc, + Cronet_UrlRequestCallback_OnReadCompletedFunc OnReadCompletedFunc, + Cronet_UrlRequestCallback_OnSucceededFunc OnSucceededFunc, + Cronet_UrlRequestCallback_OnFailedFunc OnFailedFunc, + Cronet_UrlRequestCallback_OnCanceledFunc OnCanceledFunc); + +/////////////////////// +// Concrete interface Cronet_UploadDataSink. + +// Create an instance of Cronet_UploadDataSink. +CRONET_EXPORT Cronet_UploadDataSinkPtr Cronet_UploadDataSink_Create(void); +// Destroy an instance of Cronet_UploadDataSink. +CRONET_EXPORT void Cronet_UploadDataSink_Destroy(Cronet_UploadDataSinkPtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_UploadDataSink_SetClientContext( + Cronet_UploadDataSinkPtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_UploadDataSink_GetClientContext(Cronet_UploadDataSinkPtr self); +// Concrete methods of Cronet_UploadDataSink implemented by Cronet. +// The app calls them to manipulate Cronet_UploadDataSink. +CRONET_EXPORT +void Cronet_UploadDataSink_OnReadSucceeded(Cronet_UploadDataSinkPtr self, + uint64_t bytes_read, + bool final_chunk); +CRONET_EXPORT +void Cronet_UploadDataSink_OnReadError(Cronet_UploadDataSinkPtr self, + Cronet_String error_message); +CRONET_EXPORT +void Cronet_UploadDataSink_OnRewindSucceeded(Cronet_UploadDataSinkPtr self); +CRONET_EXPORT +void Cronet_UploadDataSink_OnRewindError(Cronet_UploadDataSinkPtr self, + Cronet_String error_message); +// Concrete interface Cronet_UploadDataSink is implemented by Cronet. +// The app can implement these for testing / mocking. +typedef void (*Cronet_UploadDataSink_OnReadSucceededFunc)( + Cronet_UploadDataSinkPtr self, + uint64_t bytes_read, + bool final_chunk); +typedef void (*Cronet_UploadDataSink_OnReadErrorFunc)( + Cronet_UploadDataSinkPtr self, + Cronet_String error_message); +typedef void (*Cronet_UploadDataSink_OnRewindSucceededFunc)( + Cronet_UploadDataSinkPtr self); +typedef void (*Cronet_UploadDataSink_OnRewindErrorFunc)( + Cronet_UploadDataSinkPtr self, + Cronet_String error_message); +// Concrete interface Cronet_UploadDataSink is implemented by Cronet. +// The app can use this for testing / mocking. +CRONET_EXPORT Cronet_UploadDataSinkPtr Cronet_UploadDataSink_CreateWith( + Cronet_UploadDataSink_OnReadSucceededFunc OnReadSucceededFunc, + Cronet_UploadDataSink_OnReadErrorFunc OnReadErrorFunc, + Cronet_UploadDataSink_OnRewindSucceededFunc OnRewindSucceededFunc, + Cronet_UploadDataSink_OnRewindErrorFunc OnRewindErrorFunc); + +/////////////////////// +// Abstract interface Cronet_UploadDataProvider is implemented by the app. + +// There is no method to create a concrete implementation. + +// Destroy an instance of Cronet_UploadDataProvider. +CRONET_EXPORT void Cronet_UploadDataProvider_Destroy( + Cronet_UploadDataProviderPtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_UploadDataProvider_SetClientContext( + Cronet_UploadDataProviderPtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_UploadDataProvider_GetClientContext(Cronet_UploadDataProviderPtr self); +// Abstract interface Cronet_UploadDataProvider is implemented by the app. +// The following concrete methods forward call to app implementation. +// The app doesn't normally call them. +CRONET_EXPORT +int64_t Cronet_UploadDataProvider_GetLength(Cronet_UploadDataProviderPtr self); +CRONET_EXPORT +void Cronet_UploadDataProvider_Read(Cronet_UploadDataProviderPtr self, + Cronet_UploadDataSinkPtr upload_data_sink, + Cronet_BufferPtr buffer); +CRONET_EXPORT +void Cronet_UploadDataProvider_Rewind( + Cronet_UploadDataProviderPtr self, + Cronet_UploadDataSinkPtr upload_data_sink); +CRONET_EXPORT +void Cronet_UploadDataProvider_Close(Cronet_UploadDataProviderPtr self); +// The app implements abstract interface Cronet_UploadDataProvider by defining +// custom functions for each method. +typedef int64_t (*Cronet_UploadDataProvider_GetLengthFunc)( + Cronet_UploadDataProviderPtr self); +typedef void (*Cronet_UploadDataProvider_ReadFunc)( + Cronet_UploadDataProviderPtr self, + Cronet_UploadDataSinkPtr upload_data_sink, + Cronet_BufferPtr buffer); +typedef void (*Cronet_UploadDataProvider_RewindFunc)( + Cronet_UploadDataProviderPtr self, + Cronet_UploadDataSinkPtr upload_data_sink); +typedef void (*Cronet_UploadDataProvider_CloseFunc)( + Cronet_UploadDataProviderPtr self); +// The app creates an instance of Cronet_UploadDataProvider by providing custom +// functions for each method. +CRONET_EXPORT Cronet_UploadDataProviderPtr Cronet_UploadDataProvider_CreateWith( + Cronet_UploadDataProvider_GetLengthFunc GetLengthFunc, + Cronet_UploadDataProvider_ReadFunc ReadFunc, + Cronet_UploadDataProvider_RewindFunc RewindFunc, + Cronet_UploadDataProvider_CloseFunc CloseFunc); + +/////////////////////// +// Concrete interface Cronet_UrlRequest. + +// Create an instance of Cronet_UrlRequest. +CRONET_EXPORT Cronet_UrlRequestPtr Cronet_UrlRequest_Create(void); +// Destroy an instance of Cronet_UrlRequest. +CRONET_EXPORT void Cronet_UrlRequest_Destroy(Cronet_UrlRequestPtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_UrlRequest_SetClientContext( + Cronet_UrlRequestPtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_UrlRequest_GetClientContext(Cronet_UrlRequestPtr self); +// Concrete methods of Cronet_UrlRequest implemented by Cronet. +// The app calls them to manipulate Cronet_UrlRequest. +CRONET_EXPORT +Cronet_RESULT Cronet_UrlRequest_InitWithParams( + Cronet_UrlRequestPtr self, + Cronet_EnginePtr engine, + Cronet_String url, + Cronet_UrlRequestParamsPtr params, + Cronet_UrlRequestCallbackPtr callback, + Cronet_ExecutorPtr executor); +CRONET_EXPORT +Cronet_RESULT Cronet_UrlRequest_Start(Cronet_UrlRequestPtr self); +CRONET_EXPORT +Cronet_RESULT Cronet_UrlRequest_FollowRedirect(Cronet_UrlRequestPtr self); +CRONET_EXPORT +Cronet_RESULT Cronet_UrlRequest_Read(Cronet_UrlRequestPtr self, + Cronet_BufferPtr buffer); +CRONET_EXPORT +void Cronet_UrlRequest_Cancel(Cronet_UrlRequestPtr self); +CRONET_EXPORT +bool Cronet_UrlRequest_IsDone(Cronet_UrlRequestPtr self); +CRONET_EXPORT +void Cronet_UrlRequest_GetStatus(Cronet_UrlRequestPtr self, + Cronet_UrlRequestStatusListenerPtr listener); +// Concrete interface Cronet_UrlRequest is implemented by Cronet. +// The app can implement these for testing / mocking. +typedef Cronet_RESULT (*Cronet_UrlRequest_InitWithParamsFunc)( + Cronet_UrlRequestPtr self, + Cronet_EnginePtr engine, + Cronet_String url, + Cronet_UrlRequestParamsPtr params, + Cronet_UrlRequestCallbackPtr callback, + Cronet_ExecutorPtr executor); +typedef Cronet_RESULT (*Cronet_UrlRequest_StartFunc)(Cronet_UrlRequestPtr self); +typedef Cronet_RESULT (*Cronet_UrlRequest_FollowRedirectFunc)( + Cronet_UrlRequestPtr self); +typedef Cronet_RESULT (*Cronet_UrlRequest_ReadFunc)(Cronet_UrlRequestPtr self, + Cronet_BufferPtr buffer); +typedef void (*Cronet_UrlRequest_CancelFunc)(Cronet_UrlRequestPtr self); +typedef bool (*Cronet_UrlRequest_IsDoneFunc)(Cronet_UrlRequestPtr self); +typedef void (*Cronet_UrlRequest_GetStatusFunc)( + Cronet_UrlRequestPtr self, + Cronet_UrlRequestStatusListenerPtr listener); +// Concrete interface Cronet_UrlRequest is implemented by Cronet. +// The app can use this for testing / mocking. +CRONET_EXPORT Cronet_UrlRequestPtr Cronet_UrlRequest_CreateWith( + Cronet_UrlRequest_InitWithParamsFunc InitWithParamsFunc, + Cronet_UrlRequest_StartFunc StartFunc, + Cronet_UrlRequest_FollowRedirectFunc FollowRedirectFunc, + Cronet_UrlRequest_ReadFunc ReadFunc, + Cronet_UrlRequest_CancelFunc CancelFunc, + Cronet_UrlRequest_IsDoneFunc IsDoneFunc, + Cronet_UrlRequest_GetStatusFunc GetStatusFunc); + +/////////////////////// +// Abstract interface Cronet_RequestFinishedInfoListener is implemented by the +// app. + +// There is no method to create a concrete implementation. + +// Destroy an instance of Cronet_RequestFinishedInfoListener. +CRONET_EXPORT void Cronet_RequestFinishedInfoListener_Destroy( + Cronet_RequestFinishedInfoListenerPtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_RequestFinishedInfoListener_SetClientContext( + Cronet_RequestFinishedInfoListenerPtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_RequestFinishedInfoListener_GetClientContext( + Cronet_RequestFinishedInfoListenerPtr self); +// Abstract interface Cronet_RequestFinishedInfoListener is implemented by the +// app. The following concrete methods forward call to app implementation. The +// app doesn't normally call them. +CRONET_EXPORT +void Cronet_RequestFinishedInfoListener_OnRequestFinished( + Cronet_RequestFinishedInfoListenerPtr self, + Cronet_RequestFinishedInfoPtr request_info, + Cronet_UrlResponseInfoPtr response_info, + Cronet_ErrorPtr error); +// The app implements abstract interface Cronet_RequestFinishedInfoListener by +// defining custom functions for each method. +typedef void (*Cronet_RequestFinishedInfoListener_OnRequestFinishedFunc)( + Cronet_RequestFinishedInfoListenerPtr self, + Cronet_RequestFinishedInfoPtr request_info, + Cronet_UrlResponseInfoPtr response_info, + Cronet_ErrorPtr error); +// The app creates an instance of Cronet_RequestFinishedInfoListener by +// providing custom functions for each method. +CRONET_EXPORT Cronet_RequestFinishedInfoListenerPtr +Cronet_RequestFinishedInfoListener_CreateWith( + Cronet_RequestFinishedInfoListener_OnRequestFinishedFunc + OnRequestFinishedFunc); + +/////////////////////// +// Struct Cronet_Error. +CRONET_EXPORT Cronet_ErrorPtr Cronet_Error_Create(void); +CRONET_EXPORT void Cronet_Error_Destroy(Cronet_ErrorPtr self); +// Cronet_Error setters. +CRONET_EXPORT +void Cronet_Error_error_code_set(Cronet_ErrorPtr self, + const Cronet_Error_ERROR_CODE error_code); +CRONET_EXPORT +void Cronet_Error_message_set(Cronet_ErrorPtr self, + const Cronet_String message); +CRONET_EXPORT +void Cronet_Error_internal_error_code_set(Cronet_ErrorPtr self, + const int32_t internal_error_code); +CRONET_EXPORT +void Cronet_Error_immediately_retryable_set(Cronet_ErrorPtr self, + const bool immediately_retryable); +CRONET_EXPORT +void Cronet_Error_quic_detailed_error_code_set( + Cronet_ErrorPtr self, + const int32_t quic_detailed_error_code); +// Cronet_Error getters. +CRONET_EXPORT +Cronet_Error_ERROR_CODE Cronet_Error_error_code_get(const Cronet_ErrorPtr self); +CRONET_EXPORT +Cronet_String Cronet_Error_message_get(const Cronet_ErrorPtr self); +CRONET_EXPORT +int32_t Cronet_Error_internal_error_code_get(const Cronet_ErrorPtr self); +CRONET_EXPORT +bool Cronet_Error_immediately_retryable_get(const Cronet_ErrorPtr self); +CRONET_EXPORT +int32_t Cronet_Error_quic_detailed_error_code_get(const Cronet_ErrorPtr self); + +/////////////////////// +// Struct Cronet_QuicHint. +CRONET_EXPORT Cronet_QuicHintPtr Cronet_QuicHint_Create(void); +CRONET_EXPORT void Cronet_QuicHint_Destroy(Cronet_QuicHintPtr self); +// Cronet_QuicHint setters. +CRONET_EXPORT +void Cronet_QuicHint_host_set(Cronet_QuicHintPtr self, + const Cronet_String host); +CRONET_EXPORT +void Cronet_QuicHint_port_set(Cronet_QuicHintPtr self, const int32_t port); +CRONET_EXPORT +void Cronet_QuicHint_alternate_port_set(Cronet_QuicHintPtr self, + const int32_t alternate_port); +// Cronet_QuicHint getters. +CRONET_EXPORT +Cronet_String Cronet_QuicHint_host_get(const Cronet_QuicHintPtr self); +CRONET_EXPORT +int32_t Cronet_QuicHint_port_get(const Cronet_QuicHintPtr self); +CRONET_EXPORT +int32_t Cronet_QuicHint_alternate_port_get(const Cronet_QuicHintPtr self); + +/////////////////////// +// Struct Cronet_PublicKeyPins. +CRONET_EXPORT Cronet_PublicKeyPinsPtr Cronet_PublicKeyPins_Create(void); +CRONET_EXPORT void Cronet_PublicKeyPins_Destroy(Cronet_PublicKeyPinsPtr self); +// Cronet_PublicKeyPins setters. +CRONET_EXPORT +void Cronet_PublicKeyPins_host_set(Cronet_PublicKeyPinsPtr self, + const Cronet_String host); +CRONET_EXPORT +void Cronet_PublicKeyPins_pins_sha256_add(Cronet_PublicKeyPinsPtr self, + const Cronet_String element); +CRONET_EXPORT +void Cronet_PublicKeyPins_include_subdomains_set(Cronet_PublicKeyPinsPtr self, + const bool include_subdomains); +CRONET_EXPORT +void Cronet_PublicKeyPins_expiration_date_set(Cronet_PublicKeyPinsPtr self, + const int64_t expiration_date); +// Cronet_PublicKeyPins getters. +CRONET_EXPORT +Cronet_String Cronet_PublicKeyPins_host_get(const Cronet_PublicKeyPinsPtr self); +CRONET_EXPORT +uint32_t Cronet_PublicKeyPins_pins_sha256_size( + const Cronet_PublicKeyPinsPtr self); +CRONET_EXPORT +Cronet_String Cronet_PublicKeyPins_pins_sha256_at( + const Cronet_PublicKeyPinsPtr self, + uint32_t index); +CRONET_EXPORT +void Cronet_PublicKeyPins_pins_sha256_clear(Cronet_PublicKeyPinsPtr self); +CRONET_EXPORT +bool Cronet_PublicKeyPins_include_subdomains_get( + const Cronet_PublicKeyPinsPtr self); +CRONET_EXPORT +int64_t Cronet_PublicKeyPins_expiration_date_get( + const Cronet_PublicKeyPinsPtr self); + +/////////////////////// +// Struct Cronet_EngineParams. +CRONET_EXPORT Cronet_EngineParamsPtr Cronet_EngineParams_Create(void); +CRONET_EXPORT void Cronet_EngineParams_Destroy(Cronet_EngineParamsPtr self); +// Cronet_EngineParams setters. +CRONET_EXPORT +void Cronet_EngineParams_enable_check_result_set( + Cronet_EngineParamsPtr self, + const bool enable_check_result); +CRONET_EXPORT +void Cronet_EngineParams_user_agent_set(Cronet_EngineParamsPtr self, + const Cronet_String user_agent); +CRONET_EXPORT +void Cronet_EngineParams_accept_language_set( + Cronet_EngineParamsPtr self, + const Cronet_String accept_language); +CRONET_EXPORT +void Cronet_EngineParams_storage_path_set(Cronet_EngineParamsPtr self, + const Cronet_String storage_path); +CRONET_EXPORT +void Cronet_EngineParams_enable_quic_set(Cronet_EngineParamsPtr self, + const bool enable_quic); +CRONET_EXPORT +void Cronet_EngineParams_enable_http2_set(Cronet_EngineParamsPtr self, + const bool enable_http2); +CRONET_EXPORT +void Cronet_EngineParams_enable_brotli_set(Cronet_EngineParamsPtr self, + const bool enable_brotli); +CRONET_EXPORT +void Cronet_EngineParams_http_cache_mode_set( + Cronet_EngineParamsPtr self, + const Cronet_EngineParams_HTTP_CACHE_MODE http_cache_mode); +CRONET_EXPORT +void Cronet_EngineParams_http_cache_max_size_set( + Cronet_EngineParamsPtr self, + const int64_t http_cache_max_size); +CRONET_EXPORT +void Cronet_EngineParams_quic_hints_add(Cronet_EngineParamsPtr self, + const Cronet_QuicHintPtr element); +CRONET_EXPORT +void Cronet_EngineParams_public_key_pins_add( + Cronet_EngineParamsPtr self, + const Cronet_PublicKeyPinsPtr element); +CRONET_EXPORT +void Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_set( + Cronet_EngineParamsPtr self, + const bool enable_public_key_pinning_bypass_for_local_trust_anchors); +CRONET_EXPORT +void Cronet_EngineParams_network_thread_priority_set( + Cronet_EngineParamsPtr self, + const double network_thread_priority); +CRONET_EXPORT +void Cronet_EngineParams_experimental_options_set( + Cronet_EngineParamsPtr self, + const Cronet_String experimental_options); +// Cronet_EngineParams getters. +CRONET_EXPORT +bool Cronet_EngineParams_enable_check_result_get( + const Cronet_EngineParamsPtr self); +CRONET_EXPORT +Cronet_String Cronet_EngineParams_user_agent_get( + const Cronet_EngineParamsPtr self); +CRONET_EXPORT +Cronet_String Cronet_EngineParams_accept_language_get( + const Cronet_EngineParamsPtr self); +CRONET_EXPORT +Cronet_String Cronet_EngineParams_storage_path_get( + const Cronet_EngineParamsPtr self); +CRONET_EXPORT +bool Cronet_EngineParams_enable_quic_get(const Cronet_EngineParamsPtr self); +CRONET_EXPORT +bool Cronet_EngineParams_enable_http2_get(const Cronet_EngineParamsPtr self); +CRONET_EXPORT +bool Cronet_EngineParams_enable_brotli_get(const Cronet_EngineParamsPtr self); +CRONET_EXPORT +Cronet_EngineParams_HTTP_CACHE_MODE Cronet_EngineParams_http_cache_mode_get( + const Cronet_EngineParamsPtr self); +CRONET_EXPORT +int64_t Cronet_EngineParams_http_cache_max_size_get( + const Cronet_EngineParamsPtr self); +CRONET_EXPORT +uint32_t Cronet_EngineParams_quic_hints_size(const Cronet_EngineParamsPtr self); +CRONET_EXPORT +Cronet_QuicHintPtr Cronet_EngineParams_quic_hints_at( + const Cronet_EngineParamsPtr self, + uint32_t index); +CRONET_EXPORT +void Cronet_EngineParams_quic_hints_clear(Cronet_EngineParamsPtr self); +CRONET_EXPORT +uint32_t Cronet_EngineParams_public_key_pins_size( + const Cronet_EngineParamsPtr self); +CRONET_EXPORT +Cronet_PublicKeyPinsPtr Cronet_EngineParams_public_key_pins_at( + const Cronet_EngineParamsPtr self, + uint32_t index); +CRONET_EXPORT +void Cronet_EngineParams_public_key_pins_clear(Cronet_EngineParamsPtr self); +CRONET_EXPORT +bool Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_get( + const Cronet_EngineParamsPtr self); +CRONET_EXPORT +double Cronet_EngineParams_network_thread_priority_get( + const Cronet_EngineParamsPtr self); +CRONET_EXPORT +Cronet_String Cronet_EngineParams_experimental_options_get( + const Cronet_EngineParamsPtr self); + +/////////////////////// +// Struct Cronet_HttpHeader. +CRONET_EXPORT Cronet_HttpHeaderPtr Cronet_HttpHeader_Create(void); +CRONET_EXPORT void Cronet_HttpHeader_Destroy(Cronet_HttpHeaderPtr self); +// Cronet_HttpHeader setters. +CRONET_EXPORT +void Cronet_HttpHeader_name_set(Cronet_HttpHeaderPtr self, + const Cronet_String name); +CRONET_EXPORT +void Cronet_HttpHeader_value_set(Cronet_HttpHeaderPtr self, + const Cronet_String value); +// Cronet_HttpHeader getters. +CRONET_EXPORT +Cronet_String Cronet_HttpHeader_name_get(const Cronet_HttpHeaderPtr self); +CRONET_EXPORT +Cronet_String Cronet_HttpHeader_value_get(const Cronet_HttpHeaderPtr self); + +/////////////////////// +// Struct Cronet_UrlResponseInfo. +CRONET_EXPORT Cronet_UrlResponseInfoPtr Cronet_UrlResponseInfo_Create(void); +CRONET_EXPORT void Cronet_UrlResponseInfo_Destroy( + Cronet_UrlResponseInfoPtr self); +// Cronet_UrlResponseInfo setters. +CRONET_EXPORT +void Cronet_UrlResponseInfo_url_set(Cronet_UrlResponseInfoPtr self, + const Cronet_String url); +CRONET_EXPORT +void Cronet_UrlResponseInfo_url_chain_add(Cronet_UrlResponseInfoPtr self, + const Cronet_String element); +CRONET_EXPORT +void Cronet_UrlResponseInfo_http_status_code_set( + Cronet_UrlResponseInfoPtr self, + const int32_t http_status_code); +CRONET_EXPORT +void Cronet_UrlResponseInfo_http_status_text_set( + Cronet_UrlResponseInfoPtr self, + const Cronet_String http_status_text); +CRONET_EXPORT +void Cronet_UrlResponseInfo_all_headers_list_add( + Cronet_UrlResponseInfoPtr self, + const Cronet_HttpHeaderPtr element); +CRONET_EXPORT +void Cronet_UrlResponseInfo_was_cached_set(Cronet_UrlResponseInfoPtr self, + const bool was_cached); +CRONET_EXPORT +void Cronet_UrlResponseInfo_negotiated_protocol_set( + Cronet_UrlResponseInfoPtr self, + const Cronet_String negotiated_protocol); +CRONET_EXPORT +void Cronet_UrlResponseInfo_proxy_server_set(Cronet_UrlResponseInfoPtr self, + const Cronet_String proxy_server); +CRONET_EXPORT +void Cronet_UrlResponseInfo_received_byte_count_set( + Cronet_UrlResponseInfoPtr self, + const int64_t received_byte_count); +// Cronet_UrlResponseInfo getters. +CRONET_EXPORT +Cronet_String Cronet_UrlResponseInfo_url_get( + const Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +uint32_t Cronet_UrlResponseInfo_url_chain_size( + const Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +Cronet_String Cronet_UrlResponseInfo_url_chain_at( + const Cronet_UrlResponseInfoPtr self, + uint32_t index); +CRONET_EXPORT +void Cronet_UrlResponseInfo_url_chain_clear(Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +int32_t Cronet_UrlResponseInfo_http_status_code_get( + const Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +Cronet_String Cronet_UrlResponseInfo_http_status_text_get( + const Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +uint32_t Cronet_UrlResponseInfo_all_headers_list_size( + const Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +Cronet_HttpHeaderPtr Cronet_UrlResponseInfo_all_headers_list_at( + const Cronet_UrlResponseInfoPtr self, + uint32_t index); +CRONET_EXPORT +void Cronet_UrlResponseInfo_all_headers_list_clear( + Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +bool Cronet_UrlResponseInfo_was_cached_get( + const Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +Cronet_String Cronet_UrlResponseInfo_negotiated_protocol_get( + const Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +Cronet_String Cronet_UrlResponseInfo_proxy_server_get( + const Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +int64_t Cronet_UrlResponseInfo_received_byte_count_get( + const Cronet_UrlResponseInfoPtr self); + +/////////////////////// +// Struct Cronet_UrlRequestParams. +CRONET_EXPORT Cronet_UrlRequestParamsPtr Cronet_UrlRequestParams_Create(void); +CRONET_EXPORT void Cronet_UrlRequestParams_Destroy( + Cronet_UrlRequestParamsPtr self); +// Cronet_UrlRequestParams setters. +CRONET_EXPORT +void Cronet_UrlRequestParams_http_method_set(Cronet_UrlRequestParamsPtr self, + const Cronet_String http_method); +CRONET_EXPORT +void Cronet_UrlRequestParams_request_headers_add( + Cronet_UrlRequestParamsPtr self, + const Cronet_HttpHeaderPtr element); +CRONET_EXPORT +void Cronet_UrlRequestParams_disable_cache_set(Cronet_UrlRequestParamsPtr self, + const bool disable_cache); +CRONET_EXPORT +void Cronet_UrlRequestParams_priority_set( + Cronet_UrlRequestParamsPtr self, + const Cronet_UrlRequestParams_REQUEST_PRIORITY priority); +CRONET_EXPORT +void Cronet_UrlRequestParams_upload_data_provider_set( + Cronet_UrlRequestParamsPtr self, + const Cronet_UploadDataProviderPtr upload_data_provider); +CRONET_EXPORT +void Cronet_UrlRequestParams_upload_data_provider_executor_set( + Cronet_UrlRequestParamsPtr self, + const Cronet_ExecutorPtr upload_data_provider_executor); +CRONET_EXPORT +void Cronet_UrlRequestParams_allow_direct_executor_set( + Cronet_UrlRequestParamsPtr self, + const bool allow_direct_executor); +CRONET_EXPORT +void Cronet_UrlRequestParams_annotations_add(Cronet_UrlRequestParamsPtr self, + const Cronet_RawDataPtr element); +CRONET_EXPORT +void Cronet_UrlRequestParams_request_finished_listener_set( + Cronet_UrlRequestParamsPtr self, + const Cronet_RequestFinishedInfoListenerPtr request_finished_listener); +CRONET_EXPORT +void Cronet_UrlRequestParams_request_finished_executor_set( + Cronet_UrlRequestParamsPtr self, + const Cronet_ExecutorPtr request_finished_executor); +CRONET_EXPORT +void Cronet_UrlRequestParams_idempotency_set( + Cronet_UrlRequestParamsPtr self, + const Cronet_UrlRequestParams_IDEMPOTENCY idempotency); +// Cronet_UrlRequestParams getters. +CRONET_EXPORT +Cronet_String Cronet_UrlRequestParams_http_method_get( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +uint32_t Cronet_UrlRequestParams_request_headers_size( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +Cronet_HttpHeaderPtr Cronet_UrlRequestParams_request_headers_at( + const Cronet_UrlRequestParamsPtr self, + uint32_t index); +CRONET_EXPORT +void Cronet_UrlRequestParams_request_headers_clear( + Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +bool Cronet_UrlRequestParams_disable_cache_get( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +Cronet_UrlRequestParams_REQUEST_PRIORITY Cronet_UrlRequestParams_priority_get( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +Cronet_UploadDataProviderPtr Cronet_UrlRequestParams_upload_data_provider_get( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +Cronet_ExecutorPtr Cronet_UrlRequestParams_upload_data_provider_executor_get( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +bool Cronet_UrlRequestParams_allow_direct_executor_get( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +uint32_t Cronet_UrlRequestParams_annotations_size( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +Cronet_RawDataPtr Cronet_UrlRequestParams_annotations_at( + const Cronet_UrlRequestParamsPtr self, + uint32_t index); +CRONET_EXPORT +void Cronet_UrlRequestParams_annotations_clear(Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +Cronet_RequestFinishedInfoListenerPtr +Cronet_UrlRequestParams_request_finished_listener_get( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +Cronet_ExecutorPtr Cronet_UrlRequestParams_request_finished_executor_get( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +Cronet_UrlRequestParams_IDEMPOTENCY Cronet_UrlRequestParams_idempotency_get( + const Cronet_UrlRequestParamsPtr self); + +/////////////////////// +// Struct Cronet_DateTime. +CRONET_EXPORT Cronet_DateTimePtr Cronet_DateTime_Create(void); +CRONET_EXPORT void Cronet_DateTime_Destroy(Cronet_DateTimePtr self); +// Cronet_DateTime setters. +CRONET_EXPORT +void Cronet_DateTime_value_set(Cronet_DateTimePtr self, const int64_t value); +// Cronet_DateTime getters. +CRONET_EXPORT +int64_t Cronet_DateTime_value_get(const Cronet_DateTimePtr self); + +/////////////////////// +// Struct Cronet_Metrics. +CRONET_EXPORT Cronet_MetricsPtr Cronet_Metrics_Create(void); +CRONET_EXPORT void Cronet_Metrics_Destroy(Cronet_MetricsPtr self); +// Cronet_Metrics setters. +CRONET_EXPORT +void Cronet_Metrics_request_start_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr request_start); +// Move data from |request_start|. The caller retains ownership of +// |request_start| and must destroy it. +void Cronet_Metrics_request_start_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr request_start); +CRONET_EXPORT +void Cronet_Metrics_dns_start_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr dns_start); +// Move data from |dns_start|. The caller retains ownership of |dns_start| and +// must destroy it. +void Cronet_Metrics_dns_start_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr dns_start); +CRONET_EXPORT +void Cronet_Metrics_dns_end_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr dns_end); +// Move data from |dns_end|. The caller retains ownership of |dns_end| and must +// destroy it. +void Cronet_Metrics_dns_end_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr dns_end); +CRONET_EXPORT +void Cronet_Metrics_connect_start_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr connect_start); +// Move data from |connect_start|. The caller retains ownership of +// |connect_start| and must destroy it. +void Cronet_Metrics_connect_start_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr connect_start); +CRONET_EXPORT +void Cronet_Metrics_connect_end_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr connect_end); +// Move data from |connect_end|. The caller retains ownership of |connect_end| +// and must destroy it. +void Cronet_Metrics_connect_end_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr connect_end); +CRONET_EXPORT +void Cronet_Metrics_ssl_start_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr ssl_start); +// Move data from |ssl_start|. The caller retains ownership of |ssl_start| and +// must destroy it. +void Cronet_Metrics_ssl_start_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr ssl_start); +CRONET_EXPORT +void Cronet_Metrics_ssl_end_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr ssl_end); +// Move data from |ssl_end|. The caller retains ownership of |ssl_end| and must +// destroy it. +void Cronet_Metrics_ssl_end_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr ssl_end); +CRONET_EXPORT +void Cronet_Metrics_sending_start_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr sending_start); +// Move data from |sending_start|. The caller retains ownership of +// |sending_start| and must destroy it. +void Cronet_Metrics_sending_start_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr sending_start); +CRONET_EXPORT +void Cronet_Metrics_sending_end_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr sending_end); +// Move data from |sending_end|. The caller retains ownership of |sending_end| +// and must destroy it. +void Cronet_Metrics_sending_end_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr sending_end); +CRONET_EXPORT +void Cronet_Metrics_push_start_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr push_start); +// Move data from |push_start|. The caller retains ownership of |push_start| and +// must destroy it. +void Cronet_Metrics_push_start_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr push_start); +CRONET_EXPORT +void Cronet_Metrics_push_end_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr push_end); +// Move data from |push_end|. The caller retains ownership of |push_end| and +// must destroy it. +void Cronet_Metrics_push_end_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr push_end); +CRONET_EXPORT +void Cronet_Metrics_response_start_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr response_start); +// Move data from |response_start|. The caller retains ownership of +// |response_start| and must destroy it. +void Cronet_Metrics_response_start_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr response_start); +CRONET_EXPORT +void Cronet_Metrics_request_end_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr request_end); +// Move data from |request_end|. The caller retains ownership of |request_end| +// and must destroy it. +void Cronet_Metrics_request_end_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr request_end); +CRONET_EXPORT +void Cronet_Metrics_socket_reused_set(Cronet_MetricsPtr self, + const bool socket_reused); +CRONET_EXPORT +void Cronet_Metrics_sent_byte_count_set(Cronet_MetricsPtr self, + const int64_t sent_byte_count); +CRONET_EXPORT +void Cronet_Metrics_received_byte_count_set(Cronet_MetricsPtr self, + const int64_t received_byte_count); +// Cronet_Metrics getters. +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_request_start_get( + const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_dns_start_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_dns_end_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_connect_start_get( + const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_connect_end_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_ssl_start_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_ssl_end_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_sending_start_get( + const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_sending_end_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_push_start_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_push_end_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_response_start_get( + const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_request_end_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +bool Cronet_Metrics_socket_reused_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +int64_t Cronet_Metrics_sent_byte_count_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +int64_t Cronet_Metrics_received_byte_count_get(const Cronet_MetricsPtr self); + +/////////////////////// +// Struct Cronet_RequestFinishedInfo. +CRONET_EXPORT Cronet_RequestFinishedInfoPtr +Cronet_RequestFinishedInfo_Create(void); +CRONET_EXPORT void Cronet_RequestFinishedInfo_Destroy( + Cronet_RequestFinishedInfoPtr self); +// Cronet_RequestFinishedInfo setters. +CRONET_EXPORT +void Cronet_RequestFinishedInfo_metrics_set(Cronet_RequestFinishedInfoPtr self, + const Cronet_MetricsPtr metrics); +// Move data from |metrics|. The caller retains ownership of |metrics| and must +// destroy it. +void Cronet_RequestFinishedInfo_metrics_move(Cronet_RequestFinishedInfoPtr self, + Cronet_MetricsPtr metrics); +CRONET_EXPORT +void Cronet_RequestFinishedInfo_annotations_add( + Cronet_RequestFinishedInfoPtr self, + const Cronet_RawDataPtr element); +CRONET_EXPORT +void Cronet_RequestFinishedInfo_finished_reason_set( + Cronet_RequestFinishedInfoPtr self, + const Cronet_RequestFinishedInfo_FINISHED_REASON finished_reason); +// Cronet_RequestFinishedInfo getters. +CRONET_EXPORT +Cronet_MetricsPtr Cronet_RequestFinishedInfo_metrics_get( + const Cronet_RequestFinishedInfoPtr self); +CRONET_EXPORT +uint32_t Cronet_RequestFinishedInfo_annotations_size( + const Cronet_RequestFinishedInfoPtr self); +CRONET_EXPORT +Cronet_RawDataPtr Cronet_RequestFinishedInfo_annotations_at( + const Cronet_RequestFinishedInfoPtr self, + uint32_t index); +CRONET_EXPORT +void Cronet_RequestFinishedInfo_annotations_clear( + Cronet_RequestFinishedInfoPtr self); +CRONET_EXPORT +Cronet_RequestFinishedInfo_FINISHED_REASON +Cronet_RequestFinishedInfo_finished_reason_get( + const Cronet_RequestFinishedInfoPtr self); + +#ifdef __cplusplus +} +#endif + +#endif // COMPONENTS_CRONET_NATIVE_GENERATED_CRONET_IDL_C_H_ diff --git a/lib/src/native/include/cronet/cronet_c.h b/lib/src/native/include/cronet/cronet_c.h new file mode 100644 index 0000000..d9cd111 --- /dev/null +++ b/lib/src/native/include/cronet/cronet_c.h @@ -0,0 +1,38 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_CRONET_NATIVE_INCLUDE_CRONET_C_H_ +#define COMPONENTS_CRONET_NATIVE_INCLUDE_CRONET_C_H_ + +#include "cronet_export.h" + +// Cronet public C API is generated from cronet.idl +#include "cronet.idl_c.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Stream Engine used by Bidirectional Stream C API for GRPC. +typedef struct stream_engine stream_engine; + +// Additional Cronet C API not generated from cronet.idl. + +// Sets net::CertVerifier* raw_mock_cert_verifier for testing of Cronet_Engine. +// Must be called before Cronet_Engine_InitWithParams(). +CRONET_EXPORT void Cronet_Engine_SetMockCertVerifierForTesting( + Cronet_EnginePtr engine, + /* net::CertVerifier* */ void* raw_mock_cert_verifier); + +// Returns "stream_engine" interface for bidirectionsl stream support for GRPC. +// Returned stream engine is owned by Cronet Engine and is only valid until +// Cronet_Engine_Shutdown(). +CRONET_EXPORT stream_engine* Cronet_Engine_GetStreamEngine( + Cronet_EnginePtr engine); + +#ifdef __cplusplus +} +#endif + +#endif // COMPONENTS_CRONET_NATIVE_INCLUDE_CRONET_C_H_ diff --git a/lib/src/native/include/cronet/cronet_export.h b/lib/src/native/include/cronet/cronet_export.h new file mode 100644 index 0000000..68379ae --- /dev/null +++ b/lib/src/native/include/cronet/cronet_export.h @@ -0,0 +1,14 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_CRONET_NATIVE_INCLUDE_CRONET_EXPORT_H_ +#define COMPONENTS_CRONET_NATIVE_INCLUDE_CRONET_EXPORT_H_ + +#if defined(WIN32) +#define CRONET_EXPORT __declspec(dllexport) +#else +#define CRONET_EXPORT __attribute__((visibility("default"))) +#endif + +#endif // COMPONENTS_CRONET_NATIVE_INCLUDE_CRONET_EXPORT_H_ diff --git a/lib/src/native/include/dart/dart_api.h b/lib/src/native/include/dart/dart_api.h new file mode 100644 index 0000000..b4415cf --- /dev/null +++ b/lib/src/native/include/dart/dart_api.h @@ -0,0 +1,3953 @@ +/* + * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file + * for details. All rights reserved. Use of this source code is governed by a + * BSD-style license that can be found in the LICENSE file. + */ + +#ifndef RUNTIME_INCLUDE_DART_API_H_ +#define RUNTIME_INCLUDE_DART_API_H_ + +/** \mainpage Dart Embedding API Reference + * + * This reference describes the Dart Embedding API, which is used to embed the + * Dart Virtual Machine within C/C++ applications. + * + * This reference is generated from the header include/dart_api.h. + */ + +/* __STDC_FORMAT_MACROS has to be defined before including to + * enable platform independent printf format specifiers. */ +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS +#endif + +#include +#include +#include + +#ifdef __cplusplus +#define DART_EXTERN_C extern "C" +#else +#define DART_EXTERN_C +#endif + +#if defined(__CYGWIN__) +#error Tool chain and platform not supported. +#elif defined(_WIN32) +#if defined(DART_SHARED_LIB) +#define DART_EXPORT DART_EXTERN_C __declspec(dllexport) +#else +#define DART_EXPORT DART_EXTERN_C +#endif +#else +#if __GNUC__ >= 4 +#if defined(DART_SHARED_LIB) +#define DART_EXPORT \ + DART_EXTERN_C __attribute__((visibility("default"))) __attribute((used)) +#else +#define DART_EXPORT DART_EXTERN_C +#endif +#else +#error Tool chain not supported. +#endif +#endif + +#if __GNUC__ +#define DART_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#elif _MSC_VER +#define DART_WARN_UNUSED_RESULT _Check_return_ +#else +#define DART_WARN_UNUSED_RESULT +#endif + +/* + * ======= + * Handles + * ======= + */ + +/** + * An isolate is the unit of concurrency in Dart. Each isolate has + * its own memory and thread of control. No state is shared between + * isolates. Instead, isolates communicate by message passing. + * + * Each thread keeps track of its current isolate, which is the + * isolate which is ready to execute on the current thread. The + * current isolate may be NULL, in which case no isolate is ready to + * execute. Most of the Dart apis require there to be a current + * isolate in order to function without error. The current isolate is + * set by any call to Dart_CreateIsolateGroup or Dart_EnterIsolate. + */ +typedef struct _Dart_Isolate* Dart_Isolate; +typedef struct _Dart_IsolateGroup* Dart_IsolateGroup; + +/** + * An object reference managed by the Dart VM garbage collector. + * + * Because the garbage collector may move objects, it is unsafe to + * refer to objects directly. Instead, we refer to objects through + * handles, which are known to the garbage collector and updated + * automatically when the object is moved. Handles should be passed + * by value (except in cases like out-parameters) and should never be + * allocated on the heap. + * + * Most functions in the Dart Embedding API return a handle. When a + * function completes normally, this will be a valid handle to an + * object in the Dart VM heap. This handle may represent the result of + * the operation or it may be a special valid handle used merely to + * indicate successful completion. Note that a valid handle may in + * some cases refer to the null object. + * + * --- Error handles --- + * + * When a function encounters a problem that prevents it from + * completing normally, it returns an error handle (See Dart_IsError). + * An error handle has an associated error message that gives more + * details about the problem (See Dart_GetError). + * + * There are four kinds of error handles that can be produced, + * depending on what goes wrong: + * + * - Api error handles are produced when an api function is misused. + * This happens when a Dart embedding api function is called with + * invalid arguments or in an invalid context. + * + * - Unhandled exception error handles are produced when, during the + * execution of Dart code, an exception is thrown but not caught. + * Prototypically this would occur during a call to Dart_Invoke, but + * it can occur in any function which triggers the execution of Dart + * code (for example, Dart_ToString). + * + * An unhandled exception error provides access to an exception and + * stacktrace via the functions Dart_ErrorGetException and + * Dart_ErrorGetStackTrace. + * + * - Compilation error handles are produced when, during the execution + * of Dart code, a compile-time error occurs. As above, this can + * occur in any function which triggers the execution of Dart code. + * + * - Fatal error handles are produced when the system wants to shut + * down the current isolate. + * + * --- Propagating errors --- + * + * When an error handle is returned from the top level invocation of + * Dart code in a program, the embedder must handle the error as they + * see fit. Often, the embedder will print the error message produced + * by Dart_Error and exit the program. + * + * When an error is returned while in the body of a native function, + * it can be propagated up the call stack by calling + * Dart_PropagateError, Dart_SetReturnValue, or Dart_ThrowException. + * Errors should be propagated unless there is a specific reason not + * to. If an error is not propagated then it is ignored. For + * example, if an unhandled exception error is ignored, that + * effectively "catches" the unhandled exception. Fatal errors must + * always be propagated. + * + * When an error is propagated, any current scopes created by + * Dart_EnterScope will be exited. + * + * Using Dart_SetReturnValue to propagate an exception is somewhat + * more convenient than using Dart_PropagateError, and should be + * preferred for reasons discussed below. + * + * Dart_PropagateError and Dart_ThrowException do not return. Instead + * they transfer control non-locally using a setjmp-like mechanism. + * This can be inconvenient if you have resources that you need to + * clean up before propagating the error. + * + * When relying on Dart_PropagateError, we often return error handles + * rather than propagating them from helper functions. Consider the + * following contrived example: + * + * 1 Dart_Handle isLongStringHelper(Dart_Handle arg) { + * 2 intptr_t* length = 0; + * 3 result = Dart_StringLength(arg, &length); + * 4 if (Dart_IsError(result)) { + * 5 return result; + * 6 } + * 7 return Dart_NewBoolean(length > 100); + * 8 } + * 9 + * 10 void NativeFunction_isLongString(Dart_NativeArguments args) { + * 11 Dart_EnterScope(); + * 12 AllocateMyResource(); + * 13 Dart_Handle arg = Dart_GetNativeArgument(args, 0); + * 14 Dart_Handle result = isLongStringHelper(arg); + * 15 if (Dart_IsError(result)) { + * 16 FreeMyResource(); + * 17 Dart_PropagateError(result); + * 18 abort(); // will not reach here + * 19 } + * 20 Dart_SetReturnValue(result); + * 21 FreeMyResource(); + * 22 Dart_ExitScope(); + * 23 } + * + * In this example, we have a native function which calls a helper + * function to do its work. On line 5, the helper function could call + * Dart_PropagateError, but that would not give the native function a + * chance to call FreeMyResource(), causing a leak. Instead, the + * helper function returns the error handle to the caller, giving the + * caller a chance to clean up before propagating the error handle. + * + * When an error is propagated by calling Dart_SetReturnValue, the + * native function will be allowed to complete normally and then the + * exception will be propagated only once the native call + * returns. This can be convenient, as it allows the C code to clean + * up normally. + * + * The example can be written more simply using Dart_SetReturnValue to + * propagate the error. + * + * 1 Dart_Handle isLongStringHelper(Dart_Handle arg) { + * 2 intptr_t* length = 0; + * 3 result = Dart_StringLength(arg, &length); + * 4 if (Dart_IsError(result)) { + * 5 return result + * 6 } + * 7 return Dart_NewBoolean(length > 100); + * 8 } + * 9 + * 10 void NativeFunction_isLongString(Dart_NativeArguments args) { + * 11 Dart_EnterScope(); + * 12 AllocateMyResource(); + * 13 Dart_Handle arg = Dart_GetNativeArgument(args, 0); + * 14 Dart_SetReturnValue(isLongStringHelper(arg)); + * 15 FreeMyResource(); + * 16 Dart_ExitScope(); + * 17 } + * + * In this example, the call to Dart_SetReturnValue on line 14 will + * either return the normal return value or the error (potentially + * generated on line 3). The call to FreeMyResource on line 15 will + * execute in either case. + * + * --- Local and persistent handles --- + * + * Local handles are allocated within the current scope (see + * Dart_EnterScope) and go away when the current scope exits. Unless + * otherwise indicated, callers should assume that all functions in + * the Dart embedding api return local handles. + * + * Persistent handles are allocated within the current isolate. They + * can be used to store objects across scopes. Persistent handles have + * the lifetime of the current isolate unless they are explicitly + * deallocated (see Dart_DeletePersistentHandle). + * The type Dart_Handle represents a handle (both local and persistent). + * The type Dart_PersistentHandle is a Dart_Handle and it is used to + * document that a persistent handle is expected as a parameter to a call + * or the return value from a call is a persistent handle. + * + * FinalizableHandles are persistent handles which are auto deleted when + * the object is garbage collected. It is never safe to use these handles + * unless you know the object is still reachable. + * + * WeakPersistentHandles are persistent handles which are automatically set + * to point Dart_Null when the object is garbage collected. They are not auto + * deleted, so it is safe to use them after the object has become unreachable. + */ +typedef struct _Dart_Handle* Dart_Handle; +typedef Dart_Handle Dart_PersistentHandle; +typedef struct _Dart_WeakPersistentHandle* Dart_WeakPersistentHandle; +typedef struct _Dart_FinalizableHandle* Dart_FinalizableHandle; +// These structs are versioned by DART_API_DL_MAJOR_VERSION, bump the +// version when changing this struct. + +typedef void (*Dart_HandleFinalizer)(void* isolate_callback_data, void* peer); + +/** + * Is this an error handle? + * + * Requires there to be a current isolate. + */ +DART_EXPORT bool Dart_IsError(Dart_Handle handle); + +/** + * Is this an api error handle? + * + * Api error handles are produced when an api function is misused. + * This happens when a Dart embedding api function is called with + * invalid arguments or in an invalid context. + * + * Requires there to be a current isolate. + */ +DART_EXPORT bool Dart_IsApiError(Dart_Handle handle); + +/** + * Is this an unhandled exception error handle? + * + * Unhandled exception error handles are produced when, during the + * execution of Dart code, an exception is thrown but not caught. + * This can occur in any function which triggers the execution of Dart + * code. + * + * See Dart_ErrorGetException and Dart_ErrorGetStackTrace. + * + * Requires there to be a current isolate. + */ +DART_EXPORT bool Dart_IsUnhandledExceptionError(Dart_Handle handle); + +/** + * Is this a compilation error handle? + * + * Compilation error handles are produced when, during the execution + * of Dart code, a compile-time error occurs. This can occur in any + * function which triggers the execution of Dart code. + * + * Requires there to be a current isolate. + */ +DART_EXPORT bool Dart_IsCompilationError(Dart_Handle handle); + +/** + * Is this a fatal error handle? + * + * Fatal error handles are produced when the system wants to shut down + * the current isolate. + * + * Requires there to be a current isolate. + */ +DART_EXPORT bool Dart_IsFatalError(Dart_Handle handle); + +/** + * Gets the error message from an error handle. + * + * Requires there to be a current isolate. + * + * \return A C string containing an error message if the handle is + * error. An empty C string ("") if the handle is valid. This C + * String is scope allocated and is only valid until the next call + * to Dart_ExitScope. +*/ +DART_EXPORT const char* Dart_GetError(Dart_Handle handle); + +/** + * Is this an error handle for an unhandled exception? + */ +DART_EXPORT bool Dart_ErrorHasException(Dart_Handle handle); + +/** + * Gets the exception Object from an unhandled exception error handle. + */ +DART_EXPORT Dart_Handle Dart_ErrorGetException(Dart_Handle handle); + +/** + * Gets the stack trace Object from an unhandled exception error handle. + */ +DART_EXPORT Dart_Handle Dart_ErrorGetStackTrace(Dart_Handle handle); + +/** + * Produces an api error handle with the provided error message. + * + * Requires there to be a current isolate. + * + * \param error the error message. + */ +DART_EXPORT Dart_Handle Dart_NewApiError(const char* error); +DART_EXPORT Dart_Handle Dart_NewCompilationError(const char* error); + +/** + * Produces a new unhandled exception error handle. + * + * Requires there to be a current isolate. + * + * \param exception An instance of a Dart object to be thrown or + * an ApiError or CompilationError handle. + * When an ApiError or CompilationError handle is passed in + * a string object of the error message is created and it becomes + * the Dart object to be thrown. + */ +DART_EXPORT Dart_Handle Dart_NewUnhandledExceptionError(Dart_Handle exception); + +/** + * Propagates an error. + * + * If the provided handle is an unhandled exception error, this + * function will cause the unhandled exception to be rethrown. This + * will proceed in the standard way, walking up Dart frames until an + * appropriate 'catch' block is found, executing 'finally' blocks, + * etc. + * + * If the error is not an unhandled exception error, we will unwind + * the stack to the next C frame. Intervening Dart frames will be + * discarded; specifically, 'finally' blocks will not execute. This + * is the standard way that compilation errors (and the like) are + * handled by the Dart runtime. + * + * In either case, when an error is propagated any current scopes + * created by Dart_EnterScope will be exited. + * + * See the additional discussion under "Propagating Errors" at the + * beginning of this file. + * + * \param An error handle (See Dart_IsError) + * + * \return On success, this function does not return. On failure, the + * process is terminated. + */ +DART_EXPORT void Dart_PropagateError(Dart_Handle handle); + +/** + * Converts an object to a string. + * + * May generate an unhandled exception error. + * + * \return The converted string if no error occurs during + * the conversion. If an error does occur, an error handle is + * returned. + */ +DART_EXPORT Dart_Handle Dart_ToString(Dart_Handle object); + +/** + * Checks to see if two handles refer to identically equal objects. + * + * If both handles refer to instances, this is equivalent to using the top-level + * function identical() from dart:core. Otherwise, returns whether the two + * argument handles refer to the same object. + * + * \param obj1 An object to be compared. + * \param obj2 An object to be compared. + * + * \return True if the objects are identically equal. False otherwise. + */ +DART_EXPORT bool Dart_IdentityEquals(Dart_Handle obj1, Dart_Handle obj2); + +/** + * Allocates a handle in the current scope from a persistent handle. + */ +DART_EXPORT Dart_Handle Dart_HandleFromPersistent(Dart_PersistentHandle object); + +/** + * Allocates a handle in the current scope from a weak persistent handle. + * + * This will be a handle to Dart_Null if the object has been garbage collected. + */ +DART_EXPORT Dart_Handle +Dart_HandleFromWeakPersistent(Dart_WeakPersistentHandle object); + +/** + * Allocates a persistent handle for an object. + * + * This handle has the lifetime of the current isolate unless it is + * explicitly deallocated by calling Dart_DeletePersistentHandle. + * + * Requires there to be a current isolate. + */ +DART_EXPORT Dart_PersistentHandle Dart_NewPersistentHandle(Dart_Handle object); + +/** + * Assign value of local handle to a persistent handle. + * + * Requires there to be a current isolate. + * + * \param obj1 A persistent handle whose value needs to be set. + * \param obj2 An object whose value needs to be set to the persistent handle. + * + * \return Success if the persistent handle was set + * Otherwise, returns an error. + */ +DART_EXPORT void Dart_SetPersistentHandle(Dart_PersistentHandle obj1, + Dart_Handle obj2); + +/** + * Deallocates a persistent handle. + * + * Requires there to be a current isolate group. + */ +DART_EXPORT void Dart_DeletePersistentHandle(Dart_PersistentHandle object); + +/** + * Allocates a weak persistent handle for an object. + * + * This handle has the lifetime of the current isolate. The handle can also be + * explicitly deallocated by calling Dart_DeleteWeakPersistentHandle. + * + * If the object becomes unreachable the callback is invoked with the peer as + * argument. The callback can be executed on any thread, will have a current + * isolate group, but will not have a current isolate. The callback can only + * call Dart_DeletePersistentHandle or Dart_DeleteWeakPersistentHandle. This + * gives the embedder the ability to cleanup data associated with the object. + * The handle will point to the Dart_Null object after the finalizer has been + * run. It is illegal to call into the VM with any other Dart_* functions from + * the callback. If the handle is deleted before the object becomes + * unreachable, the callback is never invoked. + * + * Requires there to be a current isolate. + * + * \param object An object. + * \param peer A pointer to a native object or NULL. This value is + * provided to callback when it is invoked. + * \param external_allocation_size The number of externally allocated + * bytes for peer. Used to inform the garbage collector. + * \param callback A function pointer that will be invoked sometime + * after the object is garbage collected, unless the handle has been deleted. + * A valid callback needs to be specified it cannot be NULL. + * + * \return The weak persistent handle or NULL. NULL is returned in case of bad + * parameters. + */ +DART_EXPORT Dart_WeakPersistentHandle +Dart_NewWeakPersistentHandle(Dart_Handle object, + void* peer, + intptr_t external_allocation_size, + Dart_HandleFinalizer callback); + +/** + * Deletes the given weak persistent [object] handle. + * + * Requires there to be a current isolate group. + */ +DART_EXPORT void Dart_DeleteWeakPersistentHandle( + Dart_WeakPersistentHandle object); + +/** + * Updates the external memory size for the given weak persistent handle. + * + * May trigger garbage collection. + */ +DART_EXPORT void Dart_UpdateExternalSize(Dart_WeakPersistentHandle object, + intptr_t external_allocation_size); + +/** + * Allocates a finalizable handle for an object. + * + * This handle has the lifetime of the current isolate group unless the object + * pointed to by the handle is garbage collected, in this case the VM + * automatically deletes the handle after invoking the callback associated + * with the handle. The handle can also be explicitly deallocated by + * calling Dart_DeleteFinalizableHandle. + * + * If the object becomes unreachable the callback is invoked with the + * the peer as argument. The callback can be executed on any thread, will have + * an isolate group, but will not have a current isolate. The callback can only + * call Dart_DeletePersistentHandle or Dart_DeleteWeakPersistentHandle. + * This gives the embedder the ability to cleanup data associated with the + * object and clear out any cached references to the handle. All references to + * this handle after the callback will be invalid. It is illegal to call into + * the VM with any other Dart_* functions from the callback. If the handle is + * deleted before the object becomes unreachable, the callback is never + * invoked. + * + * Requires there to be a current isolate. + * + * \param object An object. + * \param peer A pointer to a native object or NULL. This value is + * provided to callback when it is invoked. + * \param external_allocation_size The number of externally allocated + * bytes for peer. Used to inform the garbage collector. + * \param callback A function pointer that will be invoked sometime + * after the object is garbage collected, unless the handle has been deleted. + * A valid callback needs to be specified it cannot be NULL. + * + * \return The finalizable handle or NULL. NULL is returned in case of bad + * parameters. + */ +DART_EXPORT Dart_FinalizableHandle +Dart_NewFinalizableHandle(Dart_Handle object, + void* peer, + intptr_t external_allocation_size, + Dart_HandleFinalizer callback); + +/** + * Deletes the given finalizable [object] handle. + * + * The caller has to provide the actual Dart object the handle was created from + * to prove the object (and therefore the finalizable handle) is still alive. + * + * Requires there to be a current isolate. + */ +DART_EXPORT void Dart_DeleteFinalizableHandle(Dart_FinalizableHandle object, + Dart_Handle strong_ref_to_object); + +/** + * Updates the external memory size for the given finalizable handle. + * + * The caller has to provide the actual Dart object the handle was created from + * to prove the object (and therefore the finalizable handle) is still alive. + * + * May trigger garbage collection. + */ +DART_EXPORT void Dart_UpdateFinalizableExternalSize( + Dart_FinalizableHandle object, + Dart_Handle strong_ref_to_object, + intptr_t external_allocation_size); + +/* + * ========================== + * Initialization and Globals + * ========================== + */ + +/** + * Gets the version string for the Dart VM. + * + * The version of the Dart VM can be accessed without initializing the VM. + * + * \return The version string for the embedded Dart VM. + */ +DART_EXPORT const char* Dart_VersionString(); + +/** + * Isolate specific flags are set when creating a new isolate using the + * Dart_IsolateFlags structure. + * + * Current version of flags is encoded in a 32-bit integer with 16 bits used + * for each part. + */ + +#define DART_FLAGS_CURRENT_VERSION (0x0000000c) + +typedef struct { + int32_t version; + bool enable_asserts; + bool use_field_guards; + bool use_osr; + bool obfuscate; + bool load_vmservice_library; + bool copy_parent_code; + bool null_safety; + bool is_system_isolate; +} Dart_IsolateFlags; + +/** + * Initialize Dart_IsolateFlags with correct version and default values. + */ +DART_EXPORT void Dart_IsolateFlagsInitialize(Dart_IsolateFlags* flags); + +/** + * An isolate creation and initialization callback function. + * + * This callback, provided by the embedder, is called when the VM + * needs to create an isolate. The callback should create an isolate + * by calling Dart_CreateIsolateGroup and load any scripts required for + * execution. + * + * This callback may be called on a different thread than the one + * running the parent isolate. + * + * When the function returns NULL, it is the responsibility of this + * function to ensure that Dart_ShutdownIsolate has been called if + * required (for example, if the isolate was created successfully by + * Dart_CreateIsolateGroup() but the root library fails to load + * successfully, then the function should call Dart_ShutdownIsolate + * before returning). + * + * When the function returns NULL, the function should set *error to + * a malloc-allocated buffer containing a useful error message. The + * caller of this function (the VM) will make sure that the buffer is + * freed. + * + * \param script_uri The uri of the main source file or snapshot to load. + * Either the URI of the parent isolate set in Dart_CreateIsolateGroup for + * Isolate.spawn, or the argument to Isolate.spawnUri canonicalized by the + * library tag handler of the parent isolate. + * The callback is responsible for loading the program by a call to + * Dart_LoadScriptFromKernel. + * \param main The name of the main entry point this isolate will + * eventually run. This is provided for advisory purposes only to + * improve debugging messages. The main function is not invoked by + * this function. + * \param package_root Ignored. + * \param package_config Uri of the package configuration file (either in format + * of .packages or .dart_tool/package_config.json) for this isolate + * to resolve package imports against. If this parameter is not passed the + * package resolution of the parent isolate should be used. + * \param flags Default flags for this isolate being spawned. Either inherited + * from the spawning isolate or passed as parameters when spawning the + * isolate from Dart code. + * \param isolate_data The isolate data which was passed to the + * parent isolate when it was created by calling Dart_CreateIsolateGroup(). + * \param error A structure into which the embedder can place a + * C string containing an error message in the case of failures. + * + * \return The embedder returns NULL if the creation and + * initialization was not successful and the isolate if successful. + */ +typedef Dart_Isolate (*Dart_IsolateGroupCreateCallback)( + const char* script_uri, + const char* main, + const char* package_root, + const char* package_config, + Dart_IsolateFlags* flags, + void* isolate_data, + char** error); + +/** + * An isolate initialization callback function. + * + * This callback, provided by the embedder, is called when the VM has created an + * isolate within an existing isolate group (i.e. from the same source as an + * existing isolate). + * + * The callback should setup native resolvers and might want to set a custom + * message handler via [Dart_SetMessageNotifyCallback] and mark the isolate as + * runnable. + * + * This callback may be called on a different thread than the one + * running the parent isolate. + * + * When the function returns `false`, it is the responsibility of this + * function to ensure that `Dart_ShutdownIsolate` has been called. + * + * When the function returns `false`, the function should set *error to + * a malloc-allocated buffer containing a useful error message. The + * caller of this function (the VM) will make sure that the buffer is + * freed. + * + * \param child_isolate_data The callback data to associate with the new + * child isolate. + * \param error A structure into which the embedder can place a + * C string containing an error message in the case the initialization fails. + * + * \return The embedder returns true if the initialization was successful and + * false otherwise (in which case the VM will terminate the isolate). + */ +typedef bool (*Dart_InitializeIsolateCallback)(void** child_isolate_data, + char** error); + +/** + * An isolate unhandled exception callback function. + * + * This callback has been DEPRECATED. + */ +typedef void (*Dart_IsolateUnhandledExceptionCallback)(Dart_Handle error); + +/** + * An isolate shutdown callback function. + * + * This callback, provided by the embedder, is called before the vm + * shuts down an isolate. The isolate being shutdown will be the current + * isolate. It is safe to run Dart code. + * + * This function should be used to dispose of native resources that + * are allocated to an isolate in order to avoid leaks. + * + * \param isolate_group_data The same callback data which was passed to the + * isolate group when it was created. + * \param isolate_data The same callback data which was passed to the isolate + * when it was created. + */ +typedef void (*Dart_IsolateShutdownCallback)(void* isolate_group_data, + void* isolate_data); + +/** + * An isolate cleanup callback function. + * + * This callback, provided by the embedder, is called after the vm + * shuts down an isolate. There will be no current isolate and it is *not* + * safe to run Dart code. + * + * This function should be used to dispose of native resources that + * are allocated to an isolate in order to avoid leaks. + * + * \param isolate_group_data The same callback data which was passed to the + * isolate group when it was created. + * \param isolate_data The same callback data which was passed to the isolate + * when it was created. + */ +typedef void (*Dart_IsolateCleanupCallback)(void* isolate_group_data, + void* isolate_data); + +/** + * An isolate group cleanup callback function. + * + * This callback, provided by the embedder, is called after the vm + * shuts down an isolate group. + * + * This function should be used to dispose of native resources that + * are allocated to an isolate in order to avoid leaks. + * + * \param isolate_group_data The same callback data which was passed to the + * isolate group when it was created. + * + */ +typedef void (*Dart_IsolateGroupCleanupCallback)(void* isolate_group_data); + +/** + * A thread death callback function. + * This callback, provided by the embedder, is called before a thread in the + * vm thread pool exits. + * This function could be used to dispose of native resources that + * are associated and attached to the thread, in order to avoid leaks. + */ +typedef void (*Dart_ThreadExitCallback)(); + +/** + * Callbacks provided by the embedder for file operations. If the + * embedder does not allow file operations these callbacks can be + * NULL. + * + * Dart_FileOpenCallback - opens a file for reading or writing. + * \param name The name of the file to open. + * \param write A boolean variable which indicates if the file is to + * opened for writing. If there is an existing file it needs to truncated. + * + * Dart_FileReadCallback - Read contents of file. + * \param data Buffer allocated in the callback into which the contents + * of the file are read into. It is the responsibility of the caller to + * free this buffer. + * \param file_length A variable into which the length of the file is returned. + * In the case of an error this value would be -1. + * \param stream Handle to the opened file. + * + * Dart_FileWriteCallback - Write data into file. + * \param data Buffer which needs to be written into the file. + * \param length Length of the buffer. + * \param stream Handle to the opened file. + * + * Dart_FileCloseCallback - Closes the opened file. + * \param stream Handle to the opened file. + * + */ +typedef void* (*Dart_FileOpenCallback)(const char* name, bool write); + +typedef void (*Dart_FileReadCallback)(uint8_t** data, + intptr_t* file_length, + void* stream); + +typedef void (*Dart_FileWriteCallback)(const void* data, + intptr_t length, + void* stream); + +typedef void (*Dart_FileCloseCallback)(void* stream); + +typedef bool (*Dart_EntropySource)(uint8_t* buffer, intptr_t length); + +/** + * Callback provided by the embedder that is used by the vmservice isolate + * to request the asset archive. The asset archive must be an uncompressed tar + * archive that is stored in a Uint8List. + * + * If the embedder has no vmservice isolate assets, the callback can be NULL. + * + * \return The embedder must return a handle to a Uint8List containing an + * uncompressed tar archive or null. + */ +typedef Dart_Handle (*Dart_GetVMServiceAssetsArchive)(); + +/** + * The current version of the Dart_InitializeFlags. Should be incremented every + * time Dart_InitializeFlags changes in a binary incompatible way. + */ +#define DART_INITIALIZE_PARAMS_CURRENT_VERSION (0x00000004) + +/** Forward declaration */ +struct Dart_CodeObserver; + +/** + * Callback provided by the embedder that is used by the VM to notify on code + * object creation, *before* it is invoked the first time. + * This is useful for embedders wanting to e.g. keep track of PCs beyond + * the lifetime of the garbage collected code objects. + * Note that an address range may be used by more than one code object over the + * lifecycle of a process. Clients of this function should record timestamps for + * these compilation events and when collecting PCs to disambiguate reused + * address ranges. + */ +typedef void (*Dart_OnNewCodeCallback)(struct Dart_CodeObserver* observer, + const char* name, + uintptr_t base, + uintptr_t size); + +typedef struct Dart_CodeObserver { + void* data; + + Dart_OnNewCodeCallback on_new_code; +} Dart_CodeObserver; + +/** + * Describes how to initialize the VM. Used with Dart_Initialize. + * + * \param version Identifies the version of the struct used by the client. + * should be initialized to DART_INITIALIZE_PARAMS_CURRENT_VERSION. + * \param vm_isolate_snapshot A buffer containing a snapshot of the VM isolate + * or NULL if no snapshot is provided. If provided, the buffer must remain + * valid until Dart_Cleanup returns. + * \param instructions_snapshot A buffer containing a snapshot of precompiled + * instructions, or NULL if no snapshot is provided. If provided, the buffer + * must remain valid until Dart_Cleanup returns. + * \param initialize_isolate A function to be called during isolate + * initialization inside an existing isolate group. + * See Dart_InitializeIsolateCallback. + * \param create_group A function to be called during isolate group creation. + * See Dart_IsolateGroupCreateCallback. + * \param shutdown A function to be called right before an isolate is shutdown. + * See Dart_IsolateShutdownCallback. + * \param cleanup A function to be called after an isolate was shutdown. + * See Dart_IsolateCleanupCallback. + * \param cleanup_group A function to be called after an isolate group is shutdown. + * See Dart_IsolateGroupCleanupCallback. + * \param get_service_assets A function to be called by the service isolate when + * it requires the vmservice assets archive. + * See Dart_GetVMServiceAssetsArchive. + * \param code_observer An external code observer callback function. + * The observer can be invoked as early as during the Dart_Initialize() call. + */ +typedef struct { + int32_t version; + const uint8_t* vm_snapshot_data; + const uint8_t* vm_snapshot_instructions; + Dart_IsolateGroupCreateCallback create_group; + Dart_InitializeIsolateCallback initialize_isolate; + Dart_IsolateShutdownCallback shutdown_isolate; + Dart_IsolateCleanupCallback cleanup_isolate; + Dart_IsolateGroupCleanupCallback cleanup_group; + Dart_ThreadExitCallback thread_exit; + Dart_FileOpenCallback file_open; + Dart_FileReadCallback file_read; + Dart_FileWriteCallback file_write; + Dart_FileCloseCallback file_close; + Dart_EntropySource entropy_source; + Dart_GetVMServiceAssetsArchive get_service_assets; + bool start_kernel_isolate; + Dart_CodeObserver* code_observer; +} Dart_InitializeParams; + +/** + * Initializes the VM. + * + * \param params A struct containing initialization information. The version + * field of the struct must be DART_INITIALIZE_PARAMS_CURRENT_VERSION. + * + * \return NULL if initialization is successful. Returns an error message + * otherwise. The caller is responsible for freeing the error message. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT char* Dart_Initialize( + Dart_InitializeParams* params); + +/** + * Cleanup state in the VM before process termination. + * + * \return NULL if cleanup is successful. Returns an error message otherwise. + * The caller is responsible for freeing the error message. + * + * NOTE: This function must not be called on a thread that was created by the VM + * itself. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT char* Dart_Cleanup(); + +/** + * Sets command line flags. Should be called before Dart_Initialize. + * + * \param argc The length of the arguments array. + * \param argv An array of arguments. + * + * \return NULL if successful. Returns an error message otherwise. + * The caller is responsible for freeing the error message. + * + * NOTE: This call does not store references to the passed in c-strings. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT char* Dart_SetVMFlags(int argc, + const char** argv); + +/** + * Returns true if the named VM flag is of boolean type, specified, and set to + * true. + * + * \param flag_name The name of the flag without leading punctuation + * (example: "enable_asserts"). + */ +DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name); + +/* + * ======== + * Isolates + * ======== + */ + +/** + * Creates a new isolate. The new isolate becomes the current isolate. + * + * A snapshot can be used to restore the VM quickly to a saved state + * and is useful for fast startup. If snapshot data is provided, the + * isolate will be started using that snapshot data. Requires a core snapshot or + * an app snapshot created by Dart_CreateSnapshot or + * Dart_CreatePrecompiledSnapshot* from a VM with the same version. + * + * Requires there to be no current isolate. + * + * \param script_uri The main source file or snapshot this isolate will load. + * The VM will provide this URI to the Dart_IsolateGroupCreateCallback when a child + * isolate is created by Isolate.spawn. The embedder should use a URI that + * allows it to load the same program into such a child isolate. + * \param name A short name for the isolate to improve debugging messages. + * Typically of the format 'foo.dart:main()'. + * \param isolate_snapshot_data + * \param isolate_snapshot_instructions Buffers containing a snapshot of the + * isolate or NULL if no snapshot is provided. If provided, the buffers must + * remain valid until the isolate shuts down. + * \param flags Pointer to VM specific flags or NULL for default flags. + * \param isolate_group_data Embedder group data. This data can be obtained + * by calling Dart_IsolateGroupData and will be passed to the + * Dart_IsolateShutdownCallback, Dart_IsolateCleanupCallback, and + * Dart_IsolateGroupCleanupCallback. + * \param isolate_data Embedder data. This data will be passed to + * the Dart_IsolateGroupCreateCallback when new isolates are spawned from + * this parent isolate. + * \param error Returns NULL if creation is successful, an error message + * otherwise. The caller is responsible for calling free() on the error + * message. + * + * \return The new isolate on success, or NULL if isolate creation failed. + */ +DART_EXPORT Dart_Isolate +Dart_CreateIsolateGroup(const char* script_uri, + const char* name, + const uint8_t* isolate_snapshot_data, + const uint8_t* isolate_snapshot_instructions, + Dart_IsolateFlags* flags, + void* isolate_group_data, + void* isolate_data, + char** error); +/** + * Creates a new isolate inside the isolate group of [group_member]. + * + * Requires there to be no current isolate. + * + * \param group_member An isolate from the same group into which the newly created + * isolate should be born into. Other threads may not have entered / enter this + * member isolate. + * \param name A short name for the isolate for debugging purposes. + * \param shutdown_callback A callback to be called when the isolate is being + * shutdown (may be NULL). + * \param cleanup_callback A callback to be called when the isolate is being + * cleaned up (may be NULL). + * \param isolate_data The embedder-specific data associated with this isolate. + * \param error Set to NULL if creation is successful, set to an error + * message otherwise. The caller is responsible for calling free() on the + * error message. + * + * \return The newly created isolate on success, or NULL if isolate creation + * failed. + * + * If successful, the newly created isolate will become the current isolate. + */ +DART_EXPORT Dart_Isolate +Dart_CreateIsolateInGroup(Dart_Isolate group_member, + const char* name, + Dart_IsolateShutdownCallback shutdown_callback, + Dart_IsolateCleanupCallback cleanup_callback, + void* child_isolate_data, + char** error); + +/* TODO(turnidge): Document behavior when there is already a current + * isolate. */ + +/** + * Creates a new isolate from a Dart Kernel file. The new isolate + * becomes the current isolate. + * + * Requires there to be no current isolate. + * + * \param script_uri The main source file or snapshot this isolate will load. + * The VM will provide this URI to the Dart_IsolateGroupCreateCallback when a child + * isolate is created by Isolate.spawn. The embedder should use a URI that + * allows it to load the same program into such a child isolate. + * \param name A short name for the isolate to improve debugging messages. + * Typically of the format 'foo.dart:main()'. + * \param kernel_buffer + * \param kernel_buffer_size A buffer which contains a kernel/DIL program. Must + * remain valid until isolate shutdown. + * \param flags Pointer to VM specific flags or NULL for default flags. + * \param isolate_group_data Embedder group data. This data can be obtained + * by calling Dart_IsolateGroupData and will be passed to the + * Dart_IsolateShutdownCallback, Dart_IsolateCleanupCallback, and + * Dart_IsolateGroupCleanupCallback. + * \param isolate_data Embedder data. This data will be passed to + * the Dart_IsolateGroupCreateCallback when new isolates are spawned from + * this parent isolate. + * \param error Returns NULL if creation is successful, an error message + * otherwise. The caller is responsible for calling free() on the error + * message. + * + * \return The new isolate on success, or NULL if isolate creation failed. + */ +DART_EXPORT Dart_Isolate +Dart_CreateIsolateGroupFromKernel(const char* script_uri, + const char* name, + const uint8_t* kernel_buffer, + intptr_t kernel_buffer_size, + Dart_IsolateFlags* flags, + void* isolate_group_data, + void* isolate_data, + char** error); +/** + * Shuts down the current isolate. After this call, the current isolate is NULL. + * Any current scopes created by Dart_EnterScope will be exited. Invokes the + * shutdown callback and any callbacks of remaining weak persistent handles. + * + * Requires there to be a current isolate. + */ +DART_EXPORT void Dart_ShutdownIsolate(); +/* TODO(turnidge): Document behavior when there is no current isolate. */ + +/** + * Returns the current isolate. Will return NULL if there is no + * current isolate. + */ +DART_EXPORT Dart_Isolate Dart_CurrentIsolate(); + +/** + * Returns the callback data associated with the current isolate. This + * data was set when the isolate got created or initialized. + */ +DART_EXPORT void* Dart_CurrentIsolateData(); + +/** + * Returns the callback data associated with the given isolate. This + * data was set when the isolate got created or initialized. + */ +DART_EXPORT void* Dart_IsolateData(Dart_Isolate isolate); + +/** + * Returns the current isolate group. Will return NULL if there is no + * current isolate group. + */ +DART_EXPORT Dart_IsolateGroup Dart_CurrentIsolateGroup(); + +/** + * Returns the callback data associated with the current isolate group. This + * data was passed to the isolate group when it was created. + */ +DART_EXPORT void* Dart_CurrentIsolateGroupData(); + +/** + * Returns the callback data associated with the specified isolate group. This + * data was passed to the isolate when it was created. + * The embedder is responsible for ensuring the consistency of this data + * with respect to the lifecycle of an isolate group. + */ +DART_EXPORT void* Dart_IsolateGroupData(Dart_Isolate isolate); + +/** + * Returns the debugging name for the current isolate. + * + * This name is unique to each isolate and should only be used to make + * debugging messages more comprehensible. + */ +DART_EXPORT Dart_Handle Dart_DebugName(); + +/** + * Returns the ID for an isolate which is used to query the service protocol. + * + * It is the responsibility of the caller to free the returned ID. + */ +DART_EXPORT const char* Dart_IsolateServiceId(Dart_Isolate isolate); + +/** + * Enters an isolate. After calling this function, + * the current isolate will be set to the provided isolate. + * + * Requires there to be no current isolate. Multiple threads may not be in + * the same isolate at once. + */ +DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate); + +/** + * Kills the given isolate. + * + * This function has the same effect as dart:isolate's + * Isolate.kill(priority:immediate). + * It can interrupt ordinary Dart code but not native code. If the isolate is + * in the middle of a long running native function, the isolate will not be + * killed until control returns to Dart. + * + * Does not require a current isolate. It is safe to kill the current isolate if + * there is one. + */ +DART_EXPORT void Dart_KillIsolate(Dart_Isolate isolate); + +/** + * Notifies the VM that the embedder expects |size| bytes of memory have become + * unreachable. The VM may use this hint to adjust the garbage collector's + * growth policy. + * + * Multiple calls are interpreted as increasing, not replacing, the estimate of + * unreachable memory. + * + * Requires there to be a current isolate. + */ +DART_EXPORT void Dart_HintFreed(intptr_t size); + +/** + * Notifies the VM that the embedder expects to be idle until |deadline|. The VM + * may use this time to perform garbage collection or other tasks to avoid + * delays during execution of Dart code in the future. + * + * |deadline| is measured in microseconds against the system's monotonic time. + * This clock can be accessed via Dart_TimelineGetMicros(). + * + * Requires there to be a current isolate. + */ +DART_EXPORT void Dart_NotifyIdle(int64_t deadline); + +/** + * Notifies the VM that the system is running low on memory. + * + * Does not require a current isolate. Only valid after calling Dart_Initialize. + */ +DART_EXPORT void Dart_NotifyLowMemory(); + +/** + * Starts the CPU sampling profiler. + */ +DART_EXPORT void Dart_StartProfiling(); + +/** + * Stops the CPU sampling profiler. + * + * Note that some profile samples might still be taken after this fucntion + * returns due to the asynchronous nature of the implementation on some + * platforms. + */ +DART_EXPORT void Dart_StopProfiling(); + +/** + * Notifies the VM that the current thread should not be profiled until a + * matching call to Dart_ThreadEnableProfiling is made. + * + * NOTE: By default, if a thread has entered an isolate it will be profiled. + * This function should be used when an embedder knows a thread is about + * to make a blocking call and wants to avoid unnecessary interrupts by + * the profiler. + */ +DART_EXPORT void Dart_ThreadDisableProfiling(); + +/** + * Notifies the VM that the current thread should be profiled. + * + * NOTE: It is only legal to call this function *after* calling + * Dart_ThreadDisableProfiling. + * + * NOTE: By default, if a thread has entered an isolate it will be profiled. + */ +DART_EXPORT void Dart_ThreadEnableProfiling(); + +/** + * Register symbol information for the Dart VM's profiler and crash dumps. + * + * This consumes the output of //topaz/runtime/dart/profiler_symbols, which + * should be treated as opaque. + */ +DART_EXPORT void Dart_AddSymbols(const char* dso_name, + void* buffer, + intptr_t buffer_size); + +/** + * Exits an isolate. After this call, Dart_CurrentIsolate will + * return NULL. + * + * Requires there to be a current isolate. + */ +DART_EXPORT void Dart_ExitIsolate(); +/* TODO(turnidge): We don't want users of the api to be able to exit a + * "pure" dart isolate. Implement and document. */ + +/** + * Creates a full snapshot of the current isolate heap. + * + * A full snapshot is a compact representation of the dart vm isolate heap + * and dart isolate heap states. These snapshots are used to initialize + * the vm isolate on startup and fast initialization of an isolate. + * A Snapshot of the heap is created before any dart code has executed. + * + * Requires there to be a current isolate. Not available in the precompiled + * runtime (check Dart_IsPrecompiledRuntime). + * + * \param buffer Returns a pointer to a buffer containing the + * snapshot. This buffer is scope allocated and is only valid + * until the next call to Dart_ExitScope. + * \param size Returns the size of the buffer. + * \param is_core Create a snapshot containing core libraries. + * Such snapshot should be agnostic to null safety mode. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_CreateSnapshot(uint8_t** vm_snapshot_data_buffer, + intptr_t* vm_snapshot_data_size, + uint8_t** isolate_snapshot_data_buffer, + intptr_t* isolate_snapshot_data_size, + bool is_core); + +/** + * Returns whether the buffer contains a kernel file. + * + * \param buffer Pointer to a buffer that might contain a kernel binary. + * \param buffer_size Size of the buffer. + * + * \return Whether the buffer contains a kernel binary (full or partial). + */ +DART_EXPORT bool Dart_IsKernel(const uint8_t* buffer, intptr_t buffer_size); + +/** + * Make isolate runnable. + * + * When isolates are spawned, this function is used to indicate that + * the creation and initialization (including script loading) of the + * isolate is complete and the isolate can start. + * This function expects there to be no current isolate. + * + * \param isolate The isolate to be made runnable. + * + * \return NULL if successful. Returns an error message otherwise. The caller + * is responsible for freeing the error message. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT char* Dart_IsolateMakeRunnable( + Dart_Isolate isolate); + +/* + * ================== + * Messages and Ports + * ================== + */ + +/** + * A port is used to send or receive inter-isolate messages + */ +typedef int64_t Dart_Port; + +/** + * ILLEGAL_PORT is a port number guaranteed never to be associated with a valid + * port. + */ +#define ILLEGAL_PORT ((Dart_Port)0) + +/** + * A message notification callback. + * + * This callback allows the embedder to provide an alternate wakeup + * mechanism for the delivery of inter-isolate messages. It is the + * responsibility of the embedder to call Dart_HandleMessage to + * process the message. + */ +typedef void (*Dart_MessageNotifyCallback)(Dart_Isolate dest_isolate); + +/** + * Allows embedders to provide an alternative wakeup mechanism for the + * delivery of inter-isolate messages. This setting only applies to + * the current isolate. + * + * Most embedders will only call this function once, before isolate + * execution begins. If this function is called after isolate + * execution begins, the embedder is responsible for threading issues. + */ +DART_EXPORT void Dart_SetMessageNotifyCallback( + Dart_MessageNotifyCallback message_notify_callback); +/* TODO(turnidge): Consider moving this to isolate creation so that it + * is impossible to mess up. */ + +/** + * Query the current message notify callback for the isolate. + * + * \return The current message notify callback for the isolate. + */ +DART_EXPORT Dart_MessageNotifyCallback Dart_GetMessageNotifyCallback(); + +/** + * The VM's default message handler supports pausing an isolate before it + * processes the first message and right after the it processes the isolate's + * final message. This can be controlled for all isolates by two VM flags: + * + * `--pause-isolates-on-start` + * `--pause-isolates-on-exit` + * + * Additionally, Dart_SetShouldPauseOnStart and Dart_SetShouldPauseOnExit can be + * used to control this behaviour on a per-isolate basis. + * + * When an embedder is using a Dart_MessageNotifyCallback the embedder + * needs to cooperate with the VM so that the service protocol can report + * accurate information about isolates and so that tools such as debuggers + * work reliably. + * + * The following functions can be used to implement pausing on start and exit. + */ + +/** + * If the VM flag `--pause-isolates-on-start` was passed this will be true. + * + * \return A boolean value indicating if pause on start was requested. + */ +DART_EXPORT bool Dart_ShouldPauseOnStart(); + +/** + * Override the VM flag `--pause-isolates-on-start` for the current isolate. + * + * \param should_pause Should the isolate be paused on start? + * + * NOTE: This must be called before Dart_IsolateMakeRunnable. + */ +DART_EXPORT void Dart_SetShouldPauseOnStart(bool should_pause); + +/** + * Is the current isolate paused on start? + * + * \return A boolean value indicating if the isolate is paused on start. + */ +DART_EXPORT bool Dart_IsPausedOnStart(); + +/** + * Called when the embedder has paused the current isolate on start and when + * the embedder has resumed the isolate. + * + * \param paused Is the isolate paused on start? + */ +DART_EXPORT void Dart_SetPausedOnStart(bool paused); + +/** + * If the VM flag `--pause-isolates-on-exit` was passed this will be true. + * + * \return A boolean value indicating if pause on exit was requested. + */ +DART_EXPORT bool Dart_ShouldPauseOnExit(); + +/** + * Override the VM flag `--pause-isolates-on-exit` for the current isolate. + * + * \param should_pause Should the isolate be paused on exit? + * + */ +DART_EXPORT void Dart_SetShouldPauseOnExit(bool should_pause); + +/** + * Is the current isolate paused on exit? + * + * \return A boolean value indicating if the isolate is paused on exit. + */ +DART_EXPORT bool Dart_IsPausedOnExit(); + +/** + * Called when the embedder has paused the current isolate on exit and when + * the embedder has resumed the isolate. + * + * \param paused Is the isolate paused on exit? + */ +DART_EXPORT void Dart_SetPausedOnExit(bool paused); + +/** + * Called when the embedder has caught a top level unhandled exception error + * in the current isolate. + * + * NOTE: It is illegal to call this twice on the same isolate without first + * clearing the sticky error to null. + * + * \param error The unhandled exception error. + */ +DART_EXPORT void Dart_SetStickyError(Dart_Handle error); + +/** + * Does the current isolate have a sticky error? + */ +DART_EXPORT bool Dart_HasStickyError(); + +/** + * Gets the sticky error for the current isolate. + * + * \return A handle to the sticky error object or null. + */ +DART_EXPORT Dart_Handle Dart_GetStickyError(); + +/** + * Handles the next pending message for the current isolate. + * + * May generate an unhandled exception error. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_HandleMessage(); + +/** + * Drains the microtask queue, then blocks the calling thread until the current + * isolate recieves a message, then handles all messages. + * + * \param timeout_millis When non-zero, the call returns after the indicated + number of milliseconds even if no message was received. + * \return A valid handle if no error occurs, otherwise an error handle. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_WaitForEvent(int64_t timeout_millis); + +/** + * Handles any pending messages for the vm service for the current + * isolate. + * + * This function may be used by an embedder at a breakpoint to avoid + * pausing the vm service. + * + * This function can indirectly cause the message notify callback to + * be called. + * + * \return true if the vm service requests the program resume + * execution, false otherwise + */ +DART_EXPORT bool Dart_HandleServiceMessages(); + +/** + * Does the current isolate have pending service messages? + * + * \return true if the isolate has pending service messages, false otherwise. + */ +DART_EXPORT bool Dart_HasServiceMessages(); + +/** + * Processes any incoming messages for the current isolate. + * + * This function may only be used when the embedder has not provided + * an alternate message delivery mechanism with + * Dart_SetMessageCallbacks. It is provided for convenience. + * + * This function waits for incoming messages for the current + * isolate. As new messages arrive, they are handled using + * Dart_HandleMessage. The routine exits when all ports to the + * current isolate are closed. + * + * \return A valid handle if the run loop exited successfully. If an + * exception or other error occurs while processing messages, an + * error handle is returned. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_RunLoop(); + +/** + * Lets the VM run message processing for the isolate. + * + * This function expects there to a current isolate and the current isolate + * must not have an active api scope. The VM will take care of making the + * isolate runnable (if not already), handles its message loop and will take + * care of shutting the isolate down once it's done. + * + * \param errors_are_fatal Whether uncaught errors should be fatal. + * \param on_error_port A port to notify on uncaught errors (or ILLEGAL_PORT). + * \param on_exit_port A port to notify on exit (or ILLEGAL_PORT). + * \param error A non-NULL pointer which will hold an error message if the call + * fails. The error has to be free()ed by the caller. + * + * \return If successfull the VM takes owernship of the isolate and takes care + * of its message loop. If not successful the caller retains owernship of the + * isolate. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT bool Dart_RunLoopAsync( + bool errors_are_fatal, + Dart_Port on_error_port, + Dart_Port on_exit_port, + char** error); + +/* TODO(turnidge): Should this be removed from the public api? */ + +/** + * Gets the main port id for the current isolate. + */ +DART_EXPORT Dart_Port Dart_GetMainPortId(); + +/** + * Does the current isolate have live ReceivePorts? + * + * A ReceivePort is live when it has not been closed. + */ +DART_EXPORT bool Dart_HasLivePorts(); + +/** + * Posts a message for some isolate. The message is a serialized + * object. + * + * Requires there to be a current isolate. + * + * \param port The destination port. + * \param object An object from the current isolate. + * + * \return True if the message was posted. + */ +DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle object); + +/** + * Returns a new SendPort with the provided port id. + * + * \param port_id The destination port. + * + * \return A new SendPort if no errors occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id); + +/** + * Gets the SendPort id for the provided SendPort. + * \param port A SendPort object whose id is desired. + * \param port_id Returns the id of the SendPort. + * \return Success if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_SendPortGetId(Dart_Handle port, + Dart_Port* port_id); + +/* + * ====== + * Scopes + * ====== + */ + +/** + * Enters a new scope. + * + * All new local handles will be created in this scope. Additionally, + * some functions may return "scope allocated" memory which is only + * valid within this scope. + * + * Requires there to be a current isolate. + */ +DART_EXPORT void Dart_EnterScope(); + +/** + * Exits a scope. + * + * The previous scope (if any) becomes the current scope. + * + * Requires there to be a current isolate. + */ +DART_EXPORT void Dart_ExitScope(); + +/** + * The Dart VM uses "zone allocation" for temporary structures. Zones + * support very fast allocation of small chunks of memory. The chunks + * cannot be deallocated individually, but instead zones support + * deallocating all chunks in one fast operation. + * + * This function makes it possible for the embedder to allocate + * temporary data in the VMs zone allocator. + * + * Zone allocation is possible: + * 1. when inside a scope where local handles can be allocated + * 2. when processing a message from a native port in a native port + * handler + * + * All the memory allocated this way will be reclaimed either on the + * next call to Dart_ExitScope or when the native port handler exits. + * + * \param size Size of the memory to allocate. + * + * \return A pointer to the allocated memory. NULL if allocation + * failed. Failure might due to is no current VM zone. + */ +DART_EXPORT uint8_t* Dart_ScopeAllocate(intptr_t size); + +/* + * ======= + * Objects + * ======= + */ + +/** + * Returns the null object. + * + * \return A handle to the null object. + */ +DART_EXPORT Dart_Handle Dart_Null(); + +/** + * Is this object null? + */ +DART_EXPORT bool Dart_IsNull(Dart_Handle object); + +/** + * Returns the empty string object. + * + * \return A handle to the empty string object. + */ +DART_EXPORT Dart_Handle Dart_EmptyString(); + +/** + * Returns types that are not classes, and which therefore cannot be looked up + * as library members by Dart_GetType. + * + * \return A handle to the dynamic, void or Never type. + */ +DART_EXPORT Dart_Handle Dart_TypeDynamic(); +DART_EXPORT Dart_Handle Dart_TypeVoid(); +DART_EXPORT Dart_Handle Dart_TypeNever(); + +/** + * Checks if the two objects are equal. + * + * The result of the comparison is returned through the 'equal' + * parameter. The return value itself is used to indicate success or + * failure, not equality. + * + * May generate an unhandled exception error. + * + * \param obj1 An object to be compared. + * \param obj2 An object to be compared. + * \param equal Returns the result of the equality comparison. + * + * \return A valid handle if no error occurs during the comparison. + */ +DART_EXPORT Dart_Handle Dart_ObjectEquals(Dart_Handle obj1, + Dart_Handle obj2, + bool* equal); + +/** + * Is this object an instance of some type? + * + * The result of the test is returned through the 'instanceof' parameter. + * The return value itself is used to indicate success or failure. + * + * \param object An object. + * \param type A type. + * \param instanceof Return true if 'object' is an instance of type 'type'. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT Dart_Handle Dart_ObjectIsType(Dart_Handle object, + Dart_Handle type, + bool* instanceof); + +/** + * Query object type. + * + * \param object Some Object. + * + * \return true if Object is of the specified type. + */ +DART_EXPORT bool Dart_IsInstance(Dart_Handle object); +DART_EXPORT bool Dart_IsNumber(Dart_Handle object); +DART_EXPORT bool Dart_IsInteger(Dart_Handle object); +DART_EXPORT bool Dart_IsDouble(Dart_Handle object); +DART_EXPORT bool Dart_IsBoolean(Dart_Handle object); +DART_EXPORT bool Dart_IsString(Dart_Handle object); +DART_EXPORT bool Dart_IsStringLatin1(Dart_Handle object); /* (ISO-8859-1) */ +DART_EXPORT bool Dart_IsExternalString(Dart_Handle object); +DART_EXPORT bool Dart_IsList(Dart_Handle object); +DART_EXPORT bool Dart_IsMap(Dart_Handle object); +DART_EXPORT bool Dart_IsLibrary(Dart_Handle object); +DART_EXPORT bool Dart_IsType(Dart_Handle handle); +DART_EXPORT bool Dart_IsFunction(Dart_Handle handle); +DART_EXPORT bool Dart_IsVariable(Dart_Handle handle); +DART_EXPORT bool Dart_IsTypeVariable(Dart_Handle handle); +DART_EXPORT bool Dart_IsClosure(Dart_Handle object); +DART_EXPORT bool Dart_IsTypedData(Dart_Handle object); +DART_EXPORT bool Dart_IsByteBuffer(Dart_Handle object); +DART_EXPORT bool Dart_IsFuture(Dart_Handle object); + +/* + * ========= + * Instances + * ========= + */ + +/* + * For the purposes of the embedding api, not all objects returned are + * Dart language objects. Within the api, we use the term 'Instance' + * to indicate handles which refer to true Dart language objects. + * + * TODO(turnidge): Reorganize the "Object" section above, pulling down + * any functions that more properly belong here. */ + +/** + * Gets the type of a Dart language object. + * + * \param instance Some Dart object. + * + * \return If no error occurs, the type is returned. Otherwise an + * error handle is returned. + */ +DART_EXPORT Dart_Handle Dart_InstanceGetType(Dart_Handle instance); + +/** + * Returns the name for the provided class type. + * + * \return A valid string handle if no error occurs during the + * operation. + */ +DART_EXPORT Dart_Handle Dart_ClassName(Dart_Handle cls_type); + +/** + * Returns the name for the provided function or method. + * + * \return A valid string handle if no error occurs during the + * operation. + */ +DART_EXPORT Dart_Handle Dart_FunctionName(Dart_Handle function); + +/** + * Returns a handle to the owner of a function. + * + * The owner of an instance method or a static method is its defining + * class. The owner of a top-level function is its defining + * library. The owner of the function of a non-implicit closure is the + * function of the method or closure that defines the non-implicit + * closure. + * + * \return A valid handle to the owner of the function, or an error + * handle if the argument is not a valid handle to a function. + */ +DART_EXPORT Dart_Handle Dart_FunctionOwner(Dart_Handle function); + +/** + * Determines whether a function handle referes to a static function + * of method. + * + * For the purposes of the embedding API, a top-level function is + * implicitly declared static. + * + * \param function A handle to a function or method declaration. + * \param is_static Returns whether the function or method is declared static. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT Dart_Handle Dart_FunctionIsStatic(Dart_Handle function, + bool* is_static); + +/** + * Is this object a closure resulting from a tear-off (closurized method)? + * + * Returns true for closures produced when an ordinary method is accessed + * through a getter call. Returns false otherwise, in particular for closures + * produced from local function declarations. + * + * \param object Some Object. + * + * \return true if Object is a tear-off. + */ +DART_EXPORT bool Dart_IsTearOff(Dart_Handle object); + +/** + * Retrieves the function of a closure. + * + * \return A handle to the function of the closure, or an error handle if the + * argument is not a closure. + */ +DART_EXPORT Dart_Handle Dart_ClosureFunction(Dart_Handle closure); + +/** + * Returns a handle to the library which contains class. + * + * \return A valid handle to the library with owns class, null if the class + * has no library or an error handle if the argument is not a valid handle + * to a class type. + */ +DART_EXPORT Dart_Handle Dart_ClassLibrary(Dart_Handle cls_type); + +/* + * ============================= + * Numbers, Integers and Doubles + * ============================= + */ + +/** + * Does this Integer fit into a 64-bit signed integer? + * + * \param integer An integer. + * \param fits Returns true if the integer fits into a 64-bit signed integer. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer, + bool* fits); + +/** + * Does this Integer fit into a 64-bit unsigned integer? + * + * \param integer An integer. + * \param fits Returns true if the integer fits into a 64-bit unsigned integer. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT Dart_Handle Dart_IntegerFitsIntoUint64(Dart_Handle integer, + bool* fits); + +/** + * Returns an Integer with the provided value. + * + * \param value The value of the integer. + * + * \return The Integer object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value); + +/** + * Returns an Integer with the provided value. + * + * \param value The unsigned value of the integer. + * + * \return The Integer object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_NewIntegerFromUint64(uint64_t value); + +/** + * Returns an Integer with the provided value. + * + * \param value The value of the integer represented as a C string + * containing a hexadecimal number. + * + * \return The Integer object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_NewIntegerFromHexCString(const char* value); + +/** + * Gets the value of an Integer. + * + * The integer must fit into a 64-bit signed integer, otherwise an error occurs. + * + * \param integer An Integer. + * \param value Returns the value of the Integer. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT Dart_Handle Dart_IntegerToInt64(Dart_Handle integer, + int64_t* value); + +/** + * Gets the value of an Integer. + * + * The integer must fit into a 64-bit unsigned integer, otherwise an + * error occurs. + * + * \param integer An Integer. + * \param value Returns the value of the Integer. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT Dart_Handle Dart_IntegerToUint64(Dart_Handle integer, + uint64_t* value); + +/** + * Gets the value of an integer as a hexadecimal C string. + * + * \param integer An Integer. + * \param value Returns the value of the Integer as a hexadecimal C + * string. This C string is scope allocated and is only valid until + * the next call to Dart_ExitScope. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT Dart_Handle Dart_IntegerToHexCString(Dart_Handle integer, + const char** value); + +/** + * Returns a Double with the provided value. + * + * \param value A double. + * + * \return The Double object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_NewDouble(double value); + +/** + * Gets the value of a Double + * + * \param double_obj A Double + * \param value Returns the value of the Double. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT Dart_Handle Dart_DoubleValue(Dart_Handle double_obj, double* value); + +/** + * Returns a closure of static function 'function_name' in the class 'class_name' + * in the exported namespace of specified 'library'. + * + * \param library Library object + * \param cls_type Type object representing a Class + * \param function_name Name of the static function in the class + * + * \return A valid Dart instance if no error occurs during the operation. + */ +DART_EXPORT Dart_Handle Dart_GetStaticMethodClosure(Dart_Handle library, + Dart_Handle cls_type, + Dart_Handle function_name); + +/* + * ======== + * Booleans + * ======== + */ + +/** + * Returns the True object. + * + * Requires there to be a current isolate. + * + * \return A handle to the True object. + */ +DART_EXPORT Dart_Handle Dart_True(); + +/** + * Returns the False object. + * + * Requires there to be a current isolate. + * + * \return A handle to the False object. + */ +DART_EXPORT Dart_Handle Dart_False(); + +/** + * Returns a Boolean with the provided value. + * + * \param value true or false. + * + * \return The Boolean object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_NewBoolean(bool value); + +/** + * Gets the value of a Boolean + * + * \param boolean_obj A Boolean + * \param value Returns the value of the Boolean. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT Dart_Handle Dart_BooleanValue(Dart_Handle boolean_obj, bool* value); + +/* + * ======= + * Strings + * ======= + */ + +/** + * Gets the length of a String. + * + * \param str A String. + * \param length Returns the length of the String. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT Dart_Handle Dart_StringLength(Dart_Handle str, intptr_t* length); + +/** + * Returns a String built from the provided C string + * (There is an implicit assumption that the C string passed in contains + * UTF-8 encoded characters and '\0' is considered as a termination + * character). + * + * \param value A C String + * + * \return The String object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_NewStringFromCString(const char* str); +/* TODO(turnidge): Document what happens when we run out of memory + * during this call. */ + +/** + * Returns a String built from an array of UTF-8 encoded characters. + * + * \param utf8_array An array of UTF-8 encoded characters. + * \param length The length of the codepoints array. + * + * \return The String object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_NewStringFromUTF8(const uint8_t* utf8_array, + intptr_t length); + +/** + * Returns a String built from an array of UTF-16 encoded characters. + * + * \param utf16_array An array of UTF-16 encoded characters. + * \param length The length of the codepoints array. + * + * \return The String object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_NewStringFromUTF16(const uint16_t* utf16_array, + intptr_t length); + +/** + * Returns a String built from an array of UTF-32 encoded characters. + * + * \param utf32_array An array of UTF-32 encoded characters. + * \param length The length of the codepoints array. + * + * \return The String object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_NewStringFromUTF32(const int32_t* utf32_array, + intptr_t length); + +/** + * Returns a String which references an external array of + * Latin-1 (ISO-8859-1) encoded characters. + * + * \param latin1_array Array of Latin-1 encoded characters. This must not move. + * \param length The length of the characters array. + * \param peer An external pointer to associate with this string. + * \param external_allocation_size The number of externally allocated + * bytes for peer. Used to inform the garbage collector. + * \param callback A callback to be called when this string is finalized. + * + * \return The String object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle +Dart_NewExternalLatin1String(const uint8_t* latin1_array, + intptr_t length, + void* peer, + intptr_t external_allocation_size, + Dart_HandleFinalizer callback); + +/** + * Returns a String which references an external array of UTF-16 encoded + * characters. + * + * \param utf16_array An array of UTF-16 encoded characters. This must not move. + * \param length The length of the characters array. + * \param peer An external pointer to associate with this string. + * \param external_allocation_size The number of externally allocated + * bytes for peer. Used to inform the garbage collector. + * \param callback A callback to be called when this string is finalized. + * + * \return The String object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle +Dart_NewExternalUTF16String(const uint16_t* utf16_array, + intptr_t length, + void* peer, + intptr_t external_allocation_size, + Dart_HandleFinalizer callback); + +/** + * Gets the C string representation of a String. + * (It is a sequence of UTF-8 encoded values with a '\0' termination.) + * + * \param str A string. + * \param cstr Returns the String represented as a C string. + * This C string is scope allocated and is only valid until + * the next call to Dart_ExitScope. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle str, + const char** cstr); + +/** + * Gets a UTF-8 encoded representation of a String. + * + * Any unpaired surrogate code points in the string will be converted as + * replacement characters (U+FFFD, 0xEF 0xBF 0xBD in UTF-8). If you need + * to preserve unpaired surrogates, use the Dart_StringToUTF16 function. + * + * \param str A string. + * \param utf8_array Returns the String represented as UTF-8 code + * units. This UTF-8 array is scope allocated and is only valid + * until the next call to Dart_ExitScope. + * \param length Used to return the length of the array which was + * actually used. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT Dart_Handle Dart_StringToUTF8(Dart_Handle str, + uint8_t** utf8_array, + intptr_t* length); + +/** + * Gets the data corresponding to the string object. This function returns + * the data only for Latin-1 (ISO-8859-1) string objects. For all other + * string objects it returns an error. + * + * \param str A string. + * \param latin1_array An array allocated by the caller, used to return + * the string data. + * \param length Used to pass in the length of the provided array. + * Used to return the length of the array which was actually used. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT Dart_Handle Dart_StringToLatin1(Dart_Handle str, + uint8_t* latin1_array, + intptr_t* length); + +/** + * Gets the UTF-16 encoded representation of a string. + * + * \param str A string. + * \param utf16_array An array allocated by the caller, used to return + * the array of UTF-16 encoded characters. + * \param length Used to pass in the length of the provided array. + * Used to return the length of the array which was actually used. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT Dart_Handle Dart_StringToUTF16(Dart_Handle str, + uint16_t* utf16_array, + intptr_t* length); + +/** + * Gets the storage size in bytes of a String. + * + * \param str A String. + * \param length Returns the storage size in bytes of the String. + * This is the size in bytes needed to store the String. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT Dart_Handle Dart_StringStorageSize(Dart_Handle str, intptr_t* size); + +/** + * Retrieves some properties associated with a String. + * Properties retrieved are: + * - character size of the string (one or two byte) + * - length of the string + * - peer pointer of string if it is an external string. + * \param str A String. + * \param char_size Returns the character size of the String. + * \param str_len Returns the length of the String. + * \param peer Returns the peer pointer associated with the String or 0 if + * there is no peer pointer for it. + * \return Success if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_StringGetProperties(Dart_Handle str, + intptr_t* char_size, + intptr_t* str_len, + void** peer); + +/* + * ===== + * Lists + * ===== + */ + +/** + * Returns a List of the desired length. + * + * \param length The length of the list. + * + * \return The List object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_NewList(intptr_t length); + +typedef enum { + Dart_CoreType_Dynamic, + Dart_CoreType_Int, + Dart_CoreType_String, +} Dart_CoreType_Id; + +// TODO(bkonyi): convert this to use nullable types once NNBD is enabled. +/** + * Returns a List of the desired length with the desired legacy element type. + * + * \param element_type_id The type of elements of the list. + * \param length The length of the list. + * + * \return The List object if no error occurs. Otherwise returns an error + * handle. + */ +DART_EXPORT Dart_Handle Dart_NewListOf(Dart_CoreType_Id element_type_id, + intptr_t length); + +/** + * Returns a List of the desired length with the desired element type. + * + * \param element_type Handle to a nullable type object. E.g., from + * Dart_GetType or Dart_GetNullableType. + * + * \param length The length of the list. + * + * \return The List object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_NewListOfType(Dart_Handle element_type, + intptr_t length); + +/** + * Returns a List of the desired length with the desired element type, filled + * with the provided object. + * + * \param element_type Handle to a type object. E.g., from Dart_GetType. + * + * \param fill_object Handle to an object of type 'element_type' that will be + * used to populate the list. This parameter can only be Dart_Null() if the + * length of the list is 0 or 'element_type' is a nullable type. + * + * \param length The length of the list. + * + * \return The List object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_NewListOfTypeFilled(Dart_Handle element_type, + Dart_Handle fill_object, + intptr_t length); + +/** + * Gets the length of a List. + * + * May generate an unhandled exception error. + * + * \param list A List. + * \param length Returns the length of the List. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT Dart_Handle Dart_ListLength(Dart_Handle list, intptr_t* length); + +/** + * Gets the Object at some index of a List. + * + * If the index is out of bounds, an error occurs. + * + * May generate an unhandled exception error. + * + * \param list A List. + * \param index A valid index into the List. + * + * \return The Object in the List at the specified index if no error + * occurs. Otherwise returns an error handle. + */ +DART_EXPORT Dart_Handle Dart_ListGetAt(Dart_Handle list, intptr_t index); + +/** +* Gets a range of Objects from a List. +* +* If any of the requested index values are out of bounds, an error occurs. +* +* May generate an unhandled exception error. +* +* \param list A List. +* \param offset The offset of the first item to get. +* \param length The number of items to get. +* \param result A pointer to fill with the objects. +* +* \return Success if no error occurs during the operation. +*/ +DART_EXPORT Dart_Handle Dart_ListGetRange(Dart_Handle list, + intptr_t offset, + intptr_t length, + Dart_Handle* result); + +/** + * Sets the Object at some index of a List. + * + * If the index is out of bounds, an error occurs. + * + * May generate an unhandled exception error. + * + * \param array A List. + * \param index A valid index into the List. + * \param value The Object to put in the List. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT Dart_Handle Dart_ListSetAt(Dart_Handle list, + intptr_t index, + Dart_Handle value); + +/** + * May generate an unhandled exception error. + */ +DART_EXPORT Dart_Handle Dart_ListGetAsBytes(Dart_Handle list, + intptr_t offset, + uint8_t* native_array, + intptr_t length); + +/** + * May generate an unhandled exception error. + */ +DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list, + intptr_t offset, + const uint8_t* native_array, + intptr_t length); + +/* + * ==== + * Maps + * ==== + */ + +/** + * Gets the Object at some key of a Map. + * + * May generate an unhandled exception error. + * + * \param map A Map. + * \param key An Object. + * + * \return The value in the map at the specified key, null if the map does not + * contain the key, or an error handle. + */ +DART_EXPORT Dart_Handle Dart_MapGetAt(Dart_Handle map, Dart_Handle key); + +/** + * Returns whether the Map contains a given key. + * + * May generate an unhandled exception error. + * + * \param map A Map. + * + * \return A handle on a boolean indicating whether map contains the key. + * Otherwise returns an error handle. + */ +DART_EXPORT Dart_Handle Dart_MapContainsKey(Dart_Handle map, Dart_Handle key); + +/** + * Gets the list of keys of a Map. + * + * May generate an unhandled exception error. + * + * \param map A Map. + * + * \return The list of key Objects if no error occurs. Otherwise returns an + * error handle. + */ +DART_EXPORT Dart_Handle Dart_MapKeys(Dart_Handle map); + +/* + * ========== + * Typed Data + * ========== + */ + +typedef enum { + Dart_TypedData_kByteData = 0, + Dart_TypedData_kInt8, + Dart_TypedData_kUint8, + Dart_TypedData_kUint8Clamped, + Dart_TypedData_kInt16, + Dart_TypedData_kUint16, + Dart_TypedData_kInt32, + Dart_TypedData_kUint32, + Dart_TypedData_kInt64, + Dart_TypedData_kUint64, + Dart_TypedData_kFloat32, + Dart_TypedData_kFloat64, + Dart_TypedData_kInt32x4, + Dart_TypedData_kFloat32x4, + Dart_TypedData_kFloat64x2, + Dart_TypedData_kInvalid +} Dart_TypedData_Type; + +/** + * Return type if this object is a TypedData object. + * + * \return kInvalid if the object is not a TypedData object or the appropriate + * Dart_TypedData_Type. + */ +DART_EXPORT Dart_TypedData_Type Dart_GetTypeOfTypedData(Dart_Handle object); + +/** + * Return type if this object is an external TypedData object. + * + * \return kInvalid if the object is not an external TypedData object or + * the appropriate Dart_TypedData_Type. + */ +DART_EXPORT Dart_TypedData_Type +Dart_GetTypeOfExternalTypedData(Dart_Handle object); + +/** + * Returns a TypedData object of the desired length and type. + * + * \param type The type of the TypedData object. + * \param length The length of the TypedData object (length in type units). + * + * \return The TypedData object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_NewTypedData(Dart_TypedData_Type type, + intptr_t length); + +/** + * Returns a TypedData object which references an external data array. + * + * \param type The type of the data array. + * \param data A data array. This array must not move. + * \param length The length of the data array (length in type units). + * + * \return The TypedData object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_NewExternalTypedData(Dart_TypedData_Type type, + void* data, + intptr_t length); + +/** + * Returns a TypedData object which references an external data array. + * + * \param type The type of the data array. + * \param data A data array. This array must not move. + * \param length The length of the data array (length in type units). + * \param peer A pointer to a native object or NULL. This value is + * provided to callback when it is invoked. + * \param external_allocation_size The number of externally allocated + * bytes for peer. Used to inform the garbage collector. + * \param callback A function pointer that will be invoked sometime + * after the object is garbage collected, unless the handle has been deleted. + * A valid callback needs to be specified it cannot be NULL. + * + * \return The TypedData object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle +Dart_NewExternalTypedDataWithFinalizer(Dart_TypedData_Type type, + void* data, + intptr_t length, + void* peer, + intptr_t external_allocation_size, + Dart_HandleFinalizer callback); + +/** + * Returns a ByteBuffer object for the typed data. + * + * \param type_data The TypedData object. + * + * \return The ByteBuffer object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_NewByteBuffer(Dart_Handle typed_data); + +/** + * Acquires access to the internal data address of a TypedData object. + * + * \param object The typed data object whose internal data address is to + * be accessed. + * \param type The type of the object is returned here. + * \param data The internal data address is returned here. + * \param len Size of the typed array is returned here. + * + * Notes: + * When the internal address of the object is acquired any calls to a + * Dart API function that could potentially allocate an object or run + * any Dart code will return an error. + * + * Any Dart API functions for accessing the data should not be called + * before the corresponding release. In particular, the object should + * not be acquired again before its release. This leads to undefined + * behavior. + * + * \return Success if the internal data address is acquired successfully. + * Otherwise, returns an error handle. + */ +DART_EXPORT Dart_Handle Dart_TypedDataAcquireData(Dart_Handle object, + Dart_TypedData_Type* type, + void** data, + intptr_t* len); + +/** + * Releases access to the internal data address that was acquired earlier using + * Dart_TypedDataAcquireData. + * + * \param object The typed data object whose internal data address is to be + * released. + * + * \return Success if the internal data address is released successfully. + * Otherwise, returns an error handle. + */ +DART_EXPORT Dart_Handle Dart_TypedDataReleaseData(Dart_Handle object); + +/** + * Returns the TypedData object associated with the ByteBuffer object. + * + * \param byte_buffer The ByteBuffer object. + * + * \return The TypedData object if no error occurs. Otherwise returns + * an error handle. + */ +DART_EXPORT Dart_Handle Dart_GetDataFromByteBuffer(Dart_Handle byte_buffer); + +/* + * ============================================================ + * Invoking Constructors, Methods, Closures and Field accessors + * ============================================================ + */ + +/** + * Invokes a constructor, creating a new object. + * + * This function allows hidden constructors (constructors with leading + * underscores) to be called. + * + * \param type Type of object to be constructed. + * \param constructor_name The name of the constructor to invoke. Use + * Dart_Null() or Dart_EmptyString() to invoke the unnamed constructor. + * This name should not include the name of the class. + * \param number_of_arguments Size of the arguments array. + * \param arguments An array of arguments to the constructor. + * + * \return If the constructor is called and completes successfully, + * then the new object. If an error occurs during execution, then an + * error handle is returned. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_New(Dart_Handle type, + Dart_Handle constructor_name, + int number_of_arguments, + Dart_Handle* arguments); + +/** + * Allocate a new object without invoking a constructor. + * + * \param type The type of an object to be allocated. + * + * \return The new object. If an error occurs during execution, then an + * error handle is returned. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_Allocate(Dart_Handle type); + +/** + * Allocate a new object without invoking a constructor, and sets specified + * native fields. + * + * \param type The type of an object to be allocated. + * \param num_native_fields The number of native fields to set. + * \param native_fields An array containing the value of native fields. + * + * \return The new object. If an error occurs during execution, then an + * error handle is returned. + */ +DART_EXPORT Dart_Handle +Dart_AllocateWithNativeFields(Dart_Handle type, + intptr_t num_native_fields, + const intptr_t* native_fields); + +/** + * Invokes a method or function. + * + * The 'target' parameter may be an object, type, or library. If + * 'target' is an object, then this function will invoke an instance + * method. If 'target' is a type, then this function will invoke a + * static method. If 'target' is a library, then this function will + * invoke a top-level function from that library. + * NOTE: This API call cannot be used to invoke methods of a type object. + * + * This function ignores visibility (leading underscores in names). + * + * May generate an unhandled exception error. + * + * \param target An object, type, or library. + * \param name The name of the function or method to invoke. + * \param number_of_arguments Size of the arguments array. + * \param arguments An array of arguments to the function. + * + * \return If the function or method is called and completes + * successfully, then the return value is returned. If an error + * occurs during execution, then an error handle is returned. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_Invoke(Dart_Handle target, + Dart_Handle name, + int number_of_arguments, + Dart_Handle* arguments); +/* TODO(turnidge): Document how to invoke operators. */ + +/** + * Invokes a Closure with the given arguments. + * + * May generate an unhandled exception error. + * + * \return If no error occurs during execution, then the result of + * invoking the closure is returned. If an error occurs during + * execution, then an error handle is returned. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_InvokeClosure(Dart_Handle closure, + int number_of_arguments, + Dart_Handle* arguments); + +/** + * Invokes a Generative Constructor on an object that was previously + * allocated using Dart_Allocate/Dart_AllocateWithNativeFields. + * + * The 'target' parameter must be an object. + * + * This function ignores visibility (leading underscores in names). + * + * May generate an unhandled exception error. + * + * \param target An object. + * \param name The name of the constructor to invoke. + * Use Dart_Null() or Dart_EmptyString() to invoke the unnamed constructor. + * \param number_of_arguments Size of the arguments array. + * \param arguments An array of arguments to the function. + * + * \return If the constructor is called and completes + * successfully, then the object is returned. If an error + * occurs during execution, then an error handle is returned. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_InvokeConstructor(Dart_Handle object, + Dart_Handle name, + int number_of_arguments, + Dart_Handle* arguments); + +/** + * Gets the value of a field. + * + * The 'container' parameter may be an object, type, or library. If + * 'container' is an object, then this function will access an + * instance field. If 'container' is a type, then this function will + * access a static field. If 'container' is a library, then this + * function will access a top-level variable. + * NOTE: This API call cannot be used to access fields of a type object. + * + * This function ignores field visibility (leading underscores in names). + * + * May generate an unhandled exception error. + * + * \param container An object, type, or library. + * \param name A field name. + * + * \return If no error occurs, then the value of the field is + * returned. Otherwise an error handle is returned. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_GetField(Dart_Handle container, Dart_Handle name); + +/** + * Sets the value of a field. + * + * The 'container' parameter may actually be an object, type, or + * library. If 'container' is an object, then this function will + * access an instance field. If 'container' is a type, then this + * function will access a static field. If 'container' is a library, + * then this function will access a top-level variable. + * NOTE: This API call cannot be used to access fields of a type object. + * + * This function ignores field visibility (leading underscores in names). + * + * May generate an unhandled exception error. + * + * \param container An object, type, or library. + * \param name A field name. + * \param value The new field value. + * + * \return A valid handle if no error occurs. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_SetField(Dart_Handle container, Dart_Handle name, Dart_Handle value); + +/* + * ========== + * Exceptions + * ========== + */ + +/* + * TODO(turnidge): Remove these functions from the api and replace all + * uses with Dart_NewUnhandledExceptionError. */ + +/** + * Throws an exception. + * + * This function causes a Dart language exception to be thrown. This + * will proceed in the standard way, walking up Dart frames until an + * appropriate 'catch' block is found, executing 'finally' blocks, + * etc. + * + * If an error handle is passed into this function, the error is + * propagated immediately. See Dart_PropagateError for a discussion + * of error propagation. + * + * If successful, this function does not return. Note that this means + * that the destructors of any stack-allocated C++ objects will not be + * called. If there are no Dart frames on the stack, an error occurs. + * + * \return An error handle if the exception was not thrown. + * Otherwise the function does not return. + */ +DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception); + +/** + * Rethrows an exception. + * + * Rethrows an exception, unwinding all dart frames on the stack. If + * successful, this function does not return. Note that this means + * that the destructors of any stack-allocated C++ objects will not be + * called. If there are no Dart frames on the stack, an error occurs. + * + * \return An error handle if the exception was not thrown. + * Otherwise the function does not return. + */ +DART_EXPORT Dart_Handle Dart_ReThrowException(Dart_Handle exception, + Dart_Handle stacktrace); + +/* + * =========================== + * Native fields and functions + * =========================== + */ + +/** + * Gets the number of native instance fields in an object. + */ +DART_EXPORT Dart_Handle Dart_GetNativeInstanceFieldCount(Dart_Handle obj, + int* count); + +/** + * Gets the value of a native field. + * + * TODO(turnidge): Document. + */ +DART_EXPORT Dart_Handle Dart_GetNativeInstanceField(Dart_Handle obj, + int index, + intptr_t* value); + +/** + * Sets the value of a native field. + * + * TODO(turnidge): Document. + */ +DART_EXPORT Dart_Handle Dart_SetNativeInstanceField(Dart_Handle obj, + int index, + intptr_t value); + +/** + * The arguments to a native function. + * + * This object is passed to a native function to represent its + * arguments and return value. It allows access to the arguments to a + * native function by index. It also allows the return value of a + * native function to be set. + */ +typedef struct _Dart_NativeArguments* Dart_NativeArguments; + +/** + * Extracts current isolate group data from the native arguments structure. + */ +DART_EXPORT void* Dart_GetNativeIsolateGroupData(Dart_NativeArguments args); + +typedef enum { + Dart_NativeArgument_kBool = 0, + Dart_NativeArgument_kInt32, + Dart_NativeArgument_kUint32, + Dart_NativeArgument_kInt64, + Dart_NativeArgument_kUint64, + Dart_NativeArgument_kDouble, + Dart_NativeArgument_kString, + Dart_NativeArgument_kInstance, + Dart_NativeArgument_kNativeFields, +} Dart_NativeArgument_Type; + +typedef struct _Dart_NativeArgument_Descriptor { + uint8_t type; + uint8_t index; +} Dart_NativeArgument_Descriptor; + +typedef union _Dart_NativeArgument_Value { + bool as_bool; + int32_t as_int32; + uint32_t as_uint32; + int64_t as_int64; + uint64_t as_uint64; + double as_double; + struct { + Dart_Handle dart_str; + void* peer; + } as_string; + struct { + intptr_t num_fields; + intptr_t* values; + } as_native_fields; + Dart_Handle as_instance; +} Dart_NativeArgument_Value; + +enum { + kNativeArgNumberPos = 0, + kNativeArgNumberSize = 8, + kNativeArgTypePos = kNativeArgNumberPos + kNativeArgNumberSize, + kNativeArgTypeSize = 8, +}; + +#define BITMASK(size) ((1 << size) - 1) +#define DART_NATIVE_ARG_DESCRIPTOR(type, position) \ + (((type & BITMASK(kNativeArgTypeSize)) << kNativeArgTypePos) | \ + (position & BITMASK(kNativeArgNumberSize))) + +/** + * Gets the native arguments based on the types passed in and populates + * the passed arguments buffer with appropriate native values. + * + * \param args the Native arguments block passed into the native call. + * \param num_arguments length of argument descriptor array and argument + * values array passed in. + * \param arg_descriptors an array that describes the arguments that + * need to be retrieved. For each argument to be retrieved the descriptor + * contains the argument number (0, 1 etc.) and the argument type + * described using Dart_NativeArgument_Type, e.g: + * DART_NATIVE_ARG_DESCRIPTOR(Dart_NativeArgument_kBool, 1) indicates + * that the first argument is to be retrieved and it should be a boolean. + * \param arg_values array into which the native arguments need to be + * extracted into, the array is allocated by the caller (it could be + * stack allocated to avoid the malloc/free performance overhead). + * + * \return Success if all the arguments could be extracted correctly, + * returns an error handle if there were any errors while extracting the + * arguments (mismatched number of arguments, incorrect types, etc.). + */ +DART_EXPORT Dart_Handle +Dart_GetNativeArguments(Dart_NativeArguments args, + int num_arguments, + const Dart_NativeArgument_Descriptor* arg_descriptors, + Dart_NativeArgument_Value* arg_values); + +/** + * Gets the native argument at some index. + */ +DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, + int index); +/* TODO(turnidge): Specify the behavior of an out-of-bounds access. */ + +/** + * Gets the number of native arguments. + */ +DART_EXPORT int Dart_GetNativeArgumentCount(Dart_NativeArguments args); + +/** + * Gets all the native fields of the native argument at some index. + * \param args Native arguments structure. + * \param arg_index Index of the desired argument in the structure above. + * \param num_fields size of the intptr_t array 'field_values' passed in. + * \param field_values intptr_t array in which native field values are returned. + * \return Success if the native fields where copied in successfully. Otherwise + * returns an error handle. On success the native field values are copied + * into the 'field_values' array, if the argument at 'arg_index' is a + * null object then 0 is copied as the native field values into the + * 'field_values' array. + */ +DART_EXPORT Dart_Handle +Dart_GetNativeFieldsOfArgument(Dart_NativeArguments args, + int arg_index, + int num_fields, + intptr_t* field_values); + +/** + * Gets the native field of the receiver. + */ +DART_EXPORT Dart_Handle Dart_GetNativeReceiver(Dart_NativeArguments args, + intptr_t* value); + +/** + * Gets a string native argument at some index. + * \param args Native arguments structure. + * \param arg_index Index of the desired argument in the structure above. + * \param peer Returns the peer pointer if the string argument has one. + * \return Success if the string argument has a peer, if it does not + * have a peer then the String object is returned. Otherwise returns + * an error handle (argument is not a String object). + */ +DART_EXPORT Dart_Handle Dart_GetNativeStringArgument(Dart_NativeArguments args, + int arg_index, + void** peer); + +/** + * Gets an integer native argument at some index. + * \param args Native arguments structure. + * \param arg_index Index of the desired argument in the structure above. + * \param value Returns the integer value if the argument is an Integer. + * \return Success if no error occurs. Otherwise returns an error handle. + */ +DART_EXPORT Dart_Handle Dart_GetNativeIntegerArgument(Dart_NativeArguments args, + int index, + int64_t* value); + +/** + * Gets a boolean native argument at some index. + * \param args Native arguments structure. + * \param arg_index Index of the desired argument in the structure above. + * \param value Returns the boolean value if the argument is a Boolean. + * \return Success if no error occurs. Otherwise returns an error handle. + */ +DART_EXPORT Dart_Handle Dart_GetNativeBooleanArgument(Dart_NativeArguments args, + int index, + bool* value); + +/** + * Gets a double native argument at some index. + * \param args Native arguments structure. + * \param arg_index Index of the desired argument in the structure above. + * \param value Returns the double value if the argument is a double. + * \return Success if no error occurs. Otherwise returns an error handle. + */ +DART_EXPORT Dart_Handle Dart_GetNativeDoubleArgument(Dart_NativeArguments args, + int index, + double* value); + +/** + * Sets the return value for a native function. + * + * If retval is an Error handle, then error will be propagated once + * the native functions exits. See Dart_PropagateError for a + * discussion of how different types of errors are propagated. + */ +DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args, + Dart_Handle retval); + +DART_EXPORT void Dart_SetWeakHandleReturnValue(Dart_NativeArguments args, + Dart_WeakPersistentHandle rval); + +DART_EXPORT void Dart_SetBooleanReturnValue(Dart_NativeArguments args, + bool retval); + +DART_EXPORT void Dart_SetIntegerReturnValue(Dart_NativeArguments args, + int64_t retval); + +DART_EXPORT void Dart_SetDoubleReturnValue(Dart_NativeArguments args, + double retval); + +/** + * A native function. + */ +typedef void (*Dart_NativeFunction)(Dart_NativeArguments arguments); + +/** + * Native entry resolution callback. + * + * For libraries and scripts which have native functions, the embedder + * can provide a native entry resolver. This callback is used to map a + * name/arity to a Dart_NativeFunction. If no function is found, the + * callback should return NULL. + * + * The parameters to the native resolver function are: + * \param name a Dart string which is the name of the native function. + * \param num_of_arguments is the number of arguments expected by the + * native function. + * \param auto_setup_scope is a boolean flag that can be set by the resolver + * to indicate if this function needs a Dart API scope (see Dart_EnterScope/ + * Dart_ExitScope) to be setup automatically by the VM before calling into + * the native function. By default most native functions would require this + * to be true but some light weight native functions which do not call back + * into the VM through the Dart API may not require a Dart scope to be + * setup automatically. + * + * \return A valid Dart_NativeFunction which resolves to a native entry point + * for the native function. + * + * See Dart_SetNativeResolver. + */ +typedef Dart_NativeFunction (*Dart_NativeEntryResolver)(Dart_Handle name, + int num_of_arguments, + bool* auto_setup_scope); +/* TODO(turnidge): Consider renaming to NativeFunctionResolver or + * NativeResolver. */ + +/** + * Native entry symbol lookup callback. + * + * For libraries and scripts which have native functions, the embedder + * can provide a callback for mapping a native entry to a symbol. This callback + * maps a native function entry PC to the native function name. If no native + * entry symbol can be found, the callback should return NULL. + * + * The parameters to the native reverse resolver function are: + * \param nf A Dart_NativeFunction. + * + * \return A const UTF-8 string containing the symbol name or NULL. + * + * See Dart_SetNativeResolver. + */ +typedef const uint8_t* (*Dart_NativeEntrySymbol)(Dart_NativeFunction nf); + +/* + * =========== + * Environment + * =========== + */ + +/** + * An environment lookup callback function. + * + * \param name The name of the value to lookup in the environment. + * + * \return A valid handle to a string if the name exists in the + * current environment or Dart_Null() if not. + */ +typedef Dart_Handle (*Dart_EnvironmentCallback)(Dart_Handle name); + +/** + * Sets the environment callback for the current isolate. This + * callback is used to lookup environment values by name in the + * current environment. This enables the embedder to supply values for + * the const constructors bool.fromEnvironment, int.fromEnvironment + * and String.fromEnvironment. + */ +DART_EXPORT Dart_Handle +Dart_SetEnvironmentCallback(Dart_EnvironmentCallback callback); + +/** + * Sets the callback used to resolve native functions for a library. + * + * \param library A library. + * \param resolver A native entry resolver. + * + * \return A valid handle if the native resolver was set successfully. + */ +DART_EXPORT Dart_Handle +Dart_SetNativeResolver(Dart_Handle library, + Dart_NativeEntryResolver resolver, + Dart_NativeEntrySymbol symbol); +/* TODO(turnidge): Rename to Dart_LibrarySetNativeResolver? */ + +/** + * Returns the callback used to resolve native functions for a library. + * + * \param library A library. + * \param resolver a pointer to a Dart_NativeEntryResolver + * + * \return A valid handle if the library was found. + */ +DART_EXPORT Dart_Handle +Dart_GetNativeResolver(Dart_Handle library, Dart_NativeEntryResolver* resolver); + +/** + * Returns the callback used to resolve native function symbols for a library. + * + * \param library A library. + * \param resolver a pointer to a Dart_NativeEntrySymbol. + * + * \return A valid handle if the library was found. + */ +DART_EXPORT Dart_Handle Dart_GetNativeSymbol(Dart_Handle library, + Dart_NativeEntrySymbol* resolver); + +/* + * ===================== + * Scripts and Libraries + * ===================== + */ + +typedef enum { + Dart_kCanonicalizeUrl = 0, + Dart_kImportTag, + Dart_kKernelTag, + Dart_kImportExtensionTag, +} Dart_LibraryTag; + +/** + * The library tag handler is a multi-purpose callback provided by the + * embedder to the Dart VM. The embedder implements the tag handler to + * provide the ability to load Dart scripts and imports. + * + * -- TAGS -- + * + * Dart_kCanonicalizeUrl + * + * This tag indicates that the embedder should canonicalize 'url' with + * respect to 'library'. For most embedders, the + * Dart_DefaultCanonicalizeUrl function is a sufficient implementation + * of this tag. The return value should be a string holding the + * canonicalized url. + * + * Dart_kImportTag + * + * This tag is used to load a library from IsolateMirror.loadUri. The embedder + * should call Dart_LoadLibraryFromKernel to provide the library to the VM. The + * return value should be an error or library (the result from + * Dart_LoadLibraryFromKernel). + * + * Dart_kKernelTag + * + * This tag is used to load the intermediate file (kernel) generated by + * the Dart front end. This tag is typically used when a 'hot-reload' + * of an application is needed and the VM is 'use dart front end' mode. + * The dart front end typically compiles all the scripts, imports and part + * files into one intermediate file hence we don't use the source/import or + * script tags. The return value should be an error or a TypedData containing + * the kernel bytes. + * + * Dart_kImportExtensionTag + * + * This tag is used to load an external import (shared object file). The + * extension path must have the scheme 'dart-ext:'. + */ +typedef Dart_Handle (*Dart_LibraryTagHandler)( + Dart_LibraryTag tag, + Dart_Handle library_or_package_map_url, + Dart_Handle url); + +/** + * Sets library tag handler for the current isolate. This handler is + * used to handle the various tags encountered while loading libraries + * or scripts in the isolate. + * + * \param handler Handler code to be used for handling the various tags + * encountered while loading libraries or scripts in the isolate. + * + * \return If no error occurs, the handler is set for the isolate. + * Otherwise an error handle is returned. + * + * TODO(turnidge): Document. + */ +DART_EXPORT Dart_Handle +Dart_SetLibraryTagHandler(Dart_LibraryTagHandler handler); + +/** + * Handles deferred loading requests. When this handler is invoked, it should + * eventually load the deferred loading unit with the given id and call + * Dart_DeferredLoadComplete or Dart_DeferredLoadCompleteError. It is + * recommended that the loading occur asynchronously, but it is permitted to + * call Dart_DeferredLoadComplete or Dart_DeferredLoadCompleteError before the + * handler returns. + * + * If an error is returned, it will be propogated through + * `prefix.loadLibrary()`. This is useful for synchronous + * implementations, which must propogate any unwind errors from + * Dart_DeferredLoadComplete or Dart_DeferredLoadComplete. Otherwise the handler + * should return a non-error such as `Dart_Null()`. + */ +typedef Dart_Handle (*Dart_DeferredLoadHandler)(intptr_t loading_unit_id); + +/** + * Sets the deferred load handler for the current isolate. This handler is + * used to handle loading deferred imports in an AppJIT or AppAOT program. + */ +DART_EXPORT Dart_Handle +Dart_SetDeferredLoadHandler(Dart_DeferredLoadHandler handler); + +/** + * Notifies the VM that a deferred load completed successfully. This function + * will eventually cause the corresponding `prefix.loadLibrary()` futures to + * complete. + * + * Requires the current isolate to be the same current isolate during the + * invocation of the Dart_DeferredLoadHandler. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_DeferredLoadComplete(intptr_t loading_unit_id, + const uint8_t* snapshot_data, + const uint8_t* snapshot_instructions); + +/** + * Notifies the VM that a deferred load failed. This function + * will eventually cause the corresponding `prefix.loadLibrary()` futures to + * complete with an error. + * + * If `transient` is true, future invocations of `prefix.loadLibrary()` will + * trigger new load requests. If false, futures invocation will complete with + * the same error. + * + * Requires the current isolate to be the same current isolate during the + * invocation of the Dart_DeferredLoadHandler. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_DeferredLoadCompleteError(intptr_t loading_unit_id, + const char* error_message, + bool transient); + +/** + * Canonicalizes a url with respect to some library. + * + * The url is resolved with respect to the library's url and some url + * normalizations are performed. + * + * This canonicalization function should be sufficient for most + * embedders to implement the Dart_kCanonicalizeUrl tag. + * + * \param base_url The base url relative to which the url is + * being resolved. + * \param url The url being resolved and canonicalized. This + * parameter is a string handle. + * + * \return If no error occurs, a String object is returned. Otherwise + * an error handle is returned. + */ +DART_EXPORT Dart_Handle Dart_DefaultCanonicalizeUrl(Dart_Handle base_url, + Dart_Handle url); + +/** + * Loads the root library for the current isolate. + * + * Requires there to be no current root library. + * + * \param buffer A buffer which contains a kernel binary (see + * pkg/kernel/binary.md). Must remain valid until isolate group shutdown. + * \param buffer_size Length of the passed in buffer. + * + * \return A handle to the root library, or an error. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_LoadScriptFromKernel(const uint8_t* kernel_buffer, intptr_t kernel_size); + +/** + * Gets the library for the root script for the current isolate. + * + * If the root script has not yet been set for the current isolate, + * this function returns Dart_Null(). This function never returns an + * error handle. + * + * \return Returns the root Library for the current isolate or Dart_Null(). + */ +DART_EXPORT Dart_Handle Dart_RootLibrary(); + +/** + * Sets the root library for the current isolate. + * + * \return Returns an error handle if `library` is not a library handle. + */ +DART_EXPORT Dart_Handle Dart_SetRootLibrary(Dart_Handle library); + +/** + * Lookup or instantiate a legacy type by name and type arguments from a + * Library. + * + * \param library The library containing the class or interface. + * \param class_name The class name for the type. + * \param number_of_type_arguments Number of type arguments. + * For non parametric types the number of type arguments would be 0. + * \param type_arguments Pointer to an array of type arguments. + * For non parameteric types a NULL would be passed in for this argument. + * + * \return If no error occurs, the type is returned. + * Otherwise an error handle is returned. + */ +DART_EXPORT Dart_Handle Dart_GetType(Dart_Handle library, + Dart_Handle class_name, + intptr_t number_of_type_arguments, + Dart_Handle* type_arguments); + +/** + * Lookup or instantiate a nullable type by name and type arguments from + * Library. + * + * \param library The library containing the class or interface. + * \param class_name The class name for the type. + * \param number_of_type_arguments Number of type arguments. + * For non parametric types the number of type arguments would be 0. + * \param type_arguments Pointer to an array of type arguments. + * For non parameteric types a NULL would be passed in for this argument. + * + * \return If no error occurs, the type is returned. + * Otherwise an error handle is returned. + */ +DART_EXPORT Dart_Handle Dart_GetNullableType(Dart_Handle library, + Dart_Handle class_name, + intptr_t number_of_type_arguments, + Dart_Handle* type_arguments); + +/** + * Lookup or instantiate a non-nullable type by name and type arguments from + * Library. + * + * \param library The library containing the class or interface. + * \param class_name The class name for the type. + * \param number_of_type_arguments Number of type arguments. + * For non parametric types the number of type arguments would be 0. + * \param type_arguments Pointer to an array of type arguments. + * For non parameteric types a NULL would be passed in for this argument. + * + * \return If no error occurs, the type is returned. + * Otherwise an error handle is returned. + */ +DART_EXPORT Dart_Handle +Dart_GetNonNullableType(Dart_Handle library, + Dart_Handle class_name, + intptr_t number_of_type_arguments, + Dart_Handle* type_arguments); + +/** + * Creates a nullable version of the provided type. + * + * \param type The type to be converted to a nullable type. + * + * \return If no error occurs, a nullable type is returned. + * Otherwise an error handle is returned. + */ +DART_EXPORT Dart_Handle Dart_TypeToNullableType(Dart_Handle type); + +/** + * Creates a non-nullable version of the provided type. + * + * \param type The type to be converted to a non-nullable type. + * + * \return If no error occurs, a non-nullable type is returned. + * Otherwise an error handle is returned. + */ +DART_EXPORT Dart_Handle Dart_TypeToNonNullableType(Dart_Handle type); + +/** + * A type's nullability. + * + * \param type A Dart type. + * \param result An out parameter containing the result of the check. True if + * the type is of the specified nullability, false otherwise. + * + * \return Returns an error handle if type is not of type Type. + */ +DART_EXPORT Dart_Handle Dart_IsNullableType(Dart_Handle type, bool* result); +DART_EXPORT Dart_Handle Dart_IsNonNullableType(Dart_Handle type, bool* result); +DART_EXPORT Dart_Handle Dart_IsLegacyType(Dart_Handle type, bool* result); + +/** + * Lookup a class or interface by name from a Library. + * + * \param library The library containing the class or interface. + * \param class_name The name of the class or interface. + * + * \return If no error occurs, the class or interface is + * returned. Otherwise an error handle is returned. + */ +DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, + Dart_Handle class_name); +/* TODO(asiva): The above method needs to be removed once all uses + * of it are removed from the embedder code. */ + +/** + * Returns an import path to a Library, such as "file:///test.dart" or + * "dart:core". + */ +DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library); + +/** + * Returns a URL from which a Library was loaded. + */ +DART_EXPORT Dart_Handle Dart_LibraryResolvedUrl(Dart_Handle library); + +/** + * \return An array of libraries. + */ +DART_EXPORT Dart_Handle Dart_GetLoadedLibraries(); + +DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url); +/* TODO(turnidge): Consider returning Dart_Null() when the library is + * not found to distinguish that from a true error case. */ + +/** + * Report an loading error for the library. + * + * \param library The library that failed to load. + * \param error The Dart error instance containing the load error. + * + * \return If the VM handles the error, the return value is + * a null handle. If it doesn't handle the error, the error + * object is returned. + */ +DART_EXPORT Dart_Handle Dart_LibraryHandleError(Dart_Handle library, + Dart_Handle error); + +/** + * Called by the embedder to load a partial program. Does not set the root + * library. + * + * \param buffer A buffer which contains a kernel binary (see + * pkg/kernel/binary.md). Must remain valid until isolate shutdown. + * \param buffer_size Length of the passed in buffer. + * + * \return A handle to the main library of the compilation unit, or an error. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_LoadLibraryFromKernel(const uint8_t* kernel_buffer, + intptr_t kernel_buffer_size); + +/** + * Returns a flattened list of pairs. The first element in each pair is the + * importing library and and the second element is the imported library for each + * import in the isolate of a library whose URI's scheme is [scheme]. + * + * Requires there to be a current isolate. + * + * \return A handle to a list of flattened pairs of importer-importee. + */ +DART_EXPORT Dart_Handle Dart_GetImportsOfScheme(Dart_Handle scheme); + +/** + * Indicates that all outstanding load requests have been satisfied. + * This finalizes all the new classes loaded and optionally completes + * deferred library futures. + * + * Requires there to be a current isolate. + * + * \param complete_futures Specify true if all deferred library + * futures should be completed, false otherwise. + * + * \return Success if all classes have been finalized and deferred library + * futures are completed. Otherwise, returns an error. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_FinalizeLoading(bool complete_futures); + +/* + * ===== + * Peers + * ===== + */ + +/** + * The peer field is a lazily allocated field intended for storage of + * an uncommonly used values. Most instances types can have a peer + * field allocated. The exceptions are subtypes of Null, num, and + * bool. + */ + +/** + * Returns the value of peer field of 'object' in 'peer'. + * + * \param object An object. + * \param peer An out parameter that returns the value of the peer + * field. + * + * \return Returns an error if 'object' is a subtype of Null, num, or + * bool. + */ +DART_EXPORT Dart_Handle Dart_GetPeer(Dart_Handle object, void** peer); + +/** + * Sets the value of the peer field of 'object' to the value of + * 'peer'. + * + * \param object An object. + * \param peer A value to store in the peer field. + * + * \return Returns an error if 'object' is a subtype of Null, num, or + * bool. + */ +DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); + +/* + * ====== + * Kernel + * ====== + */ + +/** + * Experimental support for Dart to Kernel parser isolate. + * + * TODO(hausner): Document finalized interface. + * + */ + +// TODO(33433): Remove kernel service from the embedding API. + +typedef enum { + Dart_KernelCompilationStatus_Unknown = -1, + Dart_KernelCompilationStatus_Ok = 0, + Dart_KernelCompilationStatus_Error = 1, + Dart_KernelCompilationStatus_Crash = 2, +} Dart_KernelCompilationStatus; + +typedef struct { + Dart_KernelCompilationStatus status; + bool null_safety; + char* error; + uint8_t* kernel; + intptr_t kernel_size; +} Dart_KernelCompilationResult; + +typedef enum { + Dart_KernelCompilationVerbosityLevel_Error = 0, + Dart_KernelCompilationVerbosityLevel_Warning, + Dart_KernelCompilationVerbosityLevel_Info, + Dart_KernelCompilationVerbosityLevel_All, +} Dart_KernelCompilationVerbosityLevel; + +DART_EXPORT bool Dart_IsKernelIsolate(Dart_Isolate isolate); +DART_EXPORT bool Dart_KernelIsolateIsRunning(); +DART_EXPORT Dart_Port Dart_KernelPort(); + +/** + * Compiles the given `script_uri` to a kernel file. + * + * \param platform_kernel A buffer containing the kernel of the platform (e.g. + * `vm_platform_strong.dill`). The VM does not take ownership of this memory. + * + * \param platform_kernel_size The length of the platform_kernel buffer. + * + * \param snapshot_compile Set to `true` when the compilation is for a snapshot. + * This is used by the frontend to determine if compilation related information + * should be printed to console (e.g., null safety mode). + * + * \param verbosity Specifies the logging behavior of the kernel compilation + * service. + * + * \return Returns the result of the compilation. + * + * On a successful compilation the returned [Dart_KernelCompilationResult] has + * a status of [Dart_KernelCompilationStatus_Ok] and the `kernel`/`kernel_size` + * fields are set. The caller takes ownership of the malloc()ed buffer. + * + * On a failed compilation the `error` might be set describing the reason for + * the failed compilation. The caller takes ownership of the malloc()ed + * error. + * + * Requires there to be a current isolate. + */ +DART_EXPORT Dart_KernelCompilationResult +Dart_CompileToKernel(const char* script_uri, + const uint8_t* platform_kernel, + const intptr_t platform_kernel_size, + bool incremental_compile, + bool snapshot_compile, + const char* package_config, + Dart_KernelCompilationVerbosityLevel verbosity); + +typedef struct { + const char* uri; + const char* source; +} Dart_SourceFile; + +DART_EXPORT Dart_KernelCompilationResult Dart_KernelListDependencies(); + +/** + * Sets the kernel buffer which will be used to load Dart SDK sources + * dynamically at runtime. + * + * \param platform_kernel A buffer containing kernel which has sources for the + * Dart SDK populated. Note: The VM does not take ownership of this memory. + * + * \param platform_kernel_size The length of the platform_kernel buffer. + */ +DART_EXPORT void Dart_SetDartLibrarySourcesKernel( + const uint8_t* platform_kernel, + const intptr_t platform_kernel_size); + +/** + * Detect the null safety opt-in status. + * + * When running from source, it is based on the opt-in status of `script_uri`. + * When running from a kernel buffer, it is based on the mode used when + * generating `kernel_buffer`. + * When running from an appJIT or AOT snapshot, it is based on the mode used + * when generating `snapshot_data`. + * + * \param script_uri Uri of the script that contains the source code + * + * \param package_config Uri of the package configuration file (either in format + * of .packages or .dart_tool/package_config.json) for the null safety + * detection to resolve package imports against. If this parameter is not + * passed the package resolution of the parent isolate should be used. + * + * \param original_working_directory current working directory when the VM + * process was launched, this is used to correctly resolve the path specified + * for package_config. + * + * \param snapshot_data + * + * \param snapshot_instructions Buffers containing a snapshot of the + * isolate or NULL if no snapshot is provided. If provided, the buffers must + * remain valid until the isolate shuts down. + * + * \param kernel_buffer + * + * \param kernel_buffer_size A buffer which contains a kernel/DIL program. Must + * remain valid until isolate shutdown. + * + * \return Returns true if the null safety is opted in by the input being + * run `script_uri`, `snapshot_data` or `kernel_buffer`. + * + */ +DART_EXPORT bool Dart_DetectNullSafety(const char* script_uri, + const char* package_config, + const char* original_working_directory, + const uint8_t* snapshot_data, + const uint8_t* snapshot_instructions, + const uint8_t* kernel_buffer, + intptr_t kernel_buffer_size); + +#define DART_KERNEL_ISOLATE_NAME "kernel-service" + +/* + * ======= + * Service + * ======= + */ + +#define DART_VM_SERVICE_ISOLATE_NAME "vm-service" + +/** + * Returns true if isolate is the service isolate. + * + * \param isolate An isolate + * + * \return Returns true if 'isolate' is the service isolate. + */ +DART_EXPORT bool Dart_IsServiceIsolate(Dart_Isolate isolate); + +/** + * Writes the CPU profile to the timeline as a series of 'instant' events. + * + * Note that this is an expensive operation. + * + * \param main_port The main port of the Isolate whose profile samples to write. + * \param error An optional error, must be free()ed by caller. + * + * \return Returns true if the profile is successfully written and false + * otherwise. + */ +DART_EXPORT bool Dart_WriteProfileToTimeline(Dart_Port main_port, char** error); + +/* + * ==================== + * Compilation Feedback + * ==================== + */ + +/** + * Record all functions which have been compiled in the current isolate. + * + * \param buffer Returns a pointer to a buffer containing the trace. + * This buffer is scope allocated and is only valid until the next call to + * Dart_ExitScope. + * \param size Returns the size of the buffer. + * \return Returns an valid handle upon success. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_SaveCompilationTrace(uint8_t** buffer, intptr_t* buffer_length); + +/** + * Compile all functions from data from Dart_SaveCompilationTrace. Unlike JIT + * feedback, this data is fuzzy: loading does not need to happen in the exact + * program that was saved, the saver and loader do not need to agree on checked + * mode versus production mode or debug/release/product. + * + * \return Returns an error handle if a compilation error was encountered. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_LoadCompilationTrace(uint8_t* buffer, intptr_t buffer_length); + +/** + * Record runtime feedback for the current isolate, including type feedback + * and usage counters. + * + * \param buffer Returns a pointer to a buffer containing the trace. + * This buffer is scope allocated and is only valid until the next call to + * Dart_ExitScope. + * \param size Returns the size of the buffer. + * \return Returns an valid handle upon success. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_SaveTypeFeedback(uint8_t** buffer, intptr_t* buffer_length); + +/** + * Compile functions using data from Dart_SaveTypeFeedback. The data must from a + * VM with the same version and compiler flags. + * + * \return Returns an error handle if a compilation error was encountered or a + * version mismatch is detected. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_LoadTypeFeedback(uint8_t* buffer, intptr_t buffer_length); + +/* + * ============== + * Precompilation + * ============== + */ + +/** + * Compiles all functions reachable from entry points and marks + * the isolate to disallow future compilation. + * + * Entry points should be specified using `@pragma("vm:entry-point")` + * annotation. + * + * \return An error handle if a compilation error or runtime error running const + * constructors was encountered. + */ +DART_EXPORT Dart_Handle Dart_Precompile(); + +typedef void (*Dart_CreateLoadingUnitCallback)( + void* callback_data, + intptr_t loading_unit_id, + void** write_callback_data, + void** write_debug_callback_data); +typedef void (*Dart_StreamingWriteCallback)(void* callback_data, + const uint8_t* buffer, + intptr_t size); +typedef void (*Dart_StreamingCloseCallback)(void* callback_data); + +DART_EXPORT Dart_Handle Dart_LoadingUnitLibraryUris(intptr_t loading_unit_id); + +// On Darwin systems, 'dlsym' adds an '_' to the beginning of the symbol name. +// Use the '...CSymbol' definitions for resolving through 'dlsym'. The actual +// symbol names in the objects are given by the '...AsmSymbol' definitions. +#if defined(__APPLE__) +#define kSnapshotBuildIdCSymbol "kDartSnapshotBuildId" +#define kVmSnapshotDataCSymbol "kDartVmSnapshotData" +#define kVmSnapshotInstructionsCSymbol "kDartVmSnapshotInstructions" +#define kVmSnapshotBssCSymbol "kDartVmSnapshotBss" +#define kIsolateSnapshotDataCSymbol "kDartIsolateSnapshotData" +#define kIsolateSnapshotInstructionsCSymbol "kDartIsolateSnapshotInstructions" +#define kIsolateSnapshotBssCSymbol "kDartIsolateSnapshotBss" +#else +#define kSnapshotBuildIdCSymbol "_kDartSnapshotBuildId" +#define kVmSnapshotDataCSymbol "_kDartVmSnapshotData" +#define kVmSnapshotInstructionsCSymbol "_kDartVmSnapshotInstructions" +#define kVmSnapshotBssCSymbol "_kDartVmSnapshotBss" +#define kIsolateSnapshotDataCSymbol "_kDartIsolateSnapshotData" +#define kIsolateSnapshotInstructionsCSymbol "_kDartIsolateSnapshotInstructions" +#define kIsolateSnapshotBssCSymbol "_kDartIsolateSnapshotBss" +#endif + +#define kSnapshotBuildIdAsmSymbol "_kDartSnapshotBuildId" +#define kVmSnapshotDataAsmSymbol "_kDartVmSnapshotData" +#define kVmSnapshotInstructionsAsmSymbol "_kDartVmSnapshotInstructions" +#define kVmSnapshotBssAsmSymbol "_kDartVmSnapshotBss" +#define kIsolateSnapshotDataAsmSymbol "_kDartIsolateSnapshotData" +#define kIsolateSnapshotInstructionsAsmSymbol \ + "_kDartIsolateSnapshotInstructions" +#define kIsolateSnapshotBssAsmSymbol "_kDartIsolateSnapshotBss" + +/** + * Creates a precompiled snapshot. + * - A root library must have been loaded. + * - Dart_Precompile must have been called. + * + * Outputs an assembly file defining the symbols listed in the definitions + * above. + * + * The assembly should be compiled as a static or shared library and linked or + * loaded by the embedder. Running this snapshot requires a VM compiled with + * DART_PRECOMPILED_SNAPSHOT. The kDartVmSnapshotData and + * kDartVmSnapshotInstructions should be passed to Dart_Initialize. The + * kDartIsolateSnapshotData and kDartIsolateSnapshotInstructions should be + * passed to Dart_CreateIsolateGroup. + * + * The callback will be invoked one or more times to provide the assembly code. + * + * If stripped is true, then the assembly code will not include DWARF + * debugging sections. + * + * If debug_callback_data is provided, debug_callback_data will be used with + * the callback to provide separate debugging information. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_CreateAppAOTSnapshotAsAssembly(Dart_StreamingWriteCallback callback, + void* callback_data, + bool stripped, + void* debug_callback_data); +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_CreateAppAOTSnapshotAsAssemblies( + Dart_CreateLoadingUnitCallback next_callback, + void* next_callback_data, + bool stripped, + Dart_StreamingWriteCallback write_callback, + Dart_StreamingCloseCallback close_callback); + +/** + * Creates a precompiled snapshot. + * - A root library must have been loaded. + * - Dart_Precompile must have been called. + * + * Outputs an ELF shared library defining the symbols + * - _kDartVmSnapshotData + * - _kDartVmSnapshotInstructions + * - _kDartIsolateSnapshotData + * - _kDartIsolateSnapshotInstructions + * + * The shared library should be dynamically loaded by the embedder. + * Running this snapshot requires a VM compiled with DART_PRECOMPILED_SNAPSHOT. + * The kDartVmSnapshotData and kDartVmSnapshotInstructions should be passed to + * Dart_Initialize. The kDartIsolateSnapshotData and + * kDartIsolateSnapshotInstructions should be passed to Dart_CreateIsolate. + * + * The callback will be invoked one or more times to provide the binary output. + * + * If stripped is true, then the binary output will not include DWARF + * debugging sections. + * + * If debug_callback_data is provided, debug_callback_data will be used with + * the callback to provide separate debugging information. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_CreateAppAOTSnapshotAsElf(Dart_StreamingWriteCallback callback, + void* callback_data, + bool stripped, + void* debug_callback_data); +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_CreateAppAOTSnapshotAsElfs(Dart_CreateLoadingUnitCallback next_callback, + void* next_callback_data, + bool stripped, + Dart_StreamingWriteCallback write_callback, + Dart_StreamingCloseCallback close_callback); + +/** + * Like Dart_CreateAppAOTSnapshotAsAssembly, but only includes + * kDartVmSnapshotData and kDartVmSnapshotInstructions. It also does + * not strip DWARF information from the generated assembly or allow for + * separate debug information. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_CreateVMAOTSnapshotAsAssembly(Dart_StreamingWriteCallback callback, + void* callback_data); + +/** + * Sorts the class-ids in depth first traversal order of the inheritance + * tree. This is a costly operation, but it can make method dispatch + * more efficient and is done before writing snapshots. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_SortClasses(); + +/** + * Creates a snapshot that caches compiled code and type feedback for faster + * startup and quicker warmup in a subsequent process. + * + * Outputs a snapshot in two pieces. The pieces should be passed to + * Dart_CreateIsolateGroup in a VM using the same VM snapshot pieces used in the + * current VM. The instructions piece must be loaded with read and execute + * permissions; the data piece may be loaded as read-only. + * + * - Requires the VM to have not been started with --precompilation. + * - Not supported when targeting IA32. + * - The VM writing the snapshot and the VM reading the snapshot must be the + * same version, must be built in the same DEBUG/RELEASE/PRODUCT mode, must + * be targeting the same architecture, and must both be in checked mode or + * both in unchecked mode. + * + * The buffers are scope allocated and are only valid until the next call to + * Dart_ExitScope. + * + * \return A valid handle if no error occurs during the operation. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_CreateAppJITSnapshotAsBlobs(uint8_t** isolate_snapshot_data_buffer, + intptr_t* isolate_snapshot_data_size, + uint8_t** isolate_snapshot_instructions_buffer, + intptr_t* isolate_snapshot_instructions_size); + +/** + * Like Dart_CreateAppJITSnapshotAsBlobs, but also creates a new VM snapshot. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_CreateCoreJITSnapshotAsBlobs( + uint8_t** vm_snapshot_data_buffer, + intptr_t* vm_snapshot_data_size, + uint8_t** vm_snapshot_instructions_buffer, + intptr_t* vm_snapshot_instructions_size, + uint8_t** isolate_snapshot_data_buffer, + intptr_t* isolate_snapshot_data_size, + uint8_t** isolate_snapshot_instructions_buffer, + intptr_t* isolate_snapshot_instructions_size); + +/** + * Get obfuscation map for precompiled code. + * + * Obfuscation map is encoded as a JSON array of pairs (original name, + * obfuscated name). + * + * \return Returns an error handler if the VM was built in a mode that does not + * support obfuscation. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle +Dart_GetObfuscationMap(uint8_t** buffer, intptr_t* buffer_length); + +/** + * Returns whether the VM only supports running from precompiled snapshots and + * not from any other kind of snapshot or from source (that is, the VM was + * compiled with DART_PRECOMPILED_RUNTIME). + */ +DART_EXPORT bool Dart_IsPrecompiledRuntime(); + +/** + * Print a native stack trace. Used for crash handling. + * + * If context is NULL, prints the current stack trace. Otherwise, context + * should be a CONTEXT* (Windows) or ucontext_t* (POSIX) from a signal handler + * running on the current thread. + */ +DART_EXPORT void Dart_DumpNativeStackTrace(void* context); + +/** + * Indicate that the process is about to abort, and the Dart VM should not + * attempt to cleanup resources. + */ +DART_EXPORT void Dart_PrepareToAbort(); + +#endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ diff --git a/lib/src/native/include/dart/dart_api_dl.c b/lib/src/native/include/dart/dart_api_dl.c new file mode 100644 index 0000000..a2dbac6 --- /dev/null +++ b/lib/src/native/include/dart/dart_api_dl.c @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file + * for details. All rights reserved. Use of this source code is governed by a + * BSD-style license that can be found in the LICENSE file. + */ + +#include "dart_api_dl.h" /* NOLINT */ +#include "dart_version.h" /* NOLINT */ +#include "runtime/dart_api_dl_impl.h" /* NOLINT */ + +#include + +#define DART_API_DL_DEFINITIONS(name, R, A) name##_Type name##_DL = NULL; + +DART_API_ALL_DL_SYMBOLS(DART_API_DL_DEFINITIONS) + +#undef DART_API_DL_DEFINITIONS + +typedef void* DartApiEntry_function; + +DartApiEntry_function FindFunctionPointer(const DartApiEntry* entries, + const char* name) { + while (entries->name != NULL) { + if (strcmp(entries->name, name) == 0) return (DartApiEntry_function) entries->function; + entries++; + } + return NULL; +} + +intptr_t Dart_InitializeApiDL(void* data) { + DartApi* dart_api_data = (DartApi*)data; + + if (dart_api_data->major != DART_API_DL_MAJOR_VERSION) { + // If the DartVM we're running on does not have the same version as this + // file was compiled against, refuse to initialize. The symbols are not + // compatible. + return -1; + } + // Minor versions are allowed to be different. + // If the DartVM has a higher minor version, it will provide more symbols + // than we initialize here. + // If the DartVM has a lower minor version, it will not provide all symbols. + // In that case, we leave the missing symbols un-initialized. Those symbols + // should not be used by the Dart and native code. The client is responsible + // for checking the minor version number himself based on which symbols it + // is using. + // (If we would error out on this case, recompiling native code against a + // newer SDK would break all uses on older SDKs, which is too strict.) + + const DartApiEntry* dart_api_function_pointers = dart_api_data->functions; + +#define DART_API_DL_INIT(name, R, A) \ + name##_DL = \ + (name##_Type)(FindFunctionPointer(dart_api_function_pointers, #name)); + DART_API_ALL_DL_SYMBOLS(DART_API_DL_INIT) +#undef DART_API_DL_INIT + + return 0; +} diff --git a/lib/src/native/include/dart/dart_api_dl.h b/lib/src/native/include/dart/dart_api_dl.h new file mode 100644 index 0000000..0854d71 --- /dev/null +++ b/lib/src/native/include/dart/dart_api_dl.h @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file + * for details. All rights reserved. Use of this source code is governed by a + * BSD-style license that can be found in the LICENSE file. + */ + +#ifndef RUNTIME_INCLUDE_DART_API_DL_H_ +#define RUNTIME_INCLUDE_DART_API_DL_H_ + +#include "dart_api.h" /* NOLINT */ +#include "dart_native_api.h" /* NOLINT */ + +/** \mainpage Dynamically Linked Dart API + * + * This exposes a subset of symbols from dart_api.h and dart_native_api.h + * available in every Dart embedder through dynamic linking. + * + * All symbols are postfixed with _DL to indicate that they are dynamically + * linked and to prevent conflicts with the original symbol. + * + * Link `dart_api_dl.c` file into your library and invoke + * `Dart_InitializeApiDL` with `NativeApi.initializeApiDLData`. + */ + +#ifdef __cplusplus +#define DART_EXTERN extern "C" +#else +#define DART_EXTERN extern +#endif + +DART_EXTERN intptr_t Dart_InitializeApiDL(void* data); + +// ============================================================================ +// IMPORTANT! Never update these signatures without properly updating +// DART_API_DL_MAJOR_VERSION and DART_API_DL_MINOR_VERSION. +// +// Verbatim copy of `dart_native_api.h` and `dart_api.h` symbol names and types +// to trigger compile-time errors if the sybols in those files are updated +// without updating these. +// +// Function return and argument types, and typedefs are carbon copied. Structs +// are typechecked nominally in C/C++, so they are not copied, instead a +// comment is added to their definition. +typedef int64_t Dart_Port_DL; + +typedef void (*Dart_NativeMessageHandler_DL)(Dart_Port_DL dest_port_id, + Dart_CObject* message); + +// dart_native_api.h symbols can be called on any thread. +#define DART_NATIVE_API_DL_SYMBOLS(F) \ + /***** dart_native_api.h *****/ \ + /* Dart_Port */ \ + F(Dart_PostCObject, bool, (Dart_Port_DL port_id, Dart_CObject * message)) \ + F(Dart_PostInteger, bool, (Dart_Port_DL port_id, int64_t message)) \ + F(Dart_NewNativePort, Dart_Port_DL, \ + (const char* name, Dart_NativeMessageHandler_DL handler, \ + bool handle_concurrently)) \ + F(Dart_CloseNativePort, bool, (Dart_Port_DL native_port_id)) + +// dart_api.h symbols can only be called on Dart threads. +#define DART_API_DL_SYMBOLS(F) \ + /***** dart_api.h *****/ \ + /* Errors */ \ + F(Dart_IsError, bool, (Dart_Handle handle)) \ + F(Dart_IsApiError, bool, (Dart_Handle handle)) \ + F(Dart_IsUnhandledExceptionError, bool, (Dart_Handle handle)) \ + F(Dart_IsCompilationError, bool, (Dart_Handle handle)) \ + F(Dart_IsFatalError, bool, (Dart_Handle handle)) \ + F(Dart_GetError, const char*, (Dart_Handle handle)) \ + F(Dart_ErrorHasException, bool, (Dart_Handle handle)) \ + F(Dart_ErrorGetException, Dart_Handle, (Dart_Handle handle)) \ + F(Dart_ErrorGetStackTrace, Dart_Handle, (Dart_Handle handle)) \ + F(Dart_NewApiError, Dart_Handle, (const char* error)) \ + F(Dart_NewCompilationError, Dart_Handle, (const char* error)) \ + F(Dart_NewUnhandledExceptionError, Dart_Handle, (Dart_Handle exception)) \ + F(Dart_PropagateError, void, (Dart_Handle handle)) \ + /* Dart_Handle, Dart_PersistentHandle, Dart_WeakPersistentHandle */ \ + F(Dart_HandleFromPersistent, Dart_Handle, (Dart_PersistentHandle object)) \ + F(Dart_HandleFromWeakPersistent, Dart_Handle, \ + (Dart_WeakPersistentHandle object)) \ + F(Dart_NewPersistentHandle, Dart_PersistentHandle, (Dart_Handle object)) \ + F(Dart_SetPersistentHandle, void, \ + (Dart_PersistentHandle obj1, Dart_Handle obj2)) \ + F(Dart_DeletePersistentHandle, void, (Dart_PersistentHandle object)) \ + F(Dart_NewWeakPersistentHandle, Dart_WeakPersistentHandle, \ + (Dart_Handle object, void* peer, intptr_t external_allocation_size, \ + Dart_HandleFinalizer callback)) \ + F(Dart_DeleteWeakPersistentHandle, void, (Dart_WeakPersistentHandle object)) \ + F(Dart_UpdateExternalSize, void, \ + (Dart_WeakPersistentHandle object, intptr_t external_allocation_size)) \ + F(Dart_NewFinalizableHandle, Dart_FinalizableHandle, \ + (Dart_Handle object, void* peer, intptr_t external_allocation_size, \ + Dart_HandleFinalizer callback)) \ + F(Dart_DeleteFinalizableHandle, void, \ + (Dart_FinalizableHandle object, Dart_Handle strong_ref_to_object)) \ + F(Dart_UpdateFinalizableExternalSize, void, \ + (Dart_FinalizableHandle object, Dart_Handle strong_ref_to_object, \ + intptr_t external_allocation_size)) \ + /* Dart_Port */ \ + F(Dart_Post, bool, (Dart_Port_DL port_id, Dart_Handle object)) \ + F(Dart_NewSendPort, Dart_Handle, (Dart_Port_DL port_id)) \ + F(Dart_SendPortGetId, Dart_Handle, \ + (Dart_Handle port, Dart_Port_DL * port_id)) \ + /* Scopes */ \ + F(Dart_EnterScope, void, ()) \ + F(Dart_ExitScope, void, ()) + +#define DART_API_ALL_DL_SYMBOLS(F) \ + DART_NATIVE_API_DL_SYMBOLS(F) \ + DART_API_DL_SYMBOLS(F) +// IMPORTANT! Never update these signatures without properly updating +// DART_API_DL_MAJOR_VERSION and DART_API_DL_MINOR_VERSION. +// +// End of verbatim copy. +// ============================================================================ + +#define DART_API_DL_DECLARATIONS(name, R, A) \ + typedef R(*name##_Type) A; \ + DART_EXTERN name##_Type name##_DL; + +DART_API_ALL_DL_SYMBOLS(DART_API_DL_DECLARATIONS) + +#undef DART_API_DL_DEFINITIONS + +#undef DART_EXTERN + +#endif /* RUNTIME_INCLUDE_DART_API_DL_H_ */ /* NOLINT */ diff --git a/lib/src/native/include/dart/dart_native_api.h b/lib/src/native/include/dart/dart_native_api.h new file mode 100644 index 0000000..a40c522 --- /dev/null +++ b/lib/src/native/include/dart/dart_native_api.h @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file + * for details. All rights reserved. Use of this source code is governed by a + * BSD-style license that can be found in the LICENSE file. + */ + +#ifndef RUNTIME_INCLUDE_DART_NATIVE_API_H_ +#define RUNTIME_INCLUDE_DART_NATIVE_API_H_ + +#include "dart_api.h" /* NOLINT */ + +/* + * ========================================== + * Message sending/receiving from native code + * ========================================== + */ + +/** + * A Dart_CObject is used for representing Dart objects as native C + * data outside the Dart heap. These objects are totally detached from + * the Dart heap. Only a subset of the Dart objects have a + * representation as a Dart_CObject. + * + * The string encoding in the 'value.as_string' is UTF-8. + * + * All the different types from dart:typed_data are exposed as type + * kTypedData. The specific type from dart:typed_data is in the type + * field of the as_typed_data structure. The length in the + * as_typed_data structure is always in bytes. + * + * The data for kTypedData is copied on message send and ownership remains with + * the caller. The ownership of data for kExternalTyped is passed to the VM on + * message send and returned when the VM invokes the + * Dart_HandleFinalizer callback; a non-NULL callback must be provided. + */ +typedef enum { + Dart_CObject_kNull = 0, + Dart_CObject_kBool, + Dart_CObject_kInt32, + Dart_CObject_kInt64, + Dart_CObject_kDouble, + Dart_CObject_kString, + Dart_CObject_kArray, + Dart_CObject_kTypedData, + Dart_CObject_kExternalTypedData, + Dart_CObject_kSendPort, + Dart_CObject_kCapability, + Dart_CObject_kUnsupported, + Dart_CObject_kNumberOfTypes +} Dart_CObject_Type; + +typedef struct _Dart_CObject { + Dart_CObject_Type type; + union { + bool as_bool; + int32_t as_int32; + int64_t as_int64; + double as_double; + char* as_string; + struct { + Dart_Port id; + Dart_Port origin_id; + } as_send_port; + struct { + int64_t id; + } as_capability; + struct { + intptr_t length; + struct _Dart_CObject** values; + } as_array; + struct { + Dart_TypedData_Type type; + intptr_t length; + uint8_t* values; + } as_typed_data; + struct { + Dart_TypedData_Type type; + intptr_t length; + uint8_t* data; + void* peer; + Dart_HandleFinalizer callback; + } as_external_typed_data; + } value; +} Dart_CObject; +// This struct is versioned by DART_API_DL_MAJOR_VERSION, bump the version when +// changing this struct. + +/** + * Posts a message on some port. The message will contain the Dart_CObject + * object graph rooted in 'message'. + * + * While the message is being sent the state of the graph of Dart_CObject + * structures rooted in 'message' should not be accessed, as the message + * generation will make temporary modifications to the data. When the message + * has been sent the graph will be fully restored. + * + * If true is returned, the message was enqueued, and finalizers for external + * typed data will eventually run, even if the receiving isolate shuts down + * before processing the message. If false is returned, the message was not + * enqueued and ownership of external typed data in the message remains with the + * caller. + * + * This function may be called on any thread when the VM is running (that is, + * after Dart_Initialize has returned and before Dart_Cleanup has been called). + * + * \param port_id The destination port. + * \param message The message to send. + * + * \return True if the message was posted. + */ +DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject* message); + +/** + * Posts a message on some port. The message will contain the integer 'message'. + * + * \param port_id The destination port. + * \param message The message to send. + * + * \return True if the message was posted. + */ +DART_EXPORT bool Dart_PostInteger(Dart_Port port_id, int64_t message); + +/** + * A native message handler. + * + * This handler is associated with a native port by calling + * Dart_NewNativePort. + * + * The message received is decoded into the message structure. The + * lifetime of the message data is controlled by the caller. All the + * data references from the message are allocated by the caller and + * will be reclaimed when returning to it. + */ +typedef void (*Dart_NativeMessageHandler)(Dart_Port dest_port_id, + Dart_CObject* message); + +/** + * Creates a new native port. When messages are received on this + * native port, then they will be dispatched to the provided native + * message handler. + * + * \param name The name of this port in debugging messages. + * \param handler The C handler to run when messages arrive on the port. + * \param handle_concurrently Is it okay to process requests on this + * native port concurrently? + * + * \return If successful, returns the port id for the native port. In + * case of error, returns ILLEGAL_PORT. + */ +DART_EXPORT Dart_Port Dart_NewNativePort(const char* name, + Dart_NativeMessageHandler handler, + bool handle_concurrently); +/* TODO(turnidge): Currently handle_concurrently is ignored. */ + +/** + * Closes the native port with the given id. + * + * The port must have been allocated by a call to Dart_NewNativePort. + * + * \param native_port_id The id of the native port to close. + * + * \return Returns true if the port was closed successfully. + */ +DART_EXPORT bool Dart_CloseNativePort(Dart_Port native_port_id); + +/* + * ================== + * Verification Tools + * ================== + */ + +/** + * Forces all loaded classes and functions to be compiled eagerly in + * the current isolate.. + * + * TODO(turnidge): Document. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CompileAll(); + +/** + * Finalizes all classes. + */ +DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_FinalizeAllClasses(); + +/* This function is intentionally undocumented. + * + * It should not be used outside internal tests. + */ +DART_EXPORT void* Dart_ExecuteInternalCommand(const char* command, void* arg); + +#endif /* INCLUDE_DART_NATIVE_API_H_ */ /* NOLINT */ diff --git a/lib/src/native/include/dart/dart_tools_api.h b/lib/src/native/include/dart/dart_tools_api.h new file mode 100644 index 0000000..a106d42 --- /dev/null +++ b/lib/src/native/include/dart/dart_tools_api.h @@ -0,0 +1,499 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +#ifndef RUNTIME_INCLUDE_DART_TOOLS_API_H_ +#define RUNTIME_INCLUDE_DART_TOOLS_API_H_ + +#include "dart_api.h" /* NOLINT */ + +/** \mainpage Dart Tools Embedding API Reference + * + * This reference describes the Dart embedding API for tools. Tools include + * a debugger, service protocol, and timeline. + * + * NOTE: The APIs described in this file are unstable and subject to change. + * + * This reference is generated from the header include/dart_tools_api.h. + */ + +/* + * ======== + * Debugger + * ======== + */ + +/** + * ILLEGAL_ISOLATE_ID is a number guaranteed never to be associated with a + * valid isolate. + */ +#define ILLEGAL_ISOLATE_ID ILLEGAL_PORT + + +/* + * ======= + * Service + * ======= + */ + +/** + * A service request callback function. + * + * These callbacks, registered by the embedder, are called when the VM receives + * a service request it can't handle and the service request command name + * matches one of the embedder registered handlers. + * + * The return value of the callback indicates whether the response + * should be used as a regular result or an error result. + * Specifically, if the callback returns true, a regular JSON-RPC + * response is built in the following way: + * + * { + * "jsonrpc": "2.0", + * "result": , + * "id": , + * } + * + * If the callback returns false, a JSON-RPC error is built like this: + * + * { + * "jsonrpc": "2.0", + * "error": , + * "id": , + * } + * + * \param method The rpc method name. + * \param param_keys Service requests can have key-value pair parameters. The + * keys and values are flattened and stored in arrays. + * \param param_values The values associated with the keys. + * \param num_params The length of the param_keys and param_values arrays. + * \param user_data The user_data pointer registered with this handler. + * \param result A C string containing a valid JSON object. The returned + * pointer will be freed by the VM by calling free. + * + * \return True if the result is a regular JSON-RPC response, false if the + * result is a JSON-RPC error. + */ +typedef bool (*Dart_ServiceRequestCallback)(const char* method, + const char** param_keys, + const char** param_values, + intptr_t num_params, + void* user_data, + const char** json_object); + +/** + * Register a Dart_ServiceRequestCallback to be called to handle + * requests for the named rpc on a specific isolate. The callback will + * be invoked with the current isolate set to the request target. + * + * \param method The name of the method that this callback is responsible for. + * \param callback The callback to invoke. + * \param user_data The user data passed to the callback. + * + * NOTE: If multiple callbacks with the same name are registered, only + * the last callback registered will be remembered. + */ +DART_EXPORT void Dart_RegisterIsolateServiceRequestCallback( + const char* method, + Dart_ServiceRequestCallback callback, + void* user_data); + +/** + * Register a Dart_ServiceRequestCallback to be called to handle + * requests for the named rpc. The callback will be invoked without a + * current isolate. + * + * \param method The name of the command that this callback is responsible for. + * \param callback The callback to invoke. + * \param user_data The user data passed to the callback. + * + * NOTE: If multiple callbacks with the same name are registered, only + * the last callback registered will be remembered. + */ +DART_EXPORT void Dart_RegisterRootServiceRequestCallback( + const char* method, + Dart_ServiceRequestCallback callback, + void* user_data); + +/** + * Embedder information which can be requested by the VM for internal or + * reporting purposes. + * + * The pointers in this structure are not going to be cached or freed by the VM. + */ + + #define DART_EMBEDDER_INFORMATION_CURRENT_VERSION (0x00000001) + +typedef struct { + int32_t version; + const char* name; // [optional] The name of the embedder + int64_t current_rss; // [optional] the current RSS of the embedder + int64_t max_rss; // [optional] the maximum RSS of the embedder +} Dart_EmbedderInformation; + +/** + * Callback provided by the embedder that is used by the vm to request + * information. + * + * \return Returns a pointer to a Dart_EmbedderInformation structure. + * The embedder keeps the ownership of the structure and any field in it. + * The embedder must ensure that the structure will remain valid until the + * next invokation of the callback. + */ +typedef void (*Dart_EmbedderInformationCallback)( + Dart_EmbedderInformation* info); + +/** + * Register a Dart_ServiceRequestCallback to be called to handle + * requests for the named rpc. The callback will be invoked without a + * current isolate. + * + * \param method The name of the command that this callback is responsible for. + * \param callback The callback to invoke. + * \param user_data The user data passed to the callback. + * + * NOTE: If multiple callbacks with the same name are registered, only + * the last callback registered will be remembered. + */ +DART_EXPORT void Dart_SetEmbedderInformationCallback( + Dart_EmbedderInformationCallback callback); + +/** + * Invoke a vm-service method and wait for its result. + * + * \param request_json The utf8-encoded json-rpc request. + * \param request_json_length The length of the json-rpc request. + * + * \param response_json The returned utf8-encoded json response, must be + * free()ed by caller. + * \param response_json_length The length of the returned json response. + * \param error An optional error, must be free()ed by caller. + * + * \return Whether the call was sucessfully performed. + * + * NOTE: This method does not need a current isolate and must not have the + * vm-isolate being the current isolate. It must be called after + * Dart_Initialize() and before Dart_Cleanup(). + */ +DART_EXPORT bool Dart_InvokeVMServiceMethod(uint8_t* request_json, + intptr_t request_json_length, + uint8_t** response_json, + intptr_t* response_json_length, + char** error); + +/* + * ======== + * Event Streams + * ======== + */ + +/** + * A callback invoked when the VM service gets a request to listen to + * some stream. + * + * \return Returns true iff the embedder supports the named stream id. + */ +typedef bool (*Dart_ServiceStreamListenCallback)(const char* stream_id); + +/** + * A callback invoked when the VM service gets a request to cancel + * some stream. + */ +typedef void (*Dart_ServiceStreamCancelCallback)(const char* stream_id); + +/** + * Adds VM service stream callbacks. + * + * \param listen_callback A function pointer to a listen callback function. + * A listen callback function should not be already set when this function + * is called. A NULL value removes the existing listen callback function + * if any. + * + * \param cancel_callback A function pointer to a cancel callback function. + * A cancel callback function should not be already set when this function + * is called. A NULL value removes the existing cancel callback function + * if any. + * + * \return Success if the callbacks were added. Otherwise, returns an + * error handle. + */ +DART_EXPORT char* Dart_SetServiceStreamCallbacks( + Dart_ServiceStreamListenCallback listen_callback, + Dart_ServiceStreamCancelCallback cancel_callback); + +/** + * A callback invoked when the VM service receives an event. + */ +typedef void (*Dart_NativeStreamConsumer)(const uint8_t* event_json, + intptr_t event_json_length); + +/** + * Sets the native VM service stream callbacks for a particular stream. + * Note: The function may be called on multiple threads concurrently. + * + * \param consumer A function pointer to an event handler callback function. + * A NULL value removes the existing listen callback function if any. + * + * \param stream_id The ID of the stream on which to set the callback. + */ +DART_EXPORT void Dart_SetNativeServiceStreamCallback( + Dart_NativeStreamConsumer consumer, + const char* stream_id); + +/** + * Sends a data event to clients of the VM Service. + * + * A data event is used to pass an array of bytes to subscribed VM + * Service clients. For example, in the standalone embedder, this is + * function used to provide WriteEvents on the Stdout and Stderr + * streams. + * + * If the embedder passes in a stream id for which no client is + * subscribed, then the event is ignored. + * + * \param stream_id The id of the stream on which to post the event. + * + * \param event_kind A string identifying what kind of event this is. + * For example, 'WriteEvent'. + * + * \param bytes A pointer to an array of bytes. + * + * \param bytes_length The length of the byte array. + * + * \return Success if the arguments are well formed. Otherwise, returns an + * error handle. + */ +DART_EXPORT Dart_Handle Dart_ServiceSendDataEvent(const char* stream_id, + const char* event_kind, + const uint8_t* bytes, + intptr_t bytes_length); + +/** + * Usage statistics for a space/generation at a particular moment in time. + * + * \param used Amount of memory used, in bytes. + * + * \param capacity Memory capacity, in bytes. + * + * \param external External memory, in bytes. + * + * \param collections How many times the garbage collector has run in this + * space. + * + * \param time Cumulative time spent collecting garbage in this space, in + * seconds. + * + * \param avg_collection_period Average time between garbage collector running + * in this space, in milliseconds. + */ +typedef struct { + intptr_t used; + intptr_t capacity; + intptr_t external; + intptr_t collections; + double time; + double avg_collection_period; +} Dart_GCStats; + +/** + * A Garbage Collection event with memory usage statistics. + * + * \param type The event type. Static lifetime. + * + * \param reason The reason for the GC event. Static lifetime. + * + * \param new_space Data for New Space. + * + * \param old_space Data for Old Space. + */ +typedef struct { + const char* type; + const char* reason; + const char* isolate_id; + + Dart_GCStats new_space; + Dart_GCStats old_space; +} Dart_GCEvent; + +/** + * A callback invoked when the VM emits a GC event. + * + * \param event The GC event data. Pointer only valid for the duration of the + * callback. + */ +typedef void (*Dart_GCEventCallback)(Dart_GCEvent* event); + +/** + * Sets the native GC event callback. + * + * \param callback A function pointer to an event handler callback function. + * A NULL value removes the existing listen callback function if any. + */ +DART_EXPORT void Dart_SetGCEventCallback(Dart_GCEventCallback callback); + +/* + * ======== + * Reload support + * ======== + * + * These functions are used to implement reloading in the Dart VM. + * This is an experimental feature, so embedders should be prepared + * for these functions to change. + */ + +/** + * A callback which determines whether the file at some url has been + * modified since some time. If the file cannot be found, true should + * be returned. + */ +typedef bool (*Dart_FileModifiedCallback)(const char* url, int64_t since); + +DART_EXPORT char* Dart_SetFileModifiedCallback( + Dart_FileModifiedCallback file_modified_callback); + +/** + * Returns true if isolate is currently reloading. + */ +DART_EXPORT bool Dart_IsReloading(); + +/* + * ======== + * Timeline + * ======== + */ + +/** + * Returns a timestamp in microseconds. This timestamp is suitable for + * passing into the timeline system, and uses the same monotonic clock + * as dart:developer's Timeline.now. + * + * \return A timestamp that can be passed to the timeline system. + */ +DART_EXPORT int64_t Dart_TimelineGetMicros(); + +/** Timeline stream for Dart API calls */ +#define DART_TIMELINE_STREAM_API (1 << 0) +/** Timeline stream for compiler events */ +#define DART_TIMELINE_STREAM_COMPILER (1 << 1) +/** Timeline stream for Dart provided events */ +#define DART_TIMELINE_STREAM_DART (1 << 2) +/** Timeline stream for debugger provided events */ +#define DART_TIMELINE_STREAM_DEBUGGER (1 << 3) +/** Timeline stream for embedder provided events */ +#define DART_TIMELINE_STREAM_EMBEDDER (1 << 4) +/** Timeline stream for GC events */ +#define DART_TIMELINE_STREAM_GC (1 << 5) +/** Timeline stream for isolate events */ +#define DART_TIMELINE_STREAM_ISOLATE (1 << 6) +/** Timeline stream for VM events */ +#define DART_TIMELINE_STREAM_VM (1 << 7) + +/** All timeline streams */ +#define DART_TIMELINE_STREAM_ALL \ + (DART_TIMELINE_STREAM_API | DART_TIMELINE_STREAM_COMPILER | \ + DART_TIMELINE_STREAM_DART | DART_TIMELINE_STREAM_DEBUGGER | \ + DART_TIMELINE_STREAM_EMBEDDER | DART_TIMELINE_STREAM_GC | \ + DART_TIMELINE_STREAM_ISOLATE | DART_TIMELINE_STREAM_VM) + +/** Disable all timeline stream recording */ +#define DART_TIMELINE_STREAM_DISABLE 0 + +/** + * Start recording timeline events for the entire VM (including all isolates). + * + * \param stream_mask A bitmask of streams that should be recorded. + * + * NOTE: Calling with 0 disables recording of all streams. + */ +DART_EXPORT void Dart_GlobalTimelineSetRecordedStreams(int64_t stream_mask); + +typedef enum { + Dart_Timeline_Event_Begin, // Phase = 'B'. + Dart_Timeline_Event_End, // Phase = 'E'. + Dart_Timeline_Event_Instant, // Phase = 'i'. + Dart_Timeline_Event_Duration, // Phase = 'X'. + Dart_Timeline_Event_Async_Begin, // Phase = 'b'. + Dart_Timeline_Event_Async_End, // Phase = 'e'. + Dart_Timeline_Event_Async_Instant, // Phase = 'n'. + Dart_Timeline_Event_Counter, // Phase = 'C'. + Dart_Timeline_Event_Flow_Begin, // Phase = 's'. + Dart_Timeline_Event_Flow_Step, // Phase = 't'. + Dart_Timeline_Event_Flow_End, // Phase = 'f'. +} Dart_Timeline_Event_Type; + +/** + * Add a timeline event to the embedder stream. + * + * \param label The name of the event. Its lifetime must extend at least until + * Dart_Cleanup. + * \param timestamp0 The first timestamp of the event. + * \param timestamp1_or_async_id The second timestamp of the event or + * the async id. + * \param argument_count The number of argument names and values. + * \param argument_names An array of names of the arguments. The lifetime of the + * names must extend at least until Dart_Cleanup. The array may be reclaimed + * when this call returns. + * \param argument_values An array of values of the arguments. The values and + * the array may be reclaimed when this call returns. + */ +DART_EXPORT void Dart_TimelineEvent(const char* label, + int64_t timestamp0, + int64_t timestamp1_or_async_id, + Dart_Timeline_Event_Type type, + intptr_t argument_count, + const char** argument_names, + const char** argument_values); + +/** + * Associates a name with the current thread. This name will be used to name + * threads in the timeline. Can only be called after a call to Dart_Initialize. + * + * \param name The name of the thread. + */ +DART_EXPORT void Dart_SetThreadName(const char* name); + +/* + * ======= + * Metrics + * ======= + */ + +/** + * Return metrics gathered for the VM and individual isolates. + * + * NOTE: Non-heap metrics are not available in PRODUCT builds of Dart. + * Calling the non-heap metric functions on a PRODUCT build might return invalid metrics. + */ +DART_EXPORT int64_t Dart_VMIsolateCountMetric(); // Counter +DART_EXPORT int64_t Dart_VMCurrentRSSMetric(); // Byte +DART_EXPORT int64_t Dart_VMPeakRSSMetric(); // Byte +DART_EXPORT int64_t +Dart_IsolateHeapOldUsedMetric(Dart_Isolate isolate); // Byte +DART_EXPORT int64_t +Dart_IsolateHeapOldUsedMaxMetric(Dart_Isolate isolate); // Byte +DART_EXPORT int64_t +Dart_IsolateHeapOldCapacityMetric(Dart_Isolate isolate); // Byte +DART_EXPORT int64_t +Dart_IsolateHeapOldCapacityMaxMetric(Dart_Isolate isolate); // Byte +DART_EXPORT int64_t +Dart_IsolateHeapOldExternalMetric(Dart_Isolate isolate); // Byte +DART_EXPORT int64_t +Dart_IsolateHeapNewUsedMetric(Dart_Isolate isolate); // Byte +DART_EXPORT int64_t +Dart_IsolateHeapNewUsedMaxMetric(Dart_Isolate isolate); // Byte +DART_EXPORT int64_t +Dart_IsolateHeapNewCapacityMetric(Dart_Isolate isolate); // Byte +DART_EXPORT int64_t +Dart_IsolateHeapNewCapacityMaxMetric(Dart_Isolate isolate); // Byte +DART_EXPORT int64_t +Dart_IsolateHeapNewExternalMetric(Dart_Isolate isolate); // Byte +DART_EXPORT int64_t +Dart_IsolateHeapGlobalUsedMetric(Dart_Isolate isolate); // Byte +DART_EXPORT int64_t +Dart_IsolateHeapGlobalUsedMaxMetric(Dart_Isolate isolate); // Byte +DART_EXPORT int64_t +Dart_IsolateRunnableLatencyMetric(Dart_Isolate isolate); // Microsecond +DART_EXPORT int64_t +Dart_IsolateRunnableHeapSizeMetric(Dart_Isolate isolate); // Byte + +#endif // RUNTIME_INCLUDE_DART_TOOLS_API_H_ diff --git a/lib/src/native/include/dart/dart_version.h b/lib/src/native/include/dart/dart_version.h new file mode 100644 index 0000000..b3b4924 --- /dev/null +++ b/lib/src/native/include/dart/dart_version.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file + * for details. All rights reserved. Use of this source code is governed by a + * BSD-style license that can be found in the LICENSE file. + */ + +#ifndef RUNTIME_INCLUDE_DART_VERSION_H_ +#define RUNTIME_INCLUDE_DART_VERSION_H_ + +// On breaking changes the major version is increased. +// On backwards compatible changes the minor version is increased. +// The versioning covers the symbols exposed in dart_api_dl.h +#define DART_API_DL_MAJOR_VERSION 2 +#define DART_API_DL_MINOR_VERSION 0 + +#endif /* RUNTIME_INCLUDE_DART_VERSION_H_ */ /* NOLINT */ diff --git a/lib/src/native/include/dart/runtime/dart_api_dl_impl.h b/lib/src/native/include/dart/runtime/dart_api_dl_impl.h new file mode 100644 index 0000000..ad13a4b --- /dev/null +++ b/lib/src/native/include/dart/runtime/dart_api_dl_impl.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file + * for details. All rights reserved. Use of this source code is governed by a + * BSD-style license that can be found in the LICENSE file. + */ + +#ifndef RUNTIME_INCLUDE_INTERNAL_DART_API_DL_IMPL_H_ +#define RUNTIME_INCLUDE_INTERNAL_DART_API_DL_IMPL_H_ + +typedef struct { + const char* name; + void (*function)(); +} DartApiEntry; + +typedef struct { + const int major; + const int minor; + const DartApiEntry* const functions; +} DartApi; + +#endif /* RUNTIME_INCLUDE_INTERNAL_DART_API_DL_IMPL_H_ */ /* NOLINT */ diff --git a/lib/src/native/wrapper/CMakeLists.txt b/lib/src/native/wrapper/CMakeLists.txt new file mode 100644 index 0000000..3e70b1f --- /dev/null +++ b/lib/src/native/wrapper/CMakeLists.txt @@ -0,0 +1,46 @@ +# CMAKE file for windows build. + +cmake_minimum_required(VERSION 3.15) +set(PROJECT_NAME "cronet_sample") +project(${PROJECT_NAME} LANGUAGES C CXX) + +# This value is used when generating builds using this plugin, so it must +# not be changed +set(PLUGIN_NAME "wrapper") + +add_compile_definitions(WIN32) +add_compile_definitions(DART_SHARED_LIB) + + +add_library(${PLUGIN_NAME} SHARED + "wrapper.cc" + "sample_executor.cc" + "${CMAKE_CURRENT_SOURCE_DIR}/../include/dart/dart_api_dl.c" +) + +# apply_standard_settings(${PLUGIN_NAME}) + +set_target_properties(${PLUGIN_NAME} PROPERTIES + CXX_VISIBILITY_PRESET hidden) + +target_include_directories(${PLUGIN_NAME} INTERFACE + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/../include/dart" + "${CMAKE_CURRENT_SOURCE_DIR}/../include/dart/runtime" + +) + +set(DART_DIR "C:/tools/dart-sdk/bin") +find_library(DART_LIB dart.lib ${DART_DIR}) +target_link_libraries(${PLUGIN_NAME} PRIVATE ${DART_LIB}) + + +set(MSVC_DISABLED_WARNINGS_LIST + "C4152" # nonstandard extension, function/data pointer conversion in expression + "C4255" + "C4820" + "C4255" + "C4668" +) +string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR ${MSVC_DISABLED_WARNINGS_LIST}) +set(CMAKE_C_FLAGS "-utf-8 -Wall -WX ${MSVC_DISABLED_WARNINGS_STR}") \ No newline at end of file diff --git a/lib/src/native/wrapper/build.sh b/lib/src/native/wrapper/build.sh new file mode 100644 index 0000000..e61d3ba --- /dev/null +++ b/lib/src/native/wrapper/build.sh @@ -0,0 +1,8 @@ +# Takes the path to wrapper source code path & cronet version as parameter +if [ $# -le 1 ] + then + echo "Provide '\"\"'" + exit 2 +fi +cd $1 +g++ -std=c++11 -DCRONET_VERSION=$2 -fPIC -rdynamic -shared -W -o wrapper.so wrapper.cc sample_executor.cc ../include/dart/dart_api_dl.c -ldl -I../include/dart/ -DDART_SHARED_LIB -fpermissive -Wl,-z,origin -Wl,-rpath,'$ORIGIN' -Wl,-rpath,'$ORIGIN/cronet_binaries/linux64/' diff --git a/lib/src/native/wrapper/sample_executor.cc b/lib/src/native/wrapper/sample_executor.cc new file mode 100644 index 0000000..6ca3559 --- /dev/null +++ b/lib/src/native/wrapper/sample_executor.cc @@ -0,0 +1,119 @@ +// Derived from Chromium sample. + +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#include "sample_executor.h" +#include +extern LIBTYPE handle; + +// cronet function loading and exposing macros +// use IMPORT to expose a API unchanged or just for private use - accessable as func_name +// use P_IMPORT for those API who needs to be wrapped before exposing - accessable as _func_name + +#define IMPORT(r_type, f_name, ...) r_type (* f_name) (__VA_ARGS__) = reinterpret_cast(dlsym(handle, #f_name)) + +#define P_IMPORT(r_type, f_name, ...) r_type (* _ ## f_name) (__VA_ARGS__) = reinterpret_cast(dlsym(handle, #f_name)) + +/* Executor Only */ + +IMPORT(Cronet_ExecutorPtr, Cronet_Executor_CreateWith, Cronet_Executor_ExecuteFunc); +IMPORT(void, Cronet_Executor_SetClientContext, Cronet_ExecutorPtr, Cronet_ClientContext); +IMPORT(void, Cronet_Executor_Destroy, Cronet_ExecutorPtr); +IMPORT(void, Cronet_Runnable_Run, Cronet_RunnablePtr); +IMPORT(void, Cronet_Runnable_Destroy, Cronet_RunnablePtr); +IMPORT(Cronet_ClientContext, Cronet_Executor_GetClientContext, Cronet_ExecutorPtr); + +SampleExecutor::SampleExecutor() + : executor_thread_(SampleExecutor::ThreadLoop, this) {} +SampleExecutor::~SampleExecutor() { + std::cout << "SampleExec Destructor" << std::endl; + ShutdownExecutor(); + Cronet_Executor_Destroy(executor_); +} + +void SampleExecutor::Init() { + executor_ = Cronet_Executor_CreateWith(SampleExecutor::Execute); + Cronet_Executor_SetClientContext(executor_, this); +} + +Cronet_ExecutorPtr SampleExecutor::GetExecutor() { + return executor_; +} +void SampleExecutor::ShutdownExecutor() { + printf("Executor shut down\n"); + // Break tasks loop. + { + std::lock_guard lock(lock_); + stop_thread_loop_ = true; + } + task_available_.notify_one(); + // Wait for executor thread. + executor_thread_.join(); +} +void SampleExecutor::RunTasksInQueue() { + printf("Running tasks"); + // Process runnables in |task_queue_|. + while (true) { + printf("loop\n"); + Cronet_RunnablePtr runnable = nullptr; + { + + // Wait for a task to run or stop signal. + std::unique_lock lock(lock_); + while (task_queue_.empty() && !stop_thread_loop_) { + printf("waiting\n"); + task_available_.wait(lock); + } + if (stop_thread_loop_) { + printf("stop thread\n"); + break; + } + if (task_queue_.empty()) { + printf("task queue empty\n"); + continue; + } + runnable = task_queue_.front(); + task_queue_.pop(); + + } + Cronet_Runnable_Run(runnable); + Cronet_Runnable_Destroy(runnable); + } + // Delete remaining tasks. + std::queue tasks_to_destroy; + { + std::unique_lock lock(lock_); + tasks_to_destroy.swap(task_queue_); + } + while (!tasks_to_destroy.empty()) { + Cronet_Runnable_Destroy(tasks_to_destroy.front()); + tasks_to_destroy.pop(); + } +} +/* static */ +void SampleExecutor::ThreadLoop(SampleExecutor* executor) { + executor->RunTasksInQueue(); +} +void SampleExecutor::Execute(Cronet_RunnablePtr runnable) { + // printf("Execute\n"); + { + std::lock_guard lock(lock_); + if (!stop_thread_loop_) { + task_queue_.push(runnable); + runnable = nullptr; + } + } + if (runnable) { + Cronet_Runnable_Destroy(runnable); + } else { + task_available_.notify_one(); + } +} +/* static */ +void SampleExecutor::Execute(Cronet_ExecutorPtr self, + Cronet_RunnablePtr runnable) { + auto* executor = + static_cast(Cronet_Executor_GetClientContext(self)); + executor->Execute(runnable); +} \ No newline at end of file diff --git a/lib/src/native/wrapper/sample_executor.h b/lib/src/native/wrapper/sample_executor.h new file mode 100644 index 0000000..56285db --- /dev/null +++ b/lib/src/native/wrapper/sample_executor.h @@ -0,0 +1,45 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#ifndef COMPONENTS_CRONET_NATIVE_SAMPLE_SAMPLE_EXECUTOR_H_ +#define COMPONENTS_CRONET_NATIVE_SAMPLE_SAMPLE_EXECUTOR_H_ +// Cronet sample is expected to be used outside of Chromium infrastructure, +// and as such has to rely on STL directly instead of //base alternatives. +#include +#include +#include +#include +#include "wrapper.h" +// Sample implementation of Cronet_Executor interface using static +// methods to map C API into instance of C++ class. +class SampleExecutor { + public: + SampleExecutor(); + ~SampleExecutor(); + void Init(); + // Gets Cronet_ExecutorPtr implemented by |this|. + Cronet_ExecutorPtr GetExecutor(); + // Shuts down the executor, so all pending tasks are destroyed without + // getting executed. + void ShutdownExecutor(); + private: + // Runs tasks in |task_queue_| until |stop_thread_loop_| is set to true. + void RunTasksInQueue(); + static void ThreadLoop(SampleExecutor* executor); + // Adds |runnable| to |task_queue_| to execute on |executor_thread_|. + void Execute(Cronet_RunnablePtr runnable); + // Implementation of Cronet_Executor methods. + static void Execute(Cronet_ExecutorPtr self, Cronet_RunnablePtr runnable); + // Synchronise access to |task_queue_| and |stop_thread_loop_|; + std::mutex lock_; + // Tasks to run. + std::queue task_queue_; + // Notified if task is added to |task_queue_| or |stop_thread_loop_| is set. + std::condition_variable task_available_; + // Set to true to stop running tasks. + bool stop_thread_loop_ = false; + // Thread on which tasks are executed. + std::thread executor_thread_; + Cronet_ExecutorPtr executor_; +}; +#endif // COMPONENTS_CRONET_NATIVE_SAMPLE_SAMPLE_EXECUTOR_H_ \ No newline at end of file diff --git a/lib/src/native/wrapper/wrapper.cc b/lib/src/native/wrapper/wrapper.cc new file mode 100644 index 0000000..79ddd5d --- /dev/null +++ b/lib/src/native/wrapper/wrapper.cc @@ -0,0 +1,426 @@ +#include "../include/dart/dart_api.h" +#include "../include/dart/dart_native_api.h" +#include "../include/dart/dart_tools_api.h" +// #include"dart_api_dl.c" +#include "wrapper.h" +#include "sample_executor.h" +#include +#include +#include + +// Set CRONET_VERSION from build script + +#ifdef CRONET_VERSION + #define CRONET_LIB_NAME CRONET_LIB_PREFIX "." CRONET_VERSION CRONET_LIB_EXTENSION +#else + #define CRONET_LIB_NAME CRONET_LIB_PREFIX ".86.0.4240.198" CRONET_LIB_EXTENSION +#endif + +// cronet function loading and exposing macros +// use IMPORT for private use - accessable as func_name +// use P_IMPORT for those API who needs to be wrapped before exposing - accessable as _func_name + +#define IMPORT(r_type, f_name, ...) r_type (* f_name) (__VA_ARGS__) = reinterpret_cast(dlsym(handle, #f_name)) + +#define P_IMPORT(r_type, f_name, ...) r_type (* _ ## f_name) (__VA_ARGS__) = reinterpret_cast(dlsym(handle, #f_name)) + +//////////////////////////////////////////////////////////////////////////////// +// Initialize `dart_api_dl.h` +intptr_t InitDartApiDL(void* data) { + printf("Initializing"); + return Dart_InitializeApiDL(data); +} + +//////////////////////////////////////////////////////////////////////////////// + +// loading cronet +LIBTYPE handle = OPENLIB(CRONET_LIB_NAME); +std::unordered_map requestNativePorts; + +static void FreeFinalizer(void*, void* value) { + free(value); +} + + +/* Callback Helpers */ + +// Registers the Dart side's +// ReceievePort's NativePort component +// +// This is required to send the data +void registerCallbackHandler(Dart_Port send_port, Cronet_UrlRequestPtr rp) { + requestNativePorts[rp] = send_port; +} + +// This sends the callback name and the associated data +// with it to the Dart side via NativePort +// +// Sent data is broken into 3 parts. +// message[0] is the method name, which is a string +// message[1] contains all the data to pass to that method +void dispatchCallback(const char* methodname, Cronet_UrlRequestPtr request, Dart_CObject args) { + Dart_CObject c_method_name; + c_method_name.type = Dart_CObject_kString; + c_method_name.value.as_string = const_cast(methodname); + + Dart_CObject* c_request_arr[] = {&c_method_name, &args}; + Dart_CObject c_request; + + c_request.type = Dart_CObject_kArray; + c_request.value.as_array.values = c_request_arr; + c_request.value.as_array.length = + sizeof(c_request_arr) / sizeof(c_request_arr[0]); + + Dart_PostCObject_DL(requestNativePorts[request], &c_request); +} + +// Builds the arguments to pass to the Dart side +// as a parameter to the callbacks +// Data processed here are +// consumed as from message[2] if +// message is the name of the data +// receieved by the ReceievePort +Dart_CObject callbackArgBuilder(int num, ...) { + Dart_CObject c_request_data; + va_list valist; + va_start(valist, num); + void* request_buffer = malloc(sizeof(uint64_t) * num); + uint64_t* buf = reinterpret_cast(request_buffer); + + for(int i = 0; i < num; i++) { + buf[i] = va_arg(valist,uint64_t); + } + + c_request_data.type = Dart_CObject_kExternalTypedData; + c_request_data.value.as_external_typed_data.type = Dart_TypedData_kUint64; + c_request_data.value.as_external_typed_data.length = sizeof(uint64_t) * num; // 4 args to pass + c_request_data.value.as_external_typed_data.data = static_cast(request_buffer); + c_request_data.value.as_external_typed_data.peer = request_buffer; + c_request_data.value.as_external_typed_data.callback = FreeFinalizer; + + va_end(valist); + + return c_request_data; +} + + +/* Getting Cronet's Functions */ +P_IMPORT(Cronet_EnginePtr,Cronet_Engine_Create , void); +P_IMPORT(void, Cronet_Engine_Destroy, Cronet_EnginePtr); +P_IMPORT(Cronet_RESULT, Cronet_Engine_Shutdown, Cronet_EnginePtr); +P_IMPORT(Cronet_String, Cronet_Engine_GetVersionString, Cronet_EnginePtr); + +P_IMPORT(Cronet_EngineParamsPtr, Cronet_EngineParams_Create, void); +P_IMPORT(void, Cronet_EngineParams_Destroy, Cronet_EngineParamsPtr); + +P_IMPORT(Cronet_QuicHintPtr,Cronet_QuicHint_Create, void); +P_IMPORT(void, Cronet_QuicHint_Destroy, Cronet_QuicHintPtr); +P_IMPORT(void, Cronet_QuicHint_host_set, Cronet_QuicHintPtr self, const Cronet_String host); +P_IMPORT(void, Cronet_QuicHint_port_set, Cronet_QuicHintPtr self, const int32_t port); +P_IMPORT(void, Cronet_QuicHint_alternate_port_set, Cronet_QuicHintPtr self, const int32_t alternate_port); + +P_IMPORT(void, Cronet_EngineParams_enable_check_result_set, Cronet_EngineParamsPtr, const bool); +P_IMPORT(void, Cronet_EngineParams_user_agent_set, Cronet_EngineParamsPtr, const Cronet_String); +P_IMPORT(void, Cronet_EngineParams_enable_quic_set, Cronet_EngineParamsPtr, const bool); +P_IMPORT(void, Cronet_EngineParams_quic_hints_add, Cronet_EngineParamsPtr self,const Cronet_QuicHintPtr element); +P_IMPORT(void, Cronet_EngineParams_enable_http2_set, Cronet_EngineParamsPtr, const bool); +P_IMPORT(void, Cronet_EngineParams_enable_brotli_set, Cronet_EngineParamsPtr, const bool); +P_IMPORT(void, Cronet_EngineParams_accept_language_set, Cronet_EngineParamsPtr, const Cronet_String); +P_IMPORT(void, Cronet_EngineParams_http_cache_mode_set, Cronet_EngineParamsPtr, const Cronet_EngineParams_HTTP_CACHE_MODE http_cache_mode); +P_IMPORT(void, Cronet_EngineParams_http_cache_max_size_set, Cronet_EngineParamsPtr, const int64_t http_cache_max_size); +P_IMPORT(void, Cronet_EngineParams_storage_path_set, Cronet_EngineParamsPtr, const Cronet_String storage_path); + +P_IMPORT(Cronet_RESULT, Cronet_Engine_StartWithParams, Cronet_EnginePtr, Cronet_EngineParamsPtr); +P_IMPORT(Cronet_UrlRequestPtr, Cronet_UrlRequest_Create, void); +P_IMPORT(void, Cronet_UrlRequest_Destroy, Cronet_UrlRequestPtr); +P_IMPORT(void, Cronet_UrlRequest_Cancel, Cronet_UrlRequestPtr); +P_IMPORT(void, Cronet_UrlRequest_SetClientContext, Cronet_UrlRequestPtr, Cronet_ClientContext); +P_IMPORT(Cronet_ClientContext, Cronet_UrlRequest_GetClientContext, Cronet_UrlRequestPtr); +P_IMPORT(Cronet_UrlRequestParamsPtr, Cronet_UrlRequestParams_Create, void); +P_IMPORT(void, Cronet_UrlRequestParams_http_method_set, Cronet_UrlRequestParamsPtr, const Cronet_String); + +P_IMPORT(void, Cronet_UrlRequestParams_request_headers_add, Cronet_UrlRequestParamsPtr, const Cronet_HttpHeaderPtr); + +void Cronet_UrlRequestParams_request_headers_add( + Cronet_UrlRequestParamsPtr self, + const Cronet_HttpHeaderPtr element) {return _Cronet_UrlRequestParams_request_headers_add(self, element);} + +P_IMPORT(Cronet_HttpHeaderPtr, Cronet_HttpHeader_Create, void); +Cronet_HttpHeaderPtr Cronet_HttpHeader_Create(void) {return _Cronet_HttpHeader_Create();} + +P_IMPORT(void,Cronet_HttpHeader_Destroy, Cronet_HttpHeaderPtr); +void Cronet_HttpHeader_Destroy(Cronet_HttpHeaderPtr self) {return _Cronet_HttpHeader_Destroy(self);} + +P_IMPORT(void,Cronet_HttpHeader_name_set, Cronet_HttpHeaderPtr, const Cronet_String); + +void Cronet_HttpHeader_name_set(Cronet_HttpHeaderPtr self, + const Cronet_String name) {return _Cronet_HttpHeader_name_set(self, name);} + +P_IMPORT(void,Cronet_HttpHeader_value_set, Cronet_HttpHeaderPtr, const Cronet_String); +void Cronet_HttpHeader_value_set(Cronet_HttpHeaderPtr self, + const Cronet_String value) {return _Cronet_HttpHeader_value_set(self, value);} + +// Unexposed - see Cronet_UrlRequest_Init +P_IMPORT(Cronet_RESULT, Cronet_UrlRequest_InitWithParams, Cronet_UrlRequestPtr, Cronet_EnginePtr, Cronet_String, Cronet_UrlRequestParamsPtr, Cronet_UrlRequestCallbackPtr, Cronet_ExecutorPtr); + +// Unexposed - see Cronet_UrlRequest_Init +P_IMPORT(Cronet_UrlRequestCallbackPtr, Cronet_UrlRequestCallback_CreateWith, + Cronet_UrlRequestCallback_OnRedirectReceivedFunc, + Cronet_UrlRequestCallback_OnResponseStartedFunc, + Cronet_UrlRequestCallback_OnReadCompletedFunc, + Cronet_UrlRequestCallback_OnSucceededFunc, + Cronet_UrlRequestCallback_OnFailedFunc, + Cronet_UrlRequestCallback_OnCanceledFunc); + +P_IMPORT(Cronet_RESULT, Cronet_UrlRequest_Start, Cronet_UrlRequestPtr); +P_IMPORT(Cronet_RESULT, Cronet_UrlRequest_FollowRedirect, Cronet_UrlRequestPtr); +P_IMPORT(Cronet_RESULT, Cronet_UrlRequest_Read, Cronet_UrlRequestPtr, Cronet_BufferPtr); +P_IMPORT(Cronet_BufferPtr, Cronet_Buffer_Create, void); +P_IMPORT(void, Cronet_Buffer_Destroy, Cronet_BufferPtr); +P_IMPORT(void, Cronet_Buffer_InitWithAlloc, Cronet_BufferPtr, uint64_t); +P_IMPORT(uint64_t, Cronet_Buffer_GetSize, Cronet_BufferPtr); +P_IMPORT(Cronet_RawDataPtr, Cronet_Buffer_GetData, Cronet_BufferPtr); +P_IMPORT(int64_t, Cronet_UrlResponseInfo_received_byte_count_get, Cronet_UrlResponseInfoPtr); +P_IMPORT(Cronet_String, Cronet_Error_message_get, const Cronet_ErrorPtr); + +P_IMPORT(bool, Cronet_Engine_StartNetLogToFile, Cronet_EnginePtr self,Cronet_String file_name,bool log_all); +P_IMPORT(void, Cronet_Engine_StopNetLog,Cronet_EnginePtr self); + +bool Cronet_Engine_StartNetLogToFile(Cronet_EnginePtr self, + Cronet_String file_name, + bool log_all) { + return _Cronet_Engine_StartNetLogToFile(self, file_name, true); +} + +void Cronet_Engine_StopNetLog(Cronet_EnginePtr self) {return _Cronet_Engine_StopNetLog(self);} + +/* Engine Cleanup Tasks */ +static void HttpClientDestroy(void* isolate_callback_data, + void* peer) { + std::cout << "Engine Destroy" << std::endl; + Cronet_EnginePtr ce = reinterpret_cast(peer); + _Cronet_Engine_Shutdown(ce); + _Cronet_Engine_Destroy(ce); +} + +void unloadCronet() { + CLOSELIB(handle); +} + +void removeRequest(Cronet_UrlRequestPtr rp) { + requestNativePorts.erase(rp); +} + +// Register our HttpClient object from dart side +void registerHttpClient(Dart_Handle h, Cronet_EnginePtr ce) { + void* peer = ce; + intptr_t size = 8; + Dart_NewFinalizableHandle_DL(h, peer, size, HttpClientDestroy); +} + + + +P_IMPORT(int32_t, Cronet_UrlResponseInfo_http_status_code_get, const Cronet_UrlResponseInfoPtr); +int32_t Cronet_UrlResponseInfo_http_status_code_get(const Cronet_UrlResponseInfoPtr self) {return _Cronet_UrlResponseInfo_http_status_code_get(self);} + + +P_IMPORT(Cronet_String, Cronet_UrlResponseInfo_http_status_text_get, const Cronet_UrlResponseInfoPtr); +Cronet_String Cronet_UrlResponseInfo_http_status_text_get(const Cronet_UrlResponseInfoPtr self) {return _Cronet_UrlResponseInfo_http_status_text_get(self);} + + +/* URL Callbacks Implementations */ + +void OnRedirectReceived( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_String newLocationUrl) { + dispatchCallback("OnRedirectReceived",request, callbackArgBuilder(2, newLocationUrl, info)); +} + +void OnResponseStarted( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info) { + + // Create and allocate 32kb buffer. + Cronet_BufferPtr buffer = _Cronet_Buffer_Create(); + _Cronet_Buffer_InitWithAlloc(buffer, 32 * 1024); + + dispatchCallback("OnResponseStarted",request, callbackArgBuilder(1, info)); + + // Started reading the response. + _Cronet_UrlRequest_Read(request, buffer); + +} + + +void OnReadCompleted( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_BufferPtr buffer, + uint64_t bytes_read) { + dispatchCallback("OnReadCompleted",request, callbackArgBuilder(4, request, info, buffer, bytes_read)); +} + + +void OnSucceeded(Cronet_UrlRequestCallbackPtr self, Cronet_UrlRequestPtr request, Cronet_UrlResponseInfoPtr info) { + printf("OnSucceeded"); + std::cout << "OnSucceeded called." << std::endl; + dispatchCallback("OnSucceeded",request, callbackArgBuilder(1, info)); +} + +void OnFailed( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_ErrorPtr error) { + printf("OnFailed"); + dispatchCallback("OnFailed",request, callbackArgBuilder(1, _Cronet_Error_message_get(error))); +} + +void OnCanceled( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info) { + printf("OnCanceled"); + dispatchCallback("OnCanceled",request, callbackArgBuilder(0)); +} + + +/* Interface */ + +Cronet_EnginePtr Cronet_Engine_Create() { + printf("Cronet_Engine_Create"); + // Checks if cronet is loaded properly + // As this is the first function to call, + // if this succeeds, every subsequent use + // of cronet [handle] should. + if (!handle) { + std::clog << dlerror() << std::endl; + exit(EXIT_FAILURE); + } + return _Cronet_Engine_Create(); +} + +Cronet_RESULT Cronet_Engine_Shutdown(Cronet_EnginePtr self) { return _Cronet_Engine_Shutdown(self); } + +// Mapping Cronet Function -> Wrapper function +// Most of them are unchanged, except some. +// Note: Can someone suggest a better way to +// map unchanged APIs? +Cronet_String Cronet_Engine_GetVersionString(Cronet_EnginePtr ce) {return _Cronet_Engine_GetVersionString(ce);} +Cronet_EngineParamsPtr Cronet_EngineParams_Create(void) {return _Cronet_EngineParams_Create();} +void Cronet_EngineParams_Destroy(Cronet_EngineParamsPtr self) {} +void Cronet_EngineParams_enable_check_result_set( + Cronet_EngineParamsPtr self, + const bool enable_check_result) {return _Cronet_EngineParams_enable_check_result_set(self,enable_check_result);} + +Cronet_QuicHintPtr Cronet_QuicHint_Create(void) { + return _Cronet_QuicHint_Create(); +} + +void Cronet_QuicHint_Destroy(Cronet_QuicHintPtr self) { + return _Cronet_QuicHint_Destroy(self); +} + +void Cronet_QuicHint_host_set(Cronet_QuicHintPtr self, + const Cronet_String host) { + return _Cronet_QuicHint_host_set(self, host); +} + +void Cronet_QuicHint_port_set(Cronet_QuicHintPtr self, const int32_t port) { + return _Cronet_QuicHint_port_set(self, port); +} + +void Cronet_QuicHint_alternate_port_set(Cronet_QuicHintPtr self, + const int32_t alternate_port) { + return _Cronet_QuicHint_alternate_port_set(self, alternate_port); +} + +void Cronet_EngineParams_user_agent_set(Cronet_EngineParamsPtr self, + const Cronet_String user_agent){_Cronet_EngineParams_user_agent_set(self, user_agent);} + +void Cronet_EngineParams_enable_quic_set(Cronet_EngineParamsPtr self, + const bool enable_quic){_Cronet_EngineParams_enable_quic_set(self,enable_quic);} + +void Cronet_EngineParams_accept_language_set( + Cronet_EngineParamsPtr self, + const Cronet_String accept_language) {return _Cronet_EngineParams_accept_language_set(self, accept_language);} + +void Cronet_EngineParams_storage_path_set(Cronet_EngineParamsPtr self, + const Cronet_String storage_path) { + return _Cronet_EngineParams_storage_path_set(self, storage_path); +} + +void Cronet_EngineParams_enable_http2_set(Cronet_EngineParamsPtr self, + const bool enable_http2) { + return _Cronet_EngineParams_enable_http2_set(self, enable_http2); +} + +void Cronet_EngineParams_quic_hints_add(Cronet_EngineParamsPtr self, + const Cronet_QuicHintPtr element) { + return _Cronet_EngineParams_quic_hints_add(self, element); + +} + +void Cronet_EngineParams_enable_brotli_set(Cronet_EngineParamsPtr self, + const bool enable_brotli) { + return _Cronet_EngineParams_enable_brotli_set(self, enable_brotli); +} + +void Cronet_EngineParams_http_cache_mode_set( + Cronet_EngineParamsPtr self, + const Cronet_EngineParams_HTTP_CACHE_MODE http_cache_mode) { + return _Cronet_EngineParams_http_cache_mode_set(self, http_cache_mode); + } + +void Cronet_EngineParams_http_cache_max_size_set( + Cronet_EngineParamsPtr self, + const int64_t http_cache_max_size) { + return _Cronet_EngineParams_http_cache_max_size_set(self, http_cache_max_size); +} + +Cronet_RESULT Cronet_Engine_StartWithParams(Cronet_EnginePtr self, + Cronet_EngineParamsPtr params) {return _Cronet_Engine_StartWithParams(self, params);} + +Cronet_UrlRequestPtr Cronet_UrlRequest_Create(void) {return _Cronet_UrlRequest_Create();} + +void Cronet_UrlRequest_Destroy(Cronet_UrlRequestPtr self) {return _Cronet_UrlRequest_Destroy(self);} +void Cronet_UrlRequest_Cancel(Cronet_UrlRequestPtr self) {return _Cronet_UrlRequest_Cancel(self);} + +void Cronet_UrlRequest_SetClientContext(Cronet_UrlRequestPtr self, Cronet_ClientContext client_context) {return _Cronet_UrlRequest_SetClientContext(self, client_context);} +Cronet_ClientContext Cronet_UrlRequest_GetClientContext(Cronet_UrlRequestPtr self) {return _Cronet_UrlRequest_GetClientContext(self);} + +Cronet_UrlRequestParamsPtr Cronet_UrlRequestParams_Create(void) {return _Cronet_UrlRequestParams_Create();} + +void Cronet_UrlRequestParams_http_method_set(Cronet_UrlRequestParamsPtr self, const Cronet_String http_method) {return _Cronet_UrlRequestParams_http_method_set(self, http_method);} + +Cronet_RESULT Cronet_UrlRequest_Start(Cronet_UrlRequestPtr self) {return _Cronet_UrlRequest_Start(self);} +Cronet_RESULT Cronet_UrlRequest_FollowRedirect(Cronet_UrlRequestPtr self) {return _Cronet_UrlRequest_FollowRedirect(self);} +Cronet_RESULT Cronet_UrlRequest_Read(Cronet_UrlRequestPtr self, Cronet_BufferPtr buffer) {return _Cronet_UrlRequest_Read(self, buffer);} + +Cronet_RawDataPtr Cronet_Buffer_GetData(Cronet_BufferPtr buffer) {return _Cronet_Buffer_GetData(buffer);} +uint64_t Cronet_Buffer_GetSize(Cronet_BufferPtr self) {return _Cronet_Buffer_GetSize(self);} + + +ExecutorPtr Create_Executor() { + return new SampleExecutor(); +} + +void Destroy_Executor(ExecutorPtr executor) { + delete reinterpret_cast(executor); +} + + +// NOTE: Changed from original cronet's api. executor & callback params aren't needed +Cronet_RESULT Cronet_UrlRequest_Init(Cronet_UrlRequestPtr self, Cronet_EnginePtr engine, Cronet_String url, Cronet_UrlRequestParamsPtr params, ExecutorPtr _executor) { + SampleExecutor* executor = reinterpret_cast(_executor); + executor->Init(); + Cronet_UrlRequestCallbackPtr urCallback = _Cronet_UrlRequestCallback_CreateWith(OnRedirectReceived, OnResponseStarted, OnReadCompleted, + OnSucceeded, OnFailed, OnCanceled); + return _Cronet_UrlRequest_InitWithParams(self, engine, url, params, urCallback, executor->GetExecutor()); + +} + diff --git a/lib/src/native/wrapper/wrapper.h b/lib/src/native/wrapper/wrapper.h new file mode 100644 index 0000000..0630d51 --- /dev/null +++ b/lib/src/native/wrapper/wrapper.h @@ -0,0 +1,395 @@ +// This is same as cronet's header file except a few changes here and there. +#ifndef WRAPPER_H_ +#define WRAPPER_H_ + +// #include "dart_api.h" +// #include "dart_native_api.h" + +#include "../include/dart/dart_api_dl.h" + + +#include"wrapper_export.h" + +#include + +#ifdef __linux__ + #include + #define LIBTYPE void* + #define OPENLIB(libname) dlopen((libname), RTLD_NOW) + #define CLOSELIB(handle) dlclose((handle)) + #define CRONET_LIB_PREFIX "libcronet" + #define CRONET_LIB_EXTENSION ".so" +#elif defined(_WIN32) +#include + #define LIBTYPE HINSTANCE + #define OPENLIB(libname) LoadLibrary(TEXT(libname)) + #define dlsym(lib, fn) (void *)GetProcAddress((lib), (fn)) + #define dlerror() GetLastError() + #define CLOSELIB(handle) FreeLibrary((handle)) + #define CRONET_LIB_PREFIX "cronet" + #define CRONET_LIB_EXTENSION ".dll" +#endif + + +#ifdef __cplusplus + + +extern "C" { +#endif + +#include + + +/* Wrapper Helpers */ + + +DART_EXPORT void dispatchCallback(char* methodname); + +DART_EXPORT intptr_t InitDartApiDL(void* data); +DART_EXPORT void unloadCronet(); + + +typedef void* ExecutorPtr; + +DART_EXPORT ExecutorPtr Create_Executor(); +DART_EXPORT void Destroy_Executor(ExecutorPtr executor); + +/* typedefs, enums & struct declaration from cronet. Derived from cronet.idl_c.h */ + +typedef const char* Cronet_String; +typedef void* Cronet_RawDataPtr; +typedef void* Cronet_ClientContext; + +// Forward declare interfaces. +typedef struct Cronet_Buffer Cronet_Buffer; +typedef struct Cronet_Buffer* Cronet_BufferPtr; +typedef struct Cronet_BufferCallback Cronet_BufferCallback; +typedef struct Cronet_BufferCallback* Cronet_BufferCallbackPtr; +typedef struct Cronet_Runnable Cronet_Runnable; +typedef struct Cronet_Runnable* Cronet_RunnablePtr; +typedef struct Cronet_Executor Cronet_Executor; +typedef struct Cronet_Executor* Cronet_ExecutorPtr; +typedef struct Cronet_Engine Cronet_Engine; +typedef struct Cronet_Engine* Cronet_EnginePtr; +typedef struct Cronet_UrlRequestStatusListener Cronet_UrlRequestStatusListener; +typedef struct Cronet_UrlRequestStatusListener* + Cronet_UrlRequestStatusListenerPtr; +typedef struct Cronet_UrlRequestCallback Cronet_UrlRequestCallback; +typedef struct Cronet_UrlRequestCallback* Cronet_UrlRequestCallbackPtr; +typedef struct Cronet_UploadDataSink Cronet_UploadDataSink; +typedef struct Cronet_UploadDataSink* Cronet_UploadDataSinkPtr; +typedef struct Cronet_UploadDataProvider Cronet_UploadDataProvider; +typedef struct Cronet_UploadDataProvider* Cronet_UploadDataProviderPtr; +typedef struct Cronet_UrlRequest Cronet_UrlRequest; +typedef struct Cronet_UrlRequest* Cronet_UrlRequestPtr; +typedef struct Cronet_RequestFinishedInfoListener + Cronet_RequestFinishedInfoListener; +typedef struct Cronet_RequestFinishedInfoListener* + Cronet_RequestFinishedInfoListenerPtr; + +// Forward declare structs. +typedef struct Cronet_Error Cronet_Error; +typedef struct Cronet_Error* Cronet_ErrorPtr; +typedef struct Cronet_QuicHint Cronet_QuicHint; +typedef struct Cronet_QuicHint* Cronet_QuicHintPtr; +typedef struct Cronet_PublicKeyPins Cronet_PublicKeyPins; +typedef struct Cronet_PublicKeyPins* Cronet_PublicKeyPinsPtr; +typedef struct Cronet_EngineParams Cronet_EngineParams; +typedef struct Cronet_EngineParams* Cronet_EngineParamsPtr; +typedef struct Cronet_HttpHeader Cronet_HttpHeader; +typedef struct Cronet_HttpHeader* Cronet_HttpHeaderPtr; +typedef struct Cronet_UrlResponseInfo Cronet_UrlResponseInfo; +typedef struct Cronet_UrlResponseInfo* Cronet_UrlResponseInfoPtr; +typedef struct Cronet_UrlRequestParams Cronet_UrlRequestParams; +typedef struct Cronet_UrlRequestParams* Cronet_UrlRequestParamsPtr; +typedef struct Cronet_DateTime Cronet_DateTime; +typedef struct Cronet_DateTime* Cronet_DateTimePtr; +typedef struct Cronet_Metrics Cronet_Metrics; +typedef struct Cronet_Metrics* Cronet_MetricsPtr; +typedef struct Cronet_RequestFinishedInfo Cronet_RequestFinishedInfo; +typedef struct Cronet_RequestFinishedInfo* Cronet_RequestFinishedInfoPtr; + +// Declare enums +typedef enum Cronet_RESULT { + Cronet_RESULT_SUCCESS = 0, + Cronet_RESULT_ILLEGAL_ARGUMENT = -100, + Cronet_RESULT_ILLEGAL_ARGUMENT_STORAGE_PATH_MUST_EXIST = -101, + Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_PIN = -102, + Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HOSTNAME = -103, + Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HTTP_METHOD = -104, + Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HTTP_HEADER = -105, + Cronet_RESULT_ILLEGAL_STATE = -200, + Cronet_RESULT_ILLEGAL_STATE_STORAGE_PATH_IN_USE = -201, + Cronet_RESULT_ILLEGAL_STATE_CANNOT_SHUTDOWN_ENGINE_FROM_NETWORK_THREAD = -202, + Cronet_RESULT_ILLEGAL_STATE_ENGINE_ALREADY_STARTED = -203, + Cronet_RESULT_ILLEGAL_STATE_REQUEST_ALREADY_STARTED = -204, + Cronet_RESULT_ILLEGAL_STATE_REQUEST_NOT_INITIALIZED = -205, + Cronet_RESULT_ILLEGAL_STATE_REQUEST_ALREADY_INITIALIZED = -206, + Cronet_RESULT_ILLEGAL_STATE_REQUEST_NOT_STARTED = -207, + Cronet_RESULT_ILLEGAL_STATE_UNEXPECTED_REDIRECT = -208, + Cronet_RESULT_ILLEGAL_STATE_UNEXPECTED_READ = -209, + Cronet_RESULT_ILLEGAL_STATE_READ_FAILED = -210, + Cronet_RESULT_NULL_POINTER = -300, + Cronet_RESULT_NULL_POINTER_HOSTNAME = -301, + Cronet_RESULT_NULL_POINTER_SHA256_PINS = -302, + Cronet_RESULT_NULL_POINTER_EXPIRATION_DATE = -303, + Cronet_RESULT_NULL_POINTER_ENGINE = -304, + Cronet_RESULT_NULL_POINTER_URL = -305, + Cronet_RESULT_NULL_POINTER_CALLBACK = -306, + Cronet_RESULT_NULL_POINTER_EXECUTOR = -307, + Cronet_RESULT_NULL_POINTER_METHOD = -308, + Cronet_RESULT_NULL_POINTER_HEADER_NAME = -309, + Cronet_RESULT_NULL_POINTER_HEADER_VALUE = -310, + Cronet_RESULT_NULL_POINTER_PARAMS = -311, + Cronet_RESULT_NULL_POINTER_REQUEST_FINISHED_INFO_LISTENER_EXECUTOR = -312, +} Cronet_RESULT; + +typedef enum Cronet_Error_ERROR_CODE { + Cronet_Error_ERROR_CODE_ERROR_CALLBACK = 0, + Cronet_Error_ERROR_CODE_ERROR_HOSTNAME_NOT_RESOLVED = 1, + Cronet_Error_ERROR_CODE_ERROR_INTERNET_DISCONNECTED = 2, + Cronet_Error_ERROR_CODE_ERROR_NETWORK_CHANGED = 3, + Cronet_Error_ERROR_CODE_ERROR_TIMED_OUT = 4, + Cronet_Error_ERROR_CODE_ERROR_CONNECTION_CLOSED = 5, + Cronet_Error_ERROR_CODE_ERROR_CONNECTION_TIMED_OUT = 6, + Cronet_Error_ERROR_CODE_ERROR_CONNECTION_REFUSED = 7, + Cronet_Error_ERROR_CODE_ERROR_CONNECTION_RESET = 8, + Cronet_Error_ERROR_CODE_ERROR_ADDRESS_UNREACHABLE = 9, + Cronet_Error_ERROR_CODE_ERROR_QUIC_PROTOCOL_FAILED = 10, + Cronet_Error_ERROR_CODE_ERROR_OTHER = 11, +} Cronet_Error_ERROR_CODE; + +typedef enum Cronet_EngineParams_HTTP_CACHE_MODE { + Cronet_EngineParams_HTTP_CACHE_MODE_DISABLED = 0, + Cronet_EngineParams_HTTP_CACHE_MODE_IN_MEMORY = 1, + Cronet_EngineParams_HTTP_CACHE_MODE_DISK_NO_HTTP = 2, + Cronet_EngineParams_HTTP_CACHE_MODE_DISK = 3, +} Cronet_EngineParams_HTTP_CACHE_MODE; + +typedef enum Cronet_UrlRequestParams_REQUEST_PRIORITY { + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_IDLE = 0, + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_LOWEST = 1, + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_LOW = 2, + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_MEDIUM = 3, + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_HIGHEST = 4, +} Cronet_UrlRequestParams_REQUEST_PRIORITY; + +typedef enum Cronet_UrlRequestParams_IDEMPOTENCY { + Cronet_UrlRequestParams_IDEMPOTENCY_DEFAULT_IDEMPOTENCY = 0, + Cronet_UrlRequestParams_IDEMPOTENCY_IDEMPOTENT = 1, + Cronet_UrlRequestParams_IDEMPOTENCY_NOT_IDEMPOTENT = 2, +} Cronet_UrlRequestParams_IDEMPOTENCY; + +typedef enum Cronet_RequestFinishedInfo_FINISHED_REASON { + Cronet_RequestFinishedInfo_FINISHED_REASON_SUCCEEDED = 0, + Cronet_RequestFinishedInfo_FINISHED_REASON_FAILED = 1, + Cronet_RequestFinishedInfo_FINISHED_REASON_CANCELED = 2, +} Cronet_RequestFinishedInfo_FINISHED_REASON; + +typedef enum Cronet_UrlRequestStatusListener_Status { + Cronet_UrlRequestStatusListener_Status_INVALID = -1, + Cronet_UrlRequestStatusListener_Status_IDLE = 0, + Cronet_UrlRequestStatusListener_Status_WAITING_FOR_STALLED_SOCKET_POOL = 1, + Cronet_UrlRequestStatusListener_Status_WAITING_FOR_AVAILABLE_SOCKET = 2, + Cronet_UrlRequestStatusListener_Status_WAITING_FOR_DELEGATE = 3, + Cronet_UrlRequestStatusListener_Status_WAITING_FOR_CACHE = 4, + Cronet_UrlRequestStatusListener_Status_DOWNLOADING_PAC_FILE = 5, + Cronet_UrlRequestStatusListener_Status_RESOLVING_PROXY_FOR_URL = 6, + Cronet_UrlRequestStatusListener_Status_RESOLVING_HOST_IN_PAC_FILE = 7, + Cronet_UrlRequestStatusListener_Status_ESTABLISHING_PROXY_TUNNEL = 8, + Cronet_UrlRequestStatusListener_Status_RESOLVING_HOST = 9, + Cronet_UrlRequestStatusListener_Status_CONNECTING = 10, + Cronet_UrlRequestStatusListener_Status_SSL_HANDSHAKE = 11, + Cronet_UrlRequestStatusListener_Status_SENDING_REQUEST = 12, + Cronet_UrlRequestStatusListener_Status_WAITING_FOR_RESPONSE = 13, + Cronet_UrlRequestStatusListener_Status_READING_RESPONSE = 14, +} Cronet_UrlRequestStatusListener_Status; + + +DART_EXPORT void registerHttpClient(Dart_Handle h, Cronet_EnginePtr ce); +DART_EXPORT void registerCallbackHandler(Dart_Port nativePort, Cronet_UrlRequestPtr rp); +DART_EXPORT void removeRequest(Cronet_UrlRequestPtr rp); +/* function signatures derived from cronet.idl_c.h. +NOTE: Some are modified if required for wrapping */ + + +/////////////////////// +// Struct Cronet_QuicHint. +CRONET_EXPORT Cronet_QuicHintPtr Cronet_QuicHint_Create(void); +CRONET_EXPORT void Cronet_QuicHint_Destroy(Cronet_QuicHintPtr self); +// Cronet_QuicHint setters. +CRONET_EXPORT +void Cronet_QuicHint_host_set(Cronet_QuicHintPtr self, + const Cronet_String host); +CRONET_EXPORT +void Cronet_QuicHint_port_set(Cronet_QuicHintPtr self, const int32_t port); +CRONET_EXPORT +void Cronet_QuicHint_alternate_port_set(Cronet_QuicHintPtr self, + const int32_t alternate_port); + + + +CRONET_EXPORT Cronet_EnginePtr Cronet_Engine_Create(void); + +CRONET_EXPORT Cronet_String Cronet_Engine_GetVersionString(Cronet_EnginePtr self); + +CRONET_EXPORT Cronet_EngineParamsPtr Cronet_EngineParams_Create(void); +CRONET_EXPORT void Cronet_EngineParams_Destroy(Cronet_EngineParamsPtr self); + +CRONET_EXPORT +void Cronet_EngineParams_user_agent_set(Cronet_EngineParamsPtr self, + const Cronet_String user_agent); + +CRONET_EXPORT +void Cronet_EngineParams_enable_quic_set(Cronet_EngineParamsPtr self, + const bool enable_quic); + +CRONET_EXPORT +void Cronet_EngineParams_quic_hints_add(Cronet_EngineParamsPtr self, + const Cronet_QuicHintPtr element); + +CRONET_EXPORT +void Cronet_EngineParams_accept_language_set( + Cronet_EngineParamsPtr self, + const Cronet_String accept_language); + +CRONET_EXPORT +void Cronet_EngineParams_storage_path_set(Cronet_EngineParamsPtr self, + const Cronet_String storage_path); + +CRONET_EXPORT +void Cronet_EngineParams_enable_http2_set(Cronet_EngineParamsPtr self, + const bool enable_http2); +CRONET_EXPORT +void Cronet_EngineParams_enable_brotli_set(Cronet_EngineParamsPtr self, + const bool enable_brotli); +CRONET_EXPORT +void Cronet_EngineParams_http_cache_mode_set( + Cronet_EngineParamsPtr self, + const Cronet_EngineParams_HTTP_CACHE_MODE http_cache_mode); +CRONET_EXPORT +void Cronet_EngineParams_http_cache_max_size_set( + Cronet_EngineParamsPtr self, + const int64_t http_cache_max_size); + +CRONET_EXPORT +Cronet_RESULT Cronet_Engine_StartWithParams(Cronet_EnginePtr self, + Cronet_EngineParamsPtr params); +CRONET_EXPORT +Cronet_RESULT Cronet_Engine_Shutdown(Cronet_EnginePtr self); + +typedef void (*Cronet_UrlRequestCallback_OnRedirectReceivedFunc)( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_String new_location_url); +typedef void (*Cronet_UrlRequestCallback_OnResponseStartedFunc)( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); +typedef void (*Cronet_UrlRequestCallback_OnReadCompletedFunc)( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_BufferPtr buffer, + uint64_t bytes_read); +typedef void (*Cronet_UrlRequestCallback_OnSucceededFunc)( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); +typedef void (*Cronet_UrlRequestCallback_OnFailedFunc)( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_ErrorPtr error); +typedef void (*Cronet_UrlRequestCallback_OnCanceledFunc)( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); + + +// Create an instance of Cronet_UrlRequest. +CRONET_EXPORT Cronet_UrlRequestPtr Cronet_UrlRequest_Create(void); +// Destroy an instance of Cronet_UrlRequest. +CRONET_EXPORT void Cronet_UrlRequest_Destroy(Cronet_UrlRequestPtr self); + +CRONET_EXPORT void Cronet_UrlRequest_Cancel(Cronet_UrlRequestPtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_UrlRequest_SetClientContext( + Cronet_UrlRequestPtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_UrlRequest_GetClientContext(Cronet_UrlRequestPtr self); + +// Struct Cronet_UrlRequestParams. +CRONET_EXPORT Cronet_UrlRequestParamsPtr Cronet_UrlRequestParams_Create(void); +// Cronet_UrlRequestParams setters. +CRONET_EXPORT +void Cronet_UrlRequestParams_http_method_set(Cronet_UrlRequestParamsPtr self, + const Cronet_String http_method); + +CRONET_EXPORT +void Cronet_UrlRequestParams_request_headers_add( + Cronet_UrlRequestParamsPtr self, + const Cronet_HttpHeaderPtr element); + +CRONET_EXPORT +Cronet_RESULT Cronet_UrlRequest_Start(Cronet_UrlRequestPtr self); +CRONET_EXPORT +Cronet_RESULT Cronet_UrlRequest_FollowRedirect(Cronet_UrlRequestPtr self); +CRONET_EXPORT +Cronet_RESULT Cronet_UrlRequest_Read(Cronet_UrlRequestPtr self, + Cronet_BufferPtr buffer); + +DART_EXPORT Cronet_RESULT Cronet_UrlRequest_Init(Cronet_UrlRequestPtr self, Cronet_EnginePtr engine, Cronet_String url, Cronet_UrlRequestParamsPtr params, ExecutorPtr _executor); + + +CRONET_EXPORT Cronet_HttpHeaderPtr Cronet_HttpHeader_Create(void); +CRONET_EXPORT void Cronet_HttpHeader_Destroy(Cronet_HttpHeaderPtr self); +// Cronet_HttpHeader setters. +CRONET_EXPORT +void Cronet_HttpHeader_name_set(Cronet_HttpHeaderPtr self, + const Cronet_String name); +CRONET_EXPORT +void Cronet_HttpHeader_value_set(Cronet_HttpHeaderPtr self, + const Cronet_String value); + +CRONET_EXPORT +int32_t Cronet_UrlResponseInfo_http_status_code_get( + const Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +Cronet_String Cronet_UrlResponseInfo_http_status_text_get( + const Cronet_UrlResponseInfoPtr self); + +// Create an instance of Cronet_Buffer. +// CRONET_EXPORT Cronet_BufferPtr Cronet_Buffer_Create(void); + +// Destroy an instance of Cronet_Buffer. +// CRONET_EXPORT void Cronet_Buffer_Destroy(Cronet_BufferPtr self); + +// CRONET_EXPORT void Cronet_Buffer_InitWithAlloc(Cronet_BufferPtr self, uint64_t size); + +CRONET_EXPORT uint64_t Cronet_Buffer_GetSize(Cronet_BufferPtr self); +CRONET_EXPORT Cronet_RawDataPtr Cronet_Buffer_GetData(Cronet_BufferPtr self); + +CRONET_EXPORT +bool Cronet_Engine_StartNetLogToFile(Cronet_EnginePtr self, + Cronet_String file_name, + bool log_all); +CRONET_EXPORT +void Cronet_Engine_StopNetLog(Cronet_EnginePtr self); + +// CRONET_EXPORT +// Cronet_String Cronet_Error_message_get(const Cronet_ErrorPtr self); + + +/* executor only */ + +typedef void (*Cronet_Executor_ExecuteFunc)(Cronet_ExecutorPtr self, Cronet_RunnablePtr command); + + +#ifdef __cplusplus +} +#endif + +#endif // WRAPPER_H_ \ No newline at end of file diff --git a/lib/src/native/wrapper/wrapper_export.h b/lib/src/native/wrapper/wrapper_export.h new file mode 100644 index 0000000..72313d3 --- /dev/null +++ b/lib/src/native/wrapper/wrapper_export.h @@ -0,0 +1,10 @@ +#ifndef WRAPPER_EXPORT_H_ +#define WRAPPER_EXPORT_H_ + +#if defined(WIN32) +#define CRONET_EXPORT __declspec(dllexport) +#else +#define CRONET_EXPORT __attribute__((visibility("default"))) +#endif + +#endif // WRAPPER_EXPORT_H_ \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index e66a593..36758aa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,9 +10,81 @@ description: Experimental Cronet dart bindings. environment: sdk: '>=2.12.0 <3.0.0' + # flutter: ">=1.20.0" dependencies: + # flutter: + # sdk: flutter + ffi: ^1.0.0 + path: ^1.8.0 dev_dependencies: + ffigen: ^2.4.2 lints: ^1.0.1 test: ^1.17.5 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter. +flutter: + # This section identifies this Flutter project as a plugin project. + # The 'pluginClass' and Android 'package' identifiers should not ordinarily + # be modified. They are used by the tooling to maintain consistency when + # adding or updating assets for this project. + plugin: + platforms: + android: + package: com.example.cronet + pluginClass: CronetPlugin + # windows: + # pluginClass: CronetPlugin + # linux: + # pluginClass: CronetPlugin + +ffigen: + name: 'Cronet' + description: 'Bindings to Cronet' + output: 'lib/src/generated_bindings.dart' + array-workaround: true + headers: + entry-points: + - 'lib/src/native/wrapper/wrapper.h' + include-directives: + - 'lib/src/native/wrapper/wrapper.h' + - 'dart_api.h' + - 'dart_native_api.h' + - 'dart_api_dl.h' + - 'lib/src/native/wrapper/wrapper_export.h' + compiler-opts: + - '-Ilib/src/native/include/dart/ -DDART_SHARED_LIB' + # To add assets to your plugin package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/assets-and-images/#from-packages + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware. + + # To add custom fonts to your plugin package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/custom-fonts/#from-packages From 4d3bb124861fac191d50054aff96b38ec20a07fc Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Sat, 12 Jun 2021 12:12:06 +0530 Subject: [PATCH 02/42] refactor: third_party APIs (cronet) seperated from wrapper.h Added LICENSE preamble in files --- lib/src/generated_bindings.dart | 1103 ++++++----- lib/src/native/include/cronet/cronet.idl_c.h | 1808 +++++++++--------- lib/src/native/wrapper/CMakeLists.txt | 1 + lib/src/native/wrapper/build.sh | 2 +- lib/src/native/wrapper/wrapper.cc | 4 + lib/src/native/wrapper/wrapper.h | 342 +--- lib/src/native/wrapper/wrapper_export.h | 6 +- pubspec.yaml | 6 +- 8 files changed, 1507 insertions(+), 1765 deletions(-) diff --git a/lib/src/generated_bindings.dart b/lib/src/generated_bindings.dart index 876da12..7b51555 100644 --- a/lib/src/generated_bindings.dart +++ b/lib/src/generated_bindings.dart @@ -119,6 +119,268 @@ class Cronet { late final _dart_removeRequest _removeRequest = _removeRequest_ptr.asFunction<_dart_removeRequest>(); + int Cronet_UrlRequest_Init( + ffi.Pointer self, + ffi.Pointer engine, + ffi.Pointer url, + ffi.Pointer params, + ffi.Pointer _executor, + ) { + return _Cronet_UrlRequest_Init( + self, + engine, + url, + params, + _executor, + ); + } + + late final _Cronet_UrlRequest_Init_ptr = + _lookup>( + 'Cronet_UrlRequest_Init'); + late final _dart_Cronet_UrlRequest_Init _Cronet_UrlRequest_Init = + _Cronet_UrlRequest_Init_ptr.asFunction<_dart_Cronet_UrlRequest_Init>(); + + int Cronet_Buffer_GetSize( + ffi.Pointer self, + ) { + return _Cronet_Buffer_GetSize( + self, + ); + } + + late final _Cronet_Buffer_GetSize_ptr = + _lookup>( + 'Cronet_Buffer_GetSize'); + late final _dart_Cronet_Buffer_GetSize _Cronet_Buffer_GetSize = + _Cronet_Buffer_GetSize_ptr.asFunction<_dart_Cronet_Buffer_GetSize>(); + + ffi.Pointer Cronet_Buffer_GetData( + ffi.Pointer self, + ) { + return _Cronet_Buffer_GetData( + self, + ); + } + + late final _Cronet_Buffer_GetData_ptr = + _lookup>( + 'Cronet_Buffer_GetData'); + late final _dart_Cronet_Buffer_GetData _Cronet_Buffer_GetData = + _Cronet_Buffer_GetData_ptr.asFunction<_dart_Cronet_Buffer_GetData>(); + + ffi.Pointer Cronet_Engine_Create() { + return _Cronet_Engine_Create(); + } + + late final _Cronet_Engine_Create_ptr = + _lookup>( + 'Cronet_Engine_Create'); + late final _dart_Cronet_Engine_Create _Cronet_Engine_Create = + _Cronet_Engine_Create_ptr.asFunction<_dart_Cronet_Engine_Create>(); + + int Cronet_Engine_StartWithParams( + ffi.Pointer self, + ffi.Pointer params, + ) { + return _Cronet_Engine_StartWithParams( + self, + params, + ); + } + + late final _Cronet_Engine_StartWithParams_ptr = + _lookup>( + 'Cronet_Engine_StartWithParams'); + late final _dart_Cronet_Engine_StartWithParams + _Cronet_Engine_StartWithParams = _Cronet_Engine_StartWithParams_ptr + .asFunction<_dart_Cronet_Engine_StartWithParams>(); + + bool Cronet_Engine_StartNetLogToFile( + ffi.Pointer self, + ffi.Pointer file_name, + bool log_all, + ) { + return _Cronet_Engine_StartNetLogToFile( + self, + file_name, + log_all ? 1 : 0, + ) != + 0; + } + + late final _Cronet_Engine_StartNetLogToFile_ptr = + _lookup>( + 'Cronet_Engine_StartNetLogToFile'); + late final _dart_Cronet_Engine_StartNetLogToFile + _Cronet_Engine_StartNetLogToFile = _Cronet_Engine_StartNetLogToFile_ptr + .asFunction<_dart_Cronet_Engine_StartNetLogToFile>(); + + void Cronet_Engine_StopNetLog( + ffi.Pointer self, + ) { + return _Cronet_Engine_StopNetLog( + self, + ); + } + + late final _Cronet_Engine_StopNetLog_ptr = + _lookup>( + 'Cronet_Engine_StopNetLog'); + late final _dart_Cronet_Engine_StopNetLog _Cronet_Engine_StopNetLog = + _Cronet_Engine_StopNetLog_ptr.asFunction< + _dart_Cronet_Engine_StopNetLog>(); + + int Cronet_Engine_Shutdown( + ffi.Pointer self, + ) { + return _Cronet_Engine_Shutdown( + self, + ); + } + + late final _Cronet_Engine_Shutdown_ptr = + _lookup>( + 'Cronet_Engine_Shutdown'); + late final _dart_Cronet_Engine_Shutdown _Cronet_Engine_Shutdown = + _Cronet_Engine_Shutdown_ptr.asFunction<_dart_Cronet_Engine_Shutdown>(); + + ffi.Pointer Cronet_Engine_GetVersionString( + ffi.Pointer self, + ) { + return _Cronet_Engine_GetVersionString( + self, + ); + } + + late final _Cronet_Engine_GetVersionString_ptr = + _lookup>( + 'Cronet_Engine_GetVersionString'); + late final _dart_Cronet_Engine_GetVersionString + _Cronet_Engine_GetVersionString = _Cronet_Engine_GetVersionString_ptr + .asFunction<_dart_Cronet_Engine_GetVersionString>(); + + /// //////////////////// + ffi.Pointer Cronet_UrlRequest_Create() { + return _Cronet_UrlRequest_Create(); + } + + late final _Cronet_UrlRequest_Create_ptr = + _lookup>( + 'Cronet_UrlRequest_Create'); + late final _dart_Cronet_UrlRequest_Create _Cronet_UrlRequest_Create = + _Cronet_UrlRequest_Create_ptr.asFunction< + _dart_Cronet_UrlRequest_Create>(); + + void Cronet_UrlRequest_Destroy( + ffi.Pointer self, + ) { + return _Cronet_UrlRequest_Destroy( + self, + ); + } + + late final _Cronet_UrlRequest_Destroy_ptr = + _lookup>( + 'Cronet_UrlRequest_Destroy'); + late final _dart_Cronet_UrlRequest_Destroy _Cronet_UrlRequest_Destroy = + _Cronet_UrlRequest_Destroy_ptr.asFunction< + _dart_Cronet_UrlRequest_Destroy>(); + + void Cronet_UrlRequest_SetClientContext( + ffi.Pointer self, + ffi.Pointer client_context, + ) { + return _Cronet_UrlRequest_SetClientContext( + self, + client_context, + ); + } + + late final _Cronet_UrlRequest_SetClientContext_ptr = + _lookup>( + 'Cronet_UrlRequest_SetClientContext'); + late final _dart_Cronet_UrlRequest_SetClientContext + _Cronet_UrlRequest_SetClientContext = + _Cronet_UrlRequest_SetClientContext_ptr.asFunction< + _dart_Cronet_UrlRequest_SetClientContext>(); + + ffi.Pointer Cronet_UrlRequest_GetClientContext( + ffi.Pointer self, + ) { + return _Cronet_UrlRequest_GetClientContext( + self, + ); + } + + late final _Cronet_UrlRequest_GetClientContext_ptr = + _lookup>( + 'Cronet_UrlRequest_GetClientContext'); + late final _dart_Cronet_UrlRequest_GetClientContext + _Cronet_UrlRequest_GetClientContext = + _Cronet_UrlRequest_GetClientContext_ptr.asFunction< + _dart_Cronet_UrlRequest_GetClientContext>(); + + int Cronet_UrlRequest_Start( + ffi.Pointer self, + ) { + return _Cronet_UrlRequest_Start( + self, + ); + } + + late final _Cronet_UrlRequest_Start_ptr = + _lookup>( + 'Cronet_UrlRequest_Start'); + late final _dart_Cronet_UrlRequest_Start _Cronet_UrlRequest_Start = + _Cronet_UrlRequest_Start_ptr.asFunction<_dart_Cronet_UrlRequest_Start>(); + + int Cronet_UrlRequest_FollowRedirect( + ffi.Pointer self, + ) { + return _Cronet_UrlRequest_FollowRedirect( + self, + ); + } + + late final _Cronet_UrlRequest_FollowRedirect_ptr = + _lookup>( + 'Cronet_UrlRequest_FollowRedirect'); + late final _dart_Cronet_UrlRequest_FollowRedirect + _Cronet_UrlRequest_FollowRedirect = _Cronet_UrlRequest_FollowRedirect_ptr + .asFunction<_dart_Cronet_UrlRequest_FollowRedirect>(); + + int Cronet_UrlRequest_Read( + ffi.Pointer self, + ffi.Pointer buffer, + ) { + return _Cronet_UrlRequest_Read( + self, + buffer, + ); + } + + late final _Cronet_UrlRequest_Read_ptr = + _lookup>( + 'Cronet_UrlRequest_Read'); + late final _dart_Cronet_UrlRequest_Read _Cronet_UrlRequest_Read = + _Cronet_UrlRequest_Read_ptr.asFunction<_dart_Cronet_UrlRequest_Read>(); + + void Cronet_UrlRequest_Cancel( + ffi.Pointer self, + ) { + return _Cronet_UrlRequest_Cancel( + self, + ); + } + + late final _Cronet_UrlRequest_Cancel_ptr = + _lookup>( + 'Cronet_UrlRequest_Cancel'); + late final _dart_Cronet_UrlRequest_Cancel _Cronet_UrlRequest_Cancel = + _Cronet_UrlRequest_Cancel_ptr.asFunction< + _dart_Cronet_UrlRequest_Cancel>(); + /// //////////////////// ffi.Pointer Cronet_QuicHint_Create() { return _Cronet_QuicHint_Create(); @@ -196,31 +458,7 @@ class Cronet { _Cronet_QuicHint_alternate_port_set_ptr.asFunction< _dart_Cronet_QuicHint_alternate_port_set>(); - ffi.Pointer Cronet_Engine_Create() { - return _Cronet_Engine_Create(); - } - - late final _Cronet_Engine_Create_ptr = - _lookup>( - 'Cronet_Engine_Create'); - late final _dart_Cronet_Engine_Create _Cronet_Engine_Create = - _Cronet_Engine_Create_ptr.asFunction<_dart_Cronet_Engine_Create>(); - - ffi.Pointer Cronet_Engine_GetVersionString( - ffi.Pointer self, - ) { - return _Cronet_Engine_GetVersionString( - self, - ); - } - - late final _Cronet_Engine_GetVersionString_ptr = - _lookup>( - 'Cronet_Engine_GetVersionString'); - late final _dart_Cronet_Engine_GetVersionString - _Cronet_Engine_GetVersionString = _Cronet_Engine_GetVersionString_ptr - .asFunction<_dart_Cronet_Engine_GetVersionString>(); - + /// //////////////////// ffi.Pointer Cronet_EngineParams_Create() { return _Cronet_EngineParams_Create(); } @@ -247,59 +485,41 @@ class Cronet { _Cronet_EngineParams_Destroy_ptr.asFunction< _dart_Cronet_EngineParams_Destroy>(); - void Cronet_EngineParams_user_agent_set( - ffi.Pointer self, - ffi.Pointer user_agent, - ) { - return _Cronet_EngineParams_user_agent_set( - self, - user_agent, - ); - } - - late final _Cronet_EngineParams_user_agent_set_ptr = - _lookup>( - 'Cronet_EngineParams_user_agent_set'); - late final _dart_Cronet_EngineParams_user_agent_set - _Cronet_EngineParams_user_agent_set = - _Cronet_EngineParams_user_agent_set_ptr.asFunction< - _dart_Cronet_EngineParams_user_agent_set>(); - - void Cronet_EngineParams_enable_quic_set( + void Cronet_EngineParams_enable_check_result_set( ffi.Pointer self, - bool enable_quic, + bool enable_check_result, ) { - return _Cronet_EngineParams_enable_quic_set( + return _Cronet_EngineParams_enable_check_result_set( self, - enable_quic ? 1 : 0, + enable_check_result ? 1 : 0, ); } - late final _Cronet_EngineParams_enable_quic_set_ptr = - _lookup>( - 'Cronet_EngineParams_enable_quic_set'); - late final _dart_Cronet_EngineParams_enable_quic_set - _Cronet_EngineParams_enable_quic_set = - _Cronet_EngineParams_enable_quic_set_ptr.asFunction< - _dart_Cronet_EngineParams_enable_quic_set>(); + late final _Cronet_EngineParams_enable_check_result_set_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_EngineParams_enable_check_result_set>>( + 'Cronet_EngineParams_enable_check_result_set'); + late final _dart_Cronet_EngineParams_enable_check_result_set + _Cronet_EngineParams_enable_check_result_set = + _Cronet_EngineParams_enable_check_result_set_ptr.asFunction< + _dart_Cronet_EngineParams_enable_check_result_set>(); - void Cronet_EngineParams_quic_hints_add( + void Cronet_EngineParams_user_agent_set( ffi.Pointer self, - ffi.Pointer element, + ffi.Pointer user_agent, ) { - return _Cronet_EngineParams_quic_hints_add( + return _Cronet_EngineParams_user_agent_set( self, - element, + user_agent, ); } - late final _Cronet_EngineParams_quic_hints_add_ptr = - _lookup>( - 'Cronet_EngineParams_quic_hints_add'); - late final _dart_Cronet_EngineParams_quic_hints_add - _Cronet_EngineParams_quic_hints_add = - _Cronet_EngineParams_quic_hints_add_ptr.asFunction< - _dart_Cronet_EngineParams_quic_hints_add>(); + late final _Cronet_EngineParams_user_agent_set_ptr = + _lookup>( + 'Cronet_EngineParams_user_agent_set'); + late final _dart_Cronet_EngineParams_user_agent_set + _Cronet_EngineParams_user_agent_set = + _Cronet_EngineParams_user_agent_set_ptr.asFunction< + _dart_Cronet_EngineParams_user_agent_set>(); void Cronet_EngineParams_accept_language_set( ffi.Pointer self, @@ -337,6 +557,24 @@ class Cronet { _Cronet_EngineParams_storage_path_set_ptr.asFunction< _dart_Cronet_EngineParams_storage_path_set>(); + void Cronet_EngineParams_enable_quic_set( + ffi.Pointer self, + bool enable_quic, + ) { + return _Cronet_EngineParams_enable_quic_set( + self, + enable_quic ? 1 : 0, + ); + } + + late final _Cronet_EngineParams_enable_quic_set_ptr = + _lookup>( + 'Cronet_EngineParams_enable_quic_set'); + late final _dart_Cronet_EngineParams_enable_quic_set + _Cronet_EngineParams_enable_quic_set = + _Cronet_EngineParams_enable_quic_set_ptr.asFunction< + _dart_Cronet_EngineParams_enable_quic_set>(); + void Cronet_EngineParams_enable_http2_set( ffi.Pointer self, bool enable_http2, @@ -409,226 +647,25 @@ class Cronet { _Cronet_EngineParams_http_cache_max_size_set_ptr.asFunction< _dart_Cronet_EngineParams_http_cache_max_size_set>(); - int Cronet_Engine_StartWithParams( - ffi.Pointer self, - ffi.Pointer params, - ) { - return _Cronet_Engine_StartWithParams( - self, - params, - ); - } - - late final _Cronet_Engine_StartWithParams_ptr = - _lookup>( - 'Cronet_Engine_StartWithParams'); - late final _dart_Cronet_Engine_StartWithParams - _Cronet_Engine_StartWithParams = _Cronet_Engine_StartWithParams_ptr - .asFunction<_dart_Cronet_Engine_StartWithParams>(); - - int Cronet_Engine_Shutdown( - ffi.Pointer self, - ) { - return _Cronet_Engine_Shutdown( - self, - ); - } - - late final _Cronet_Engine_Shutdown_ptr = - _lookup>( - 'Cronet_Engine_Shutdown'); - late final _dart_Cronet_Engine_Shutdown _Cronet_Engine_Shutdown = - _Cronet_Engine_Shutdown_ptr.asFunction<_dart_Cronet_Engine_Shutdown>(); - - ffi.Pointer Cronet_UrlRequest_Create() { - return _Cronet_UrlRequest_Create(); - } - - late final _Cronet_UrlRequest_Create_ptr = - _lookup>( - 'Cronet_UrlRequest_Create'); - late final _dart_Cronet_UrlRequest_Create _Cronet_UrlRequest_Create = - _Cronet_UrlRequest_Create_ptr.asFunction< - _dart_Cronet_UrlRequest_Create>(); - - void Cronet_UrlRequest_Destroy( - ffi.Pointer self, - ) { - return _Cronet_UrlRequest_Destroy( - self, - ); - } - - late final _Cronet_UrlRequest_Destroy_ptr = - _lookup>( - 'Cronet_UrlRequest_Destroy'); - late final _dart_Cronet_UrlRequest_Destroy _Cronet_UrlRequest_Destroy = - _Cronet_UrlRequest_Destroy_ptr.asFunction< - _dart_Cronet_UrlRequest_Destroy>(); - - void Cronet_UrlRequest_Cancel( - ffi.Pointer self, - ) { - return _Cronet_UrlRequest_Cancel( - self, - ); - } - - late final _Cronet_UrlRequest_Cancel_ptr = - _lookup>( - 'Cronet_UrlRequest_Cancel'); - late final _dart_Cronet_UrlRequest_Cancel _Cronet_UrlRequest_Cancel = - _Cronet_UrlRequest_Cancel_ptr.asFunction< - _dart_Cronet_UrlRequest_Cancel>(); - - void Cronet_UrlRequest_SetClientContext( - ffi.Pointer self, - ffi.Pointer client_context, - ) { - return _Cronet_UrlRequest_SetClientContext( - self, - client_context, - ); - } - - late final _Cronet_UrlRequest_SetClientContext_ptr = - _lookup>( - 'Cronet_UrlRequest_SetClientContext'); - late final _dart_Cronet_UrlRequest_SetClientContext - _Cronet_UrlRequest_SetClientContext = - _Cronet_UrlRequest_SetClientContext_ptr.asFunction< - _dart_Cronet_UrlRequest_SetClientContext>(); - - ffi.Pointer Cronet_UrlRequest_GetClientContext( - ffi.Pointer self, - ) { - return _Cronet_UrlRequest_GetClientContext( - self, - ); - } - - late final _Cronet_UrlRequest_GetClientContext_ptr = - _lookup>( - 'Cronet_UrlRequest_GetClientContext'); - late final _dart_Cronet_UrlRequest_GetClientContext - _Cronet_UrlRequest_GetClientContext = - _Cronet_UrlRequest_GetClientContext_ptr.asFunction< - _dart_Cronet_UrlRequest_GetClientContext>(); - - ffi.Pointer Cronet_UrlRequestParams_Create() { - return _Cronet_UrlRequestParams_Create(); - } - - late final _Cronet_UrlRequestParams_Create_ptr = - _lookup>( - 'Cronet_UrlRequestParams_Create'); - late final _dart_Cronet_UrlRequestParams_Create - _Cronet_UrlRequestParams_Create = _Cronet_UrlRequestParams_Create_ptr - .asFunction<_dart_Cronet_UrlRequestParams_Create>(); - - void Cronet_UrlRequestParams_http_method_set( - ffi.Pointer self, - ffi.Pointer http_method, - ) { - return _Cronet_UrlRequestParams_http_method_set( - self, - http_method, - ); - } - - late final _Cronet_UrlRequestParams_http_method_set_ptr = - _lookup>( - 'Cronet_UrlRequestParams_http_method_set'); - late final _dart_Cronet_UrlRequestParams_http_method_set - _Cronet_UrlRequestParams_http_method_set = - _Cronet_UrlRequestParams_http_method_set_ptr.asFunction< - _dart_Cronet_UrlRequestParams_http_method_set>(); - - void Cronet_UrlRequestParams_request_headers_add( - ffi.Pointer self, - ffi.Pointer element, - ) { - return _Cronet_UrlRequestParams_request_headers_add( - self, - element, - ); - } - - late final _Cronet_UrlRequestParams_request_headers_add_ptr = _lookup< - ffi.NativeFunction<_c_Cronet_UrlRequestParams_request_headers_add>>( - 'Cronet_UrlRequestParams_request_headers_add'); - late final _dart_Cronet_UrlRequestParams_request_headers_add - _Cronet_UrlRequestParams_request_headers_add = - _Cronet_UrlRequestParams_request_headers_add_ptr.asFunction< - _dart_Cronet_UrlRequestParams_request_headers_add>(); - - int Cronet_UrlRequest_Start( - ffi.Pointer self, - ) { - return _Cronet_UrlRequest_Start( - self, - ); - } - - late final _Cronet_UrlRequest_Start_ptr = - _lookup>( - 'Cronet_UrlRequest_Start'); - late final _dart_Cronet_UrlRequest_Start _Cronet_UrlRequest_Start = - _Cronet_UrlRequest_Start_ptr.asFunction<_dart_Cronet_UrlRequest_Start>(); - - int Cronet_UrlRequest_FollowRedirect( - ffi.Pointer self, - ) { - return _Cronet_UrlRequest_FollowRedirect( - self, - ); - } - - late final _Cronet_UrlRequest_FollowRedirect_ptr = - _lookup>( - 'Cronet_UrlRequest_FollowRedirect'); - late final _dart_Cronet_UrlRequest_FollowRedirect - _Cronet_UrlRequest_FollowRedirect = _Cronet_UrlRequest_FollowRedirect_ptr - .asFunction<_dart_Cronet_UrlRequest_FollowRedirect>(); - - int Cronet_UrlRequest_Read( - ffi.Pointer self, - ffi.Pointer buffer, - ) { - return _Cronet_UrlRequest_Read( - self, - buffer, - ); - } - - late final _Cronet_UrlRequest_Read_ptr = - _lookup>( - 'Cronet_UrlRequest_Read'); - late final _dart_Cronet_UrlRequest_Read _Cronet_UrlRequest_Read = - _Cronet_UrlRequest_Read_ptr.asFunction<_dart_Cronet_UrlRequest_Read>(); - - int Cronet_UrlRequest_Init( - ffi.Pointer self, - ffi.Pointer engine, - ffi.Pointer url, - ffi.Pointer params, - ffi.Pointer _executor, + void Cronet_EngineParams_quic_hints_add( + ffi.Pointer self, + ffi.Pointer element, ) { - return _Cronet_UrlRequest_Init( + return _Cronet_EngineParams_quic_hints_add( self, - engine, - url, - params, - _executor, + element, ); } - late final _Cronet_UrlRequest_Init_ptr = - _lookup>( - 'Cronet_UrlRequest_Init'); - late final _dart_Cronet_UrlRequest_Init _Cronet_UrlRequest_Init = - _Cronet_UrlRequest_Init_ptr.asFunction<_dart_Cronet_UrlRequest_Init>(); + late final _Cronet_EngineParams_quic_hints_add_ptr = + _lookup>( + 'Cronet_EngineParams_quic_hints_add'); + late final _dart_Cronet_EngineParams_quic_hints_add + _Cronet_EngineParams_quic_hints_add = + _Cronet_EngineParams_quic_hints_add_ptr.asFunction< + _dart_Cronet_EngineParams_quic_hints_add>(); + /// //////////////////// ffi.Pointer Cronet_HttpHeader_Create() { return _Cronet_HttpHeader_Create(); } @@ -721,70 +758,76 @@ class Cronet { _Cronet_UrlResponseInfo_http_status_text_get_ptr.asFunction< _dart_Cronet_UrlResponseInfo_http_status_text_get>(); - int Cronet_Buffer_GetSize( - ffi.Pointer self, - ) { - return _Cronet_Buffer_GetSize( - self, - ); + /// //////////////////// + ffi.Pointer Cronet_UrlRequestParams_Create() { + return _Cronet_UrlRequestParams_Create(); } - late final _Cronet_Buffer_GetSize_ptr = - _lookup>( - 'Cronet_Buffer_GetSize'); - late final _dart_Cronet_Buffer_GetSize _Cronet_Buffer_GetSize = - _Cronet_Buffer_GetSize_ptr.asFunction<_dart_Cronet_Buffer_GetSize>(); + late final _Cronet_UrlRequestParams_Create_ptr = + _lookup>( + 'Cronet_UrlRequestParams_Create'); + late final _dart_Cronet_UrlRequestParams_Create + _Cronet_UrlRequestParams_Create = _Cronet_UrlRequestParams_Create_ptr + .asFunction<_dart_Cronet_UrlRequestParams_Create>(); - ffi.Pointer Cronet_Buffer_GetData( - ffi.Pointer self, + void Cronet_UrlRequestParams_Destroy( + ffi.Pointer self, ) { - return _Cronet_Buffer_GetData( + return _Cronet_UrlRequestParams_Destroy( self, ); } - late final _Cronet_Buffer_GetData_ptr = - _lookup>( - 'Cronet_Buffer_GetData'); - late final _dart_Cronet_Buffer_GetData _Cronet_Buffer_GetData = - _Cronet_Buffer_GetData_ptr.asFunction<_dart_Cronet_Buffer_GetData>(); + late final _Cronet_UrlRequestParams_Destroy_ptr = + _lookup>( + 'Cronet_UrlRequestParams_Destroy'); + late final _dart_Cronet_UrlRequestParams_Destroy + _Cronet_UrlRequestParams_Destroy = _Cronet_UrlRequestParams_Destroy_ptr + .asFunction<_dart_Cronet_UrlRequestParams_Destroy>(); - bool Cronet_Engine_StartNetLogToFile( - ffi.Pointer self, - ffi.Pointer file_name, - bool log_all, + void Cronet_UrlRequestParams_http_method_set( + ffi.Pointer self, + ffi.Pointer http_method, ) { - return _Cronet_Engine_StartNetLogToFile( - self, - file_name, - log_all ? 1 : 0, - ) != - 0; + return _Cronet_UrlRequestParams_http_method_set( + self, + http_method, + ); } - late final _Cronet_Engine_StartNetLogToFile_ptr = - _lookup>( - 'Cronet_Engine_StartNetLogToFile'); - late final _dart_Cronet_Engine_StartNetLogToFile - _Cronet_Engine_StartNetLogToFile = _Cronet_Engine_StartNetLogToFile_ptr - .asFunction<_dart_Cronet_Engine_StartNetLogToFile>(); + late final _Cronet_UrlRequestParams_http_method_set_ptr = + _lookup>( + 'Cronet_UrlRequestParams_http_method_set'); + late final _dart_Cronet_UrlRequestParams_http_method_set + _Cronet_UrlRequestParams_http_method_set = + _Cronet_UrlRequestParams_http_method_set_ptr.asFunction< + _dart_Cronet_UrlRequestParams_http_method_set>(); - void Cronet_Engine_StopNetLog( - ffi.Pointer self, + void Cronet_UrlRequestParams_request_headers_add( + ffi.Pointer self, + ffi.Pointer element, ) { - return _Cronet_Engine_StopNetLog( + return _Cronet_UrlRequestParams_request_headers_add( self, + element, ); } - late final _Cronet_Engine_StopNetLog_ptr = - _lookup>( - 'Cronet_Engine_StopNetLog'); - late final _dart_Cronet_Engine_StopNetLog _Cronet_Engine_StopNetLog = - _Cronet_Engine_StopNetLog_ptr.asFunction< - _dart_Cronet_Engine_StopNetLog>(); + late final _Cronet_UrlRequestParams_request_headers_add_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlRequestParams_request_headers_add>>( + 'Cronet_UrlRequestParams_request_headers_add'); + late final _dart_Cronet_UrlRequestParams_request_headers_add + _Cronet_UrlRequestParams_request_headers_add = + _Cronet_UrlRequestParams_request_headers_add_ptr.asFunction< + _dart_Cronet_UrlRequestParams_request_headers_add>(); } +class Cronet_Engine extends ffi.Opaque {} + +class Cronet_UrlRequest extends ffi.Opaque {} + +class Cronet_UrlRequestParams extends ffi.Opaque {} + class Cronet_Buffer extends ffi.Opaque {} class Cronet_BufferCallback extends ffi.Opaque {} @@ -793,8 +836,6 @@ class Cronet_Runnable extends ffi.Opaque {} class Cronet_Executor extends ffi.Opaque {} -class Cronet_Engine extends ffi.Opaque {} - class Cronet_UrlRequestStatusListener extends ffi.Opaque {} class Cronet_UrlRequestCallback extends ffi.Opaque {} @@ -803,8 +844,6 @@ class Cronet_UploadDataSink extends ffi.Opaque {} class Cronet_UploadDataProvider extends ffi.Opaque {} -class Cronet_UrlRequest extends ffi.Opaque {} - class Cronet_RequestFinishedInfoListener extends ffi.Opaque {} class Cronet_Error extends ffi.Opaque {} @@ -819,8 +858,6 @@ class Cronet_HttpHeader extends ffi.Opaque {} class Cronet_UrlResponseInfo extends ffi.Opaque {} -class Cronet_UrlRequestParams extends ffi.Opaque {} - class Cronet_DateTime extends ffi.Opaque {} class Cronet_Metrics extends ffi.Opaque {} @@ -967,42 +1004,190 @@ typedef _dart_unloadCronet = void Function(); typedef _c_Create_Executor = ffi.Pointer Function(); -typedef _dart_Create_Executor = ffi.Pointer Function(); +typedef _dart_Create_Executor = ffi.Pointer Function(); + +typedef _c_Destroy_Executor = ffi.Void Function( + ffi.Pointer executor, +); + +typedef _dart_Destroy_Executor = void Function( + ffi.Pointer executor, +); + +typedef _c_registerHttpClient = ffi.Void Function( + ffi.Handle h, + ffi.Pointer ce, +); + +typedef _dart_registerHttpClient = void Function( + Object h, + ffi.Pointer ce, +); + +typedef _c_registerCallbackHandler = ffi.Void Function( + ffi.Int64 nativePort, + ffi.Pointer rp, +); + +typedef _dart_registerCallbackHandler = void Function( + int nativePort, + ffi.Pointer rp, +); + +typedef _c_removeRequest = ffi.Void Function( + ffi.Pointer rp, +); + +typedef _dart_removeRequest = void Function( + ffi.Pointer rp, +); + +typedef _c_Cronet_UrlRequest_Init = ffi.Int32 Function( + ffi.Pointer self, + ffi.Pointer engine, + ffi.Pointer url, + ffi.Pointer params, + ffi.Pointer _executor, +); + +typedef _dart_Cronet_UrlRequest_Init = int Function( + ffi.Pointer self, + ffi.Pointer engine, + ffi.Pointer url, + ffi.Pointer params, + ffi.Pointer _executor, +); + +typedef _c_Cronet_Buffer_GetSize = ffi.Uint64 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Buffer_GetSize = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Buffer_GetData = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Buffer_GetData = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Engine_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_Engine_Create = ffi.Pointer Function(); + +typedef _c_Cronet_Engine_StartWithParams = ffi.Int32 Function( + ffi.Pointer self, + ffi.Pointer params, +); + +typedef _dart_Cronet_Engine_StartWithParams = int Function( + ffi.Pointer self, + ffi.Pointer params, +); + +typedef _c_Cronet_Engine_StartNetLogToFile = ffi.Uint8 Function( + ffi.Pointer self, + ffi.Pointer file_name, + ffi.Uint8 log_all, +); + +typedef _dart_Cronet_Engine_StartNetLogToFile = int Function( + ffi.Pointer self, + ffi.Pointer file_name, + int log_all, +); + +typedef _c_Cronet_Engine_StopNetLog = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Engine_StopNetLog = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Engine_Shutdown = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Engine_Shutdown = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Engine_GetVersionString = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Engine_GetVersionString = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequest_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_UrlRequest_Create = ffi.Pointer + Function(); + +typedef _c_Cronet_UrlRequest_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequest_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequest_SetClientContext = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _dart_Cronet_UrlRequest_SetClientContext = void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _c_Cronet_UrlRequest_GetClientContext = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequest_GetClientContext = ffi.Pointer + Function( + ffi.Pointer self, +); -typedef _c_Destroy_Executor = ffi.Void Function( - ffi.Pointer executor, +typedef _c_Cronet_UrlRequest_Start = ffi.Int32 Function( + ffi.Pointer self, ); -typedef _dart_Destroy_Executor = void Function( - ffi.Pointer executor, +typedef _dart_Cronet_UrlRequest_Start = int Function( + ffi.Pointer self, ); -typedef _c_registerHttpClient = ffi.Void Function( - ffi.Handle h, - ffi.Pointer ce, +typedef _c_Cronet_UrlRequest_FollowRedirect = ffi.Int32 Function( + ffi.Pointer self, ); -typedef _dart_registerHttpClient = void Function( - Object h, - ffi.Pointer ce, +typedef _dart_Cronet_UrlRequest_FollowRedirect = int Function( + ffi.Pointer self, ); -typedef _c_registerCallbackHandler = ffi.Void Function( - ffi.Int64 nativePort, - ffi.Pointer rp, +typedef _c_Cronet_UrlRequest_Read = ffi.Int32 Function( + ffi.Pointer self, + ffi.Pointer buffer, ); -typedef _dart_registerCallbackHandler = void Function( - int nativePort, - ffi.Pointer rp, +typedef _dart_Cronet_UrlRequest_Read = int Function( + ffi.Pointer self, + ffi.Pointer buffer, ); -typedef _c_removeRequest = ffi.Void Function( - ffi.Pointer rp, +typedef _c_Cronet_UrlRequest_Cancel = ffi.Void Function( + ffi.Pointer self, ); -typedef _dart_removeRequest = void Function( - ffi.Pointer rp, +typedef _dart_Cronet_UrlRequest_Cancel = void Function( + ffi.Pointer self, ); typedef _c_Cronet_QuicHint_Create = ffi.Pointer Function(); @@ -1047,18 +1232,6 @@ typedef _dart_Cronet_QuicHint_alternate_port_set = void Function( int alternate_port, ); -typedef _c_Cronet_Engine_Create = ffi.Pointer Function(); - -typedef _dart_Cronet_Engine_Create = ffi.Pointer Function(); - -typedef _c_Cronet_Engine_GetVersionString = ffi.Pointer Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_Engine_GetVersionString = ffi.Pointer Function( - ffi.Pointer self, -); - typedef _c_Cronet_EngineParams_Create = ffi.Pointer Function(); @@ -1073,34 +1246,24 @@ typedef _dart_Cronet_EngineParams_Destroy = void Function( ffi.Pointer self, ); -typedef _c_Cronet_EngineParams_user_agent_set = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer user_agent, -); - -typedef _dart_Cronet_EngineParams_user_agent_set = void Function( - ffi.Pointer self, - ffi.Pointer user_agent, -); - -typedef _c_Cronet_EngineParams_enable_quic_set = ffi.Void Function( +typedef _c_Cronet_EngineParams_enable_check_result_set = ffi.Void Function( ffi.Pointer self, - ffi.Uint8 enable_quic, + ffi.Uint8 enable_check_result, ); -typedef _dart_Cronet_EngineParams_enable_quic_set = void Function( +typedef _dart_Cronet_EngineParams_enable_check_result_set = void Function( ffi.Pointer self, - int enable_quic, + int enable_check_result, ); -typedef _c_Cronet_EngineParams_quic_hints_add = ffi.Void Function( +typedef _c_Cronet_EngineParams_user_agent_set = ffi.Void Function( ffi.Pointer self, - ffi.Pointer element, + ffi.Pointer user_agent, ); -typedef _dart_Cronet_EngineParams_quic_hints_add = void Function( +typedef _dart_Cronet_EngineParams_user_agent_set = void Function( ffi.Pointer self, - ffi.Pointer element, + ffi.Pointer user_agent, ); typedef _c_Cronet_EngineParams_accept_language_set = ffi.Void Function( @@ -1123,6 +1286,16 @@ typedef _dart_Cronet_EngineParams_storage_path_set = void Function( ffi.Pointer storage_path, ); +typedef _c_Cronet_EngineParams_enable_quic_set = ffi.Void Function( + ffi.Pointer self, + ffi.Uint8 enable_quic, +); + +typedef _dart_Cronet_EngineParams_enable_quic_set = void Function( + ffi.Pointer self, + int enable_quic, +); + typedef _c_Cronet_EngineParams_enable_http2_set = ffi.Void Function( ffi.Pointer self, ffi.Uint8 enable_http2, @@ -1163,130 +1336,14 @@ typedef _dart_Cronet_EngineParams_http_cache_max_size_set = void Function( int http_cache_max_size, ); -typedef _c_Cronet_Engine_StartWithParams = ffi.Int32 Function( - ffi.Pointer self, - ffi.Pointer params, -); - -typedef _dart_Cronet_Engine_StartWithParams = int Function( - ffi.Pointer self, - ffi.Pointer params, -); - -typedef _c_Cronet_Engine_Shutdown = ffi.Int32 Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_Engine_Shutdown = int Function( - ffi.Pointer self, -); - -typedef _c_Cronet_UrlRequest_Create = ffi.Pointer Function(); - -typedef _dart_Cronet_UrlRequest_Create = ffi.Pointer - Function(); - -typedef _c_Cronet_UrlRequest_Destroy = ffi.Void Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_UrlRequest_Destroy = void Function( - ffi.Pointer self, -); - -typedef _c_Cronet_UrlRequest_Cancel = ffi.Void Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_UrlRequest_Cancel = void Function( - ffi.Pointer self, -); - -typedef _c_Cronet_UrlRequest_SetClientContext = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer client_context, -); - -typedef _dart_Cronet_UrlRequest_SetClientContext = void Function( - ffi.Pointer self, - ffi.Pointer client_context, -); - -typedef _c_Cronet_UrlRequest_GetClientContext = ffi.Pointer Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_UrlRequest_GetClientContext = ffi.Pointer - Function( - ffi.Pointer self, -); - -typedef _c_Cronet_UrlRequestParams_Create = ffi.Pointer - Function(); - -typedef _dart_Cronet_UrlRequestParams_Create - = ffi.Pointer Function(); - -typedef _c_Cronet_UrlRequestParams_http_method_set = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer http_method, -); - -typedef _dart_Cronet_UrlRequestParams_http_method_set = void Function( - ffi.Pointer self, - ffi.Pointer http_method, -); - -typedef _c_Cronet_UrlRequestParams_request_headers_add = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer element, -); - -typedef _dart_Cronet_UrlRequestParams_request_headers_add = void Function( - ffi.Pointer self, - ffi.Pointer element, -); - -typedef _c_Cronet_UrlRequest_Start = ffi.Int32 Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_UrlRequest_Start = int Function( - ffi.Pointer self, -); - -typedef _c_Cronet_UrlRequest_FollowRedirect = ffi.Int32 Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_UrlRequest_FollowRedirect = int Function( - ffi.Pointer self, -); - -typedef _c_Cronet_UrlRequest_Read = ffi.Int32 Function( - ffi.Pointer self, - ffi.Pointer buffer, -); - -typedef _dart_Cronet_UrlRequest_Read = int Function( - ffi.Pointer self, - ffi.Pointer buffer, -); - -typedef _c_Cronet_UrlRequest_Init = ffi.Int32 Function( - ffi.Pointer self, - ffi.Pointer engine, - ffi.Pointer url, - ffi.Pointer params, - ffi.Pointer _executor, +typedef _c_Cronet_EngineParams_quic_hints_add = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer element, ); -typedef _dart_Cronet_UrlRequest_Init = int Function( - ffi.Pointer self, - ffi.Pointer engine, - ffi.Pointer url, - ffi.Pointer params, - ffi.Pointer _executor, +typedef _dart_Cronet_EngineParams_quic_hints_add = void Function( + ffi.Pointer self, + ffi.Pointer element, ); typedef _c_Cronet_HttpHeader_Create = ffi.Pointer Function(); @@ -1340,38 +1397,36 @@ typedef _dart_Cronet_UrlResponseInfo_http_status_text_get ffi.Pointer self, ); -typedef _c_Cronet_Buffer_GetSize = ffi.Uint64 Function( - ffi.Pointer self, -); +typedef _c_Cronet_UrlRequestParams_Create = ffi.Pointer + Function(); -typedef _dart_Cronet_Buffer_GetSize = int Function( - ffi.Pointer self, -); +typedef _dart_Cronet_UrlRequestParams_Create + = ffi.Pointer Function(); -typedef _c_Cronet_Buffer_GetData = ffi.Pointer Function( - ffi.Pointer self, +typedef _c_Cronet_UrlRequestParams_Destroy = ffi.Void Function( + ffi.Pointer self, ); -typedef _dart_Cronet_Buffer_GetData = ffi.Pointer Function( - ffi.Pointer self, +typedef _dart_Cronet_UrlRequestParams_Destroy = void Function( + ffi.Pointer self, ); -typedef _c_Cronet_Engine_StartNetLogToFile = ffi.Uint8 Function( - ffi.Pointer self, - ffi.Pointer file_name, - ffi.Uint8 log_all, +typedef _c_Cronet_UrlRequestParams_http_method_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer http_method, ); -typedef _dart_Cronet_Engine_StartNetLogToFile = int Function( - ffi.Pointer self, - ffi.Pointer file_name, - int log_all, +typedef _dart_Cronet_UrlRequestParams_http_method_set = void Function( + ffi.Pointer self, + ffi.Pointer http_method, ); -typedef _c_Cronet_Engine_StopNetLog = ffi.Void Function( - ffi.Pointer self, +typedef _c_Cronet_UrlRequestParams_request_headers_add = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer element, ); -typedef _dart_Cronet_Engine_StopNetLog = void Function( - ffi.Pointer self, +typedef _dart_Cronet_UrlRequestParams_request_headers_add = void Function( + ffi.Pointer self, + ffi.Pointer element, ); diff --git a/lib/src/native/include/cronet/cronet.idl_c.h b/lib/src/native/include/cronet/cronet.idl_c.h index 041fd8f..c8ec2c0 100644 --- a/lib/src/native/include/cronet/cronet.idl_c.h +++ b/lib/src/native/include/cronet/cronet.idl_c.h @@ -4,6 +4,8 @@ /* DO NOT EDIT. Generated from components/cronet/native/generated/cronet.idl */ +/* ONLY the APIs that are available via the wrapper is ENABLED */ + #ifndef COMPONENTS_CRONET_NATIVE_GENERATED_CRONET_IDL_C_H_ #define COMPONENTS_CRONET_NATIVE_GENERATED_CRONET_IDL_C_H_ #include "cronet_export.h" @@ -14,6 +16,8 @@ extern "C" { #include +#include + typedef const char* Cronet_String; typedef void* Cronet_RawDataPtr; typedef void* Cronet_ClientContext; @@ -163,151 +167,151 @@ typedef enum Cronet_UrlRequestStatusListener_Status { Cronet_UrlRequestStatusListener_Status_READING_RESPONSE = 14, } Cronet_UrlRequestStatusListener_Status; -// Declare constants +// // Declare constants -/////////////////////// -// Concrete interface Cronet_Buffer. +// /////////////////////// +// // Concrete interface Cronet_Buffer. -// Create an instance of Cronet_Buffer. -CRONET_EXPORT Cronet_BufferPtr Cronet_Buffer_Create(void); -// Destroy an instance of Cronet_Buffer. -CRONET_EXPORT void Cronet_Buffer_Destroy(Cronet_BufferPtr self); -// Set and get app-specific Cronet_ClientContext. -CRONET_EXPORT void Cronet_Buffer_SetClientContext( - Cronet_BufferPtr self, - Cronet_ClientContext client_context); -CRONET_EXPORT Cronet_ClientContext -Cronet_Buffer_GetClientContext(Cronet_BufferPtr self); -// Concrete methods of Cronet_Buffer implemented by Cronet. -// The app calls them to manipulate Cronet_Buffer. -CRONET_EXPORT -void Cronet_Buffer_InitWithDataAndCallback(Cronet_BufferPtr self, - Cronet_RawDataPtr data, - uint64_t size, - Cronet_BufferCallbackPtr callback); -CRONET_EXPORT -void Cronet_Buffer_InitWithAlloc(Cronet_BufferPtr self, uint64_t size); +// // Create an instance of Cronet_Buffer. +// CRONET_EXPORT Cronet_BufferPtr Cronet_Buffer_Create(void); +// // Destroy an instance of Cronet_Buffer. +// CRONET_EXPORT void Cronet_Buffer_Destroy(Cronet_BufferPtr self); +// // Set and get app-specific Cronet_ClientContext. +// CRONET_EXPORT void Cronet_Buffer_SetClientContext( +// Cronet_BufferPtr self, +// Cronet_ClientContext client_context); +// CRONET_EXPORT Cronet_ClientContext +// Cronet_Buffer_GetClientContext(Cronet_BufferPtr self); +// // Concrete methods of Cronet_Buffer implemented by Cronet. +// // The app calls them to manipulate Cronet_Buffer. +// CRONET_EXPORT +// void Cronet_Buffer_InitWithDataAndCallback(Cronet_BufferPtr self, +// Cronet_RawDataPtr data, +// uint64_t size, +// Cronet_BufferCallbackPtr callback); +// CRONET_EXPORT +// void Cronet_Buffer_InitWithAlloc(Cronet_BufferPtr self, uint64_t size); CRONET_EXPORT uint64_t Cronet_Buffer_GetSize(Cronet_BufferPtr self); CRONET_EXPORT Cronet_RawDataPtr Cronet_Buffer_GetData(Cronet_BufferPtr self); -// Concrete interface Cronet_Buffer is implemented by Cronet. -// The app can implement these for testing / mocking. -typedef void (*Cronet_Buffer_InitWithDataAndCallbackFunc)( - Cronet_BufferPtr self, - Cronet_RawDataPtr data, - uint64_t size, - Cronet_BufferCallbackPtr callback); -typedef void (*Cronet_Buffer_InitWithAllocFunc)(Cronet_BufferPtr self, - uint64_t size); -typedef uint64_t (*Cronet_Buffer_GetSizeFunc)(Cronet_BufferPtr self); -typedef Cronet_RawDataPtr (*Cronet_Buffer_GetDataFunc)(Cronet_BufferPtr self); -// Concrete interface Cronet_Buffer is implemented by Cronet. -// The app can use this for testing / mocking. -CRONET_EXPORT Cronet_BufferPtr Cronet_Buffer_CreateWith( - Cronet_Buffer_InitWithDataAndCallbackFunc InitWithDataAndCallbackFunc, - Cronet_Buffer_InitWithAllocFunc InitWithAllocFunc, - Cronet_Buffer_GetSizeFunc GetSizeFunc, - Cronet_Buffer_GetDataFunc GetDataFunc); +// // Concrete interface Cronet_Buffer is implemented by Cronet. +// // The app can implement these for testing / mocking. +// typedef void (*Cronet_Buffer_InitWithDataAndCallbackFunc)( +// Cronet_BufferPtr self, +// Cronet_RawDataPtr data, +// uint64_t size, +// Cronet_BufferCallbackPtr callback); +// typedef void (*Cronet_Buffer_InitWithAllocFunc)(Cronet_BufferPtr self, +// uint64_t size); +// typedef uint64_t (*Cronet_Buffer_GetSizeFunc)(Cronet_BufferPtr self); +// typedef Cronet_RawDataPtr (*Cronet_Buffer_GetDataFunc)(Cronet_BufferPtr self); +// // Concrete interface Cronet_Buffer is implemented by Cronet. +// // The app can use this for testing / mocking. +// CRONET_EXPORT Cronet_BufferPtr Cronet_Buffer_CreateWith( +// Cronet_Buffer_InitWithDataAndCallbackFunc InitWithDataAndCallbackFunc, +// Cronet_Buffer_InitWithAllocFunc InitWithAllocFunc, +// Cronet_Buffer_GetSizeFunc GetSizeFunc, +// Cronet_Buffer_GetDataFunc GetDataFunc); -/////////////////////// -// Abstract interface Cronet_BufferCallback is implemented by the app. +// /////////////////////// +// // Abstract interface Cronet_BufferCallback is implemented by the app. -// There is no method to create a concrete implementation. +// // There is no method to create a concrete implementation. -// Destroy an instance of Cronet_BufferCallback. -CRONET_EXPORT void Cronet_BufferCallback_Destroy(Cronet_BufferCallbackPtr self); -// Set and get app-specific Cronet_ClientContext. -CRONET_EXPORT void Cronet_BufferCallback_SetClientContext( - Cronet_BufferCallbackPtr self, - Cronet_ClientContext client_context); -CRONET_EXPORT Cronet_ClientContext -Cronet_BufferCallback_GetClientContext(Cronet_BufferCallbackPtr self); -// Abstract interface Cronet_BufferCallback is implemented by the app. -// The following concrete methods forward call to app implementation. -// The app doesn't normally call them. -CRONET_EXPORT -void Cronet_BufferCallback_OnDestroy(Cronet_BufferCallbackPtr self, - Cronet_BufferPtr buffer); -// The app implements abstract interface Cronet_BufferCallback by defining -// custom functions for each method. -typedef void (*Cronet_BufferCallback_OnDestroyFunc)( - Cronet_BufferCallbackPtr self, - Cronet_BufferPtr buffer); -// The app creates an instance of Cronet_BufferCallback by providing custom -// functions for each method. -CRONET_EXPORT Cronet_BufferCallbackPtr Cronet_BufferCallback_CreateWith( - Cronet_BufferCallback_OnDestroyFunc OnDestroyFunc); +// // Destroy an instance of Cronet_BufferCallback. +// CRONET_EXPORT void Cronet_BufferCallback_Destroy(Cronet_BufferCallbackPtr self); +// // Set and get app-specific Cronet_ClientContext. +// CRONET_EXPORT void Cronet_BufferCallback_SetClientContext( +// Cronet_BufferCallbackPtr self, +// Cronet_ClientContext client_context); +// CRONET_EXPORT Cronet_ClientContext +// Cronet_BufferCallback_GetClientContext(Cronet_BufferCallbackPtr self); +// // Abstract interface Cronet_BufferCallback is implemented by the app. +// // The following concrete methods forward call to app implementation. +// // The app doesn't normally call them. +// CRONET_EXPORT +// void Cronet_BufferCallback_OnDestroy(Cronet_BufferCallbackPtr self, +// Cronet_BufferPtr buffer); +// // The app implements abstract interface Cronet_BufferCallback by defining +// // custom functions for each method. +// typedef void (*Cronet_BufferCallback_OnDestroyFunc)( +// Cronet_BufferCallbackPtr self, +// Cronet_BufferPtr buffer); +// // The app creates an instance of Cronet_BufferCallback by providing custom +// // functions for each method. +// CRONET_EXPORT Cronet_BufferCallbackPtr Cronet_BufferCallback_CreateWith( +// Cronet_BufferCallback_OnDestroyFunc OnDestroyFunc); -/////////////////////// -// Abstract interface Cronet_Runnable is implemented by the app. +// /////////////////////// +// // Abstract interface Cronet_Runnable is implemented by the app. -// There is no method to create a concrete implementation. +// // There is no method to create a concrete implementation. -// Destroy an instance of Cronet_Runnable. -CRONET_EXPORT void Cronet_Runnable_Destroy(Cronet_RunnablePtr self); -// Set and get app-specific Cronet_ClientContext. -CRONET_EXPORT void Cronet_Runnable_SetClientContext( - Cronet_RunnablePtr self, - Cronet_ClientContext client_context); -CRONET_EXPORT Cronet_ClientContext -Cronet_Runnable_GetClientContext(Cronet_RunnablePtr self); -// Abstract interface Cronet_Runnable is implemented by the app. -// The following concrete methods forward call to app implementation. -// The app doesn't normally call them. -CRONET_EXPORT -void Cronet_Runnable_Run(Cronet_RunnablePtr self); -// The app implements abstract interface Cronet_Runnable by defining custom -// functions for each method. -typedef void (*Cronet_Runnable_RunFunc)(Cronet_RunnablePtr self); -// The app creates an instance of Cronet_Runnable by providing custom functions -// for each method. -CRONET_EXPORT Cronet_RunnablePtr -Cronet_Runnable_CreateWith(Cronet_Runnable_RunFunc RunFunc); +// // Destroy an instance of Cronet_Runnable. +// CRONET_EXPORT void Cronet_Runnable_Destroy(Cronet_RunnablePtr self); +// // Set and get app-specific Cronet_ClientContext. +// CRONET_EXPORT void Cronet_Runnable_SetClientContext( +// Cronet_RunnablePtr self, +// Cronet_ClientContext client_context); +// CRONET_EXPORT Cronet_ClientContext +// Cronet_Runnable_GetClientContext(Cronet_RunnablePtr self); +// // Abstract interface Cronet_Runnable is implemented by the app. +// // The following concrete methods forward call to app implementation. +// // The app doesn't normally call them. +// CRONET_EXPORT +// void Cronet_Runnable_Run(Cronet_RunnablePtr self); +// // The app implements abstract interface Cronet_Runnable by defining custom +// // functions for each method. +// typedef void (*Cronet_Runnable_RunFunc)(Cronet_RunnablePtr self); +// // The app creates an instance of Cronet_Runnable by providing custom functions +// // for each method. +// CRONET_EXPORT Cronet_RunnablePtr +// Cronet_Runnable_CreateWith(Cronet_Runnable_RunFunc RunFunc); -/////////////////////// -// Abstract interface Cronet_Executor is implemented by the app. +// /////////////////////// +// // Abstract interface Cronet_Executor is implemented by the app. -// There is no method to create a concrete implementation. +// // There is no method to create a concrete implementation. -// Destroy an instance of Cronet_Executor. -CRONET_EXPORT void Cronet_Executor_Destroy(Cronet_ExecutorPtr self); -// Set and get app-specific Cronet_ClientContext. -CRONET_EXPORT void Cronet_Executor_SetClientContext( - Cronet_ExecutorPtr self, - Cronet_ClientContext client_context); -CRONET_EXPORT Cronet_ClientContext -Cronet_Executor_GetClientContext(Cronet_ExecutorPtr self); -// Abstract interface Cronet_Executor is implemented by the app. -// The following concrete methods forward call to app implementation. -// The app doesn't normally call them. -CRONET_EXPORT -void Cronet_Executor_Execute(Cronet_ExecutorPtr self, - Cronet_RunnablePtr command); -// The app implements abstract interface Cronet_Executor by defining custom -// functions for each method. -typedef void (*Cronet_Executor_ExecuteFunc)(Cronet_ExecutorPtr self, - Cronet_RunnablePtr command); -// The app creates an instance of Cronet_Executor by providing custom functions -// for each method. -CRONET_EXPORT Cronet_ExecutorPtr -Cronet_Executor_CreateWith(Cronet_Executor_ExecuteFunc ExecuteFunc); +// // Destroy an instance of Cronet_Executor. +// CRONET_EXPORT void Cronet_Executor_Destroy(Cronet_ExecutorPtr self); +// // Set and get app-specific Cronet_ClientContext. +// CRONET_EXPORT void Cronet_Executor_SetClientContext( +// Cronet_ExecutorPtr self, +// Cronet_ClientContext client_context); +// CRONET_EXPORT Cronet_ClientContext +// Cronet_Executor_GetClientContext(Cronet_ExecutorPtr self); +// // Abstract interface Cronet_Executor is implemented by the app. +// // The following concrete methods forward call to app implementation. +// // The app doesn't normally call them. +// CRONET_EXPORT +// void Cronet_Executor_Execute(Cronet_ExecutorPtr self, +// Cronet_RunnablePtr command); +// // The app implements abstract interface Cronet_Executor by defining custom +// // functions for each method. +// typedef void (*Cronet_Executor_ExecuteFunc)(Cronet_ExecutorPtr self, +// Cronet_RunnablePtr command); +// // The app creates an instance of Cronet_Executor by providing custom functions +// // for each method. +// CRONET_EXPORT Cronet_ExecutorPtr +// Cronet_Executor_CreateWith(Cronet_Executor_ExecuteFunc ExecuteFunc); -/////////////////////// -// Concrete interface Cronet_Engine. +// /////////////////////// +// // Concrete interface Cronet_Engine. -// Create an instance of Cronet_Engine. +// // Create an instance of Cronet_Engine. CRONET_EXPORT Cronet_EnginePtr Cronet_Engine_Create(void); -// Destroy an instance of Cronet_Engine. -CRONET_EXPORT void Cronet_Engine_Destroy(Cronet_EnginePtr self); -// Set and get app-specific Cronet_ClientContext. -CRONET_EXPORT void Cronet_Engine_SetClientContext( - Cronet_EnginePtr self, - Cronet_ClientContext client_context); -CRONET_EXPORT Cronet_ClientContext -Cronet_Engine_GetClientContext(Cronet_EnginePtr self); -// Concrete methods of Cronet_Engine implemented by Cronet. -// The app calls them to manipulate Cronet_Engine. +// // Destroy an instance of Cronet_Engine. +// CRONET_EXPORT void Cronet_Engine_Destroy(Cronet_EnginePtr self); +// // Set and get app-specific Cronet_ClientContext. +// CRONET_EXPORT void Cronet_Engine_SetClientContext( +// Cronet_EnginePtr self, +// Cronet_ClientContext client_context); +// CRONET_EXPORT Cronet_ClientContext +// Cronet_Engine_GetClientContext(Cronet_EnginePtr self); +// // Concrete methods of Cronet_Engine implemented by Cronet. +// // The app calls them to manipulate Cronet_Engine. CRONET_EXPORT Cronet_RESULT Cronet_Engine_StartWithParams(Cronet_EnginePtr self, Cronet_EngineParamsPtr params); @@ -321,17 +325,17 @@ CRONET_EXPORT Cronet_RESULT Cronet_Engine_Shutdown(Cronet_EnginePtr self); CRONET_EXPORT Cronet_String Cronet_Engine_GetVersionString(Cronet_EnginePtr self); -CRONET_EXPORT -Cronet_String Cronet_Engine_GetDefaultUserAgent(Cronet_EnginePtr self); -CRONET_EXPORT -void Cronet_Engine_AddRequestFinishedListener( - Cronet_EnginePtr self, - Cronet_RequestFinishedInfoListenerPtr listener, - Cronet_ExecutorPtr executor); -CRONET_EXPORT -void Cronet_Engine_RemoveRequestFinishedListener( - Cronet_EnginePtr self, - Cronet_RequestFinishedInfoListenerPtr listener); +// CRONET_EXPORT +// Cronet_String Cronet_Engine_GetDefaultUserAgent(Cronet_EnginePtr self); +// CRONET_EXPORT +// void Cronet_Engine_AddRequestFinishedListener( +// Cronet_EnginePtr self, +// Cronet_RequestFinishedInfoListenerPtr listener, +// Cronet_ExecutorPtr executor); +// CRONET_EXPORT +// void Cronet_Engine_RemoveRequestFinishedListener( +// Cronet_EnginePtr self, +// Cronet_RequestFinishedInfoListenerPtr listener); // Concrete interface Cronet_Engine is implemented by Cronet. // The app can implement these for testing / mocking. typedef Cronet_RESULT (*Cronet_Engine_StartWithParamsFunc)( @@ -353,100 +357,100 @@ typedef void (*Cronet_Engine_AddRequestFinishedListenerFunc)( typedef void (*Cronet_Engine_RemoveRequestFinishedListenerFunc)( Cronet_EnginePtr self, Cronet_RequestFinishedInfoListenerPtr listener); -// Concrete interface Cronet_Engine is implemented by Cronet. -// The app can use this for testing / mocking. -CRONET_EXPORT Cronet_EnginePtr Cronet_Engine_CreateWith( - Cronet_Engine_StartWithParamsFunc StartWithParamsFunc, - Cronet_Engine_StartNetLogToFileFunc StartNetLogToFileFunc, - Cronet_Engine_StopNetLogFunc StopNetLogFunc, - Cronet_Engine_ShutdownFunc ShutdownFunc, - Cronet_Engine_GetVersionStringFunc GetVersionStringFunc, - Cronet_Engine_GetDefaultUserAgentFunc GetDefaultUserAgentFunc, - Cronet_Engine_AddRequestFinishedListenerFunc AddRequestFinishedListenerFunc, - Cronet_Engine_RemoveRequestFinishedListenerFunc - RemoveRequestFinishedListenerFunc); +// // Concrete interface Cronet_Engine is implemented by Cronet. +// // The app can use this for testing / mocking. +// CRONET_EXPORT Cronet_EnginePtr Cronet_Engine_CreateWith( +// Cronet_Engine_StartWithParamsFunc StartWithParamsFunc, +// Cronet_Engine_StartNetLogToFileFunc StartNetLogToFileFunc, +// Cronet_Engine_StopNetLogFunc StopNetLogFunc, +// Cronet_Engine_ShutdownFunc ShutdownFunc, +// Cronet_Engine_GetVersionStringFunc GetVersionStringFunc, +// Cronet_Engine_GetDefaultUserAgentFunc GetDefaultUserAgentFunc, +// Cronet_Engine_AddRequestFinishedListenerFunc AddRequestFinishedListenerFunc, +// Cronet_Engine_RemoveRequestFinishedListenerFunc +// RemoveRequestFinishedListenerFunc); -/////////////////////// -// Abstract interface Cronet_UrlRequestStatusListener is implemented by the app. +// /////////////////////// +// // Abstract interface Cronet_UrlRequestStatusListener is implemented by the app. -// There is no method to create a concrete implementation. +// // There is no method to create a concrete implementation. -// Destroy an instance of Cronet_UrlRequestStatusListener. -CRONET_EXPORT void Cronet_UrlRequestStatusListener_Destroy( - Cronet_UrlRequestStatusListenerPtr self); -// Set and get app-specific Cronet_ClientContext. -CRONET_EXPORT void Cronet_UrlRequestStatusListener_SetClientContext( - Cronet_UrlRequestStatusListenerPtr self, - Cronet_ClientContext client_context); -CRONET_EXPORT Cronet_ClientContext -Cronet_UrlRequestStatusListener_GetClientContext( - Cronet_UrlRequestStatusListenerPtr self); -// Abstract interface Cronet_UrlRequestStatusListener is implemented by the app. -// The following concrete methods forward call to app implementation. -// The app doesn't normally call them. -CRONET_EXPORT -void Cronet_UrlRequestStatusListener_OnStatus( - Cronet_UrlRequestStatusListenerPtr self, - Cronet_UrlRequestStatusListener_Status status); -// The app implements abstract interface Cronet_UrlRequestStatusListener by -// defining custom functions for each method. -typedef void (*Cronet_UrlRequestStatusListener_OnStatusFunc)( - Cronet_UrlRequestStatusListenerPtr self, - Cronet_UrlRequestStatusListener_Status status); -// The app creates an instance of Cronet_UrlRequestStatusListener by providing -// custom functions for each method. -CRONET_EXPORT Cronet_UrlRequestStatusListenerPtr -Cronet_UrlRequestStatusListener_CreateWith( - Cronet_UrlRequestStatusListener_OnStatusFunc OnStatusFunc); +// // Destroy an instance of Cronet_UrlRequestStatusListener. +// CRONET_EXPORT void Cronet_UrlRequestStatusListener_Destroy( +// Cronet_UrlRequestStatusListenerPtr self); +// // Set and get app-specific Cronet_ClientContext. +// CRONET_EXPORT void Cronet_UrlRequestStatusListener_SetClientContext( +// Cronet_UrlRequestStatusListenerPtr self, +// Cronet_ClientContext client_context); +// CRONET_EXPORT Cronet_ClientContext +// Cronet_UrlRequestStatusListener_GetClientContext( +// Cronet_UrlRequestStatusListenerPtr self); +// // Abstract interface Cronet_UrlRequestStatusListener is implemented by the app. +// // The following concrete methods forward call to app implementation. +// // The app doesn't normally call them. +// CRONET_EXPORT +// void Cronet_UrlRequestStatusListener_OnStatus( +// Cronet_UrlRequestStatusListenerPtr self, +// Cronet_UrlRequestStatusListener_Status status); +// // The app implements abstract interface Cronet_UrlRequestStatusListener by +// // defining custom functions for each method. +// typedef void (*Cronet_UrlRequestStatusListener_OnStatusFunc)( +// Cronet_UrlRequestStatusListenerPtr self, +// Cronet_UrlRequestStatusListener_Status status); +// // The app creates an instance of Cronet_UrlRequestStatusListener by providing +// // custom functions for each method. +// CRONET_EXPORT Cronet_UrlRequestStatusListenerPtr +// Cronet_UrlRequestStatusListener_CreateWith( +// Cronet_UrlRequestStatusListener_OnStatusFunc OnStatusFunc); -/////////////////////// -// Abstract interface Cronet_UrlRequestCallback is implemented by the app. +// /////////////////////// +// // Abstract interface Cronet_UrlRequestCallback is implemented by the app. -// There is no method to create a concrete implementation. +// // There is no method to create a concrete implementation. -// Destroy an instance of Cronet_UrlRequestCallback. -CRONET_EXPORT void Cronet_UrlRequestCallback_Destroy( - Cronet_UrlRequestCallbackPtr self); -// Set and get app-specific Cronet_ClientContext. -CRONET_EXPORT void Cronet_UrlRequestCallback_SetClientContext( - Cronet_UrlRequestCallbackPtr self, - Cronet_ClientContext client_context); -CRONET_EXPORT Cronet_ClientContext -Cronet_UrlRequestCallback_GetClientContext(Cronet_UrlRequestCallbackPtr self); -// Abstract interface Cronet_UrlRequestCallback is implemented by the app. -// The following concrete methods forward call to app implementation. -// The app doesn't normally call them. -CRONET_EXPORT -void Cronet_UrlRequestCallback_OnRedirectReceived( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info, - Cronet_String new_location_url); -CRONET_EXPORT -void Cronet_UrlRequestCallback_OnResponseStarted( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info); -CRONET_EXPORT -void Cronet_UrlRequestCallback_OnReadCompleted( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info, - Cronet_BufferPtr buffer, - uint64_t bytes_read); -CRONET_EXPORT -void Cronet_UrlRequestCallback_OnSucceeded(Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info); -CRONET_EXPORT -void Cronet_UrlRequestCallback_OnFailed(Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info, - Cronet_ErrorPtr error); -CRONET_EXPORT -void Cronet_UrlRequestCallback_OnCanceled(Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info); +// // Destroy an instance of Cronet_UrlRequestCallback. +// CRONET_EXPORT void Cronet_UrlRequestCallback_Destroy( +// Cronet_UrlRequestCallbackPtr self); +// // Set and get app-specific Cronet_ClientContext. +// CRONET_EXPORT void Cronet_UrlRequestCallback_SetClientContext( +// Cronet_UrlRequestCallbackPtr self, +// Cronet_ClientContext client_context); +// CRONET_EXPORT Cronet_ClientContext +// Cronet_UrlRequestCallback_GetClientContext(Cronet_UrlRequestCallbackPtr self); +// // Abstract interface Cronet_UrlRequestCallback is implemented by the app. +// // The following concrete methods forward call to app implementation. +// // The app doesn't normally call them. +// CRONET_EXPORT +// void Cronet_UrlRequestCallback_OnRedirectReceived( +// Cronet_UrlRequestCallbackPtr self, +// Cronet_UrlRequestPtr request, +// Cronet_UrlResponseInfoPtr info, +// Cronet_String new_location_url); +// CRONET_EXPORT +// void Cronet_UrlRequestCallback_OnResponseStarted( +// Cronet_UrlRequestCallbackPtr self, +// Cronet_UrlRequestPtr request, +// Cronet_UrlResponseInfoPtr info); +// CRONET_EXPORT +// void Cronet_UrlRequestCallback_OnReadCompleted( +// Cronet_UrlRequestCallbackPtr self, +// Cronet_UrlRequestPtr request, +// Cronet_UrlResponseInfoPtr info, +// Cronet_BufferPtr buffer, +// uint64_t bytes_read); +// CRONET_EXPORT +// void Cronet_UrlRequestCallback_OnSucceeded(Cronet_UrlRequestCallbackPtr self, +// Cronet_UrlRequestPtr request, +// Cronet_UrlResponseInfoPtr info); +// CRONET_EXPORT +// void Cronet_UrlRequestCallback_OnFailed(Cronet_UrlRequestCallbackPtr self, +// Cronet_UrlRequestPtr request, +// Cronet_UrlResponseInfoPtr info, +// Cronet_ErrorPtr error); +// CRONET_EXPORT +// void Cronet_UrlRequestCallback_OnCanceled(Cronet_UrlRequestCallbackPtr self, +// Cronet_UrlRequestPtr request, +// Cronet_UrlResponseInfoPtr info); // The app implements abstract interface Cronet_UrlRequestCallback by defining // custom functions for each method. typedef void (*Cronet_UrlRequestCallback_OnRedirectReceivedFunc)( @@ -477,114 +481,114 @@ typedef void (*Cronet_UrlRequestCallback_OnCanceledFunc)( Cronet_UrlRequestCallbackPtr self, Cronet_UrlRequestPtr request, Cronet_UrlResponseInfoPtr info); -// The app creates an instance of Cronet_UrlRequestCallback by providing custom -// functions for each method. -CRONET_EXPORT Cronet_UrlRequestCallbackPtr Cronet_UrlRequestCallback_CreateWith( - Cronet_UrlRequestCallback_OnRedirectReceivedFunc OnRedirectReceivedFunc, - Cronet_UrlRequestCallback_OnResponseStartedFunc OnResponseStartedFunc, - Cronet_UrlRequestCallback_OnReadCompletedFunc OnReadCompletedFunc, - Cronet_UrlRequestCallback_OnSucceededFunc OnSucceededFunc, - Cronet_UrlRequestCallback_OnFailedFunc OnFailedFunc, - Cronet_UrlRequestCallback_OnCanceledFunc OnCanceledFunc); +// // The app creates an instance of Cronet_UrlRequestCallback by providing custom +// // functions for each method. +// CRONET_EXPORT Cronet_UrlRequestCallbackPtr Cronet_UrlRequestCallback_CreateWith( +// Cronet_UrlRequestCallback_OnRedirectReceivedFunc OnRedirectReceivedFunc, +// Cronet_UrlRequestCallback_OnResponseStartedFunc OnResponseStartedFunc, +// Cronet_UrlRequestCallback_OnReadCompletedFunc OnReadCompletedFunc, +// Cronet_UrlRequestCallback_OnSucceededFunc OnSucceededFunc, +// Cronet_UrlRequestCallback_OnFailedFunc OnFailedFunc, +// Cronet_UrlRequestCallback_OnCanceledFunc OnCanceledFunc); -/////////////////////// -// Concrete interface Cronet_UploadDataSink. +// /////////////////////// +// // Concrete interface Cronet_UploadDataSink. -// Create an instance of Cronet_UploadDataSink. -CRONET_EXPORT Cronet_UploadDataSinkPtr Cronet_UploadDataSink_Create(void); -// Destroy an instance of Cronet_UploadDataSink. -CRONET_EXPORT void Cronet_UploadDataSink_Destroy(Cronet_UploadDataSinkPtr self); -// Set and get app-specific Cronet_ClientContext. -CRONET_EXPORT void Cronet_UploadDataSink_SetClientContext( - Cronet_UploadDataSinkPtr self, - Cronet_ClientContext client_context); -CRONET_EXPORT Cronet_ClientContext -Cronet_UploadDataSink_GetClientContext(Cronet_UploadDataSinkPtr self); -// Concrete methods of Cronet_UploadDataSink implemented by Cronet. -// The app calls them to manipulate Cronet_UploadDataSink. -CRONET_EXPORT -void Cronet_UploadDataSink_OnReadSucceeded(Cronet_UploadDataSinkPtr self, - uint64_t bytes_read, - bool final_chunk); -CRONET_EXPORT -void Cronet_UploadDataSink_OnReadError(Cronet_UploadDataSinkPtr self, - Cronet_String error_message); -CRONET_EXPORT -void Cronet_UploadDataSink_OnRewindSucceeded(Cronet_UploadDataSinkPtr self); -CRONET_EXPORT -void Cronet_UploadDataSink_OnRewindError(Cronet_UploadDataSinkPtr self, - Cronet_String error_message); -// Concrete interface Cronet_UploadDataSink is implemented by Cronet. -// The app can implement these for testing / mocking. -typedef void (*Cronet_UploadDataSink_OnReadSucceededFunc)( - Cronet_UploadDataSinkPtr self, - uint64_t bytes_read, - bool final_chunk); -typedef void (*Cronet_UploadDataSink_OnReadErrorFunc)( - Cronet_UploadDataSinkPtr self, - Cronet_String error_message); -typedef void (*Cronet_UploadDataSink_OnRewindSucceededFunc)( - Cronet_UploadDataSinkPtr self); -typedef void (*Cronet_UploadDataSink_OnRewindErrorFunc)( - Cronet_UploadDataSinkPtr self, - Cronet_String error_message); -// Concrete interface Cronet_UploadDataSink is implemented by Cronet. -// The app can use this for testing / mocking. -CRONET_EXPORT Cronet_UploadDataSinkPtr Cronet_UploadDataSink_CreateWith( - Cronet_UploadDataSink_OnReadSucceededFunc OnReadSucceededFunc, - Cronet_UploadDataSink_OnReadErrorFunc OnReadErrorFunc, - Cronet_UploadDataSink_OnRewindSucceededFunc OnRewindSucceededFunc, - Cronet_UploadDataSink_OnRewindErrorFunc OnRewindErrorFunc); +// // Create an instance of Cronet_UploadDataSink. +// CRONET_EXPORT Cronet_UploadDataSinkPtr Cronet_UploadDataSink_Create(void); +// // Destroy an instance of Cronet_UploadDataSink. +// CRONET_EXPORT void Cronet_UploadDataSink_Destroy(Cronet_UploadDataSinkPtr self); +// // Set and get app-specific Cronet_ClientContext. +// CRONET_EXPORT void Cronet_UploadDataSink_SetClientContext( +// Cronet_UploadDataSinkPtr self, +// Cronet_ClientContext client_context); +// CRONET_EXPORT Cronet_ClientContext +// Cronet_UploadDataSink_GetClientContext(Cronet_UploadDataSinkPtr self); +// // Concrete methods of Cronet_UploadDataSink implemented by Cronet. +// // The app calls them to manipulate Cronet_UploadDataSink. +// CRONET_EXPORT +// void Cronet_UploadDataSink_OnReadSucceeded(Cronet_UploadDataSinkPtr self, +// uint64_t bytes_read, +// bool final_chunk); +// CRONET_EXPORT +// void Cronet_UploadDataSink_OnReadError(Cronet_UploadDataSinkPtr self, +// Cronet_String error_message); +// CRONET_EXPORT +// void Cronet_UploadDataSink_OnRewindSucceeded(Cronet_UploadDataSinkPtr self); +// CRONET_EXPORT +// void Cronet_UploadDataSink_OnRewindError(Cronet_UploadDataSinkPtr self, +// Cronet_String error_message); +// // Concrete interface Cronet_UploadDataSink is implemented by Cronet. +// // The app can implement these for testing / mocking. +// typedef void (*Cronet_UploadDataSink_OnReadSucceededFunc)( +// Cronet_UploadDataSinkPtr self, +// uint64_t bytes_read, +// bool final_chunk); +// typedef void (*Cronet_UploadDataSink_OnReadErrorFunc)( +// Cronet_UploadDataSinkPtr self, +// Cronet_String error_message); +// typedef void (*Cronet_UploadDataSink_OnRewindSucceededFunc)( +// Cronet_UploadDataSinkPtr self); +// typedef void (*Cronet_UploadDataSink_OnRewindErrorFunc)( +// Cronet_UploadDataSinkPtr self, +// Cronet_String error_message); +// // Concrete interface Cronet_UploadDataSink is implemented by Cronet. +// // The app can use this for testing / mocking. +// CRONET_EXPORT Cronet_UploadDataSinkPtr Cronet_UploadDataSink_CreateWith( +// Cronet_UploadDataSink_OnReadSucceededFunc OnReadSucceededFunc, +// Cronet_UploadDataSink_OnReadErrorFunc OnReadErrorFunc, +// Cronet_UploadDataSink_OnRewindSucceededFunc OnRewindSucceededFunc, +// Cronet_UploadDataSink_OnRewindErrorFunc OnRewindErrorFunc); -/////////////////////// -// Abstract interface Cronet_UploadDataProvider is implemented by the app. +// /////////////////////// +// // Abstract interface Cronet_UploadDataProvider is implemented by the app. -// There is no method to create a concrete implementation. +// // There is no method to create a concrete implementation. -// Destroy an instance of Cronet_UploadDataProvider. -CRONET_EXPORT void Cronet_UploadDataProvider_Destroy( - Cronet_UploadDataProviderPtr self); -// Set and get app-specific Cronet_ClientContext. -CRONET_EXPORT void Cronet_UploadDataProvider_SetClientContext( - Cronet_UploadDataProviderPtr self, - Cronet_ClientContext client_context); -CRONET_EXPORT Cronet_ClientContext -Cronet_UploadDataProvider_GetClientContext(Cronet_UploadDataProviderPtr self); -// Abstract interface Cronet_UploadDataProvider is implemented by the app. -// The following concrete methods forward call to app implementation. -// The app doesn't normally call them. -CRONET_EXPORT -int64_t Cronet_UploadDataProvider_GetLength(Cronet_UploadDataProviderPtr self); -CRONET_EXPORT -void Cronet_UploadDataProvider_Read(Cronet_UploadDataProviderPtr self, - Cronet_UploadDataSinkPtr upload_data_sink, - Cronet_BufferPtr buffer); -CRONET_EXPORT -void Cronet_UploadDataProvider_Rewind( - Cronet_UploadDataProviderPtr self, - Cronet_UploadDataSinkPtr upload_data_sink); -CRONET_EXPORT -void Cronet_UploadDataProvider_Close(Cronet_UploadDataProviderPtr self); -// The app implements abstract interface Cronet_UploadDataProvider by defining -// custom functions for each method. -typedef int64_t (*Cronet_UploadDataProvider_GetLengthFunc)( - Cronet_UploadDataProviderPtr self); -typedef void (*Cronet_UploadDataProvider_ReadFunc)( - Cronet_UploadDataProviderPtr self, - Cronet_UploadDataSinkPtr upload_data_sink, - Cronet_BufferPtr buffer); -typedef void (*Cronet_UploadDataProvider_RewindFunc)( - Cronet_UploadDataProviderPtr self, - Cronet_UploadDataSinkPtr upload_data_sink); -typedef void (*Cronet_UploadDataProvider_CloseFunc)( - Cronet_UploadDataProviderPtr self); -// The app creates an instance of Cronet_UploadDataProvider by providing custom -// functions for each method. -CRONET_EXPORT Cronet_UploadDataProviderPtr Cronet_UploadDataProvider_CreateWith( - Cronet_UploadDataProvider_GetLengthFunc GetLengthFunc, - Cronet_UploadDataProvider_ReadFunc ReadFunc, - Cronet_UploadDataProvider_RewindFunc RewindFunc, - Cronet_UploadDataProvider_CloseFunc CloseFunc); +// // Destroy an instance of Cronet_UploadDataProvider. +// CRONET_EXPORT void Cronet_UploadDataProvider_Destroy( +// Cronet_UploadDataProviderPtr self); +// // Set and get app-specific Cronet_ClientContext. +// CRONET_EXPORT void Cronet_UploadDataProvider_SetClientContext( +// Cronet_UploadDataProviderPtr self, +// Cronet_ClientContext client_context); +// CRONET_EXPORT Cronet_ClientContext +// Cronet_UploadDataProvider_GetClientContext(Cronet_UploadDataProviderPtr self); +// // Abstract interface Cronet_UploadDataProvider is implemented by the app. +// // The following concrete methods forward call to app implementation. +// // The app doesn't normally call them. +// CRONET_EXPORT +// int64_t Cronet_UploadDataProvider_GetLength(Cronet_UploadDataProviderPtr self); +// CRONET_EXPORT +// void Cronet_UploadDataProvider_Read(Cronet_UploadDataProviderPtr self, +// Cronet_UploadDataSinkPtr upload_data_sink, +// Cronet_BufferPtr buffer); +// CRONET_EXPORT +// void Cronet_UploadDataProvider_Rewind( +// Cronet_UploadDataProviderPtr self, +// Cronet_UploadDataSinkPtr upload_data_sink); +// CRONET_EXPORT +// void Cronet_UploadDataProvider_Close(Cronet_UploadDataProviderPtr self); +// // The app implements abstract interface Cronet_UploadDataProvider by defining +// // custom functions for each method. +// typedef int64_t (*Cronet_UploadDataProvider_GetLengthFunc)( +// Cronet_UploadDataProviderPtr self); +// typedef void (*Cronet_UploadDataProvider_ReadFunc)( +// Cronet_UploadDataProviderPtr self, +// Cronet_UploadDataSinkPtr upload_data_sink, +// Cronet_BufferPtr buffer); +// typedef void (*Cronet_UploadDataProvider_RewindFunc)( +// Cronet_UploadDataProviderPtr self, +// Cronet_UploadDataSinkPtr upload_data_sink); +// typedef void (*Cronet_UploadDataProvider_CloseFunc)( +// Cronet_UploadDataProviderPtr self); +// // The app creates an instance of Cronet_UploadDataProvider by providing custom +// // functions for each method. +// CRONET_EXPORT Cronet_UploadDataProviderPtr Cronet_UploadDataProvider_CreateWith( +// Cronet_UploadDataProvider_GetLengthFunc GetLengthFunc, +// Cronet_UploadDataProvider_ReadFunc ReadFunc, +// Cronet_UploadDataProvider_RewindFunc RewindFunc, +// Cronet_UploadDataProvider_CloseFunc CloseFunc); /////////////////////// // Concrete interface Cronet_UrlRequest. @@ -599,16 +603,16 @@ CRONET_EXPORT void Cronet_UrlRequest_SetClientContext( Cronet_ClientContext client_context); CRONET_EXPORT Cronet_ClientContext Cronet_UrlRequest_GetClientContext(Cronet_UrlRequestPtr self); -// Concrete methods of Cronet_UrlRequest implemented by Cronet. -// The app calls them to manipulate Cronet_UrlRequest. -CRONET_EXPORT -Cronet_RESULT Cronet_UrlRequest_InitWithParams( - Cronet_UrlRequestPtr self, - Cronet_EnginePtr engine, - Cronet_String url, - Cronet_UrlRequestParamsPtr params, - Cronet_UrlRequestCallbackPtr callback, - Cronet_ExecutorPtr executor); +// // Concrete methods of Cronet_UrlRequest implemented by Cronet. +// // The app calls them to manipulate Cronet_UrlRequest. +// CRONET_EXPORT +// Cronet_RESULT Cronet_UrlRequest_InitWithParams( +// Cronet_UrlRequestPtr self, +// Cronet_EnginePtr engine, +// Cronet_String url, +// Cronet_UrlRequestParamsPtr params, +// Cronet_UrlRequestCallbackPtr callback, +// Cronet_ExecutorPtr executor); CRONET_EXPORT Cronet_RESULT Cronet_UrlRequest_Start(Cronet_UrlRequestPtr self); CRONET_EXPORT @@ -618,112 +622,112 @@ Cronet_RESULT Cronet_UrlRequest_Read(Cronet_UrlRequestPtr self, Cronet_BufferPtr buffer); CRONET_EXPORT void Cronet_UrlRequest_Cancel(Cronet_UrlRequestPtr self); -CRONET_EXPORT -bool Cronet_UrlRequest_IsDone(Cronet_UrlRequestPtr self); -CRONET_EXPORT -void Cronet_UrlRequest_GetStatus(Cronet_UrlRequestPtr self, - Cronet_UrlRequestStatusListenerPtr listener); -// Concrete interface Cronet_UrlRequest is implemented by Cronet. -// The app can implement these for testing / mocking. -typedef Cronet_RESULT (*Cronet_UrlRequest_InitWithParamsFunc)( - Cronet_UrlRequestPtr self, - Cronet_EnginePtr engine, - Cronet_String url, - Cronet_UrlRequestParamsPtr params, - Cronet_UrlRequestCallbackPtr callback, - Cronet_ExecutorPtr executor); -typedef Cronet_RESULT (*Cronet_UrlRequest_StartFunc)(Cronet_UrlRequestPtr self); -typedef Cronet_RESULT (*Cronet_UrlRequest_FollowRedirectFunc)( - Cronet_UrlRequestPtr self); -typedef Cronet_RESULT (*Cronet_UrlRequest_ReadFunc)(Cronet_UrlRequestPtr self, - Cronet_BufferPtr buffer); -typedef void (*Cronet_UrlRequest_CancelFunc)(Cronet_UrlRequestPtr self); -typedef bool (*Cronet_UrlRequest_IsDoneFunc)(Cronet_UrlRequestPtr self); -typedef void (*Cronet_UrlRequest_GetStatusFunc)( - Cronet_UrlRequestPtr self, - Cronet_UrlRequestStatusListenerPtr listener); -// Concrete interface Cronet_UrlRequest is implemented by Cronet. -// The app can use this for testing / mocking. -CRONET_EXPORT Cronet_UrlRequestPtr Cronet_UrlRequest_CreateWith( - Cronet_UrlRequest_InitWithParamsFunc InitWithParamsFunc, - Cronet_UrlRequest_StartFunc StartFunc, - Cronet_UrlRequest_FollowRedirectFunc FollowRedirectFunc, - Cronet_UrlRequest_ReadFunc ReadFunc, - Cronet_UrlRequest_CancelFunc CancelFunc, - Cronet_UrlRequest_IsDoneFunc IsDoneFunc, - Cronet_UrlRequest_GetStatusFunc GetStatusFunc); +// CRONET_EXPORT +// bool Cronet_UrlRequest_IsDone(Cronet_UrlRequestPtr self); +// CRONET_EXPORT +// void Cronet_UrlRequest_GetStatus(Cronet_UrlRequestPtr self, +// Cronet_UrlRequestStatusListenerPtr listener); +// // Concrete interface Cronet_UrlRequest is implemented by Cronet. +// // The app can implement these for testing / mocking. +// typedef Cronet_RESULT (*Cronet_UrlRequest_InitWithParamsFunc)( +// Cronet_UrlRequestPtr self, +// Cronet_EnginePtr engine, +// Cronet_String url, +// Cronet_UrlRequestParamsPtr params, +// Cronet_UrlRequestCallbackPtr callback, +// Cronet_ExecutorPtr executor); +// typedef Cronet_RESULT (*Cronet_UrlRequest_StartFunc)(Cronet_UrlRequestPtr self); +// typedef Cronet_RESULT (*Cronet_UrlRequest_FollowRedirectFunc)( +// Cronet_UrlRequestPtr self); +// typedef Cronet_RESULT (*Cronet_UrlRequest_ReadFunc)(Cronet_UrlRequestPtr self, +// Cronet_BufferPtr buffer); +// typedef void (*Cronet_UrlRequest_CancelFunc)(Cronet_UrlRequestPtr self); +// typedef bool (*Cronet_UrlRequest_IsDoneFunc)(Cronet_UrlRequestPtr self); +// typedef void (*Cronet_UrlRequest_GetStatusFunc)( +// Cronet_UrlRequestPtr self, +// Cronet_UrlRequestStatusListenerPtr listener); +// // Concrete interface Cronet_UrlRequest is implemented by Cronet. +// // The app can use this for testing / mocking. +// CRONET_EXPORT Cronet_UrlRequestPtr Cronet_UrlRequest_CreateWith( +// Cronet_UrlRequest_InitWithParamsFunc InitWithParamsFunc, +// Cronet_UrlRequest_StartFunc StartFunc, +// Cronet_UrlRequest_FollowRedirectFunc FollowRedirectFunc, +// Cronet_UrlRequest_ReadFunc ReadFunc, +// Cronet_UrlRequest_CancelFunc CancelFunc, +// Cronet_UrlRequest_IsDoneFunc IsDoneFunc, +// Cronet_UrlRequest_GetStatusFunc GetStatusFunc); -/////////////////////// -// Abstract interface Cronet_RequestFinishedInfoListener is implemented by the -// app. +// /////////////////////// +// // Abstract interface Cronet_RequestFinishedInfoListener is implemented by the +// // app. -// There is no method to create a concrete implementation. +// // There is no method to create a concrete implementation. -// Destroy an instance of Cronet_RequestFinishedInfoListener. -CRONET_EXPORT void Cronet_RequestFinishedInfoListener_Destroy( - Cronet_RequestFinishedInfoListenerPtr self); -// Set and get app-specific Cronet_ClientContext. -CRONET_EXPORT void Cronet_RequestFinishedInfoListener_SetClientContext( - Cronet_RequestFinishedInfoListenerPtr self, - Cronet_ClientContext client_context); -CRONET_EXPORT Cronet_ClientContext -Cronet_RequestFinishedInfoListener_GetClientContext( - Cronet_RequestFinishedInfoListenerPtr self); -// Abstract interface Cronet_RequestFinishedInfoListener is implemented by the -// app. The following concrete methods forward call to app implementation. The -// app doesn't normally call them. -CRONET_EXPORT -void Cronet_RequestFinishedInfoListener_OnRequestFinished( - Cronet_RequestFinishedInfoListenerPtr self, - Cronet_RequestFinishedInfoPtr request_info, - Cronet_UrlResponseInfoPtr response_info, - Cronet_ErrorPtr error); -// The app implements abstract interface Cronet_RequestFinishedInfoListener by -// defining custom functions for each method. -typedef void (*Cronet_RequestFinishedInfoListener_OnRequestFinishedFunc)( - Cronet_RequestFinishedInfoListenerPtr self, - Cronet_RequestFinishedInfoPtr request_info, - Cronet_UrlResponseInfoPtr response_info, - Cronet_ErrorPtr error); -// The app creates an instance of Cronet_RequestFinishedInfoListener by -// providing custom functions for each method. -CRONET_EXPORT Cronet_RequestFinishedInfoListenerPtr -Cronet_RequestFinishedInfoListener_CreateWith( - Cronet_RequestFinishedInfoListener_OnRequestFinishedFunc - OnRequestFinishedFunc); +// // Destroy an instance of Cronet_RequestFinishedInfoListener. +// CRONET_EXPORT void Cronet_RequestFinishedInfoListener_Destroy( +// Cronet_RequestFinishedInfoListenerPtr self); +// // Set and get app-specific Cronet_ClientContext. +// CRONET_EXPORT void Cronet_RequestFinishedInfoListener_SetClientContext( +// Cronet_RequestFinishedInfoListenerPtr self, +// Cronet_ClientContext client_context); +// CRONET_EXPORT Cronet_ClientContext +// Cronet_RequestFinishedInfoListener_GetClientContext( +// Cronet_RequestFinishedInfoListenerPtr self); +// // Abstract interface Cronet_RequestFinishedInfoListener is implemented by the +// // app. The following concrete methods forward call to app implementation. The +// // app doesn't normally call them. +// CRONET_EXPORT +// void Cronet_RequestFinishedInfoListener_OnRequestFinished( +// Cronet_RequestFinishedInfoListenerPtr self, +// Cronet_RequestFinishedInfoPtr request_info, +// Cronet_UrlResponseInfoPtr response_info, +// Cronet_ErrorPtr error); +// // The app implements abstract interface Cronet_RequestFinishedInfoListener by +// // defining custom functions for each method. +// typedef void (*Cronet_RequestFinishedInfoListener_OnRequestFinishedFunc)( +// Cronet_RequestFinishedInfoListenerPtr self, +// Cronet_RequestFinishedInfoPtr request_info, +// Cronet_UrlResponseInfoPtr response_info, +// Cronet_ErrorPtr error); +// // The app creates an instance of Cronet_RequestFinishedInfoListener by +// // providing custom functions for each method. +// CRONET_EXPORT Cronet_RequestFinishedInfoListenerPtr +// Cronet_RequestFinishedInfoListener_CreateWith( +// Cronet_RequestFinishedInfoListener_OnRequestFinishedFunc +// OnRequestFinishedFunc); -/////////////////////// -// Struct Cronet_Error. -CRONET_EXPORT Cronet_ErrorPtr Cronet_Error_Create(void); -CRONET_EXPORT void Cronet_Error_Destroy(Cronet_ErrorPtr self); -// Cronet_Error setters. -CRONET_EXPORT -void Cronet_Error_error_code_set(Cronet_ErrorPtr self, - const Cronet_Error_ERROR_CODE error_code); -CRONET_EXPORT -void Cronet_Error_message_set(Cronet_ErrorPtr self, - const Cronet_String message); -CRONET_EXPORT -void Cronet_Error_internal_error_code_set(Cronet_ErrorPtr self, - const int32_t internal_error_code); -CRONET_EXPORT -void Cronet_Error_immediately_retryable_set(Cronet_ErrorPtr self, - const bool immediately_retryable); -CRONET_EXPORT -void Cronet_Error_quic_detailed_error_code_set( - Cronet_ErrorPtr self, - const int32_t quic_detailed_error_code); -// Cronet_Error getters. -CRONET_EXPORT -Cronet_Error_ERROR_CODE Cronet_Error_error_code_get(const Cronet_ErrorPtr self); -CRONET_EXPORT -Cronet_String Cronet_Error_message_get(const Cronet_ErrorPtr self); -CRONET_EXPORT -int32_t Cronet_Error_internal_error_code_get(const Cronet_ErrorPtr self); -CRONET_EXPORT -bool Cronet_Error_immediately_retryable_get(const Cronet_ErrorPtr self); -CRONET_EXPORT -int32_t Cronet_Error_quic_detailed_error_code_get(const Cronet_ErrorPtr self); +// /////////////////////// +// // Struct Cronet_Error. +// CRONET_EXPORT Cronet_ErrorPtr Cronet_Error_Create(void); +// CRONET_EXPORT void Cronet_Error_Destroy(Cronet_ErrorPtr self); +// // Cronet_Error setters. +// CRONET_EXPORT +// void Cronet_Error_error_code_set(Cronet_ErrorPtr self, +// const Cronet_Error_ERROR_CODE error_code); +// CRONET_EXPORT +// void Cronet_Error_message_set(Cronet_ErrorPtr self, +// const Cronet_String message); +// CRONET_EXPORT +// void Cronet_Error_internal_error_code_set(Cronet_ErrorPtr self, +// const int32_t internal_error_code); +// CRONET_EXPORT +// void Cronet_Error_immediately_retryable_set(Cronet_ErrorPtr self, +// const bool immediately_retryable); +// CRONET_EXPORT +// void Cronet_Error_quic_detailed_error_code_set( +// Cronet_ErrorPtr self, +// const int32_t quic_detailed_error_code); +// // Cronet_Error getters. +// CRONET_EXPORT +// Cronet_Error_ERROR_CODE Cronet_Error_error_code_get(const Cronet_ErrorPtr self); +// CRONET_EXPORT +// Cronet_String Cronet_Error_message_get(const Cronet_ErrorPtr self); +// CRONET_EXPORT +// int32_t Cronet_Error_internal_error_code_get(const Cronet_ErrorPtr self); +// CRONET_EXPORT +// bool Cronet_Error_immediately_retryable_get(const Cronet_ErrorPtr self); +// CRONET_EXPORT +// int32_t Cronet_Error_quic_detailed_error_code_get(const Cronet_ErrorPtr self); /////////////////////// // Struct Cronet_QuicHint. @@ -738,49 +742,49 @@ void Cronet_QuicHint_port_set(Cronet_QuicHintPtr self, const int32_t port); CRONET_EXPORT void Cronet_QuicHint_alternate_port_set(Cronet_QuicHintPtr self, const int32_t alternate_port); -// Cronet_QuicHint getters. -CRONET_EXPORT -Cronet_String Cronet_QuicHint_host_get(const Cronet_QuicHintPtr self); -CRONET_EXPORT -int32_t Cronet_QuicHint_port_get(const Cronet_QuicHintPtr self); -CRONET_EXPORT -int32_t Cronet_QuicHint_alternate_port_get(const Cronet_QuicHintPtr self); +// // Cronet_QuicHint getters. +// CRONET_EXPORT +// Cronet_String Cronet_QuicHint_host_get(const Cronet_QuicHintPtr self); +// CRONET_EXPORT +// int32_t Cronet_QuicHint_port_get(const Cronet_QuicHintPtr self); +// CRONET_EXPORT +// int32_t Cronet_QuicHint_alternate_port_get(const Cronet_QuicHintPtr self); -/////////////////////// -// Struct Cronet_PublicKeyPins. -CRONET_EXPORT Cronet_PublicKeyPinsPtr Cronet_PublicKeyPins_Create(void); -CRONET_EXPORT void Cronet_PublicKeyPins_Destroy(Cronet_PublicKeyPinsPtr self); -// Cronet_PublicKeyPins setters. -CRONET_EXPORT -void Cronet_PublicKeyPins_host_set(Cronet_PublicKeyPinsPtr self, - const Cronet_String host); -CRONET_EXPORT -void Cronet_PublicKeyPins_pins_sha256_add(Cronet_PublicKeyPinsPtr self, - const Cronet_String element); -CRONET_EXPORT -void Cronet_PublicKeyPins_include_subdomains_set(Cronet_PublicKeyPinsPtr self, - const bool include_subdomains); -CRONET_EXPORT -void Cronet_PublicKeyPins_expiration_date_set(Cronet_PublicKeyPinsPtr self, - const int64_t expiration_date); -// Cronet_PublicKeyPins getters. -CRONET_EXPORT -Cronet_String Cronet_PublicKeyPins_host_get(const Cronet_PublicKeyPinsPtr self); -CRONET_EXPORT -uint32_t Cronet_PublicKeyPins_pins_sha256_size( - const Cronet_PublicKeyPinsPtr self); -CRONET_EXPORT -Cronet_String Cronet_PublicKeyPins_pins_sha256_at( - const Cronet_PublicKeyPinsPtr self, - uint32_t index); -CRONET_EXPORT -void Cronet_PublicKeyPins_pins_sha256_clear(Cronet_PublicKeyPinsPtr self); -CRONET_EXPORT -bool Cronet_PublicKeyPins_include_subdomains_get( - const Cronet_PublicKeyPinsPtr self); -CRONET_EXPORT -int64_t Cronet_PublicKeyPins_expiration_date_get( - const Cronet_PublicKeyPinsPtr self); +// /////////////////////// +// // Struct Cronet_PublicKeyPins. +// CRONET_EXPORT Cronet_PublicKeyPinsPtr Cronet_PublicKeyPins_Create(void); +// CRONET_EXPORT void Cronet_PublicKeyPins_Destroy(Cronet_PublicKeyPinsPtr self); +// // Cronet_PublicKeyPins setters. +// CRONET_EXPORT +// void Cronet_PublicKeyPins_host_set(Cronet_PublicKeyPinsPtr self, +// const Cronet_String host); +// CRONET_EXPORT +// void Cronet_PublicKeyPins_pins_sha256_add(Cronet_PublicKeyPinsPtr self, +// const Cronet_String element); +// CRONET_EXPORT +// void Cronet_PublicKeyPins_include_subdomains_set(Cronet_PublicKeyPinsPtr self, +// const bool include_subdomains); +// CRONET_EXPORT +// void Cronet_PublicKeyPins_expiration_date_set(Cronet_PublicKeyPinsPtr self, +// const int64_t expiration_date); +// // Cronet_PublicKeyPins getters. +// CRONET_EXPORT +// Cronet_String Cronet_PublicKeyPins_host_get(const Cronet_PublicKeyPinsPtr self); +// CRONET_EXPORT +// uint32_t Cronet_PublicKeyPins_pins_sha256_size( +// const Cronet_PublicKeyPinsPtr self); +// CRONET_EXPORT +// Cronet_String Cronet_PublicKeyPins_pins_sha256_at( +// const Cronet_PublicKeyPinsPtr self, +// uint32_t index); +// CRONET_EXPORT +// void Cronet_PublicKeyPins_pins_sha256_clear(Cronet_PublicKeyPinsPtr self); +// CRONET_EXPORT +// bool Cronet_PublicKeyPins_include_subdomains_get( +// const Cronet_PublicKeyPinsPtr self); +// CRONET_EXPORT +// int64_t Cronet_PublicKeyPins_expiration_date_get( +// const Cronet_PublicKeyPinsPtr self); /////////////////////// // Struct Cronet_EngineParams. @@ -821,73 +825,73 @@ void Cronet_EngineParams_http_cache_max_size_set( CRONET_EXPORT void Cronet_EngineParams_quic_hints_add(Cronet_EngineParamsPtr self, const Cronet_QuicHintPtr element); -CRONET_EXPORT -void Cronet_EngineParams_public_key_pins_add( - Cronet_EngineParamsPtr self, - const Cronet_PublicKeyPinsPtr element); -CRONET_EXPORT -void Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_set( - Cronet_EngineParamsPtr self, - const bool enable_public_key_pinning_bypass_for_local_trust_anchors); -CRONET_EXPORT -void Cronet_EngineParams_network_thread_priority_set( - Cronet_EngineParamsPtr self, - const double network_thread_priority); -CRONET_EXPORT -void Cronet_EngineParams_experimental_options_set( - Cronet_EngineParamsPtr self, - const Cronet_String experimental_options); -// Cronet_EngineParams getters. -CRONET_EXPORT -bool Cronet_EngineParams_enable_check_result_get( - const Cronet_EngineParamsPtr self); -CRONET_EXPORT -Cronet_String Cronet_EngineParams_user_agent_get( - const Cronet_EngineParamsPtr self); -CRONET_EXPORT -Cronet_String Cronet_EngineParams_accept_language_get( - const Cronet_EngineParamsPtr self); -CRONET_EXPORT -Cronet_String Cronet_EngineParams_storage_path_get( - const Cronet_EngineParamsPtr self); -CRONET_EXPORT -bool Cronet_EngineParams_enable_quic_get(const Cronet_EngineParamsPtr self); -CRONET_EXPORT -bool Cronet_EngineParams_enable_http2_get(const Cronet_EngineParamsPtr self); -CRONET_EXPORT -bool Cronet_EngineParams_enable_brotli_get(const Cronet_EngineParamsPtr self); -CRONET_EXPORT -Cronet_EngineParams_HTTP_CACHE_MODE Cronet_EngineParams_http_cache_mode_get( - const Cronet_EngineParamsPtr self); -CRONET_EXPORT -int64_t Cronet_EngineParams_http_cache_max_size_get( - const Cronet_EngineParamsPtr self); -CRONET_EXPORT -uint32_t Cronet_EngineParams_quic_hints_size(const Cronet_EngineParamsPtr self); -CRONET_EXPORT -Cronet_QuicHintPtr Cronet_EngineParams_quic_hints_at( - const Cronet_EngineParamsPtr self, - uint32_t index); -CRONET_EXPORT -void Cronet_EngineParams_quic_hints_clear(Cronet_EngineParamsPtr self); -CRONET_EXPORT -uint32_t Cronet_EngineParams_public_key_pins_size( - const Cronet_EngineParamsPtr self); -CRONET_EXPORT -Cronet_PublicKeyPinsPtr Cronet_EngineParams_public_key_pins_at( - const Cronet_EngineParamsPtr self, - uint32_t index); -CRONET_EXPORT -void Cronet_EngineParams_public_key_pins_clear(Cronet_EngineParamsPtr self); -CRONET_EXPORT -bool Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_get( - const Cronet_EngineParamsPtr self); -CRONET_EXPORT -double Cronet_EngineParams_network_thread_priority_get( - const Cronet_EngineParamsPtr self); -CRONET_EXPORT -Cronet_String Cronet_EngineParams_experimental_options_get( - const Cronet_EngineParamsPtr self); +// CRONET_EXPORT +// void Cronet_EngineParams_public_key_pins_add( +// Cronet_EngineParamsPtr self, +// const Cronet_PublicKeyPinsPtr element); +// CRONET_EXPORT +// void Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_set( +// Cronet_EngineParamsPtr self, +// const bool enable_public_key_pinning_bypass_for_local_trust_anchors); +// CRONET_EXPORT +// void Cronet_EngineParams_network_thread_priority_set( +// Cronet_EngineParamsPtr self, +// const double network_thread_priority); +// CRONET_EXPORT +// void Cronet_EngineParams_experimental_options_set( +// Cronet_EngineParamsPtr self, +// const Cronet_String experimental_options); +// // Cronet_EngineParams getters. +// CRONET_EXPORT +// bool Cronet_EngineParams_enable_check_result_get( +// const Cronet_EngineParamsPtr self); +// CRONET_EXPORT +// Cronet_String Cronet_EngineParams_user_agent_get( +// const Cronet_EngineParamsPtr self); +// CRONET_EXPORT +// Cronet_String Cronet_EngineParams_accept_language_get( +// const Cronet_EngineParamsPtr self); +// CRONET_EXPORT +// Cronet_String Cronet_EngineParams_storage_path_get( +// const Cronet_EngineParamsPtr self); +// CRONET_EXPORT +// bool Cronet_EngineParams_enable_quic_get(const Cronet_EngineParamsPtr self); +// CRONET_EXPORT +// bool Cronet_EngineParams_enable_http2_get(const Cronet_EngineParamsPtr self); +// CRONET_EXPORT +// bool Cronet_EngineParams_enable_brotli_get(const Cronet_EngineParamsPtr self); +// CRONET_EXPORT +// Cronet_EngineParams_HTTP_CACHE_MODE Cronet_EngineParams_http_cache_mode_get( +// const Cronet_EngineParamsPtr self); +// CRONET_EXPORT +// int64_t Cronet_EngineParams_http_cache_max_size_get( +// const Cronet_EngineParamsPtr self); +// CRONET_EXPORT +// uint32_t Cronet_EngineParams_quic_hints_size(const Cronet_EngineParamsPtr self); +// CRONET_EXPORT +// Cronet_QuicHintPtr Cronet_EngineParams_quic_hints_at( +// const Cronet_EngineParamsPtr self, +// uint32_t index); +// CRONET_EXPORT +// void Cronet_EngineParams_quic_hints_clear(Cronet_EngineParamsPtr self); +// CRONET_EXPORT +// uint32_t Cronet_EngineParams_public_key_pins_size( +// const Cronet_EngineParamsPtr self); +// CRONET_EXPORT +// Cronet_PublicKeyPinsPtr Cronet_EngineParams_public_key_pins_at( +// const Cronet_EngineParamsPtr self, +// uint32_t index); +// CRONET_EXPORT +// void Cronet_EngineParams_public_key_pins_clear(Cronet_EngineParamsPtr self); +// CRONET_EXPORT +// bool Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_get( +// const Cronet_EngineParamsPtr self); +// CRONET_EXPORT +// double Cronet_EngineParams_network_thread_priority_get( +// const Cronet_EngineParamsPtr self); +// CRONET_EXPORT +// Cronet_String Cronet_EngineParams_experimental_options_get( +// const Cronet_EngineParamsPtr self); /////////////////////// // Struct Cronet_HttpHeader. @@ -900,91 +904,91 @@ void Cronet_HttpHeader_name_set(Cronet_HttpHeaderPtr self, CRONET_EXPORT void Cronet_HttpHeader_value_set(Cronet_HttpHeaderPtr self, const Cronet_String value); -// Cronet_HttpHeader getters. -CRONET_EXPORT -Cronet_String Cronet_HttpHeader_name_get(const Cronet_HttpHeaderPtr self); -CRONET_EXPORT -Cronet_String Cronet_HttpHeader_value_get(const Cronet_HttpHeaderPtr self); +// // Cronet_HttpHeader getters. +// CRONET_EXPORT +// Cronet_String Cronet_HttpHeader_name_get(const Cronet_HttpHeaderPtr self); +// CRONET_EXPORT +// Cronet_String Cronet_HttpHeader_value_get(const Cronet_HttpHeaderPtr self); -/////////////////////// -// Struct Cronet_UrlResponseInfo. -CRONET_EXPORT Cronet_UrlResponseInfoPtr Cronet_UrlResponseInfo_Create(void); -CRONET_EXPORT void Cronet_UrlResponseInfo_Destroy( - Cronet_UrlResponseInfoPtr self); -// Cronet_UrlResponseInfo setters. -CRONET_EXPORT -void Cronet_UrlResponseInfo_url_set(Cronet_UrlResponseInfoPtr self, - const Cronet_String url); -CRONET_EXPORT -void Cronet_UrlResponseInfo_url_chain_add(Cronet_UrlResponseInfoPtr self, - const Cronet_String element); -CRONET_EXPORT -void Cronet_UrlResponseInfo_http_status_code_set( - Cronet_UrlResponseInfoPtr self, - const int32_t http_status_code); -CRONET_EXPORT -void Cronet_UrlResponseInfo_http_status_text_set( - Cronet_UrlResponseInfoPtr self, - const Cronet_String http_status_text); -CRONET_EXPORT -void Cronet_UrlResponseInfo_all_headers_list_add( - Cronet_UrlResponseInfoPtr self, - const Cronet_HttpHeaderPtr element); -CRONET_EXPORT -void Cronet_UrlResponseInfo_was_cached_set(Cronet_UrlResponseInfoPtr self, - const bool was_cached); -CRONET_EXPORT -void Cronet_UrlResponseInfo_negotiated_protocol_set( - Cronet_UrlResponseInfoPtr self, - const Cronet_String negotiated_protocol); -CRONET_EXPORT -void Cronet_UrlResponseInfo_proxy_server_set(Cronet_UrlResponseInfoPtr self, - const Cronet_String proxy_server); -CRONET_EXPORT -void Cronet_UrlResponseInfo_received_byte_count_set( - Cronet_UrlResponseInfoPtr self, - const int64_t received_byte_count); -// Cronet_UrlResponseInfo getters. -CRONET_EXPORT -Cronet_String Cronet_UrlResponseInfo_url_get( - const Cronet_UrlResponseInfoPtr self); -CRONET_EXPORT -uint32_t Cronet_UrlResponseInfo_url_chain_size( - const Cronet_UrlResponseInfoPtr self); -CRONET_EXPORT -Cronet_String Cronet_UrlResponseInfo_url_chain_at( - const Cronet_UrlResponseInfoPtr self, - uint32_t index); -CRONET_EXPORT -void Cronet_UrlResponseInfo_url_chain_clear(Cronet_UrlResponseInfoPtr self); +// /////////////////////// +// // Struct Cronet_UrlResponseInfo. +// CRONET_EXPORT Cronet_UrlResponseInfoPtr Cronet_UrlResponseInfo_Create(void); +// CRONET_EXPORT void Cronet_UrlResponseInfo_Destroy( +// Cronet_UrlResponseInfoPtr self); +// // Cronet_UrlResponseInfo setters. +// CRONET_EXPORT +// void Cronet_UrlResponseInfo_url_set(Cronet_UrlResponseInfoPtr self, +// const Cronet_String url); +// CRONET_EXPORT +// void Cronet_UrlResponseInfo_url_chain_add(Cronet_UrlResponseInfoPtr self, +// const Cronet_String element); +// CRONET_EXPORT +// void Cronet_UrlResponseInfo_http_status_code_set( +// Cronet_UrlResponseInfoPtr self, +// const int32_t http_status_code); +// CRONET_EXPORT +// void Cronet_UrlResponseInfo_http_status_text_set( +// Cronet_UrlResponseInfoPtr self, +// const Cronet_String http_status_text); +// CRONET_EXPORT +// void Cronet_UrlResponseInfo_all_headers_list_add( +// Cronet_UrlResponseInfoPtr self, +// const Cronet_HttpHeaderPtr element); +// CRONET_EXPORT +// void Cronet_UrlResponseInfo_was_cached_set(Cronet_UrlResponseInfoPtr self, +// const bool was_cached); +// CRONET_EXPORT +// void Cronet_UrlResponseInfo_negotiated_protocol_set( +// Cronet_UrlResponseInfoPtr self, +// const Cronet_String negotiated_protocol); +// CRONET_EXPORT +// void Cronet_UrlResponseInfo_proxy_server_set(Cronet_UrlResponseInfoPtr self, +// const Cronet_String proxy_server); +// CRONET_EXPORT +// void Cronet_UrlResponseInfo_received_byte_count_set( +// Cronet_UrlResponseInfoPtr self, +// const int64_t received_byte_count); +// // Cronet_UrlResponseInfo getters. +// CRONET_EXPORT +// Cronet_String Cronet_UrlResponseInfo_url_get( +// const Cronet_UrlResponseInfoPtr self); +// CRONET_EXPORT +// uint32_t Cronet_UrlResponseInfo_url_chain_size( +// const Cronet_UrlResponseInfoPtr self); +// CRONET_EXPORT +// Cronet_String Cronet_UrlResponseInfo_url_chain_at( +// const Cronet_UrlResponseInfoPtr self, +// uint32_t index); +// CRONET_EXPORT +// void Cronet_UrlResponseInfo_url_chain_clear(Cronet_UrlResponseInfoPtr self); CRONET_EXPORT int32_t Cronet_UrlResponseInfo_http_status_code_get( const Cronet_UrlResponseInfoPtr self); CRONET_EXPORT Cronet_String Cronet_UrlResponseInfo_http_status_text_get( const Cronet_UrlResponseInfoPtr self); -CRONET_EXPORT -uint32_t Cronet_UrlResponseInfo_all_headers_list_size( - const Cronet_UrlResponseInfoPtr self); -CRONET_EXPORT -Cronet_HttpHeaderPtr Cronet_UrlResponseInfo_all_headers_list_at( - const Cronet_UrlResponseInfoPtr self, - uint32_t index); -CRONET_EXPORT -void Cronet_UrlResponseInfo_all_headers_list_clear( - Cronet_UrlResponseInfoPtr self); -CRONET_EXPORT -bool Cronet_UrlResponseInfo_was_cached_get( - const Cronet_UrlResponseInfoPtr self); -CRONET_EXPORT -Cronet_String Cronet_UrlResponseInfo_negotiated_protocol_get( - const Cronet_UrlResponseInfoPtr self); -CRONET_EXPORT -Cronet_String Cronet_UrlResponseInfo_proxy_server_get( - const Cronet_UrlResponseInfoPtr self); -CRONET_EXPORT -int64_t Cronet_UrlResponseInfo_received_byte_count_get( - const Cronet_UrlResponseInfoPtr self); +// CRONET_EXPORT +// uint32_t Cronet_UrlResponseInfo_all_headers_list_size( +// const Cronet_UrlResponseInfoPtr self); +// CRONET_EXPORT +// Cronet_HttpHeaderPtr Cronet_UrlResponseInfo_all_headers_list_at( +// const Cronet_UrlResponseInfoPtr self, +// uint32_t index); +// CRONET_EXPORT +// void Cronet_UrlResponseInfo_all_headers_list_clear( +// Cronet_UrlResponseInfoPtr self); +// CRONET_EXPORT +// bool Cronet_UrlResponseInfo_was_cached_get( +// const Cronet_UrlResponseInfoPtr self); +// CRONET_EXPORT +// Cronet_String Cronet_UrlResponseInfo_negotiated_protocol_get( +// const Cronet_UrlResponseInfoPtr self); +// CRONET_EXPORT +// Cronet_String Cronet_UrlResponseInfo_proxy_server_get( +// const Cronet_UrlResponseInfoPtr self); +// CRONET_EXPORT +// int64_t Cronet_UrlResponseInfo_received_byte_count_get( +// const Cronet_UrlResponseInfoPtr self); /////////////////////// // Struct Cronet_UrlRequestParams. @@ -999,283 +1003,283 @@ CRONET_EXPORT void Cronet_UrlRequestParams_request_headers_add( Cronet_UrlRequestParamsPtr self, const Cronet_HttpHeaderPtr element); -CRONET_EXPORT -void Cronet_UrlRequestParams_disable_cache_set(Cronet_UrlRequestParamsPtr self, - const bool disable_cache); -CRONET_EXPORT -void Cronet_UrlRequestParams_priority_set( - Cronet_UrlRequestParamsPtr self, - const Cronet_UrlRequestParams_REQUEST_PRIORITY priority); -CRONET_EXPORT -void Cronet_UrlRequestParams_upload_data_provider_set( - Cronet_UrlRequestParamsPtr self, - const Cronet_UploadDataProviderPtr upload_data_provider); -CRONET_EXPORT -void Cronet_UrlRequestParams_upload_data_provider_executor_set( - Cronet_UrlRequestParamsPtr self, - const Cronet_ExecutorPtr upload_data_provider_executor); -CRONET_EXPORT -void Cronet_UrlRequestParams_allow_direct_executor_set( - Cronet_UrlRequestParamsPtr self, - const bool allow_direct_executor); -CRONET_EXPORT -void Cronet_UrlRequestParams_annotations_add(Cronet_UrlRequestParamsPtr self, - const Cronet_RawDataPtr element); -CRONET_EXPORT -void Cronet_UrlRequestParams_request_finished_listener_set( - Cronet_UrlRequestParamsPtr self, - const Cronet_RequestFinishedInfoListenerPtr request_finished_listener); -CRONET_EXPORT -void Cronet_UrlRequestParams_request_finished_executor_set( - Cronet_UrlRequestParamsPtr self, - const Cronet_ExecutorPtr request_finished_executor); -CRONET_EXPORT -void Cronet_UrlRequestParams_idempotency_set( - Cronet_UrlRequestParamsPtr self, - const Cronet_UrlRequestParams_IDEMPOTENCY idempotency); -// Cronet_UrlRequestParams getters. -CRONET_EXPORT -Cronet_String Cronet_UrlRequestParams_http_method_get( - const Cronet_UrlRequestParamsPtr self); -CRONET_EXPORT -uint32_t Cronet_UrlRequestParams_request_headers_size( - const Cronet_UrlRequestParamsPtr self); -CRONET_EXPORT -Cronet_HttpHeaderPtr Cronet_UrlRequestParams_request_headers_at( - const Cronet_UrlRequestParamsPtr self, - uint32_t index); -CRONET_EXPORT -void Cronet_UrlRequestParams_request_headers_clear( - Cronet_UrlRequestParamsPtr self); -CRONET_EXPORT -bool Cronet_UrlRequestParams_disable_cache_get( - const Cronet_UrlRequestParamsPtr self); -CRONET_EXPORT -Cronet_UrlRequestParams_REQUEST_PRIORITY Cronet_UrlRequestParams_priority_get( - const Cronet_UrlRequestParamsPtr self); -CRONET_EXPORT -Cronet_UploadDataProviderPtr Cronet_UrlRequestParams_upload_data_provider_get( - const Cronet_UrlRequestParamsPtr self); -CRONET_EXPORT -Cronet_ExecutorPtr Cronet_UrlRequestParams_upload_data_provider_executor_get( - const Cronet_UrlRequestParamsPtr self); -CRONET_EXPORT -bool Cronet_UrlRequestParams_allow_direct_executor_get( - const Cronet_UrlRequestParamsPtr self); -CRONET_EXPORT -uint32_t Cronet_UrlRequestParams_annotations_size( - const Cronet_UrlRequestParamsPtr self); -CRONET_EXPORT -Cronet_RawDataPtr Cronet_UrlRequestParams_annotations_at( - const Cronet_UrlRequestParamsPtr self, - uint32_t index); -CRONET_EXPORT -void Cronet_UrlRequestParams_annotations_clear(Cronet_UrlRequestParamsPtr self); -CRONET_EXPORT -Cronet_RequestFinishedInfoListenerPtr -Cronet_UrlRequestParams_request_finished_listener_get( - const Cronet_UrlRequestParamsPtr self); -CRONET_EXPORT -Cronet_ExecutorPtr Cronet_UrlRequestParams_request_finished_executor_get( - const Cronet_UrlRequestParamsPtr self); -CRONET_EXPORT -Cronet_UrlRequestParams_IDEMPOTENCY Cronet_UrlRequestParams_idempotency_get( - const Cronet_UrlRequestParamsPtr self); +// CRONET_EXPORT +// void Cronet_UrlRequestParams_disable_cache_set(Cronet_UrlRequestParamsPtr self, +// const bool disable_cache); +// CRONET_EXPORT +// void Cronet_UrlRequestParams_priority_set( +// Cronet_UrlRequestParamsPtr self, +// const Cronet_UrlRequestParams_REQUEST_PRIORITY priority); +// CRONET_EXPORT +// void Cronet_UrlRequestParams_upload_data_provider_set( +// Cronet_UrlRequestParamsPtr self, +// const Cronet_UploadDataProviderPtr upload_data_provider); +// CRONET_EXPORT +// void Cronet_UrlRequestParams_upload_data_provider_executor_set( +// Cronet_UrlRequestParamsPtr self, +// const Cronet_ExecutorPtr upload_data_provider_executor); +// CRONET_EXPORT +// void Cronet_UrlRequestParams_allow_direct_executor_set( +// Cronet_UrlRequestParamsPtr self, +// const bool allow_direct_executor); +// CRONET_EXPORT +// void Cronet_UrlRequestParams_annotations_add(Cronet_UrlRequestParamsPtr self, +// const Cronet_RawDataPtr element); +// CRONET_EXPORT +// void Cronet_UrlRequestParams_request_finished_listener_set( +// Cronet_UrlRequestParamsPtr self, +// const Cronet_RequestFinishedInfoListenerPtr request_finished_listener); +// CRONET_EXPORT +// void Cronet_UrlRequestParams_request_finished_executor_set( +// Cronet_UrlRequestParamsPtr self, +// const Cronet_ExecutorPtr request_finished_executor); +// CRONET_EXPORT +// void Cronet_UrlRequestParams_idempotency_set( +// Cronet_UrlRequestParamsPtr self, +// const Cronet_UrlRequestParams_IDEMPOTENCY idempotency); +// // Cronet_UrlRequestParams getters. +// CRONET_EXPORT +// Cronet_String Cronet_UrlRequestParams_http_method_get( +// const Cronet_UrlRequestParamsPtr self); +// CRONET_EXPORT +// uint32_t Cronet_UrlRequestParams_request_headers_size( +// const Cronet_UrlRequestParamsPtr self); +// CRONET_EXPORT +// Cronet_HttpHeaderPtr Cronet_UrlRequestParams_request_headers_at( +// const Cronet_UrlRequestParamsPtr self, +// uint32_t index); +// CRONET_EXPORT +// void Cronet_UrlRequestParams_request_headers_clear( +// Cronet_UrlRequestParamsPtr self); +// CRONET_EXPORT +// bool Cronet_UrlRequestParams_disable_cache_get( +// const Cronet_UrlRequestParamsPtr self); +// CRONET_EXPORT +// Cronet_UrlRequestParams_REQUEST_PRIORITY Cronet_UrlRequestParams_priority_get( +// const Cronet_UrlRequestParamsPtr self); +// CRONET_EXPORT +// Cronet_UploadDataProviderPtr Cronet_UrlRequestParams_upload_data_provider_get( +// const Cronet_UrlRequestParamsPtr self); +// CRONET_EXPORT +// Cronet_ExecutorPtr Cronet_UrlRequestParams_upload_data_provider_executor_get( +// const Cronet_UrlRequestParamsPtr self); +// CRONET_EXPORT +// bool Cronet_UrlRequestParams_allow_direct_executor_get( +// const Cronet_UrlRequestParamsPtr self); +// CRONET_EXPORT +// uint32_t Cronet_UrlRequestParams_annotations_size( +// const Cronet_UrlRequestParamsPtr self); +// CRONET_EXPORT +// Cronet_RawDataPtr Cronet_UrlRequestParams_annotations_at( +// const Cronet_UrlRequestParamsPtr self, +// uint32_t index); +// CRONET_EXPORT +// void Cronet_UrlRequestParams_annotations_clear(Cronet_UrlRequestParamsPtr self); +// CRONET_EXPORT +// Cronet_RequestFinishedInfoListenerPtr +// Cronet_UrlRequestParams_request_finished_listener_get( +// const Cronet_UrlRequestParamsPtr self); +// CRONET_EXPORT +// Cronet_ExecutorPtr Cronet_UrlRequestParams_request_finished_executor_get( +// const Cronet_UrlRequestParamsPtr self); +// CRONET_EXPORT +// Cronet_UrlRequestParams_IDEMPOTENCY Cronet_UrlRequestParams_idempotency_get( +// const Cronet_UrlRequestParamsPtr self); -/////////////////////// -// Struct Cronet_DateTime. -CRONET_EXPORT Cronet_DateTimePtr Cronet_DateTime_Create(void); -CRONET_EXPORT void Cronet_DateTime_Destroy(Cronet_DateTimePtr self); -// Cronet_DateTime setters. -CRONET_EXPORT -void Cronet_DateTime_value_set(Cronet_DateTimePtr self, const int64_t value); -// Cronet_DateTime getters. -CRONET_EXPORT -int64_t Cronet_DateTime_value_get(const Cronet_DateTimePtr self); +// /////////////////////// +// // Struct Cronet_DateTime. +// CRONET_EXPORT Cronet_DateTimePtr Cronet_DateTime_Create(void); +// CRONET_EXPORT void Cronet_DateTime_Destroy(Cronet_DateTimePtr self); +// // Cronet_DateTime setters. +// CRONET_EXPORT +// void Cronet_DateTime_value_set(Cronet_DateTimePtr self, const int64_t value); +// // Cronet_DateTime getters. +// CRONET_EXPORT +// int64_t Cronet_DateTime_value_get(const Cronet_DateTimePtr self); -/////////////////////// -// Struct Cronet_Metrics. -CRONET_EXPORT Cronet_MetricsPtr Cronet_Metrics_Create(void); -CRONET_EXPORT void Cronet_Metrics_Destroy(Cronet_MetricsPtr self); -// Cronet_Metrics setters. -CRONET_EXPORT -void Cronet_Metrics_request_start_set(Cronet_MetricsPtr self, - const Cronet_DateTimePtr request_start); -// Move data from |request_start|. The caller retains ownership of -// |request_start| and must destroy it. -void Cronet_Metrics_request_start_move(Cronet_MetricsPtr self, - Cronet_DateTimePtr request_start); -CRONET_EXPORT -void Cronet_Metrics_dns_start_set(Cronet_MetricsPtr self, - const Cronet_DateTimePtr dns_start); -// Move data from |dns_start|. The caller retains ownership of |dns_start| and -// must destroy it. -void Cronet_Metrics_dns_start_move(Cronet_MetricsPtr self, - Cronet_DateTimePtr dns_start); -CRONET_EXPORT -void Cronet_Metrics_dns_end_set(Cronet_MetricsPtr self, - const Cronet_DateTimePtr dns_end); -// Move data from |dns_end|. The caller retains ownership of |dns_end| and must -// destroy it. -void Cronet_Metrics_dns_end_move(Cronet_MetricsPtr self, - Cronet_DateTimePtr dns_end); -CRONET_EXPORT -void Cronet_Metrics_connect_start_set(Cronet_MetricsPtr self, - const Cronet_DateTimePtr connect_start); -// Move data from |connect_start|. The caller retains ownership of -// |connect_start| and must destroy it. -void Cronet_Metrics_connect_start_move(Cronet_MetricsPtr self, - Cronet_DateTimePtr connect_start); -CRONET_EXPORT -void Cronet_Metrics_connect_end_set(Cronet_MetricsPtr self, - const Cronet_DateTimePtr connect_end); -// Move data from |connect_end|. The caller retains ownership of |connect_end| -// and must destroy it. -void Cronet_Metrics_connect_end_move(Cronet_MetricsPtr self, - Cronet_DateTimePtr connect_end); -CRONET_EXPORT -void Cronet_Metrics_ssl_start_set(Cronet_MetricsPtr self, - const Cronet_DateTimePtr ssl_start); -// Move data from |ssl_start|. The caller retains ownership of |ssl_start| and -// must destroy it. -void Cronet_Metrics_ssl_start_move(Cronet_MetricsPtr self, - Cronet_DateTimePtr ssl_start); -CRONET_EXPORT -void Cronet_Metrics_ssl_end_set(Cronet_MetricsPtr self, - const Cronet_DateTimePtr ssl_end); -// Move data from |ssl_end|. The caller retains ownership of |ssl_end| and must -// destroy it. -void Cronet_Metrics_ssl_end_move(Cronet_MetricsPtr self, - Cronet_DateTimePtr ssl_end); -CRONET_EXPORT -void Cronet_Metrics_sending_start_set(Cronet_MetricsPtr self, - const Cronet_DateTimePtr sending_start); -// Move data from |sending_start|. The caller retains ownership of -// |sending_start| and must destroy it. -void Cronet_Metrics_sending_start_move(Cronet_MetricsPtr self, - Cronet_DateTimePtr sending_start); -CRONET_EXPORT -void Cronet_Metrics_sending_end_set(Cronet_MetricsPtr self, - const Cronet_DateTimePtr sending_end); -// Move data from |sending_end|. The caller retains ownership of |sending_end| -// and must destroy it. -void Cronet_Metrics_sending_end_move(Cronet_MetricsPtr self, - Cronet_DateTimePtr sending_end); -CRONET_EXPORT -void Cronet_Metrics_push_start_set(Cronet_MetricsPtr self, - const Cronet_DateTimePtr push_start); -// Move data from |push_start|. The caller retains ownership of |push_start| and -// must destroy it. -void Cronet_Metrics_push_start_move(Cronet_MetricsPtr self, - Cronet_DateTimePtr push_start); -CRONET_EXPORT -void Cronet_Metrics_push_end_set(Cronet_MetricsPtr self, - const Cronet_DateTimePtr push_end); -// Move data from |push_end|. The caller retains ownership of |push_end| and -// must destroy it. -void Cronet_Metrics_push_end_move(Cronet_MetricsPtr self, - Cronet_DateTimePtr push_end); -CRONET_EXPORT -void Cronet_Metrics_response_start_set(Cronet_MetricsPtr self, - const Cronet_DateTimePtr response_start); -// Move data from |response_start|. The caller retains ownership of -// |response_start| and must destroy it. -void Cronet_Metrics_response_start_move(Cronet_MetricsPtr self, - Cronet_DateTimePtr response_start); -CRONET_EXPORT -void Cronet_Metrics_request_end_set(Cronet_MetricsPtr self, - const Cronet_DateTimePtr request_end); -// Move data from |request_end|. The caller retains ownership of |request_end| -// and must destroy it. -void Cronet_Metrics_request_end_move(Cronet_MetricsPtr self, - Cronet_DateTimePtr request_end); -CRONET_EXPORT -void Cronet_Metrics_socket_reused_set(Cronet_MetricsPtr self, - const bool socket_reused); -CRONET_EXPORT -void Cronet_Metrics_sent_byte_count_set(Cronet_MetricsPtr self, - const int64_t sent_byte_count); -CRONET_EXPORT -void Cronet_Metrics_received_byte_count_set(Cronet_MetricsPtr self, - const int64_t received_byte_count); -// Cronet_Metrics getters. -CRONET_EXPORT -Cronet_DateTimePtr Cronet_Metrics_request_start_get( - const Cronet_MetricsPtr self); -CRONET_EXPORT -Cronet_DateTimePtr Cronet_Metrics_dns_start_get(const Cronet_MetricsPtr self); -CRONET_EXPORT -Cronet_DateTimePtr Cronet_Metrics_dns_end_get(const Cronet_MetricsPtr self); -CRONET_EXPORT -Cronet_DateTimePtr Cronet_Metrics_connect_start_get( - const Cronet_MetricsPtr self); -CRONET_EXPORT -Cronet_DateTimePtr Cronet_Metrics_connect_end_get(const Cronet_MetricsPtr self); -CRONET_EXPORT -Cronet_DateTimePtr Cronet_Metrics_ssl_start_get(const Cronet_MetricsPtr self); -CRONET_EXPORT -Cronet_DateTimePtr Cronet_Metrics_ssl_end_get(const Cronet_MetricsPtr self); -CRONET_EXPORT -Cronet_DateTimePtr Cronet_Metrics_sending_start_get( - const Cronet_MetricsPtr self); -CRONET_EXPORT -Cronet_DateTimePtr Cronet_Metrics_sending_end_get(const Cronet_MetricsPtr self); -CRONET_EXPORT -Cronet_DateTimePtr Cronet_Metrics_push_start_get(const Cronet_MetricsPtr self); -CRONET_EXPORT -Cronet_DateTimePtr Cronet_Metrics_push_end_get(const Cronet_MetricsPtr self); -CRONET_EXPORT -Cronet_DateTimePtr Cronet_Metrics_response_start_get( - const Cronet_MetricsPtr self); -CRONET_EXPORT -Cronet_DateTimePtr Cronet_Metrics_request_end_get(const Cronet_MetricsPtr self); -CRONET_EXPORT -bool Cronet_Metrics_socket_reused_get(const Cronet_MetricsPtr self); -CRONET_EXPORT -int64_t Cronet_Metrics_sent_byte_count_get(const Cronet_MetricsPtr self); -CRONET_EXPORT -int64_t Cronet_Metrics_received_byte_count_get(const Cronet_MetricsPtr self); +// /////////////////////// +// // Struct Cronet_Metrics. +// CRONET_EXPORT Cronet_MetricsPtr Cronet_Metrics_Create(void); +// CRONET_EXPORT void Cronet_Metrics_Destroy(Cronet_MetricsPtr self); +// // Cronet_Metrics setters. +// CRONET_EXPORT +// void Cronet_Metrics_request_start_set(Cronet_MetricsPtr self, +// const Cronet_DateTimePtr request_start); +// // Move data from |request_start|. The caller retains ownership of +// // |request_start| and must destroy it. +// void Cronet_Metrics_request_start_move(Cronet_MetricsPtr self, +// Cronet_DateTimePtr request_start); +// CRONET_EXPORT +// void Cronet_Metrics_dns_start_set(Cronet_MetricsPtr self, +// const Cronet_DateTimePtr dns_start); +// // Move data from |dns_start|. The caller retains ownership of |dns_start| and +// // must destroy it. +// void Cronet_Metrics_dns_start_move(Cronet_MetricsPtr self, +// Cronet_DateTimePtr dns_start); +// CRONET_EXPORT +// void Cronet_Metrics_dns_end_set(Cronet_MetricsPtr self, +// const Cronet_DateTimePtr dns_end); +// // Move data from |dns_end|. The caller retains ownership of |dns_end| and must +// // destroy it. +// void Cronet_Metrics_dns_end_move(Cronet_MetricsPtr self, +// Cronet_DateTimePtr dns_end); +// CRONET_EXPORT +// void Cronet_Metrics_connect_start_set(Cronet_MetricsPtr self, +// const Cronet_DateTimePtr connect_start); +// // Move data from |connect_start|. The caller retains ownership of +// // |connect_start| and must destroy it. +// void Cronet_Metrics_connect_start_move(Cronet_MetricsPtr self, +// Cronet_DateTimePtr connect_start); +// CRONET_EXPORT +// void Cronet_Metrics_connect_end_set(Cronet_MetricsPtr self, +// const Cronet_DateTimePtr connect_end); +// // Move data from |connect_end|. The caller retains ownership of |connect_end| +// // and must destroy it. +// void Cronet_Metrics_connect_end_move(Cronet_MetricsPtr self, +// Cronet_DateTimePtr connect_end); +// CRONET_EXPORT +// void Cronet_Metrics_ssl_start_set(Cronet_MetricsPtr self, +// const Cronet_DateTimePtr ssl_start); +// // Move data from |ssl_start|. The caller retains ownership of |ssl_start| and +// // must destroy it. +// void Cronet_Metrics_ssl_start_move(Cronet_MetricsPtr self, +// Cronet_DateTimePtr ssl_start); +// CRONET_EXPORT +// void Cronet_Metrics_ssl_end_set(Cronet_MetricsPtr self, +// const Cronet_DateTimePtr ssl_end); +// // Move data from |ssl_end|. The caller retains ownership of |ssl_end| and must +// // destroy it. +// void Cronet_Metrics_ssl_end_move(Cronet_MetricsPtr self, +// Cronet_DateTimePtr ssl_end); +// CRONET_EXPORT +// void Cronet_Metrics_sending_start_set(Cronet_MetricsPtr self, +// const Cronet_DateTimePtr sending_start); +// // Move data from |sending_start|. The caller retains ownership of +// // |sending_start| and must destroy it. +// void Cronet_Metrics_sending_start_move(Cronet_MetricsPtr self, +// Cronet_DateTimePtr sending_start); +// CRONET_EXPORT +// void Cronet_Metrics_sending_end_set(Cronet_MetricsPtr self, +// const Cronet_DateTimePtr sending_end); +// // Move data from |sending_end|. The caller retains ownership of |sending_end| +// // and must destroy it. +// void Cronet_Metrics_sending_end_move(Cronet_MetricsPtr self, +// Cronet_DateTimePtr sending_end); +// CRONET_EXPORT +// void Cronet_Metrics_push_start_set(Cronet_MetricsPtr self, +// const Cronet_DateTimePtr push_start); +// // Move data from |push_start|. The caller retains ownership of |push_start| and +// // must destroy it. +// void Cronet_Metrics_push_start_move(Cronet_MetricsPtr self, +// Cronet_DateTimePtr push_start); +// CRONET_EXPORT +// void Cronet_Metrics_push_end_set(Cronet_MetricsPtr self, +// const Cronet_DateTimePtr push_end); +// // Move data from |push_end|. The caller retains ownership of |push_end| and +// // must destroy it. +// void Cronet_Metrics_push_end_move(Cronet_MetricsPtr self, +// Cronet_DateTimePtr push_end); +// CRONET_EXPORT +// void Cronet_Metrics_response_start_set(Cronet_MetricsPtr self, +// const Cronet_DateTimePtr response_start); +// // Move data from |response_start|. The caller retains ownership of +// // |response_start| and must destroy it. +// void Cronet_Metrics_response_start_move(Cronet_MetricsPtr self, +// Cronet_DateTimePtr response_start); +// CRONET_EXPORT +// void Cronet_Metrics_request_end_set(Cronet_MetricsPtr self, +// const Cronet_DateTimePtr request_end); +// // Move data from |request_end|. The caller retains ownership of |request_end| +// // and must destroy it. +// void Cronet_Metrics_request_end_move(Cronet_MetricsPtr self, +// Cronet_DateTimePtr request_end); +// CRONET_EXPORT +// void Cronet_Metrics_socket_reused_set(Cronet_MetricsPtr self, +// const bool socket_reused); +// CRONET_EXPORT +// void Cronet_Metrics_sent_byte_count_set(Cronet_MetricsPtr self, +// const int64_t sent_byte_count); +// CRONET_EXPORT +// void Cronet_Metrics_received_byte_count_set(Cronet_MetricsPtr self, +// const int64_t received_byte_count); +// // Cronet_Metrics getters. +// CRONET_EXPORT +// Cronet_DateTimePtr Cronet_Metrics_request_start_get( +// const Cronet_MetricsPtr self); +// CRONET_EXPORT +// Cronet_DateTimePtr Cronet_Metrics_dns_start_get(const Cronet_MetricsPtr self); +// CRONET_EXPORT +// Cronet_DateTimePtr Cronet_Metrics_dns_end_get(const Cronet_MetricsPtr self); +// CRONET_EXPORT +// Cronet_DateTimePtr Cronet_Metrics_connect_start_get( +// const Cronet_MetricsPtr self); +// CRONET_EXPORT +// Cronet_DateTimePtr Cronet_Metrics_connect_end_get(const Cronet_MetricsPtr self); +// CRONET_EXPORT +// Cronet_DateTimePtr Cronet_Metrics_ssl_start_get(const Cronet_MetricsPtr self); +// CRONET_EXPORT +// Cronet_DateTimePtr Cronet_Metrics_ssl_end_get(const Cronet_MetricsPtr self); +// CRONET_EXPORT +// Cronet_DateTimePtr Cronet_Metrics_sending_start_get( +// const Cronet_MetricsPtr self); +// CRONET_EXPORT +// Cronet_DateTimePtr Cronet_Metrics_sending_end_get(const Cronet_MetricsPtr self); +// CRONET_EXPORT +// Cronet_DateTimePtr Cronet_Metrics_push_start_get(const Cronet_MetricsPtr self); +// CRONET_EXPORT +// Cronet_DateTimePtr Cronet_Metrics_push_end_get(const Cronet_MetricsPtr self); +// CRONET_EXPORT +// Cronet_DateTimePtr Cronet_Metrics_response_start_get( +// const Cronet_MetricsPtr self); +// CRONET_EXPORT +// Cronet_DateTimePtr Cronet_Metrics_request_end_get(const Cronet_MetricsPtr self); +// CRONET_EXPORT +// bool Cronet_Metrics_socket_reused_get(const Cronet_MetricsPtr self); +// CRONET_EXPORT +// int64_t Cronet_Metrics_sent_byte_count_get(const Cronet_MetricsPtr self); +// CRONET_EXPORT +// int64_t Cronet_Metrics_received_byte_count_get(const Cronet_MetricsPtr self); -/////////////////////// -// Struct Cronet_RequestFinishedInfo. -CRONET_EXPORT Cronet_RequestFinishedInfoPtr -Cronet_RequestFinishedInfo_Create(void); -CRONET_EXPORT void Cronet_RequestFinishedInfo_Destroy( - Cronet_RequestFinishedInfoPtr self); -// Cronet_RequestFinishedInfo setters. -CRONET_EXPORT -void Cronet_RequestFinishedInfo_metrics_set(Cronet_RequestFinishedInfoPtr self, - const Cronet_MetricsPtr metrics); -// Move data from |metrics|. The caller retains ownership of |metrics| and must -// destroy it. -void Cronet_RequestFinishedInfo_metrics_move(Cronet_RequestFinishedInfoPtr self, - Cronet_MetricsPtr metrics); -CRONET_EXPORT -void Cronet_RequestFinishedInfo_annotations_add( - Cronet_RequestFinishedInfoPtr self, - const Cronet_RawDataPtr element); -CRONET_EXPORT -void Cronet_RequestFinishedInfo_finished_reason_set( - Cronet_RequestFinishedInfoPtr self, - const Cronet_RequestFinishedInfo_FINISHED_REASON finished_reason); -// Cronet_RequestFinishedInfo getters. -CRONET_EXPORT -Cronet_MetricsPtr Cronet_RequestFinishedInfo_metrics_get( - const Cronet_RequestFinishedInfoPtr self); -CRONET_EXPORT -uint32_t Cronet_RequestFinishedInfo_annotations_size( - const Cronet_RequestFinishedInfoPtr self); -CRONET_EXPORT -Cronet_RawDataPtr Cronet_RequestFinishedInfo_annotations_at( - const Cronet_RequestFinishedInfoPtr self, - uint32_t index); -CRONET_EXPORT -void Cronet_RequestFinishedInfo_annotations_clear( - Cronet_RequestFinishedInfoPtr self); -CRONET_EXPORT -Cronet_RequestFinishedInfo_FINISHED_REASON -Cronet_RequestFinishedInfo_finished_reason_get( - const Cronet_RequestFinishedInfoPtr self); +// /////////////////////// +// // Struct Cronet_RequestFinishedInfo. +// CRONET_EXPORT Cronet_RequestFinishedInfoPtr +// Cronet_RequestFinishedInfo_Create(void); +// CRONET_EXPORT void Cronet_RequestFinishedInfo_Destroy( +// Cronet_RequestFinishedInfoPtr self); +// // Cronet_RequestFinishedInfo setters. +// CRONET_EXPORT +// void Cronet_RequestFinishedInfo_metrics_set(Cronet_RequestFinishedInfoPtr self, +// const Cronet_MetricsPtr metrics); +// // Move data from |metrics|. The caller retains ownership of |metrics| and must +// // destroy it. +// void Cronet_RequestFinishedInfo_metrics_move(Cronet_RequestFinishedInfoPtr self, +// Cronet_MetricsPtr metrics); +// CRONET_EXPORT +// void Cronet_RequestFinishedInfo_annotations_add( +// Cronet_RequestFinishedInfoPtr self, +// const Cronet_RawDataPtr element); +// CRONET_EXPORT +// void Cronet_RequestFinishedInfo_finished_reason_set( +// Cronet_RequestFinishedInfoPtr self, +// const Cronet_RequestFinishedInfo_FINISHED_REASON finished_reason); +// // Cronet_RequestFinishedInfo getters. +// CRONET_EXPORT +// Cronet_MetricsPtr Cronet_RequestFinishedInfo_metrics_get( +// const Cronet_RequestFinishedInfoPtr self); +// CRONET_EXPORT +// uint32_t Cronet_RequestFinishedInfo_annotations_size( +// const Cronet_RequestFinishedInfoPtr self); +// CRONET_EXPORT +// Cronet_RawDataPtr Cronet_RequestFinishedInfo_annotations_at( +// const Cronet_RequestFinishedInfoPtr self, +// uint32_t index); +// CRONET_EXPORT +// void Cronet_RequestFinishedInfo_annotations_clear( +// Cronet_RequestFinishedInfoPtr self); +// CRONET_EXPORT +// Cronet_RequestFinishedInfo_FINISHED_REASON +// Cronet_RequestFinishedInfo_finished_reason_get( +// const Cronet_RequestFinishedInfoPtr self); #ifdef __cplusplus } diff --git a/lib/src/native/wrapper/CMakeLists.txt b/lib/src/native/wrapper/CMakeLists.txt index 3e70b1f..fc82c67 100644 --- a/lib/src/native/wrapper/CMakeLists.txt +++ b/lib/src/native/wrapper/CMakeLists.txt @@ -27,6 +27,7 @@ target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../include/dart" "${CMAKE_CURRENT_SOURCE_DIR}/../include/dart/runtime" + "${CMAKE_CURRENT_SOURCE_DIR}/../include/cronet" ) diff --git a/lib/src/native/wrapper/build.sh b/lib/src/native/wrapper/build.sh index e61d3ba..c78634d 100644 --- a/lib/src/native/wrapper/build.sh +++ b/lib/src/native/wrapper/build.sh @@ -5,4 +5,4 @@ if [ $# -le 1 ] exit 2 fi cd $1 -g++ -std=c++11 -DCRONET_VERSION=$2 -fPIC -rdynamic -shared -W -o wrapper.so wrapper.cc sample_executor.cc ../include/dart/dart_api_dl.c -ldl -I../include/dart/ -DDART_SHARED_LIB -fpermissive -Wl,-z,origin -Wl,-rpath,'$ORIGIN' -Wl,-rpath,'$ORIGIN/cronet_binaries/linux64/' +g++ -std=c++11 -DCRONET_VERSION=$2 -fPIC -rdynamic -shared -W -o wrapper.so wrapper.cc sample_executor.cc ../include/dart/dart_api_dl.c -ldl -I../include/cronet/ -I../include/dart/ -DDART_SHARED_LIB -fpermissive -Wl,-z,origin -Wl,-rpath,'$ORIGIN' -Wl,-rpath,'$ORIGIN/cronet_binaries/linux64/' diff --git a/lib/src/native/wrapper/wrapper.cc b/lib/src/native/wrapper/wrapper.cc index 79ddd5d..aa9c60d 100644 --- a/lib/src/native/wrapper/wrapper.cc +++ b/lib/src/native/wrapper/wrapper.cc @@ -1,3 +1,7 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + #include "../include/dart/dart_api.h" #include "../include/dart/dart_native_api.h" #include "../include/dart/dart_tools_api.h" diff --git a/lib/src/native/wrapper/wrapper.h b/lib/src/native/wrapper/wrapper.h index 0630d51..a01c713 100644 --- a/lib/src/native/wrapper/wrapper.h +++ b/lib/src/native/wrapper/wrapper.h @@ -1,11 +1,12 @@ -// This is same as cronet's header file except a few changes here and there. +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + #ifndef WRAPPER_H_ #define WRAPPER_H_ -// #include "dart_api.h" -// #include "dart_native_api.h" - #include "../include/dart/dart_api_dl.h" +#include "../include/cronet/cronet.idl_c.h" #include"wrapper_export.h" @@ -39,350 +40,19 @@ extern "C" { #include - -/* Wrapper Helpers */ - - DART_EXPORT void dispatchCallback(char* methodname); - DART_EXPORT intptr_t InitDartApiDL(void* data); DART_EXPORT void unloadCronet(); - - typedef void* ExecutorPtr; DART_EXPORT ExecutorPtr Create_Executor(); DART_EXPORT void Destroy_Executor(ExecutorPtr executor); -/* typedefs, enums & struct declaration from cronet. Derived from cronet.idl_c.h */ - -typedef const char* Cronet_String; -typedef void* Cronet_RawDataPtr; -typedef void* Cronet_ClientContext; - -// Forward declare interfaces. -typedef struct Cronet_Buffer Cronet_Buffer; -typedef struct Cronet_Buffer* Cronet_BufferPtr; -typedef struct Cronet_BufferCallback Cronet_BufferCallback; -typedef struct Cronet_BufferCallback* Cronet_BufferCallbackPtr; -typedef struct Cronet_Runnable Cronet_Runnable; -typedef struct Cronet_Runnable* Cronet_RunnablePtr; -typedef struct Cronet_Executor Cronet_Executor; -typedef struct Cronet_Executor* Cronet_ExecutorPtr; -typedef struct Cronet_Engine Cronet_Engine; -typedef struct Cronet_Engine* Cronet_EnginePtr; -typedef struct Cronet_UrlRequestStatusListener Cronet_UrlRequestStatusListener; -typedef struct Cronet_UrlRequestStatusListener* - Cronet_UrlRequestStatusListenerPtr; -typedef struct Cronet_UrlRequestCallback Cronet_UrlRequestCallback; -typedef struct Cronet_UrlRequestCallback* Cronet_UrlRequestCallbackPtr; -typedef struct Cronet_UploadDataSink Cronet_UploadDataSink; -typedef struct Cronet_UploadDataSink* Cronet_UploadDataSinkPtr; -typedef struct Cronet_UploadDataProvider Cronet_UploadDataProvider; -typedef struct Cronet_UploadDataProvider* Cronet_UploadDataProviderPtr; -typedef struct Cronet_UrlRequest Cronet_UrlRequest; -typedef struct Cronet_UrlRequest* Cronet_UrlRequestPtr; -typedef struct Cronet_RequestFinishedInfoListener - Cronet_RequestFinishedInfoListener; -typedef struct Cronet_RequestFinishedInfoListener* - Cronet_RequestFinishedInfoListenerPtr; - -// Forward declare structs. -typedef struct Cronet_Error Cronet_Error; -typedef struct Cronet_Error* Cronet_ErrorPtr; -typedef struct Cronet_QuicHint Cronet_QuicHint; -typedef struct Cronet_QuicHint* Cronet_QuicHintPtr; -typedef struct Cronet_PublicKeyPins Cronet_PublicKeyPins; -typedef struct Cronet_PublicKeyPins* Cronet_PublicKeyPinsPtr; -typedef struct Cronet_EngineParams Cronet_EngineParams; -typedef struct Cronet_EngineParams* Cronet_EngineParamsPtr; -typedef struct Cronet_HttpHeader Cronet_HttpHeader; -typedef struct Cronet_HttpHeader* Cronet_HttpHeaderPtr; -typedef struct Cronet_UrlResponseInfo Cronet_UrlResponseInfo; -typedef struct Cronet_UrlResponseInfo* Cronet_UrlResponseInfoPtr; -typedef struct Cronet_UrlRequestParams Cronet_UrlRequestParams; -typedef struct Cronet_UrlRequestParams* Cronet_UrlRequestParamsPtr; -typedef struct Cronet_DateTime Cronet_DateTime; -typedef struct Cronet_DateTime* Cronet_DateTimePtr; -typedef struct Cronet_Metrics Cronet_Metrics; -typedef struct Cronet_Metrics* Cronet_MetricsPtr; -typedef struct Cronet_RequestFinishedInfo Cronet_RequestFinishedInfo; -typedef struct Cronet_RequestFinishedInfo* Cronet_RequestFinishedInfoPtr; - -// Declare enums -typedef enum Cronet_RESULT { - Cronet_RESULT_SUCCESS = 0, - Cronet_RESULT_ILLEGAL_ARGUMENT = -100, - Cronet_RESULT_ILLEGAL_ARGUMENT_STORAGE_PATH_MUST_EXIST = -101, - Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_PIN = -102, - Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HOSTNAME = -103, - Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HTTP_METHOD = -104, - Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HTTP_HEADER = -105, - Cronet_RESULT_ILLEGAL_STATE = -200, - Cronet_RESULT_ILLEGAL_STATE_STORAGE_PATH_IN_USE = -201, - Cronet_RESULT_ILLEGAL_STATE_CANNOT_SHUTDOWN_ENGINE_FROM_NETWORK_THREAD = -202, - Cronet_RESULT_ILLEGAL_STATE_ENGINE_ALREADY_STARTED = -203, - Cronet_RESULT_ILLEGAL_STATE_REQUEST_ALREADY_STARTED = -204, - Cronet_RESULT_ILLEGAL_STATE_REQUEST_NOT_INITIALIZED = -205, - Cronet_RESULT_ILLEGAL_STATE_REQUEST_ALREADY_INITIALIZED = -206, - Cronet_RESULT_ILLEGAL_STATE_REQUEST_NOT_STARTED = -207, - Cronet_RESULT_ILLEGAL_STATE_UNEXPECTED_REDIRECT = -208, - Cronet_RESULT_ILLEGAL_STATE_UNEXPECTED_READ = -209, - Cronet_RESULT_ILLEGAL_STATE_READ_FAILED = -210, - Cronet_RESULT_NULL_POINTER = -300, - Cronet_RESULT_NULL_POINTER_HOSTNAME = -301, - Cronet_RESULT_NULL_POINTER_SHA256_PINS = -302, - Cronet_RESULT_NULL_POINTER_EXPIRATION_DATE = -303, - Cronet_RESULT_NULL_POINTER_ENGINE = -304, - Cronet_RESULT_NULL_POINTER_URL = -305, - Cronet_RESULT_NULL_POINTER_CALLBACK = -306, - Cronet_RESULT_NULL_POINTER_EXECUTOR = -307, - Cronet_RESULT_NULL_POINTER_METHOD = -308, - Cronet_RESULT_NULL_POINTER_HEADER_NAME = -309, - Cronet_RESULT_NULL_POINTER_HEADER_VALUE = -310, - Cronet_RESULT_NULL_POINTER_PARAMS = -311, - Cronet_RESULT_NULL_POINTER_REQUEST_FINISHED_INFO_LISTENER_EXECUTOR = -312, -} Cronet_RESULT; - -typedef enum Cronet_Error_ERROR_CODE { - Cronet_Error_ERROR_CODE_ERROR_CALLBACK = 0, - Cronet_Error_ERROR_CODE_ERROR_HOSTNAME_NOT_RESOLVED = 1, - Cronet_Error_ERROR_CODE_ERROR_INTERNET_DISCONNECTED = 2, - Cronet_Error_ERROR_CODE_ERROR_NETWORK_CHANGED = 3, - Cronet_Error_ERROR_CODE_ERROR_TIMED_OUT = 4, - Cronet_Error_ERROR_CODE_ERROR_CONNECTION_CLOSED = 5, - Cronet_Error_ERROR_CODE_ERROR_CONNECTION_TIMED_OUT = 6, - Cronet_Error_ERROR_CODE_ERROR_CONNECTION_REFUSED = 7, - Cronet_Error_ERROR_CODE_ERROR_CONNECTION_RESET = 8, - Cronet_Error_ERROR_CODE_ERROR_ADDRESS_UNREACHABLE = 9, - Cronet_Error_ERROR_CODE_ERROR_QUIC_PROTOCOL_FAILED = 10, - Cronet_Error_ERROR_CODE_ERROR_OTHER = 11, -} Cronet_Error_ERROR_CODE; - -typedef enum Cronet_EngineParams_HTTP_CACHE_MODE { - Cronet_EngineParams_HTTP_CACHE_MODE_DISABLED = 0, - Cronet_EngineParams_HTTP_CACHE_MODE_IN_MEMORY = 1, - Cronet_EngineParams_HTTP_CACHE_MODE_DISK_NO_HTTP = 2, - Cronet_EngineParams_HTTP_CACHE_MODE_DISK = 3, -} Cronet_EngineParams_HTTP_CACHE_MODE; - -typedef enum Cronet_UrlRequestParams_REQUEST_PRIORITY { - Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_IDLE = 0, - Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_LOWEST = 1, - Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_LOW = 2, - Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_MEDIUM = 3, - Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_HIGHEST = 4, -} Cronet_UrlRequestParams_REQUEST_PRIORITY; - -typedef enum Cronet_UrlRequestParams_IDEMPOTENCY { - Cronet_UrlRequestParams_IDEMPOTENCY_DEFAULT_IDEMPOTENCY = 0, - Cronet_UrlRequestParams_IDEMPOTENCY_IDEMPOTENT = 1, - Cronet_UrlRequestParams_IDEMPOTENCY_NOT_IDEMPOTENT = 2, -} Cronet_UrlRequestParams_IDEMPOTENCY; - -typedef enum Cronet_RequestFinishedInfo_FINISHED_REASON { - Cronet_RequestFinishedInfo_FINISHED_REASON_SUCCEEDED = 0, - Cronet_RequestFinishedInfo_FINISHED_REASON_FAILED = 1, - Cronet_RequestFinishedInfo_FINISHED_REASON_CANCELED = 2, -} Cronet_RequestFinishedInfo_FINISHED_REASON; - -typedef enum Cronet_UrlRequestStatusListener_Status { - Cronet_UrlRequestStatusListener_Status_INVALID = -1, - Cronet_UrlRequestStatusListener_Status_IDLE = 0, - Cronet_UrlRequestStatusListener_Status_WAITING_FOR_STALLED_SOCKET_POOL = 1, - Cronet_UrlRequestStatusListener_Status_WAITING_FOR_AVAILABLE_SOCKET = 2, - Cronet_UrlRequestStatusListener_Status_WAITING_FOR_DELEGATE = 3, - Cronet_UrlRequestStatusListener_Status_WAITING_FOR_CACHE = 4, - Cronet_UrlRequestStatusListener_Status_DOWNLOADING_PAC_FILE = 5, - Cronet_UrlRequestStatusListener_Status_RESOLVING_PROXY_FOR_URL = 6, - Cronet_UrlRequestStatusListener_Status_RESOLVING_HOST_IN_PAC_FILE = 7, - Cronet_UrlRequestStatusListener_Status_ESTABLISHING_PROXY_TUNNEL = 8, - Cronet_UrlRequestStatusListener_Status_RESOLVING_HOST = 9, - Cronet_UrlRequestStatusListener_Status_CONNECTING = 10, - Cronet_UrlRequestStatusListener_Status_SSL_HANDSHAKE = 11, - Cronet_UrlRequestStatusListener_Status_SENDING_REQUEST = 12, - Cronet_UrlRequestStatusListener_Status_WAITING_FOR_RESPONSE = 13, - Cronet_UrlRequestStatusListener_Status_READING_RESPONSE = 14, -} Cronet_UrlRequestStatusListener_Status; - - DART_EXPORT void registerHttpClient(Dart_Handle h, Cronet_EnginePtr ce); DART_EXPORT void registerCallbackHandler(Dart_Port nativePort, Cronet_UrlRequestPtr rp); DART_EXPORT void removeRequest(Cronet_UrlRequestPtr rp); -/* function signatures derived from cronet.idl_c.h. -NOTE: Some are modified if required for wrapping */ - - -/////////////////////// -// Struct Cronet_QuicHint. -CRONET_EXPORT Cronet_QuicHintPtr Cronet_QuicHint_Create(void); -CRONET_EXPORT void Cronet_QuicHint_Destroy(Cronet_QuicHintPtr self); -// Cronet_QuicHint setters. -CRONET_EXPORT -void Cronet_QuicHint_host_set(Cronet_QuicHintPtr self, - const Cronet_String host); -CRONET_EXPORT -void Cronet_QuicHint_port_set(Cronet_QuicHintPtr self, const int32_t port); -CRONET_EXPORT -void Cronet_QuicHint_alternate_port_set(Cronet_QuicHintPtr self, - const int32_t alternate_port); - - - -CRONET_EXPORT Cronet_EnginePtr Cronet_Engine_Create(void); - -CRONET_EXPORT Cronet_String Cronet_Engine_GetVersionString(Cronet_EnginePtr self); - -CRONET_EXPORT Cronet_EngineParamsPtr Cronet_EngineParams_Create(void); -CRONET_EXPORT void Cronet_EngineParams_Destroy(Cronet_EngineParamsPtr self); - -CRONET_EXPORT -void Cronet_EngineParams_user_agent_set(Cronet_EngineParamsPtr self, - const Cronet_String user_agent); - -CRONET_EXPORT -void Cronet_EngineParams_enable_quic_set(Cronet_EngineParamsPtr self, - const bool enable_quic); - -CRONET_EXPORT -void Cronet_EngineParams_quic_hints_add(Cronet_EngineParamsPtr self, - const Cronet_QuicHintPtr element); - -CRONET_EXPORT -void Cronet_EngineParams_accept_language_set( - Cronet_EngineParamsPtr self, - const Cronet_String accept_language); - -CRONET_EXPORT -void Cronet_EngineParams_storage_path_set(Cronet_EngineParamsPtr self, - const Cronet_String storage_path); - -CRONET_EXPORT -void Cronet_EngineParams_enable_http2_set(Cronet_EngineParamsPtr self, - const bool enable_http2); -CRONET_EXPORT -void Cronet_EngineParams_enable_brotli_set(Cronet_EngineParamsPtr self, - const bool enable_brotli); -CRONET_EXPORT -void Cronet_EngineParams_http_cache_mode_set( - Cronet_EngineParamsPtr self, - const Cronet_EngineParams_HTTP_CACHE_MODE http_cache_mode); -CRONET_EXPORT -void Cronet_EngineParams_http_cache_max_size_set( - Cronet_EngineParamsPtr self, - const int64_t http_cache_max_size); - -CRONET_EXPORT -Cronet_RESULT Cronet_Engine_StartWithParams(Cronet_EnginePtr self, - Cronet_EngineParamsPtr params); -CRONET_EXPORT -Cronet_RESULT Cronet_Engine_Shutdown(Cronet_EnginePtr self); - -typedef void (*Cronet_UrlRequestCallback_OnRedirectReceivedFunc)( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info, - Cronet_String new_location_url); -typedef void (*Cronet_UrlRequestCallback_OnResponseStartedFunc)( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info); -typedef void (*Cronet_UrlRequestCallback_OnReadCompletedFunc)( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info, - Cronet_BufferPtr buffer, - uint64_t bytes_read); -typedef void (*Cronet_UrlRequestCallback_OnSucceededFunc)( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info); -typedef void (*Cronet_UrlRequestCallback_OnFailedFunc)( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info, - Cronet_ErrorPtr error); -typedef void (*Cronet_UrlRequestCallback_OnCanceledFunc)( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info); - - -// Create an instance of Cronet_UrlRequest. -CRONET_EXPORT Cronet_UrlRequestPtr Cronet_UrlRequest_Create(void); -// Destroy an instance of Cronet_UrlRequest. -CRONET_EXPORT void Cronet_UrlRequest_Destroy(Cronet_UrlRequestPtr self); - -CRONET_EXPORT void Cronet_UrlRequest_Cancel(Cronet_UrlRequestPtr self); -// Set and get app-specific Cronet_ClientContext. -CRONET_EXPORT void Cronet_UrlRequest_SetClientContext( - Cronet_UrlRequestPtr self, - Cronet_ClientContext client_context); -CRONET_EXPORT Cronet_ClientContext -Cronet_UrlRequest_GetClientContext(Cronet_UrlRequestPtr self); - -// Struct Cronet_UrlRequestParams. -CRONET_EXPORT Cronet_UrlRequestParamsPtr Cronet_UrlRequestParams_Create(void); -// Cronet_UrlRequestParams setters. -CRONET_EXPORT -void Cronet_UrlRequestParams_http_method_set(Cronet_UrlRequestParamsPtr self, - const Cronet_String http_method); - -CRONET_EXPORT -void Cronet_UrlRequestParams_request_headers_add( - Cronet_UrlRequestParamsPtr self, - const Cronet_HttpHeaderPtr element); - -CRONET_EXPORT -Cronet_RESULT Cronet_UrlRequest_Start(Cronet_UrlRequestPtr self); -CRONET_EXPORT -Cronet_RESULT Cronet_UrlRequest_FollowRedirect(Cronet_UrlRequestPtr self); -CRONET_EXPORT -Cronet_RESULT Cronet_UrlRequest_Read(Cronet_UrlRequestPtr self, - Cronet_BufferPtr buffer); - DART_EXPORT Cronet_RESULT Cronet_UrlRequest_Init(Cronet_UrlRequestPtr self, Cronet_EnginePtr engine, Cronet_String url, Cronet_UrlRequestParamsPtr params, ExecutorPtr _executor); - -CRONET_EXPORT Cronet_HttpHeaderPtr Cronet_HttpHeader_Create(void); -CRONET_EXPORT void Cronet_HttpHeader_Destroy(Cronet_HttpHeaderPtr self); -// Cronet_HttpHeader setters. -CRONET_EXPORT -void Cronet_HttpHeader_name_set(Cronet_HttpHeaderPtr self, - const Cronet_String name); -CRONET_EXPORT -void Cronet_HttpHeader_value_set(Cronet_HttpHeaderPtr self, - const Cronet_String value); - -CRONET_EXPORT -int32_t Cronet_UrlResponseInfo_http_status_code_get( - const Cronet_UrlResponseInfoPtr self); -CRONET_EXPORT -Cronet_String Cronet_UrlResponseInfo_http_status_text_get( - const Cronet_UrlResponseInfoPtr self); - -// Create an instance of Cronet_Buffer. -// CRONET_EXPORT Cronet_BufferPtr Cronet_Buffer_Create(void); - -// Destroy an instance of Cronet_Buffer. -// CRONET_EXPORT void Cronet_Buffer_Destroy(Cronet_BufferPtr self); - -// CRONET_EXPORT void Cronet_Buffer_InitWithAlloc(Cronet_BufferPtr self, uint64_t size); - -CRONET_EXPORT uint64_t Cronet_Buffer_GetSize(Cronet_BufferPtr self); -CRONET_EXPORT Cronet_RawDataPtr Cronet_Buffer_GetData(Cronet_BufferPtr self); - -CRONET_EXPORT -bool Cronet_Engine_StartNetLogToFile(Cronet_EnginePtr self, - Cronet_String file_name, - bool log_all); -CRONET_EXPORT -void Cronet_Engine_StopNetLog(Cronet_EnginePtr self); - -// CRONET_EXPORT -// Cronet_String Cronet_Error_message_get(const Cronet_ErrorPtr self); - - /* executor only */ typedef void (*Cronet_Executor_ExecuteFunc)(Cronet_ExecutorPtr self, Cronet_RunnablePtr command); @@ -392,4 +62,4 @@ typedef void (*Cronet_Executor_ExecuteFunc)(Cronet_ExecutorPtr self, Cronet_Runn } #endif -#endif // WRAPPER_H_ \ No newline at end of file +#endif // WRAPPER_H_ diff --git a/lib/src/native/wrapper/wrapper_export.h b/lib/src/native/wrapper/wrapper_export.h index 72313d3..3b8686a 100644 --- a/lib/src/native/wrapper/wrapper_export.h +++ b/lib/src/native/wrapper/wrapper_export.h @@ -1,3 +1,7 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + #ifndef WRAPPER_EXPORT_H_ #define WRAPPER_EXPORT_H_ @@ -7,4 +11,4 @@ #define CRONET_EXPORT __attribute__((visibility("default"))) #endif -#endif // WRAPPER_EXPORT_H_ \ No newline at end of file +#endif // WRAPPER_EXPORT_H_ diff --git a/pubspec.yaml b/pubspec.yaml index 36758aa..95d1bf2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -50,14 +50,18 @@ ffigen: headers: entry-points: - 'lib/src/native/wrapper/wrapper.h' + - 'lib/src/native/include/cronet/cronet.idl_c.h' include-directives: - 'lib/src/native/wrapper/wrapper.h' + - 'lib/src/native/include/cronet/cronet.idl_c.h' - 'dart_api.h' - 'dart_native_api.h' - 'dart_api_dl.h' - 'lib/src/native/wrapper/wrapper_export.h' compiler-opts: - - '-Ilib/src/native/include/dart/ -DDART_SHARED_LIB' + - '-Ilib/src/native/include/dart/' + - '-Ilib/src/native/include/cronet/' + - '-DDART_SHARED_LIB' # To add assets to your plugin package, add an assets section, like this: # assets: # - images/a_dot_burr.jpeg From e3ca8a869c2243f18f3901dbc0abb703317b1e42 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Sat, 12 Jun 2021 20:05:47 +0530 Subject: [PATCH 03/42] initial implementation: essential APIs of http client, request & response Partial migration from: unsuitable001/dart_cronet_sample to google/cronet.dart --- .github/workflows/test-package.yml | 3 + AUTHORS | 2 + README.md | 82 ++++++ bin/cronet.dart | 14 + example_dart/analysis_options.yaml | 0 example_dart/bin/example_dart.dart | 43 +++ example_dart/pubspec.yaml | 12 + lib/cronet.dart | 6 +- lib/src/dylib_handler.dart | 93 ++++++ lib/src/{my_sum.dart => enums.dart} | 3 +- lib/src/exceptions.dart | 43 +++ lib/src/find_resource.dart | 61 ++++ lib/src/http_callback_handler.dart | 305 ++++++++++++++++++++ lib/src/http_client.dart | 278 ++++++++++++++++++ lib/src/http_client_request.dart | 263 +++++++++++++++++ lib/src/http_client_response.dart | 25 ++ lib/src/native/wrapper/BUILD.md | 34 +++ lib/src/prepare_cronet.dart | 84 ++++++ test/my_test.dart => lib/src/quic_hint.dart | 12 +- test/cronet_test.dart | 39 +++ test/http_client_close_test.dart | 48 +++ test/http_request_exceptions_test.dart | 44 +++ test/http_responses_exceptions_test.dart | 67 +++++ test/http_responses_new_api_test.dart | 43 +++ test/http_responses_test.dart | 71 +++++ 25 files changed, 1665 insertions(+), 10 deletions(-) create mode 100644 bin/cronet.dart create mode 100644 example_dart/analysis_options.yaml create mode 100644 example_dart/bin/example_dart.dart create mode 100644 example_dart/pubspec.yaml create mode 100644 lib/src/dylib_handler.dart rename lib/src/{my_sum.dart => enums.dart} (74%) create mode 100644 lib/src/exceptions.dart create mode 100644 lib/src/find_resource.dart create mode 100644 lib/src/http_callback_handler.dart create mode 100644 lib/src/http_client.dart create mode 100644 lib/src/http_client_request.dart create mode 100644 lib/src/http_client_response.dart create mode 100644 lib/src/native/wrapper/BUILD.md create mode 100644 lib/src/prepare_cronet.dart rename test/my_test.dart => lib/src/quic_hint.dart (55%) create mode 100644 test/cronet_test.dart create mode 100644 test/http_client_close_test.dart create mode 100644 test/http_request_exceptions_test.dart create mode 100644 test/http_responses_exceptions_test.dart create mode 100644 test/http_responses_new_api_test.dart create mode 100644 test/http_responses_test.dart diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index e69785c..7f07cc7 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -60,6 +60,9 @@ jobs: - id: install name: Install dependencies run: dart pub get + - id: get_binaries + name: Download Cronet Binaries + run: pub run cronet linux64 - name: Run VM tests run: dart test --platform vm if: always() && steps.install.outcome == 'success' diff --git a/AUTHORS b/AUTHORS index 846e4a1..d84d35c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -4,3 +4,5 @@ # Name/Organization Google LLC + +Soumyadip Mondal diff --git a/README.md b/README.md index d67cb00..2113853 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,85 @@ This package binds to Cronet's [native API](https://chromium.googlesource.com/chromium/src/+/master/components/cronet/native/test_instructions.md) to expose them in Dart. This is a [GSoC 2021 project](https://summerofcode.withgoogle.com/projects/#4757095741652992). + + + +## Usage + +1. Add this to `pubspec.yaml` + +```pubspec +dependencies: + cronet: + git: + url: https://github.com/google/cronet.dart.git + +``` + +2. Run this from the `root` of your project + +Desktop Platforms + +```bash +pub get +pub run cronet +``` +Supported platforms: `linux64` and `windows64` + +3. Import + +```dart +import 'package:cronet/cronet.dart'; +``` + +**Internet connection is required to download cronet binaries** + + +## Example + +```dart + final client = HttpClient(); + client + .getUrl(Uri.parse('http://info.cern.ch/')) + .then((HttpClientRequest request) { + return request.close(); + }).then((HttpClientResponse response) { + response.transform(utf8.decoder).listen((contents) { + print(contents); + }, + onDone: () => print( + 'Done!')); + }); +``` + +### Alternate API + +```dart + final client = HttpClient(); + client + .getUrl(Uri.parse('http://info.cern.ch/')) + .then((HttpClientRequest request) { + request.registerCallbacks((data, bytesRead, responseCode, next) { + print(utf8.decoder.convert(data)); + print('Status: $responseCode'); + next(); + }, + onSuccess: (responseCode) => + print('Done with status: $responseCode')).catchError( + (e) => print(e)); + }); +``` + + +## Run Example + +```bash +cd example_dart +pub run cronet +dart run +``` + +replace `` with `linux64` or `windows64` + +**Wrapper & Cronet binaries build guide**: [BUILD.md](lib/src/native/wrapper/BUILD.md) + diff --git a/bin/cronet.dart b/bin/cronet.dart new file mode 100644 index 0000000..124c6d1 --- /dev/null +++ b/bin/cronet.dart @@ -0,0 +1,14 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:cronet/src/prepare_cronet.dart'; + +Future main(List platforms) async { + for (final platform in platforms) { + if (platform.startsWith('linux')) { + buildWrapper(); + } + await downloadCronetBinaries(platform); + } +} diff --git a/example_dart/analysis_options.yaml b/example_dart/analysis_options.yaml new file mode 100644 index 0000000..e69de29 diff --git a/example_dart/bin/example_dart.dart b/example_dart/bin/example_dart.dart new file mode 100644 index 0000000..4fd2f46 --- /dev/null +++ b/example_dart/bin/example_dart.dart @@ -0,0 +1,43 @@ +import 'dart:convert'; +import 'dart:io'; +import 'package:cronet/cronet.dart'; + +/* Trying to re-impliment: https://chromium.googlesource.com/chromium/src/+/master/components/cronet/native/sample/main.cc */ + +void main(List args) { + final stopwatch = Stopwatch()..start(); + final client = HttpClient(); + for (var i = 0; i < 3; i++) { + // Demo - with concurrent requests + client + .getUrl(Uri.parse('https://postman-echo.com/headers')) + .then((HttpClientRequest request) { + if (i == 2) { + client.close(); // We will shut down the client after 3 connections. + } + return request.close(); + }).then((HttpClientResponse response) { + response.transform(utf8.decoder).listen((contents) { + print(contents); + }, onDone: () { + print('cronet implemenation took: ${stopwatch.elapsedMilliseconds} ms'); + }); + }); + } + + // Alternate API + + final client2 = HttpClient(); + client2 + .getUrl(Uri.parse('http://info.cern.ch/')) + .then((HttpClientRequest request) { + request.registerCallbacks((data, bytesRead, responseCode, next) { + print(utf8.decoder.convert(data)); + print('Status: $responseCode'); + next(); + }, + onSuccess: (responseCode) => + print('Done with status: $responseCode')).catchError( + (Object e) => print(e)); + }); +} diff --git a/example_dart/pubspec.yaml b/example_dart/pubspec.yaml new file mode 100644 index 0000000..6ae5a2c --- /dev/null +++ b/example_dart/pubspec.yaml @@ -0,0 +1,12 @@ +name: example_dart +description: A simple command-line application. +# version: 1.0.0 +# homepage: https://www.example.com + +environment: + sdk: '>=2.10.0 <3.0.0' + +dependencies: + cronet: + path: ../ +# path: ^1.7.0 diff --git a/lib/cronet.dart b/lib/cronet.dart index 6914515..91809c7 100644 --- a/lib/cronet.dart +++ b/lib/cronet.dart @@ -2,4 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -export 'src/my_sum.dart'; +export 'src/http_client.dart'; +export 'src/http_client_request.dart'; +export 'src/quic_hint.dart'; +export 'src/enums.dart'; +export 'src/exceptions.dart'; diff --git a/lib/src/dylib_handler.dart b/lib/src/dylib_handler.dart new file mode 100644 index 0000000..88c662b --- /dev/null +++ b/lib/src/dylib_handler.dart @@ -0,0 +1,93 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:ffi' show DynamicLibrary; +import 'dart:io' show Directory, File, Link, Platform; + +import 'package:path/path.dart'; + +/// Checks if [File]/[Link] exists for an [uri] +bool _doesFileExist(Uri uri) { + return File.fromUri(uri).existsSync() || Link.fromUri(uri).existsSync(); +} + +/// Checks if a dynamic library is located in +/// 1. Present Working Directory +/// 2. Current script's/executable's directory +/// 3. Current script's/executable's directory's parent +/// and returns the absolute path +/// +/// Returns [null] if can't be resolved. +String? _resolveLibUri(String name) { + var libUri = Directory.current.uri.resolve(name); + + // If lib is in Present Working Directory + if (_doesFileExist(libUri)) { + return libUri.toFilePath(windows: Platform.isWindows); + } + + // If lib is in script's directory + libUri = Uri.directory(dirname(Platform.script.path)).resolve(name); + + if (_doesFileExist(libUri)) { + return libUri.toFilePath(windows: Platform.isWindows); + } + + // If lib is in executable's directory + libUri = Uri.directory(dirname(Platform.resolvedExecutable)).resolve(name); + + if (_doesFileExist(libUri)) { + return libUri.toFilePath(windows: Platform.isWindows); + } + + // If lib is in script's directory's parent + + libUri = Uri.directory(dirname(Platform.script.path)).resolve('../$name'); + + if (_doesFileExist(libUri)) { + return libUri.toFilePath(windows: Platform.isWindows); + } + + // If lib is in executable's directory's parent + + libUri = + Uri.directory(dirname(Platform.resolvedExecutable)).resolve('../$name'); + + if (_doesFileExist(libUri)) { + return libUri.toFilePath(windows: Platform.isWindows); + } + + return null; +} + +/// Loads [wrapper] dynamic library depending on the platform. +/// This loaded [wrapper] will then load [cronet] +/// +/// Throws an [ArgumentError] if library can't be loaded. +DynamicLibrary loadWrapper() { + const fileName = 'wrapper'; + var ext = '.so'; + var prefix = ''; + + // When gradle builds the wrapper, it automatically prepends lib. + if (Platform.isAndroid) { + prefix = 'lib'; + } + + if (Platform.isWindows) { + ext = '.dll'; + } else if (Platform.isMacOS) { + ext = '.dylib'; + } + + var wrapperName = prefix + fileName + ext; + + /// [_resolveLibUri()] will try to resolve [wrapper]'s absolute path + /// If it can't find it, try looking at search paths provided by the system + wrapperName = _resolveLibUri(wrapperName) ?? wrapperName; + + return Platform.isIOS + ? DynamicLibrary.process() + : DynamicLibrary.open(wrapperName); +} diff --git a/lib/src/my_sum.dart b/lib/src/enums.dart similarity index 74% rename from lib/src/my_sum.dart rename to lib/src/enums.dart index 9c2486d..1961fb0 100644 --- a/lib/src/my_sum.dart +++ b/lib/src/enums.dart @@ -2,5 +2,4 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -/// Computes the sum of its arguments. -int mySum(int a, int b) => a + b; +enum CacheMode { disabled, inMemory, diskNoHttp, disk } diff --git a/lib/src/exceptions.dart b/lib/src/exceptions.dart new file mode 100644 index 0000000..9244ec3 --- /dev/null +++ b/lib/src/exceptions.dart @@ -0,0 +1,43 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +class LoggingException implements Exception { + const LoggingException(); +} + +class HttpException implements IOException { + final String message; + final Uri? uri; + + const HttpException(this.message, {this.uri}); + + @override + String toString() { + final b = StringBuffer()..write('HttpException: ')..write(message); + final uri = this.uri; + if (uri != null) { + b.write(', uri = $uri'); + } + return b.toString(); + } +} + +class CronetException implements Exception { + final int val; + const CronetException(this.val); + + @override + String toString() { + final b = StringBuffer() + ..write('CronetException: Cronet Result: ') + ..write(val); + return b.toString(); + } +} + +class UrlRequestException extends CronetException { + const UrlRequestException(int val) : super(val); +} diff --git a/lib/src/find_resource.dart b/lib/src/find_resource.dart new file mode 100644 index 0000000..5d88d10 --- /dev/null +++ b/lib/src/find_resource.dart @@ -0,0 +1,61 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Contains code related to asset path resolution only. Not meant to be exposed. +// This code is a modified version from ffigen package's old commit. + +import 'dart:convert'; +import 'dart:io' show File, Directory; + +/// Finds the root [Uri] of our package +Uri? findPackageRoot() { + var root = Directory.current.uri; + do { + // Traverse up till .dart_tool/package_config.json is found + final file = File.fromUri(root.resolve('.dart_tool/package_config.json')); + if (file.existsSync()) { + // get package path from package_config.json + try { + final packageMap = + jsonDecode(file.readAsStringSync()) as Map; + if (packageMap['configVersion'] == 2) { + var packageRootUriString = (packageMap['packages'] as List) + .cast>() + .firstWhere( + (element) => element['name'] == 'cronet')['rootUri'] + as String; + packageRootUriString = packageRootUriString.endsWith('/') + ? packageRootUriString + : '$packageRootUriString/'; + return file.parent.uri.resolve(packageRootUriString); + } + } catch (e, s) { + print(s); + throw Exception("Cannot resolve package:cronet's rootUri"); + } + } + } while (root != (root = root.resolve('..'))); + return null; +} + +/// Gets the [wrapper]'s source code's path +/// Throws [Exception] if not found +String wrapperSourcePath() { + // Finds this package's location + final packagePath = findPackageRoot(); + if (packagePath == null) { + throw Exception("Cannot resolve package:cronet's rootUri"); + } + final wrapperSource = packagePath.resolve('lib/src/native/wrapper'); + if (!Directory.fromUri(wrapperSource).existsSync()) { + throw Exception('Cannot find wrapper source!'); + } + return wrapperSource.toFilePath(); +} + +/// Is cronet binaries are already available in the project +bool isCronetAvailable(String platform) { + final cronetDir = Directory.current.uri.resolve('cronet_binaries/$platform/'); + return Directory.fromUri(cronetDir).existsSync(); +} diff --git a/lib/src/http_callback_handler.dart b/lib/src/http_callback_handler.dart new file mode 100644 index 0000000..edd3e75 --- /dev/null +++ b/lib/src/http_callback_handler.dart @@ -0,0 +1,305 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +part of 'http_client_request.dart'; + +/// Deserializes the message sent by +/// cronet and it's wrapper +class _CallbackRequestMessage { + final String method; + final Uint8List data; + + /// Constructs [method] and [data] from [message] + factory _CallbackRequestMessage.fromCppMessage(List message) { + return _CallbackRequestMessage._( + message[0] as String, message[1] as Uint8List); + } + + _CallbackRequestMessage._(this.method, this.data); + + @override + String toString() => 'CppRequest(method: $method)'; +} + +/// Handles every kind of callbacks that are +/// invoked by messages and data that are sent by +/// [NativePort] from native cronet library. +/// +/// +class _CallbackHandler { + final ReceivePort receivePort; + final Cronet cronet; + final Pointer executor; + + // These are a part of HttpClientRequest Public API + bool followRedirects = true; + int maxRedirects = 5; + + /// Stream controller to allow consumption of data + /// like [HttpClientResponse] + final _controller = StreamController>(); + + Completer? + _callBackCompleter; // if callback based api is used, completes when receiving data is done + + RedirectReceivedCallback? _onRedirectReceived; + ResponseStartedCallback? _onResponseStarted; + ReadDataCallback? _onReadData; + FailedCallabck? _onFailed; + CanceledCallabck? _onCanceled; + SuccessCallabck? _onSuccess; + + /// Registers the [NativePort] to the cronet side. + _CallbackHandler(this.cronet, this.executor, this.receivePort); + + Stream> get stream => _controller.stream; + + /// This sets callbacks that are registered using + /// [HttpClientRequest.registerCallbacks]. + /// + /// If [ReadDataCallback] is provided, the [Stream] returned by [HttpClientResponse.close] will be closed. + Future registerCallbacks(ReadDataCallback onReadData, + [RedirectReceivedCallback? onRedirectReceived, + ResponseStartedCallback? onResponseStarted, + FailedCallabck? onFailed, + CanceledCallabck? onCanceled, + SuccessCallabck? onSuccess]) { + _onRedirectReceived = onRedirectReceived; + _onResponseStarted = onResponseStarted; + _onReadData = onReadData; + _controller.close(); // if callbacks are registered, close the contoller + // responsible the sream for close() method (dart:io style API) + _onFailed = onFailed; + _onCanceled = onCanceled; + _onSuccess = onSuccess; + _callBackCompleter = Completer(); + return _callBackCompleter!.future; + } + + // clean up tasks for a request + // need to call then whenever we are done with the request + // either successfully or unsuccessfully. + + // TODO: Take cleanup client as param. (to be implemented by htto_client) + void cleanUpRequest(Pointer reqPtr) { + receivePort.close(); + cronet.removeRequest(reqPtr); + // cleanUpClient(); + } + + int statusChecker(Pointer respInfoPtr, int lBound, + int uBound, Function callback) { + final respCode = + cronet.Cronet_UrlResponseInfo_http_status_code_get(respInfoPtr); + if (!(respCode >= lBound && respCode <= uBound)) { + // if NOT in range + callback(); + final exception = HttpException( + cronet.Cronet_UrlResponseInfo_http_status_text_get(respInfoPtr) + .cast() + .toDartString()); + + if (_callBackCompleter != null) { + // if callbacks are registered + _callBackCompleter!.completeError(exception); + } else { + _controller.addError(exception); + _controller.close(); + } + } + return respCode; + } + + /// This listens to the messages sent by native cronet library + /// through wrapper via [NativePort]. + /// + /// This also invokes the appropriate callbacks that are registered + /// according to the network events sent from cronet side. + /// + /// This is also reponsible for providing a [Stream] of [int] + /// to create a interface like [HttpClientResponse]. + + // TODO: add Function cleanUpClient when logging and storage api is implemneted + void listen(Pointer reqPtr) { + // registers the listener on the receivePort. + // The message parameter contains both the name of the event and + // the data associated with it. + receivePort.listen((dynamic message) { + final reqMessage = + _CallbackRequestMessage.fromCppMessage(message as List); + Int64List args; + args = reqMessage.data.buffer.asInt64List(); + + switch (reqMessage.method) { + // Invoked when a redirect is received. + // Passes the new location's url and response code as parameter + case 'OnRedirectReceived': + { + log('New Location: ${Pointer.fromAddress(args[0]).cast().toDartString()}'); + final respCode = statusChecker( + Pointer.fromAddress(args[1]).cast(), + 300, + 399, + () => cleanUpRequest( + reqPtr)); // If NOT a 3XX status code, throw Exception + if (followRedirects && maxRedirects > 0) { + final res = cronet.Cronet_UrlRequest_FollowRedirect(reqPtr); + if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { + cleanUpRequest(reqPtr); + throw UrlRequestException(res); + } + maxRedirects--; + } else { + cronet.Cronet_UrlRequest_Cancel(reqPtr); + } + if (_onRedirectReceived != null) { + _onRedirectReceived!( + Pointer.fromAddress(args[0]).cast().toDartString(), + respCode); + } + } + break; + + // When server has sent the initial response + case 'OnResponseStarted': + { + final respCode = statusChecker( + Pointer.fromAddress(args[0]).cast(), + 100, + 299, + () => cleanUpRequest( + reqPtr)); // If NOT a 1XX or 2XX status code, throw Exception + log('Response started'); + if (_onResponseStarted != null) { + _onResponseStarted!(respCode); + } + } + break; + // Read a chunk of data. + // This is where we actually read + // the response from the server. + // + // Data gets added to the stream here. + // ReadDataCallback is invoked here + // with data received, no of bytes read + // and a function which can be called + // to continue reading. + case 'OnReadCompleted': + { + final request = Pointer.fromAddress(args[0]); + final info = Pointer.fromAddress(args[1]); + final buffer = Pointer.fromAddress(args[2]); + final bytesRead = args[3]; + + log('Recieved: $bytesRead'); + final respCode = statusChecker( + info, + 100, + 299, + () => cleanUpRequest( + reqPtr, + )); // If NOT a 1XX or 2XX status code, throw Exception + final data = cronet.Cronet_Buffer_GetData(buffer) + .cast() + .asTypedList(bytesRead); + + // invoke the callback + if (_onReadData != null) { + _onReadData!(data.toList(growable: false), bytesRead, respCode, + () { + final res = cronet.Cronet_UrlRequest_Read(request, buffer); + if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { + cleanUpRequest( + reqPtr, + ); + _callBackCompleter!.completeError(UrlRequestException(res)); + } + }); + } else { + // or, add data to the stream + _controller.sink.add(data.toList(growable: false)); + final res = cronet.Cronet_UrlRequest_Read(request, buffer); + if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { + cleanUpRequest( + reqPtr, + ); + _controller.addError(UrlRequestException(res)); + _controller.close(); + } + } + } + break; + // When there is any network error + // We will shut everything down after this. + case 'OnFailed': + { + final error = + Pointer.fromAddress(args[0]).cast().toDartString(); + cleanUpRequest( + reqPtr, + ); + if (_onFailed != null) { + _onFailed!(HttpException(error)); + _callBackCompleter!.complete(); + } + if (_onReadData == null) { + // if callbacks are not registered, stream isn't closed before. So, close here. + _controller.addError(HttpException(error)); + _controller.close(); + } else { + // if callback is registed but onFailed callback is not + _callBackCompleter!.completeError(HttpException(error)); + } + } + break; + // when the request is cancelled + // We will shut everything down after this. + case 'OnCanceled': + { + cleanUpRequest( + reqPtr, + ); + if (_onCanceled != null) { + _onCanceled!(); + } + if (_onReadData == null) { + // if callbacks are not registered, stream isn't closed before. So, close here. + _controller.close(); + } else { + _callBackCompleter!.complete(); + } + } + break; + // when the request is succesfully done + // all the data has received. + // We will shut everything down after this. + case 'OnSucceeded': + { + cleanUpRequest( + reqPtr, + ); + if (_onSuccess != null) { + final respInfoPtr = + Pointer.fromAddress(args[0]).cast(); + _onSuccess!(cronet.Cronet_UrlResponseInfo_http_status_code_get( + respInfoPtr)); + } + if (_onReadData == null) { + // if callbacks are not registered, stream isn't closed before. So, close here. + _controller.close(); + } else { + _callBackCompleter!.complete(); + } + } + break; + default: + { + break; + } + } + }, onError: (Object error) { + log(error.toString()); + }); + } +} diff --git a/lib/src/http_client.dart b/lib/src/http_client.dart new file mode 100644 index 0000000..1a91bf3 --- /dev/null +++ b/lib/src/http_client.dart @@ -0,0 +1,278 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:async'; +import 'dart:ffi'; +import 'dart:io' as io; + +import 'package:cronet/src/exceptions.dart'; +import 'package:ffi/ffi.dart'; + +import 'dylib_handler.dart'; +import 'enums.dart'; +import 'generated_bindings.dart'; +import 'quic_hint.dart'; +import 'http_client_request.dart'; + +// Cronet library is loaded in global scope +final _cronet = Cronet(loadWrapper()); + +/// A client that receives content, such as web pages, +/// from a server using the HTTP, HTTPS, HTTP2, Quic etc. protocol. +/// +/// HttpClient contains a number of methods to send an [HttpClientRequest] to an +/// Http server and receive an [Stream] of [List] of [int], analogus to [HttpClientResponse] back. +/// Alternatively, you can also register callbacks for different network events including +/// but not limited to receiving the raw bytes sent by the server. +/// For example, you can use the +/// [get], [getUrl], [post], and [postUrl] methods for GET and POST requests, respectively. +/// +/// +/// TODO: Implement other functions +/// +/// +/// Example Usage: +/// ```dart +/// final client = HttpClient(); +/// client.getUrl(Uri.parse('https://example.com/')) +/// .then((HttpClientRequest request) { +/// // See [HttpClientRequest] for more info +/// }); +/// ``` +class HttpClient { + final String userAgent; + final bool quic; + final bool http2; + final bool brotli; + final String acceptLanguage; + // final CacheMode cacheMode; + // final int? maxCache; + final List? quicHints; + + // TODO: Migrate enableTimelineLogging API here + + final Pointer _cronetEngine; + // Keep all the request reference in a list so if the client is being explicitly closed, we can clean up the requests. + final _requests = List.empty(growable: true); + var _stop = false; + + Uri? _temp; + + static const int defaultHttpPort = 80; + static const int defaultHttpsPort = 443; + + /// Initiates a [HttpClient]. + /// + /// An optional parameters - + /// 1. [quic] use QUIC protocol. Default - true. You can also pass [quicHints]. + /// 2. [http2] use HTTP2 protocol. Default - true + /// 3. [brotli] use brotli compression. Default - true + /// 4. [acceptLanguage] - Default - 'en_US' + /// 5. [cacheMode] - Choose from [CacheMode]. Default - [CacheMode.inMemory] (TODO) + /// 6. [maxCache] - Set maximum cache size in bytes. Set to `null` to let the system decide. Default - `10KB`. (TODO) + /// NOTE: For [CacheMode.inMemory], [maxCache] must not be null. For any other mode, it can be. + /// + /// 7. If caches and cookies should persist, provide a directory using [cronetStorage]. Keeping it null will use + /// a temporary, non persistant storage. + /// + /// Throws [CronetException] if [HttpClient] can't be created. + /// + /// Breaking Changes from `dart:io` based library: + /// + /// 1. [userAgent] property must be set when constructing [HttpClient] and can't be changed afterwards. + HttpClient({ + this.userAgent = 'Dart/2.12', + this.quic = true, + this.quicHints, + this.http2 = true, + this.brotli = true, + this.acceptLanguage = 'en_US', + }) : _cronetEngine = _cronet.Cronet_Engine_Create() { + // Initialize Dart Native API dynamically + _cronet.InitDartApiDL(NativeApi.initializeApiDLData); + _cronet.registerHttpClient(this, _cronetEngine); + + // starting the engine with parameters + final engineParams = _cronet.Cronet_EngineParams_Create(); + _cronet.Cronet_EngineParams_user_agent_set( + engineParams, userAgent.toNativeUtf8().cast()); + _cronet.Cronet_EngineParams_enable_quic_set(engineParams, quic); + + if (quicHints != null) { + for (final quicHint in quicHints!) { + final hint = _cronet.Cronet_QuicHint_Create(); + _cronet.Cronet_QuicHint_host_set( + hint, quicHint.host.toNativeUtf8().cast()); + _cronet.Cronet_QuicHint_port_set(hint, quicHint.port); + _cronet.Cronet_QuicHint_alternate_port_set( + hint, quicHint.alternatePort); + _cronet.Cronet_EngineParams_quic_hints_add(engineParams, hint); + _cronet.Cronet_QuicHint_Destroy(hint); + } + } + + _cronet.Cronet_EngineParams_enable_http2_set(engineParams, http2); + _cronet.Cronet_EngineParams_enable_brotli_set(engineParams, brotli); + _cronet.Cronet_EngineParams_accept_language_set( + engineParams, acceptLanguage.toNativeUtf8().cast()); + + // TODO: Storage and cache mode change code goes here + + final res = + _cronet.Cronet_Engine_StartWithParams(_cronetEngine, engineParams); + if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { + throw CronetException(res); + } + _cronet.Cronet_EngineParams_Destroy(engineParams); + } + + // void _cleanUpRequests(HttpClientRequest hcr) { + // _requests.remove(hcr); + // } + + /// Shuts down the HTTP client. + /// + /// If [force] is `false` (the default) the HttpClient will be kept alive until all active connections are done. If [force] is `true` any active connections will be closed to immediately release all resources. These closed connections will receive an ~error~ cancel event to indicate that the client was shut down. In both cases trying to establish a new connection after calling close will throw an exception. + /// NOTE: Temporary storage files (cache, cookies and logs if no explicit path is mentioned) are only deleted if you [close] the engine. + void close({bool force = false}) { + if (_stop) { + // if already stopped, return immediately + return; + } + _stop = true; + // TODO: add force stop code here (with abort api) + } + + Uri _getUri(String host, int port, String path) { + final _host = Uri.parse(host); + if (!_host.hasScheme) { + final scheme = (port == defaultHttpsPort) ? 'https' : 'http'; + return Uri(scheme: scheme, host: host, port: port, path: path); + } else { + return Uri( + scheme: _host.scheme, host: _host.host, port: port, path: path); + } + } + + /// Opens a [url] using a [method] like GET, PUT, POST, HEAD, PATCH, DELETE. + /// + /// Returns a [Future] of [HttpClientRequest]. + Future openUrl(String method, Uri url) { + return Future(() { + if (_stop) { + throw Exception("Client is closed. Can't open new connections"); + } + // TODO: Add clean up function when logging and storage apis are migrated + _requests.add(HttpClientRequest(url, method, _cronet, _cronetEngine)); + return _requests.last; + }); + } + + /// Opens a request on the basis of [method], [host], [port] and [path] using GET, PUT, POST, HEAD, PATCH, DELETE method + /// + /// Returns a [Future] of [HttpClientRequest]. + Future open( + String method, String host, int port, String path) { + return openUrl(method, _getUri(host, port, path)); + } + + /// Opens a [url] using GET method. + /// + /// Returns a [Future] of [HttpClientRequest]. + Future getUrl(Uri url) { + return openUrl('GET', url); + } + + /// Opens a request on the basis of [host], [port] and [path] using GET method + /// + /// Returns a [Future] of [HttpClientRequest]. + Future get(String host, int port, String path) { + return getUrl(_getUri(host, port, path)); + } + + /// Opens a [url] using HEAD method. + /// + /// Returns a [Future] of [HttpClientRequest]. + Future headUrl(Uri url) { + return openUrl('HEAD', url); + } + + /// Opens a request on the basis of [host], [port] and [path] using HEAD method + /// + /// Returns a [Future] of [HttpClientRequest]. + Future head(String host, int port, String path) { + return headUrl(_getUri(host, port, path)); + } + + /// Opens a [url] using PUT method. + /// + /// Returns a [Future] of [HttpClientRequest]. + Future putUrl(Uri url) { + return openUrl('PUT', url); + } + + /// Opens a request on the basis of [host], [port] and [path] using PUT method + /// + /// Returns a [Future] of [HttpClientRequest]. + Future put(String host, int port, String path) { + return putUrl(_getUri(host, port, path)); + } + + /// Opens a [url] using POST method. + /// + /// Returns a [Future] of [HttpClientRequest]. + Future postUrl(Uri url) { + return openUrl('POST', url); + } + + /// Opens a request on the basis of [host], [port] and [path] using POST method + /// + /// Returns a [Future] of [HttpClientRequest]. + Future post(String host, int port, String path) { + return postUrl(_getUri(host, port, path)); + } + + /// Opens a [url] using PATCH method. + /// + /// Returns a [Future] of [HttpClientRequest]. + Future patchUrl(Uri url) { + return openUrl('PATCH', url); + } + + /// Opens a request on the basis of [host], [port] and [path] using PATCH method + /// + /// Returns a [Future] of [HttpClientRequest]. + Future patch(String host, int port, String path) { + return patchUrl(_getUri(host, port, path)); + } + + /// Opens a [url] using DELETE method. + /// + /// Returns a [Future] of [HttpClientRequest]. + Future deleteUrl(Uri url) { + return openUrl('DELETE', url); + } + + /// Opens a request on the basis of [host], [port] and [path] using DELETE method + /// + /// Returns a [Future] of [HttpClientRequest]. + Future delete(String host, int port, String path) { + return deleteUrl(_getUri(host, port, path)); + } + + /// Function for resolving the proxy server to be used for a HTTP connection from the proxy configuration specified through environment variables. + /// + /// Note: It just returns [io.HttpClient.findProxyFromEnvironment]. + static String findProxyFromEnvironment(Uri url, + {Map? environment}) { + return io.HttpClient.findProxyFromEnvironment(url, + environment: environment); + } + + /// Gets Cronet's version + String get httpClientVersion => + _cronet.Cronet_Engine_GetVersionString(_cronetEngine) + .cast() + .toDartString(); +} diff --git a/lib/src/http_client_request.dart b/lib/src/http_client_request.dart new file mode 100644 index 0000000..a558bab --- /dev/null +++ b/lib/src/http_client_request.dart @@ -0,0 +1,263 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:async'; +// import 'dart:collection'; +import 'dart:convert'; +import 'dart:developer'; +import 'dart:ffi'; +import 'dart:io'; +import 'dart:isolate'; +import 'dart:typed_data'; + +import 'package:ffi/ffi.dart'; + +import 'exceptions.dart'; + +import 'generated_bindings.dart'; + +// TODO: Enable these when Headers are implemented +// part '../third_party/http_headers.dart'; +// part '../third_party/http_date.dart'; +part 'http_client_response.dart'; +part 'http_callback_handler.dart'; + +// Type definitions for various callbacks +typedef RedirectReceivedCallback = void Function( + String newLocationUrl, int responseCode); +typedef ResponseStartedCallback = void Function(int responseCode); +typedef ReadDataCallback = void Function(List data, int bytesRead, + int responseCode, Function next); // onReadComplete may confuse people +typedef FailedCallabck = void Function(HttpException exception); +typedef CanceledCallabck = void Function(); +typedef SuccessCallabck = void Function(int responseCode); + +/// HTTP request for a client connection. +/// +/// It handles all of the Http Requests made by [HttpClient]. +/// +/// Provides two ways to get data from the request. +/// [registerCallbacks] or a [HttpClientResponse] which is a [Stream>]. +/// +/// Either of them can be used at a time. +/// +/// +/// Example Usage: +/// ```dart +/// final client = HttpClient(); +/// client.getUrl(Uri.parse('https://example.com/')) +/// .then((HttpClientRequest request) { +/// return request.close(); +/// }).then((HttpClientResponse response) { +/// // Here you got the raw data. +/// // Use it as you like. +/// }); +/// ``` +/// +/// +/// TODO: Implement other functions +class HttpClientRequest implements IOSink { + final Uri _uri; + final String _method; + final Cronet _cronet; + final Pointer _cronetEngine; + final _CallbackHandler _cbh; + final Pointer _request; + // final Function _clientCleanup; // Holds the function to clean up storage after + // // request is done (if nessesary) + // // implemented in: http_client.dart + // TODO: Enable with abort API + // bool _isAborted = false; + + // TODO: See how that affects and do we need to change + // Negotiated protocol info is only available via Cronet_UrlResponseInfo + // final _headers = _HttpHeaders('1.1'); // Setting it to HTTP/1.1 + + @override + Encoding encoding; + + /// Initiates a [HttpClientRequest]. It is meant to be used by + /// [HttpClient]. Takes in [_uri], [_method], [_cronet] instance + HttpClientRequest(this._uri, this._method, this._cronet, this._cronetEngine, + // this._clientCleanup, + {this.encoding = utf8}) + : _cbh = + _CallbackHandler(_cronet, _cronet.Create_Executor(), ReceivePort()), + _request = _cronet.Cronet_UrlRequest_Create() { + // Register the native port to C side + _cronet.registerCallbackHandler( + _cbh.receivePort.sendPort.nativePort, _request); + } + + // Starts the request + void _startRequest() { + // TODO: Enable with abort API + // if (_isAborted) { + // throw Exception('Request is already aborted'); + // } + // _headers._finalize(); // making headers immutable + final requestParams = _cronet.Cronet_UrlRequestParams_Create(); + _cronet.Cronet_UrlRequestParams_http_method_set( + requestParams, _method.toNativeUtf8().cast()); + + // TODO: Setting headers go here + + final res = _cronet.Cronet_UrlRequest_Init( + _request, + _cronetEngine, + _uri.toString().toNativeUtf8().cast(), + requestParams, + _cbh.executor); + + if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { + throw UrlRequestException(res); + } + + final res2 = _cronet.Cronet_UrlRequest_Start(_request); + if (res2 != Cronet_RESULT.Cronet_RESULT_SUCCESS) { + throw UrlRequestException(res2); + } + _cbh.listen(_request); + // TODO: Enable with storage and logging api + // _cbh.listen(_request, () => _clientCleanup(this)); + } + + /// This is one of the methods to get data out of [HttpClientRequest]. + /// Accepted callbacks are [RedirectReceivedCallback], + /// [ResponseStartedCallback], [ReadDataCallback], [FailedCallabck], + /// [CanceledCallabck] and [SuccessCallabck]. + /// + /// Callbacks will be called as per sequence of the events. + ///If callbacks are registered, the [Stream] returned by [close] will be closed. + Future registerCallbacks(ReadDataCallback onReadData, + {RedirectReceivedCallback? onRedirectReceived, + ResponseStartedCallback? onResponseStarted, + FailedCallabck? onFailed, + CanceledCallabck? onCanceled, + SuccessCallabck? onSuccess}) { + final rc = _cbh.registerCallbacks(onReadData, onRedirectReceived, + onResponseStarted, onFailed, onCanceled, onSuccess); + _startRequest(); + return rc; + } + + /// Returns the [Stream] responsible for + /// emitting data received from the server + /// by cronet. + /// + /// Throws [Exception] if request is already aborted using [abort]. + /// + /// Throws [UrlRequestException] if request can't be initiated. + /// + /// Consumable similar to [HttpClientResponse] + @override + Future close() { + return Future(() { + _startRequest(); + return HttpClientResponse._(_cbh.stream); + }); + } + + /// Aborts the client connection. + /// + /// If the connection has not yet completed, the request is aborted + /// and closes the [Stream] with onDone callback you may have + /// registered. The [Exception] passed to it is thrown and + /// [StackTrace] is printed. If there is no [StackTrace] provided, + /// [StackTrace.empty] will be shown. If no [Exception] is provided, + /// no exception is thrown. + /// + /// If the [Stream] is closed, aborting has no effect. + void abort([Object? exception, StackTrace? stackTrace]) { + // TODO: Migrate abort code + throw UnimplementedError(); + } + + /// Done is same as [close]. A [HttpClientResponse] future that will complete once the response is available. + /// + /// If an error occurs before the response is available, this future will complete with an error. + @override + Future get done => close(); + + @override + void add(List data) { + // TODO: Implement this with POST request + throw UnimplementedError(); + } + + @override + void addError(Object error, [StackTrace? stackTrace]) { + // TODO: Implement this with POST request + throw UnimplementedError(); + } + + @override + Future addStream(Stream> stream) { + // TODO: Implement this with POST request + throw UnimplementedError(); + } + + @override + Future flush() { + // TODO: Implement this with POST request + throw UnimplementedError(); + } + + // Implementation taken from `dart:io` + @override + void write(Object? object) { + final string = '$object'; + if (string.isEmpty) return; + add(encoding.encode(string)); + } + + // Implementation taken from `dart:io` + @override + void writeAll(Iterable objects, [String separator = '']) { + final iterator = objects.iterator; + if (!iterator.moveNext()) return; + if (separator.isEmpty) { + do { + write(iterator.current); + } while (iterator.moveNext()); + } else { + write(iterator.current); + while (iterator.moveNext()) { + write(separator); + write(iterator.current); + } + } + } + + // Implementation taken from `dart:io` + @override + void writeCharCode(int charCode) { + write(String.fromCharCode(charCode)); + } + + // Implementation taken from `dart:io` + @override + void writeln([Object? object = '']) { + write(object); + write('\n'); + } + + /// Follow the redirects + bool get followRedirects => _cbh.followRedirects; + set followRedirects(bool follow) { + _cbh.followRedirects = follow; + } + + /// Maximum numbers of redirects to follow. + /// Have no effect if [followRedirects] is set to false. + int get maxRedirects => _cbh.maxRedirects; + set maxRedirects(int redirects) { + _cbh.maxRedirects = redirects; + } + + /// The uri of the request. + Uri get uri => _uri; + + // HttpHeaders get headers => _headers; +} diff --git a/lib/src/http_client_response.dart b/lib/src/http_client_response.dart new file mode 100644 index 0000000..236c49f --- /dev/null +++ b/lib/src/http_client_response.dart @@ -0,0 +1,25 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +part of '../src/http_client_request.dart'; + +abstract class HttpClientResponse extends Stream> { + HttpClientResponse(); + + factory HttpClientResponse._(Stream> cbhStream) { + return _HttpClientResponse(cbhStream); + } +} + +class _HttpClientResponse extends HttpClientResponse { + final Stream> cbhStream; + _HttpClientResponse(this.cbhStream); + + @override + StreamSubscription> listen(void Function(List event)? onData, + {Function? onError, void Function()? onDone, bool? cancelOnError}) { + return cbhStream.listen(onData, + onError: onError, onDone: onDone, cancelOnError: cancelOnError); + } +} diff --git a/lib/src/native/wrapper/BUILD.md b/lib/src/native/wrapper/BUILD.md new file mode 100644 index 0000000..8065c8b --- /dev/null +++ b/lib/src/native/wrapper/BUILD.md @@ -0,0 +1,34 @@ +## Build Guide + +Want to build your own? + +For building cronet: https://www.chromium.org/developers/how-tos/get-the-code & https://chromium.googlesource.com/chromium/src/+/master/components/cronet/build_instructions.md + +For building wrapper: + +From this repository root + +```bash +cd lib/src/native/wrapper +./build.sh . '"cronet_version"' +``` + +Copy the `wrapper` binary to your project's `root` folder. +Copy the cronet's binary to the `cronet_binaries/` folder from project's `root` folder. (Except on Windows. There, everything will be on root dir only) + +*If you are in 64bit linux system, `cronet_binaries/` will be `cronet_binaries/linux64`.* + +### For Windows + +Required: Visual Studio 2019 with C++ Desktop Development tools. + +1. Make sure that you have `cmake` for Visual Studio 2019 is available in your command line. If not, you should open something like `x64 Native Tools Command Prompt for VS 2019` from your start menu which will open a command prompt with required path set. + +2. In the command prompt do - +``` +cd \lib\src\native\wrapper +cmake CMakeLists.txt -B out +cmake --build out +``` +3. From there, go to `out\Debug` folder to get `wrapper.dll` + diff --git a/lib/src/prepare_cronet.dart b/lib/src/prepare_cronet.dart new file mode 100644 index 0000000..fff7071 --- /dev/null +++ b/lib/src/prepare_cronet.dart @@ -0,0 +1,84 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Contains the nessesary setup code only. Not meant to be exposed. + +import 'dart:io' show Directory, File, Process, ProcessResult, ProcessStartMode; + +// import 'package:path/path.dart'; + +import 'find_resource.dart'; + +// TODO: Change URL and Version + +const _release = '1.0.0'; +const _cronetBinaryUrl = + 'https://github.com/unsuitable001/dart_cronet_sample/releases/download/$_release/'; +final _cBinExtMap = { + 'linux64': '.tar.xz', + 'windows64': '.tar.gz', + 'androidarm64-v8a': '.tar.xz', +}; + +const _cronetVersion = '"86.0.4240.198"'; + +/// Builds the [wrapper] shared library +/// according to [build.sh] file +void buildWrapper() { + final wrapperPath = wrapperSourcePath(); + + print('Building Wrapper...'); + var result = + Process.runSync('$wrapperPath/build.sh', [wrapperPath, _cronetVersion]); + print(result.stdout); + print(result.stderr); + print('Copying wrapper to project root...'); + result = Process.runSync('cp', ['$wrapperPath/wrapper.so', '.']); + print(result.stdout); + print(result.stderr); +} + +/// Place downloaded binaries to proper location +void placeBinaries(String platform, String fileName) { + print('Extracting Cronet for $platform'); + ProcessResult res; + // Process.runSync('mkdir', ['-p', 'cronet_binaries']); + if (platform.startsWith('windows')) { + res = Process.runSync('tar', ['-xvf', fileName]); + } else { + Directory('cronet_binaries').createSync(); + + // Do we have tar extraction capability + // in dart's built-in libraries? + res = Process.runSync('tar', ['-xvf', fileName, '-C', 'cronet_binaries']); + } + + if (res.exitCode != 0) { + throw Exception( + "Can't unzip. Check if the downloaded file isn't corrupted"); + } + print('Done! Cleaning up...'); + + File(fileName).deleteSync(); + print('Done! Cronet support for $platform is now available!'); +} + +/// Download [cronet] library +/// from Github Releases +Future downloadCronetBinaries(String platform) async { + if (!isCronetAvailable(platform)) { + final fileName = platform + (_cBinExtMap[platform] ?? ''); + print('Downloading Cronet for $platform'); + final downloadUrl = _cronetBinaryUrl + fileName; + print(downloadUrl); + final dProcess = await Process.start('curl', ['-OL', downloadUrl], + mode: ProcessStartMode.inheritStdio); + if (await dProcess.exitCode != 0) { + throw Exception("Can't download. Check your network connection!"); + } + placeBinaries(platform, fileName); + } else { + print("Cronet $platform is already available. No need to download."); + } +} diff --git a/test/my_test.dart b/lib/src/quic_hint.dart similarity index 55% rename from test/my_test.dart rename to lib/src/quic_hint.dart index cdf0c4f..59cd3b0 100644 --- a/test/my_test.dart +++ b/lib/src/quic_hint.dart @@ -2,12 +2,10 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:test/test.dart'; -import 'package:cronet/cronet.dart'; +class QuicHint { + final String host; + final int port; + final int alternatePort; -void main() { - test('dummy test', () { - final result = mySum(2, 40); - expect(result, 42); - }); + QuicHint(this.host, this.port, this.alternatePort); } diff --git a/test/cronet_test.dart b/test/cronet_test.dart new file mode 100644 index 0000000..7cff67b --- /dev/null +++ b/test/cronet_test.dart @@ -0,0 +1,39 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:cronet/cronet.dart'; +import 'package:test/test.dart'; + +void main() { + late HttpClient client; + setUp(() { + client = HttpClient(); + }); + + test('Validate static constants', () { + expect(80, equals(HttpClient.defaultHttpPort)); + expect(443, equals(HttpClient.defaultHttpsPort)); + }); + + test('Loads cronet engine and gets the version string', () { + expect(client.httpClientVersion, TypeMatcher()); + }); + + test('Gets the user agent', () { + expect(client.userAgent, equals('Dart/2.12')); + }); + + test('Loads another cronet engine with different config', () { + final client2 = HttpClient(userAgent: 'Dart_Test/1.0'); + expect(client2, TypeMatcher()); + expect(client2.userAgent, equals('Dart_Test/1.0')); + client2.close(); + }); + + tearDown(() { + client.close(); + }); +} diff --git a/test/http_client_close_test.dart b/test/http_client_close_test.dart new file mode 100644 index 0000000..278a7f0 --- /dev/null +++ b/test/http_client_close_test.dart @@ -0,0 +1,48 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:convert'; +import 'dart:io'; + +import 'package:cronet/cronet.dart'; +import 'package:test/test.dart'; + +int main() { + late HttpServer server; + final sentData = 'Hello, world!'; + setUp(() async { + server = await HttpServer.bind(InternetAddress.anyIPv6, 5253); + server.listen((HttpRequest request) { + request.response.write(sentData); + request.response.close(); + }); + }); + + test('Opening new request after client close throws exception', () async { + final client = HttpClient(); + client.close(); + expect( + () async => + await client.openUrl('GET', Uri.parse('http://localhost:5253')), + throwsException); + }); + + test( + 'Closing the HttpClient after starting a request keeps the previous connection alive', + () async { + final client = HttpClient(); + final request = + await client.openUrl('GET', Uri.parse('http://localhost:5253')); + final resp = await request.close(); + client.close(); + final dataStream = resp.transform(utf8.decoder); + expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); + }); + + tearDown(() { + server.close(); + }); + + return 0; +} diff --git a/test/http_request_exceptions_test.dart b/test/http_request_exceptions_test.dart new file mode 100644 index 0000000..d1d6dba --- /dev/null +++ b/test/http_request_exceptions_test.dart @@ -0,0 +1,44 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:cronet/cronet.dart'; +import 'package:test/test.dart'; + +int main() { + late HttpClient client; + setUp(() async { + client = HttpClient(); + }); + + test('Throws HttpException if url do not exist', () async { + final request = await client.openUrl('GET', + Uri.parse('http://localghost:9999')); // localghost shouln't exist :p + final resp = await request.close(); + expect(resp, + emitsInOrder([emitsError(isA()), emitsDone])); + }); + + test('Throws HttpException if the port is wrong', () async { + final request = await client.openUrl( + 'GET', Uri.parse('http://localhost:9999')); // port 9999 should be close + final resp = await request.close(); + expect(resp, + emitsInOrder([emitsError(isA()), emitsDone])); + }); + + test('Throws HttpException if the scheme is wrong', () async { + final request = + await client.openUrl('GET', Uri.parse('random://localhost:5253')); + final resp = await request.close(); + expect(resp, + emitsInOrder([emitsError(isA()), emitsDone])); + }); + + tearDown(() { + client.close(); + }); + return 0; +} diff --git a/test/http_responses_exceptions_test.dart b/test/http_responses_exceptions_test.dart new file mode 100644 index 0000000..17eba4f --- /dev/null +++ b/test/http_responses_exceptions_test.dart @@ -0,0 +1,67 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:cronet/cronet.dart'; +import 'package:test/test.dart'; + +void main() { + late HttpClient client; + late HttpServer server; + setUp(() async { + client = HttpClient(); + server = await HttpServer.bind(InternetAddress.anyIPv6, 5255); + server.listen((HttpRequest request) { + final paths = request.uri.pathSegments; + request.response.statusCode = int.parse(paths[0]); + request.response.close(); + }); + }); + + test('Throws a HttpException: Not Found when status code is 404', () async { + final request = await client.getUrl(Uri.parse('http://localhost:5255/404')); + final resp = await request.close(); + expect( + resp, + emitsInOrder([ + emitsError(isA().having( + (exception) => exception.message, 'message', 'Not Found')), + emitsDone + ])); + }); + + test('Throws a HttpException: Unauthorized when status code is 401', + () async { + final request = await client.getUrl(Uri.parse('http://localhost:5255/401')); + final resp = await request.close(); + expect( + resp, + emitsInOrder([ + emitsError(isA().having( + (exception) => exception.message, 'message', 'Unauthorized')), + emitsDone + ])); + }); + + test('Throws a HttpException: Service Unavailable when status code is 503', + () async { + final request = await client.getUrl(Uri.parse('http://localhost:5255/503')); + final resp = await request.close(); + expect( + resp, + emitsInOrder([ + emitsError(isA().having( + (exception) => exception.message, + 'message', + 'Service Unavailable')), + emitsDone + ])); + }); + + tearDown(() { + client.close(); + server.close(); + }); +} diff --git a/test/http_responses_new_api_test.dart b/test/http_responses_new_api_test.dart new file mode 100644 index 0000000..863f49b --- /dev/null +++ b/test/http_responses_new_api_test.dart @@ -0,0 +1,43 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:convert'; +import 'dart:io'; + +import 'package:cronet/cronet.dart'; +import 'package:test/test.dart'; + +void main() { + late HttpClient client; + late HttpServer server; + final sentData = 'Hello, world!'; + setUp(() async { + client = HttpClient(); + server = await HttpServer.bind(InternetAddress.anyIPv6, 5256); + server.listen((HttpRequest request) { + if (request.method == 'CUSTOM') { + request.response.write(request.method); + } else { + request.response.write(sentData); + } + request.response.close(); + }); + }); + + test('New API: Gets Hello, world response from server using getUrl', + () async { + String resp = ''; + final request = await client.getUrl(Uri.parse('http://localhost:5256')); + await request.registerCallbacks((data, bytesRead, responseCode, next) { + resp += utf8.decoder.convert(data); + next(); + }); + expect(resp, equals(sentData)); + }); + + tearDown(() { + client.close(); + server.close(); + }); +} diff --git a/test/http_responses_test.dart b/test/http_responses_test.dart new file mode 100644 index 0000000..9efb7c5 --- /dev/null +++ b/test/http_responses_test.dart @@ -0,0 +1,71 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:convert'; +import 'dart:io'; + +import 'package:cronet/cronet.dart'; +import 'package:test/test.dart'; + +void main() { + late HttpClient client; + late HttpServer server; + final sentData = 'Hello, world!'; + setUp(() async { + client = HttpClient(); + server = await HttpServer.bind(InternetAddress.anyIPv6, 5252); + server.listen((HttpRequest request) { + if (request.method == 'CUSTOM') { + request.response.write(request.method); + } else { + request.response.write(sentData); + } + request.response.close(); + }); + }); + + test('Gets Hello, world response from server using getUrl', () async { + final request = await client.getUrl(Uri.parse('http://localhost:5252')); + final resp = await request.close(); + final dataStream = resp.transform(utf8.decoder); + expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); + }); + + test('Gets Hello, world response from server using get method', () async { + final request = await client.get('localhost', 5252, '/'); + final resp = await request.close(); + final dataStream = resp.transform(utf8.decoder); + expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); + }); + + test('Gets Hello, world response from server using openUrl method', () async { + final request = + await client.openUrl('GET', Uri.parse('http://localhost:5252')); + final resp = await request.close(); + final dataStream = resp.transform(utf8.decoder); + expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); + }); + + test( + 'Fetch Hello, world response from server using openUrl, custom method method', + () async { + final request = + await client.openUrl('CUSTOM', Uri.parse('http://localhost:5252')); + final resp = await request.close(); + final dataStream = resp.transform(utf8.decoder); + expect(dataStream, emitsInOrder([equals('CUSTOM'), emitsDone])); + }); + + test('Fetch Hello, world response from server using POST request', () async { + final request = await client.postUrl(Uri.parse('http://localhost:5252')); + final resp = await request.close(); + final dataStream = resp.transform(utf8.decoder); + expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); + }); + + tearDown(() { + client.close(); + server.close(); + }); +} From b2253a3553d25674ad48fd23ec43b3533f4121e4 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Sun, 13 Jun 2021 12:05:26 +0530 Subject: [PATCH 04/42] refactor: comments & readme fixed un-nessesary removal of code from .gitignore refined analysis options added changelog --- .gitignore | 31 +++++---- .pubignore | 4 -- CHANGELOG.md | 18 ++++- README.md | 49 +++++++------- analysis_options.yaml | 5 +- example/analysis_options.yaml | 0 lib/src/dylib_handler.dart | 30 ++++----- lib/src/find_resource.dart | 12 ++-- lib/src/http_callback_handler.dart | 102 +++++++++++++---------------- lib/src/http_client.dart | 49 +++++++------- lib/src/http_client_request.dart | 51 ++++++--------- lib/src/native/wrapper/BUILD.md | 27 ++++---- 12 files changed, 190 insertions(+), 188 deletions(-) create mode 100644 example/analysis_options.yaml diff --git a/.gitignore b/.gitignore index 524ce93..f836d97 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,15 @@ -# See https://dart.dev/guides/libraries/private-files +# See https://www.dartlang.org/guides/libraries/private-files # Files and directories created by pub. .dart_tool/ -build/ -# wrapper build directory -lib/src/native/wrapper/out .packages +build/ pubspec.lock -# IDE and debugger files. -.clangd -.gdb_history -.history -.vscode -compile_commands.json +# wrapper build directory +lib/src/native/wrapper/out # Directory created by dartdoc. -# If you don't generate documentation locally you can remove this line. doc/api/ # Avoid committing generated Javascript files: @@ -28,6 +21,22 @@ doc/api/ *.js.deps *.js.map +# IDE and debugger files. +.clangd +.gdb_history +.history +.vscode +compile_commands.json + +# IntelliJ +*.iml +*.ipr +*.iws +.idea/ + +# Mac +.DS_Store + # Cronet pre-built binaries cronet_binaries/ diff --git a/.pubignore b/.pubignore index 24e181a..cf8813e 100644 --- a/.pubignore +++ b/.pubignore @@ -12,10 +12,6 @@ pubspec.lock .vscode compile_commands.json -# Directory created by dartdoc. -# If you don't generate documentation locally you can remove this line. -doc/api/ - # Avoid committing generated Javascript files: *.dart.js *.info.json # Produced by the --dump-info flag. diff --git a/CHANGELOG.md b/CHANGELOG.md index 41cc7d8..64c1c4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ ## 0.0.1 -* TODO: Describe initial release. +### Partially migrated from unsuitable001/dart_cronet_sample + +* HttpClient with QUIC, HTTP2, brotli support. +* HttpClient with a customizable user agent string. +* HttpClient close method (without force close). +* Implemented open, openUrl & other associated methods. +* Response is consumable using 2 styles of APIs. dart:io style and callback based style. +* Different types of Exceptions are implemented. + +**Breaking Changes:** + +* Custom `SecurityContext` is no longer handled by the client. Users have to handle it in other ways. (To be documented later). +* `userAgent` property is now read-only. Custom userAgent should be passed as a constructor argument. + +**Notes:** + +If callback based API is used, `stream` based api (`dart:io` style) will be closed immediately. diff --git a/README.md b/README.md index 2113853..6004471 100644 --- a/README.md +++ b/README.md @@ -4,41 +4,33 @@ This package binds to Cronet's [native API](https://chromium.googlesource.com/ch This is a [GSoC 2021 project](https://summerofcode.withgoogle.com/projects/#4757095741652992). - - ## Usage -1. Add this to `pubspec.yaml` +1. Add package as a dependency in your `pubspec.yaml`. -```pubspec -dependencies: - cronet: - git: - url: https://github.com/google/cronet.dart.git +2. Run this from the `root` of your project. -``` + Desktop Platforms -2. Run this from the `root` of your project + ```bash + pub get + pub run cronet + ``` -Desktop Platforms - -```bash -pub get -pub run cronet -``` -Supported platforms: `linux64` and `windows64` + Supported platforms: `linux64` and `windows64` 3. Import -```dart -import 'package:cronet/cronet.dart'; -``` - -**Internet connection is required to download cronet binaries** + ```dart + import 'package:cronet/cronet.dart'; + ``` +**Note:** Internet connection is required to download cronet binaries ## Example +### `dart:io` style API + ```dart final client = HttpClient(); client @@ -72,7 +64,6 @@ import 'package:cronet/cronet.dart'; }); ``` - ## Run Example ```bash @@ -83,5 +74,15 @@ dart run replace `` with `linux64` or `windows64` -**Wrapper & Cronet binaries build guide**: [BUILD.md](lib/src/native/wrapper/BUILD.md) +## Run Tests + +```bash +pub get +pub run cronet +dart test --platform vm +``` +**Note:** Make sure that `52XX` ports are not reserved by any other process. +As some of the tests use ports in this range. + +**Wrapper & Cronet binaries build guide**: [BUILD.md](lib/src/native/wrapper/BUILD.md) diff --git a/analysis_options.yaml b/analysis_options.yaml index 7944a89..71629fc 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -9,6 +9,5 @@ analyzer: implicit-casts: false implicit-dynamic: false exclude: - - example/** - - lib/third_party/** # may not be fully migrated - - lib/src/generated_bindings.dart # ignore generated files + - example/lib/main.dart # Ignore placeholder example file. + - lib/src/generated_bindings.dart # Ignore generated files. diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml new file mode 100644 index 0000000..e69de29 diff --git a/lib/src/dylib_handler.dart b/lib/src/dylib_handler.dart index 88c662b..f081d7c 100644 --- a/lib/src/dylib_handler.dart +++ b/lib/src/dylib_handler.dart @@ -7,41 +7,41 @@ import 'dart:io' show Directory, File, Link, Platform; import 'package:path/path.dart'; -/// Checks if [File]/[Link] exists for an [uri] +/// Checks if [File]/[Link] exists for an [uri]. bool _doesFileExist(Uri uri) { return File.fromUri(uri).existsSync() || Link.fromUri(uri).existsSync(); } -/// Checks if a dynamic library is located in -/// 1. Present Working Directory -/// 2. Current script's/executable's directory -/// 3. Current script's/executable's directory's parent -/// and returns the absolute path +/// Resolves the absolute path of a resource (usually a dylib). /// -/// Returns [null] if can't be resolved. +/// Checks if a dynamic library is located in - +/// 1. Present Working Directory +/// 2. Current script's/executable's directory +/// 3. Current script's/executable's directory's parent +/// and returns the absolute path or [null] if can't be resolved. String? _resolveLibUri(String name) { var libUri = Directory.current.uri.resolve(name); - // If lib is in Present Working Directory + // If lib is in Present Working Directory. if (_doesFileExist(libUri)) { return libUri.toFilePath(windows: Platform.isWindows); } - // If lib is in script's directory + // If lib is in script's directory. libUri = Uri.directory(dirname(Platform.script.path)).resolve(name); if (_doesFileExist(libUri)) { return libUri.toFilePath(windows: Platform.isWindows); } - // If lib is in executable's directory + // If lib is in executable's directory. libUri = Uri.directory(dirname(Platform.resolvedExecutable)).resolve(name); if (_doesFileExist(libUri)) { return libUri.toFilePath(windows: Platform.isWindows); } - // If lib is in script's directory's parent + // If lib is in script's directory's parent. libUri = Uri.directory(dirname(Platform.script.path)).resolve('../$name'); @@ -49,7 +49,7 @@ String? _resolveLibUri(String name) { return libUri.toFilePath(windows: Platform.isWindows); } - // If lib is in executable's directory's parent + // If lib is in executable's directory's parent. libUri = Uri.directory(dirname(Platform.resolvedExecutable)).resolve('../$name'); @@ -62,8 +62,8 @@ String? _resolveLibUri(String name) { } /// Loads [wrapper] dynamic library depending on the platform. -/// This loaded [wrapper] will then load [cronet] /// +/// This loaded [wrapper] will then load [cronet]. /// Throws an [ArgumentError] if library can't be loaded. DynamicLibrary loadWrapper() { const fileName = 'wrapper'; @@ -83,8 +83,8 @@ DynamicLibrary loadWrapper() { var wrapperName = prefix + fileName + ext; - /// [_resolveLibUri()] will try to resolve [wrapper]'s absolute path - /// If it can't find it, try looking at search paths provided by the system + // _resolveLibUri() will try to resolve wrapper's absolute path. + // If it can't find it, try looking at search paths provided by the system. wrapperName = _resolveLibUri(wrapperName) ?? wrapperName; return Platform.isIOS diff --git a/lib/src/find_resource.dart b/lib/src/find_resource.dart index 5d88d10..459686c 100644 --- a/lib/src/find_resource.dart +++ b/lib/src/find_resource.dart @@ -8,14 +8,14 @@ import 'dart:convert'; import 'dart:io' show File, Directory; -/// Finds the root [Uri] of our package +/// Finds the root [Uri] of our package. Uri? findPackageRoot() { var root = Directory.current.uri; do { - // Traverse up till .dart_tool/package_config.json is found + // Traverse up till .dart_tool/package_config.json is found. final file = File.fromUri(root.resolve('.dart_tool/package_config.json')); if (file.existsSync()) { - // get package path from package_config.json + // get package path from package_config.json. try { final packageMap = jsonDecode(file.readAsStringSync()) as Map; @@ -39,10 +39,8 @@ Uri? findPackageRoot() { return null; } -/// Gets the [wrapper]'s source code's path -/// Throws [Exception] if not found +/// Gets the [wrapper]'s source code's path, throws [Exception] if not found. String wrapperSourcePath() { - // Finds this package's location final packagePath = findPackageRoot(); if (packagePath == null) { throw Exception("Cannot resolve package:cronet's rootUri"); @@ -54,7 +52,7 @@ String wrapperSourcePath() { return wrapperSource.toFilePath(); } -/// Is cronet binaries are already available in the project +/// Checks if cronet binaries are already available in the project. bool isCronetAvailable(String platform) { final cronetDir = Directory.current.uri.resolve('cronet_binaries/$platform/'); return Directory.fromUri(cronetDir).existsSync(); diff --git a/lib/src/http_callback_handler.dart b/lib/src/http_callback_handler.dart index edd3e75..19aba94 100644 --- a/lib/src/http_callback_handler.dart +++ b/lib/src/http_callback_handler.dart @@ -4,13 +4,12 @@ part of 'http_client_request.dart'; -/// Deserializes the message sent by -/// cronet and it's wrapper +// Deserializes the message sent by cronet and it's wrapper. class _CallbackRequestMessage { final String method; final Uint8List data; - /// Constructs [method] and [data] from [message] + // Constructs [method] and [data] from [message]. factory _CallbackRequestMessage.fromCppMessage(List message) { return _CallbackRequestMessage._( message[0] as String, message[1] as Uint8List); @@ -22,26 +21,22 @@ class _CallbackRequestMessage { String toString() => 'CppRequest(method: $method)'; } -/// Handles every kind of callbacks that are -/// invoked by messages and data that are sent by -/// [NativePort] from native cronet library. -/// -/// +// Handles every kind of callbacks that are invoked by messages and +// data that are sent by [NativePort] from native cronet library. class _CallbackHandler { final ReceivePort receivePort; final Cronet cronet; final Pointer executor; - // These are a part of HttpClientRequest Public API + // These are a part of HttpClientRequest Public API. bool followRedirects = true; int maxRedirects = 5; - /// Stream controller to allow consumption of data - /// like [HttpClientResponse] + // Stream controller to allow consumption of data like [HttpClientResponse]. final _controller = StreamController>(); - Completer? - _callBackCompleter; // if callback based api is used, completes when receiving data is done + // If callback based api is used, completes when receiving data is done. + Completer? _callBackCompleter; RedirectReceivedCallback? _onRedirectReceived; ResponseStartedCallback? _onResponseStarted; @@ -50,15 +45,14 @@ class _CallbackHandler { CanceledCallabck? _onCanceled; SuccessCallabck? _onSuccess; - /// Registers the [NativePort] to the cronet side. + // Registers the [NativePort] to the cronet side. _CallbackHandler(this.cronet, this.executor, this.receivePort); Stream> get stream => _controller.stream; - /// This sets callbacks that are registered using - /// [HttpClientRequest.registerCallbacks]. + /// Sets callbacks that are registered using [HttpClientRequest.registerCallbacks]. /// - /// If [ReadDataCallback] is provided, the [Stream] returned by [HttpClientResponse.close] will be closed. + /// If called, the [Stream] returned by [HttpClientResponse.close] will be closed. Future registerCallbacks(ReadDataCallback onReadData, [RedirectReceivedCallback? onRedirectReceived, ResponseStartedCallback? onResponseStarted, @@ -68,8 +62,11 @@ class _CallbackHandler { _onRedirectReceived = onRedirectReceived; _onResponseStarted = onResponseStarted; _onReadData = onReadData; - _controller.close(); // if callbacks are registered, close the contoller - // responsible the sream for close() method (dart:io style API) + + // If callbacks are registered, close the contoller. + // Responsible the sream for close() method (dart:io style API). + _controller.close(); + _onFailed = onFailed; _onCanceled = onCanceled; _onSuccess = onSuccess; @@ -77,9 +74,9 @@ class _CallbackHandler { return _callBackCompleter!.future; } - // clean up tasks for a request - // need to call then whenever we are done with the request - // either successfully or unsuccessfully. + // Clean up tasks for a request. + // + // We need to call this then whenever we are done with the request. // TODO: Take cleanup client as param. (to be implemented by htto_client) void cleanUpRequest(Pointer reqPtr) { @@ -88,12 +85,13 @@ class _CallbackHandler { // cleanUpClient(); } + // Checks status of an URL response. int statusChecker(Pointer respInfoPtr, int lBound, int uBound, Function callback) { final respCode = cronet.Cronet_UrlResponseInfo_http_status_code_get(respInfoPtr); if (!(respCode >= lBound && respCode <= uBound)) { - // if NOT in range + // If NOT in range. callback(); final exception = HttpException( cronet.Cronet_UrlResponseInfo_http_status_text_get(respInfoPtr) @@ -101,7 +99,7 @@ class _CallbackHandler { .toDartString()); if (_callBackCompleter != null) { - // if callbacks are registered + // If callbacks are registered. _callBackCompleter!.completeError(exception); } else { _controller.addError(exception); @@ -111,18 +109,15 @@ class _CallbackHandler { return respCode; } - /// This listens to the messages sent by native cronet library - /// through wrapper via [NativePort]. + /// This listens to the messages sent by native cronet library. /// - /// This also invokes the appropriate callbacks that are registered + /// This also invokes the appropriate callbacks that are registered, /// according to the network events sent from cronet side. - /// - /// This is also reponsible for providing a [Stream] of [int] - /// to create a interface like [HttpClientResponse]. - - // TODO: add Function cleanUpClient when logging and storage api is implemneted void listen(Pointer reqPtr) { - // registers the listener on the receivePort. + // TODO: add Function cleanUpClient when logging and storage api is implemneted + + // Registers the listener on the receivePort. + // // The message parameter contains both the name of the event and // the data associated with it. receivePort.listen((dynamic message) { @@ -133,7 +128,7 @@ class _CallbackHandler { switch (reqMessage.method) { // Invoked when a redirect is received. - // Passes the new location's url and response code as parameter + // Passes the new location's url and response code as parameter. case 'OnRedirectReceived': { log('New Location: ${Pointer.fromAddress(args[0]).cast().toDartString()}'); @@ -142,7 +137,7 @@ class _CallbackHandler { 300, 399, () => cleanUpRequest( - reqPtr)); // If NOT a 3XX status code, throw Exception + reqPtr)); // If NOT a 3XX status code, throw Exception. if (followRedirects && maxRedirects > 0) { final res = cronet.Cronet_UrlRequest_FollowRedirect(reqPtr); if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { @@ -161,7 +156,7 @@ class _CallbackHandler { } break; - // When server has sent the initial response + // When server has sent the initial response. case 'OnResponseStarted': { final respCode = statusChecker( @@ -169,7 +164,7 @@ class _CallbackHandler { 100, 299, () => cleanUpRequest( - reqPtr)); // If NOT a 1XX or 2XX status code, throw Exception + reqPtr)); // If NOT a 1XX or 2XX status code, throw Exception. log('Response started'); if (_onResponseStarted != null) { _onResponseStarted!(respCode); @@ -177,14 +172,11 @@ class _CallbackHandler { } break; // Read a chunk of data. - // This is where we actually read - // the response from the server. // + // This is where we actually read the response from the server. // Data gets added to the stream here. - // ReadDataCallback is invoked here - // with data received, no of bytes read - // and a function which can be called - // to continue reading. + // ReadDataCallback is invoked here with data received, no of bytes read, + // and a function which can be called to continue reading. case 'OnReadCompleted': { final request = Pointer.fromAddress(args[0]); @@ -199,12 +191,12 @@ class _CallbackHandler { 299, () => cleanUpRequest( reqPtr, - )); // If NOT a 1XX or 2XX status code, throw Exception + )); // If NOT a 1XX or 2XX status code, throw Exception. final data = cronet.Cronet_Buffer_GetData(buffer) .cast() .asTypedList(bytesRead); - // invoke the callback + // Invoke the callback. if (_onReadData != null) { _onReadData!(data.toList(growable: false), bytesRead, respCode, () { @@ -217,7 +209,7 @@ class _CallbackHandler { } }); } else { - // or, add data to the stream + // Or, add data to the stream. _controller.sink.add(data.toList(growable: false)); final res = cronet.Cronet_UrlRequest_Read(request, buffer); if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { @@ -230,8 +222,7 @@ class _CallbackHandler { } } break; - // When there is any network error - // We will shut everything down after this. + // In case of network error, we will shut everything down after this. case 'OnFailed': { final error = @@ -244,17 +235,16 @@ class _CallbackHandler { _callBackCompleter!.complete(); } if (_onReadData == null) { - // if callbacks are not registered, stream isn't closed before. So, close here. + // If callbacks are not registered, stream isn't closed before. So, close here. _controller.addError(HttpException(error)); _controller.close(); } else { - // if callback is registed but onFailed callback is not + // If callback is registed but onFailed callback is not. _callBackCompleter!.completeError(HttpException(error)); } } break; - // when the request is cancelled - // We will shut everything down after this. + // when the request is cancelled, we will shut everything down after this. case 'OnCanceled': { cleanUpRequest( @@ -264,16 +254,14 @@ class _CallbackHandler { _onCanceled!(); } if (_onReadData == null) { - // if callbacks are not registered, stream isn't closed before. So, close here. + // If callbacks are not registered, stream isn't closed before. So, close here. _controller.close(); } else { _callBackCompleter!.complete(); } } break; - // when the request is succesfully done - // all the data has received. - // We will shut everything down after this. + // When the request is succesfully done, we will shut everything down after this. case 'OnSucceeded': { cleanUpRequest( @@ -286,7 +274,7 @@ class _CallbackHandler { respInfoPtr)); } if (_onReadData == null) { - // if callbacks are not registered, stream isn't closed before. So, close here. + // If callbacks are not registered, stream isn't closed before. So, close here. _controller.close(); } else { _callBackCompleter!.complete(); diff --git a/lib/src/http_client.dart b/lib/src/http_client.dart index 1a91bf3..eb758cc 100644 --- a/lib/src/http_client.dart +++ b/lib/src/http_client.dart @@ -15,7 +15,7 @@ import 'generated_bindings.dart'; import 'quic_hint.dart'; import 'http_client_request.dart'; -// Cronet library is loaded in global scope +// Cronet library is loaded in global scope. final _cronet = Cronet(loadWrapper()); /// A client that receives content, such as web pages, @@ -28,10 +28,6 @@ final _cronet = Cronet(loadWrapper()); /// For example, you can use the /// [get], [getUrl], [post], and [postUrl] methods for GET and POST requests, respectively. /// -/// -/// TODO: Implement other functions -/// -/// /// Example Usage: /// ```dart /// final client = HttpClient(); @@ -53,11 +49,12 @@ class HttpClient { // TODO: Migrate enableTimelineLogging API here final Pointer _cronetEngine; - // Keep all the request reference in a list so if the client is being explicitly closed, we can clean up the requests. + // Keep all the request reference in a list so if the client is being explicitly closed, + // we can clean up the requests. final _requests = List.empty(growable: true); var _stop = false; - Uri? _temp; + // Uri? _temp; static const int defaultHttpPort = 80; static const int defaultHttpsPort = 443; @@ -71,11 +68,11 @@ class HttpClient { /// 4. [acceptLanguage] - Default - 'en_US' /// 5. [cacheMode] - Choose from [CacheMode]. Default - [CacheMode.inMemory] (TODO) /// 6. [maxCache] - Set maximum cache size in bytes. Set to `null` to let the system decide. Default - `10KB`. (TODO) - /// NOTE: For [CacheMode.inMemory], [maxCache] must not be null. For any other mode, it can be. - /// /// 7. If caches and cookies should persist, provide a directory using [cronetStorage]. Keeping it null will use /// a temporary, non persistant storage. /// + /// NOTE: For [CacheMode.inMemory], [maxCache] must not be null. For any other mode, it can be. + /// /// Throws [CronetException] if [HttpClient] can't be created. /// /// Breaking Changes from `dart:io` based library: @@ -89,11 +86,11 @@ class HttpClient { this.brotli = true, this.acceptLanguage = 'en_US', }) : _cronetEngine = _cronet.Cronet_Engine_Create() { - // Initialize Dart Native API dynamically + // Initialize Dart Native API dynamically. _cronet.InitDartApiDL(NativeApi.initializeApiDLData); _cronet.registerHttpClient(this, _cronetEngine); - // starting the engine with parameters + // Starting the engine with parameters. final engineParams = _cronet.Cronet_EngineParams_Create(); _cronet.Cronet_EngineParams_user_agent_set( engineParams, userAgent.toNativeUtf8().cast()); @@ -133,11 +130,15 @@ class HttpClient { /// Shuts down the HTTP client. /// - /// If [force] is `false` (the default) the HttpClient will be kept alive until all active connections are done. If [force] is `true` any active connections will be closed to immediately release all resources. These closed connections will receive an ~error~ cancel event to indicate that the client was shut down. In both cases trying to establish a new connection after calling close will throw an exception. - /// NOTE: Temporary storage files (cache, cookies and logs if no explicit path is mentioned) are only deleted if you [close] the engine. + /// If [force] is `false` (the default) the HttpClient will be kept alive until all + /// active connections are done. If [force] is `true` any active connections + /// will be closed to immediately release all resources. These closed connections + /// will receive an ~error~ cancel event to indicate that the client was shut down. + /// In both cases trying to establish a new connection after calling close, + /// will throw an exception. void close({bool force = false}) { if (_stop) { - // if already stopped, return immediately + // If already stopped, return immediately. return; } _stop = true; @@ -169,7 +170,8 @@ class HttpClient { }); } - /// Opens a request on the basis of [method], [host], [port] and [path] using GET, PUT, POST, HEAD, PATCH, DELETE method + /// Opens a request on the basis of [method], [host], [port] and [path] using + /// GET, PUT, POST, HEAD, PATCH, DELETE or any other method. /// /// Returns a [Future] of [HttpClientRequest]. Future open( @@ -184,7 +186,7 @@ class HttpClient { return openUrl('GET', url); } - /// Opens a request on the basis of [host], [port] and [path] using GET method + /// Opens a request on the basis of [host], [port] and [path] using GET method. /// /// Returns a [Future] of [HttpClientRequest]. Future get(String host, int port, String path) { @@ -198,7 +200,7 @@ class HttpClient { return openUrl('HEAD', url); } - /// Opens a request on the basis of [host], [port] and [path] using HEAD method + /// Opens a request on the basis of [host], [port] and [path] using HEAD method. /// /// Returns a [Future] of [HttpClientRequest]. Future head(String host, int port, String path) { @@ -212,7 +214,7 @@ class HttpClient { return openUrl('PUT', url); } - /// Opens a request on the basis of [host], [port] and [path] using PUT method + /// Opens a request on the basis of [host], [port] and [path] using PUT method. /// /// Returns a [Future] of [HttpClientRequest]. Future put(String host, int port, String path) { @@ -226,7 +228,7 @@ class HttpClient { return openUrl('POST', url); } - /// Opens a request on the basis of [host], [port] and [path] using POST method + /// Opens a request on the basis of [host], [port] and [path] using POST method. /// /// Returns a [Future] of [HttpClientRequest]. Future post(String host, int port, String path) { @@ -240,7 +242,7 @@ class HttpClient { return openUrl('PATCH', url); } - /// Opens a request on the basis of [host], [port] and [path] using PATCH method + /// Opens a request on the basis of [host], [port] and [path] using PATCH method. /// /// Returns a [Future] of [HttpClientRequest]. Future patch(String host, int port, String path) { @@ -254,16 +256,17 @@ class HttpClient { return openUrl('DELETE', url); } - /// Opens a request on the basis of [host], [port] and [path] using DELETE method + /// Opens a request on the basis of [host], [port] and [path] using DELETE method. /// /// Returns a [Future] of [HttpClientRequest]. Future delete(String host, int port, String path) { return deleteUrl(_getUri(host, port, path)); } - /// Function for resolving the proxy server to be used for a HTTP connection from the proxy configuration specified through environment variables. + /// Function for resolving the proxy server to be used for a HTTP connection from + /// the proxy configuration specified through environment variables. /// - /// Note: It just returns [io.HttpClient.findProxyFromEnvironment]. + /// Note: It just returns `dart:io` [HttpClient.findProxyFromEnvironment]. static String findProxyFromEnvironment(Uri url, {Map? environment}) { return io.HttpClient.findProxyFromEnvironment(url, diff --git a/lib/src/http_client_request.dart b/lib/src/http_client_request.dart index a558bab..49565b0 100644 --- a/lib/src/http_client_request.dart +++ b/lib/src/http_client_request.dart @@ -28,7 +28,7 @@ typedef RedirectReceivedCallback = void Function( String newLocationUrl, int responseCode); typedef ResponseStartedCallback = void Function(int responseCode); typedef ReadDataCallback = void Function(List data, int bytesRead, - int responseCode, Function next); // onReadComplete may confuse people + int responseCode, Function next); // onReadComplete may confuse people. typedef FailedCallabck = void Function(HttpException exception); typedef CanceledCallabck = void Function(); typedef SuccessCallabck = void Function(int responseCode); @@ -36,13 +36,10 @@ typedef SuccessCallabck = void Function(int responseCode); /// HTTP request for a client connection. /// /// It handles all of the Http Requests made by [HttpClient]. -/// /// Provides two ways to get data from the request. /// [registerCallbacks] or a [HttpClientResponse] which is a [Stream>]. -/// /// Either of them can be used at a time. /// -/// /// Example Usage: /// ```dart /// final client = HttpClient(); @@ -54,9 +51,7 @@ typedef SuccessCallabck = void Function(int responseCode); /// // Use it as you like. /// }); /// ``` -/// -/// -/// TODO: Implement other functions +// TODO: Implement other functions class HttpClientRequest implements IOSink { final Uri _uri; final String _method; @@ -64,9 +59,9 @@ class HttpClientRequest implements IOSink { final Pointer _cronetEngine; final _CallbackHandler _cbh; final Pointer _request; - // final Function _clientCleanup; // Holds the function to clean up storage after - // // request is done (if nessesary) - // // implemented in: http_client.dart + // final Function _clientCleanup; // Holds the function to clean up storage after + // // the request is done (if nessesary). + // // implemented in: http_client.dart // TODO: Enable with abort API // bool _isAborted = false; @@ -77,20 +72,19 @@ class HttpClientRequest implements IOSink { @override Encoding encoding; - /// Initiates a [HttpClientRequest]. It is meant to be used by - /// [HttpClient]. Takes in [_uri], [_method], [_cronet] instance + /// Initiates a [HttpClientRequest]. It is meant to be used by a [HttpClient]. HttpClientRequest(this._uri, this._method, this._cronet, this._cronetEngine, // this._clientCleanup, {this.encoding = utf8}) : _cbh = _CallbackHandler(_cronet, _cronet.Create_Executor(), ReceivePort()), _request = _cronet.Cronet_UrlRequest_Create() { - // Register the native port to C side + // Register the native port to C side. _cronet.registerCallbackHandler( _cbh.receivePort.sendPort.nativePort, _request); } - // Starts the request + // Starts the request. void _startRequest() { // TODO: Enable with abort API // if (_isAborted) { @@ -123,13 +117,13 @@ class HttpClientRequest implements IOSink { // _cbh.listen(_request, () => _clientCleanup(this)); } - /// This is one of the methods to get data out of [HttpClientRequest]. - /// Accepted callbacks are [RedirectReceivedCallback], - /// [ResponseStartedCallback], [ReadDataCallback], [FailedCallabck], - /// [CanceledCallabck] and [SuccessCallabck]. + /// Registers callbacks for all network events. /// + /// This is one of the methods to get data out of [HttpClientRequest]. + /// Accepted callbacks are [RedirectReceivedCallback], [ResponseStartedCallback], + /// [ReadDataCallback], [FailedCallabck], [CanceledCallabck] and [SuccessCallabck]. /// Callbacks will be called as per sequence of the events. - ///If callbacks are registered, the [Stream] returned by [close] will be closed. + /// If callbacks are registered, the [Stream] returned by [close] will be closed. Future registerCallbacks(ReadDataCallback onReadData, {RedirectReceivedCallback? onRedirectReceived, ResponseStartedCallback? onResponseStarted, @@ -142,15 +136,11 @@ class HttpClientRequest implements IOSink { return rc; } - /// Returns the [Stream] responsible for - /// emitting data received from the server - /// by cronet. + /// Returns [Future] of [HttpClientResponse] which can be listened for server response. /// /// Throws [Exception] if request is already aborted using [abort]. - /// /// Throws [UrlRequestException] if request can't be initiated. - /// - /// Consumable similar to [HttpClientResponse] + /// Consumable similar to [HttpClientResponse]. @override Future close() { return Future(() { @@ -167,7 +157,6 @@ class HttpClientRequest implements IOSink { /// [StackTrace] is printed. If there is no [StackTrace] provided, /// [StackTrace.empty] will be shown. If no [Exception] is provided, /// no exception is thrown. - /// /// If the [Stream] is closed, aborting has no effect. void abort([Object? exception, StackTrace? stackTrace]) { // TODO: Migrate abort code @@ -204,7 +193,7 @@ class HttpClientRequest implements IOSink { throw UnimplementedError(); } - // Implementation taken from `dart:io` + // Implementation taken from `dart:io`. @override void write(Object? object) { final string = '$object'; @@ -212,7 +201,7 @@ class HttpClientRequest implements IOSink { add(encoding.encode(string)); } - // Implementation taken from `dart:io` + // Implementation taken from `dart:io`. @override void writeAll(Iterable objects, [String separator = '']) { final iterator = objects.iterator; @@ -230,20 +219,20 @@ class HttpClientRequest implements IOSink { } } - // Implementation taken from `dart:io` + // Implementation taken from `dart:io`. @override void writeCharCode(int charCode) { write(String.fromCharCode(charCode)); } - // Implementation taken from `dart:io` + // Implementation taken from `dart:io`. @override void writeln([Object? object = '']) { write(object); write('\n'); } - /// Follow the redirects + /// Follow the redirects. bool get followRedirects => _cbh.followRedirects; set followRedirects(bool follow) { _cbh.followRedirects = follow; diff --git a/lib/src/native/wrapper/BUILD.md b/lib/src/native/wrapper/BUILD.md index 8065c8b..4b88835 100644 --- a/lib/src/native/wrapper/BUILD.md +++ b/lib/src/native/wrapper/BUILD.md @@ -1,34 +1,37 @@ -## Build Guide +# Build Guide Want to build your own? -For building cronet: https://www.chromium.org/developers/how-tos/get-the-code & https://chromium.googlesource.com/chromium/src/+/master/components/cronet/build_instructions.md +For building cronet: & For building wrapper: -From this repository root +*Paths mentioned are relative to project root.* + +## For Linux ```bash cd lib/src/native/wrapper ./build.sh . '"cronet_version"' ``` -Copy the `wrapper` binary to your project's `root` folder. -Copy the cronet's binary to the `cronet_binaries/` folder from project's `root` folder. (Except on Windows. There, everything will be on root dir only) +Copy the `wrapper` binary to your project's `root` folder. +Copy the cronet's binary to the `cronet_binaries/` folder from project's `root` folder. (Except on Windows. There, everything will be on root dir only.) *If you are in 64bit linux system, `cronet_binaries/` will be `cronet_binaries/linux64`.* -### For Windows +## For Windows Required: Visual Studio 2019 with C++ Desktop Development tools. 1. Make sure that you have `cmake` for Visual Studio 2019 is available in your command line. If not, you should open something like `x64 Native Tools Command Prompt for VS 2019` from your start menu which will open a command prompt with required path set. 2. In the command prompt do - -``` -cd \lib\src\native\wrapper -cmake CMakeLists.txt -B out -cmake --build out -``` -3. From there, go to `out\Debug` folder to get `wrapper.dll` + ```dosbatch + cd \lib\src\native\wrapper + cmake CMakeLists.txt -B out + cmake --build out + ``` + +3. From there, go to `out\Debug` folder to get `wrapper.dll` From 30cfbe693152e6de8e34cd540ec53c07f2e7105a Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Sun, 13 Jun 2021 21:25:57 +0530 Subject: [PATCH 05/42] refactor: docs, analysis, license, tests behaviour change: If registerCallbacks & close api is used togather, the later called on will resolve with a RequestListenerException. --- CHANGELOG.md | 6 -- README.md | 21 +++-- analysis_options.yaml | 3 - example/analysis_options.yaml | 0 example/lib/main.dart | 27 +----- example/pubspec.yaml | 1 + example_dart/analysis_options.yaml | 0 example_dart/pubspec.yaml | 3 + lib/src/exceptions.dart | 4 + lib/src/generated_bindings.dart | 7 ++ lib/src/http_callback_handler.dart | 28 +++--- lib/src/http_client_request.dart | 9 +- lib/src/http_client_response.dart | 5 + lib/src/native/wrapper/sample_executor.cc | 8 -- lib/src/native/wrapper/wrapper.cc | 7 -- pubspec.yaml | 35 ++----- test/cronet_test.dart | 56 ++++++------ test/http_client_close_test.dart | 62 ++++++------- test/http_request_exceptions_test.dart | 59 ++++++------ test/http_responses_exceptions_test.dart | 103 +++++++++++---------- test/http_responses_new_api_test.dart | 54 +++++------ test/http_responses_test.dart | 106 +++++++++++----------- 22 files changed, 290 insertions(+), 314 deletions(-) delete mode 100644 example/analysis_options.yaml delete mode 100644 example_dart/analysis_options.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 64c1c4a..34cd56b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,5 @@ ## 0.0.1 -### Partially migrated from unsuitable001/dart_cronet_sample - * HttpClient with QUIC, HTTP2, brotli support. * HttpClient with a customizable user agent string. * HttpClient close method (without force close). @@ -13,7 +11,3 @@ * Custom `SecurityContext` is no longer handled by the client. Users have to handle it in other ways. (To be documented later). * `userAgent` property is now read-only. Custom userAgent should be passed as a constructor argument. - -**Notes:** - -If callback based API is used, `stream` based api (`dart:io` style) will be closed immediately. diff --git a/README.md b/README.md index 6004471..dac56ee 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,18 @@ This is a [GSoC 2021 project](https://summerofcode.withgoogle.com/projects/#4757 2. Run this from the `root` of your project. - Desktop Platforms + **Dart CLI** ```bash - pub get - pub run cronet + dart pub get + dart run cronet # Downloads the cronet binaries. + ``` + + **Flutter** + + ```bash + flutter pub get + flutter run cronet # Downloads the cronet binaries. ``` Supported platforms: `linux64` and `windows64` @@ -68,17 +75,17 @@ This is a [GSoC 2021 project](https://summerofcode.withgoogle.com/projects/#4757 ```bash cd example_dart -pub run cronet +dart run cronet # Downloads the cronet binaries. dart run ``` -replace `` with `linux64` or `windows64` +Replace `` with `linux64` or `windows64` ## Run Tests ```bash -pub get -pub run cronet +dart pub get +dart run cronet # Downloads the cronet binaries. dart test --platform vm ``` diff --git a/analysis_options.yaml b/analysis_options.yaml index 71629fc..93c5024 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -8,6 +8,3 @@ analyzer: strong-mode: implicit-casts: false implicit-dynamic: false - exclude: - - example/lib/main.dart # Ignore placeholder example file. - - lib/src/generated_bindings.dart # Ignore generated files. diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml deleted file mode 100644 index e69de29..0000000 diff --git a/example/lib/main.dart b/example/lib/main.dart index 9e86bdb..89b39a6 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; -import 'dart:async'; -import 'package:flutter/services.dart'; -import 'package:cronet/cronet.dart'; +// import 'package:cronet/cronet.dart'; void main() { runApp(MyApp()); @@ -14,32 +12,11 @@ class MyApp extends StatefulWidget { } class _MyAppState extends State { - String _platformVersion = 'Unknown'; + final _platformVersion = 'Unknown'; @override void initState() { super.initState(); - initPlatformState(); - } - - // Platform messages are asynchronous, so we initialize in an async method. - Future initPlatformState() async { - String platformVersion; - // Platform messages may fail, so we use a try/catch PlatformException. - try { - platformVersion = await Cronet.platformVersion; - } on PlatformException { - platformVersion = 'Failed to get platform version.'; - } - - // If the widget was removed from the tree while the asynchronous platform - // message was in flight, we want to discard the reply rather than calling - // setState to update our non-existent appearance. - if (!mounted) return; - - setState(() { - _platformVersion = platformVersion; - }); } @override diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 4061a12..714ef67 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -27,6 +27,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + lints: ^1.0.1 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/example_dart/analysis_options.yaml b/example_dart/analysis_options.yaml deleted file mode 100644 index e69de29..0000000 diff --git a/example_dart/pubspec.yaml b/example_dart/pubspec.yaml index 6ae5a2c..9d9c44a 100644 --- a/example_dart/pubspec.yaml +++ b/example_dart/pubspec.yaml @@ -9,4 +9,7 @@ environment: dependencies: cronet: path: ../ + +dev_dependencies: + lints: ^1.0.1 # path: ^1.7.0 diff --git a/lib/src/exceptions.dart b/lib/src/exceptions.dart index 9244ec3..e640ac6 100644 --- a/lib/src/exceptions.dart +++ b/lib/src/exceptions.dart @@ -41,3 +41,7 @@ class CronetException implements Exception { class UrlRequestException extends CronetException { const UrlRequestException(int val) : super(val); } + +class ResponseListenerException implements Exception { + ResponseListenerException(); +} diff --git a/lib/src/generated_bindings.dart b/lib/src/generated_bindings.dart index 7b51555..b6ee5df 100644 --- a/lib/src/generated_bindings.dart +++ b/lib/src/generated_bindings.dart @@ -1,3 +1,10 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// ignore_for_file: non_constant_identifier_names, camel_case_types +// ignore_for_file: constant_identifier_names + // AUTO GENERATED FILE, DO NOT EDIT. // // Generated by `package:ffigen`. diff --git a/lib/src/http_callback_handler.dart b/lib/src/http_callback_handler.dart index 19aba94..9be5090 100644 --- a/lib/src/http_callback_handler.dart +++ b/lib/src/http_callback_handler.dart @@ -4,12 +4,12 @@ part of 'http_client_request.dart'; -// Deserializes the message sent by cronet and it's wrapper. +/// Deserializes the message sent by cronet and it's wrapper. class _CallbackRequestMessage { final String method; final Uint8List data; - // Constructs [method] and [data] from [message]. + /// Constructs [method] and [data] from [message]. factory _CallbackRequestMessage.fromCppMessage(List message) { return _CallbackRequestMessage._( message[0] as String, message[1] as Uint8List); @@ -21,8 +21,8 @@ class _CallbackRequestMessage { String toString() => 'CppRequest(method: $method)'; } -// Handles every kind of callbacks that are invoked by messages and -// data that are sent by [NativePort] from native cronet library. +/// Handles every kind of callbacks that are invoked by messages and +/// data that are sent by [NativePort] from native cronet library. class _CallbackHandler { final ReceivePort receivePort; final Cronet cronet; @@ -32,10 +32,10 @@ class _CallbackHandler { bool followRedirects = true; int maxRedirects = 5; - // Stream controller to allow consumption of data like [HttpClientResponse]. + /// Stream controller to allow consumption of data like [HttpClientResponse]. final _controller = StreamController>(); - // If callback based api is used, completes when receiving data is done. + /// If callback based api is used, completes when receiving data is done. Completer? _callBackCompleter; RedirectReceivedCallback? _onRedirectReceived; @@ -45,32 +45,36 @@ class _CallbackHandler { CanceledCallabck? _onCanceled; SuccessCallabck? _onSuccess; - // Registers the [NativePort] to the cronet side. + /// Registers the [NativePort] to the cronet side. _CallbackHandler(this.cronet, this.executor, this.receivePort); + /// [Stream] controller for [HttpClientResponse] Stream> get stream => _controller.stream; /// Sets callbacks that are registered using [HttpClientRequest.registerCallbacks]. /// - /// If called, the [Stream] returned by [HttpClientResponse.close] will be closed. + /// If called, the [StreamController] for [HttpClientRequest.close] will be closed. + /// Resolves with error if [Stream] already has a listener. Future registerCallbacks(ReadDataCallback onReadData, [RedirectReceivedCallback? onRedirectReceived, ResponseStartedCallback? onResponseStarted, FailedCallabck? onFailed, CanceledCallabck? onCanceled, SuccessCallabck? onSuccess]) { + _callBackCompleter = Completer(); + // If stream based api is already under use, resolve with error. + if (_controller.hasListener) { + _callBackCompleter!.completeError(ResponseListenerException()); + } _onRedirectReceived = onRedirectReceived; _onResponseStarted = onResponseStarted; _onReadData = onReadData; - // If callbacks are registered, close the contoller. - // Responsible the sream for close() method (dart:io style API). _controller.close(); _onFailed = onFailed; _onCanceled = onCanceled; _onSuccess = onSuccess; - _callBackCompleter = Completer(); return _callBackCompleter!.future; } @@ -85,7 +89,7 @@ class _CallbackHandler { // cleanUpClient(); } - // Checks status of an URL response. + /// Checks status of an URL response. int statusChecker(Pointer respInfoPtr, int lBound, int uBound, Function callback) { final respCode = diff --git a/lib/src/http_client_request.dart b/lib/src/http_client_request.dart index 49565b0..1773c68 100644 --- a/lib/src/http_client_request.dart +++ b/lib/src/http_client_request.dart @@ -119,11 +119,12 @@ class HttpClientRequest implements IOSink { /// Registers callbacks for all network events. /// + /// Throws [Exception] if callbacks are registered after listening to response [Stream]. + /// /// This is one of the methods to get data out of [HttpClientRequest]. /// Accepted callbacks are [RedirectReceivedCallback], [ResponseStartedCallback], /// [ReadDataCallback], [FailedCallabck], [CanceledCallabck] and [SuccessCallabck]. /// Callbacks will be called as per sequence of the events. - /// If callbacks are registered, the [Stream] returned by [close] will be closed. Future registerCallbacks(ReadDataCallback onReadData, {RedirectReceivedCallback? onRedirectReceived, ResponseStartedCallback? onResponseStarted, @@ -138,12 +139,16 @@ class HttpClientRequest implements IOSink { /// Returns [Future] of [HttpClientResponse] which can be listened for server response. /// - /// Throws [Exception] if request is already aborted using [abort]. + /// Throws [Exception] if callback based api is in use. /// Throws [UrlRequestException] if request can't be initiated. /// Consumable similar to [HttpClientResponse]. @override Future close() { return Future(() { + // If callback based API is being used, throw Exception. + if (_cbh._onReadData != null) { + throw ResponseListenerException(); + } _startRequest(); return HttpClientResponse._(_cbh.stream); }); diff --git a/lib/src/http_client_response.dart b/lib/src/http_client_response.dart index 236c49f..bf2cc95 100644 --- a/lib/src/http_client_response.dart +++ b/lib/src/http_client_response.dart @@ -4,6 +4,8 @@ part of '../src/http_client_request.dart'; +/// The body of a [HttpClientResponse] object is a [Stream] of data from the server. +/// Listen to the body to handle the data and be notified when the entire body is received. abstract class HttpClientResponse extends Stream> { HttpClientResponse(); @@ -12,6 +14,9 @@ abstract class HttpClientResponse extends Stream> { } } +/// Implementation of [HttpClientResponse]. +/// +/// Takes instance of callback handler and registers [listen] callbacks to the stream. class _HttpClientResponse extends HttpClientResponse { final Stream> cbhStream; _HttpClientResponse(this.cbhStream); diff --git a/lib/src/native/wrapper/sample_executor.cc b/lib/src/native/wrapper/sample_executor.cc index 6ca3559..3416c3f 100644 --- a/lib/src/native/wrapper/sample_executor.cc +++ b/lib/src/native/wrapper/sample_executor.cc @@ -27,7 +27,6 @@ IMPORT(Cronet_ClientContext, Cronet_Executor_GetClientContext, Cronet_ExecutorPt SampleExecutor::SampleExecutor() : executor_thread_(SampleExecutor::ThreadLoop, this) {} SampleExecutor::~SampleExecutor() { - std::cout << "SampleExec Destructor" << std::endl; ShutdownExecutor(); Cronet_Executor_Destroy(executor_); } @@ -41,7 +40,6 @@ Cronet_ExecutorPtr SampleExecutor::GetExecutor() { return executor_; } void SampleExecutor::ShutdownExecutor() { - printf("Executor shut down\n"); // Break tasks loop. { std::lock_guard lock(lock_); @@ -52,25 +50,20 @@ void SampleExecutor::ShutdownExecutor() { executor_thread_.join(); } void SampleExecutor::RunTasksInQueue() { - printf("Running tasks"); // Process runnables in |task_queue_|. while (true) { - printf("loop\n"); Cronet_RunnablePtr runnable = nullptr; { // Wait for a task to run or stop signal. std::unique_lock lock(lock_); while (task_queue_.empty() && !stop_thread_loop_) { - printf("waiting\n"); task_available_.wait(lock); } if (stop_thread_loop_) { - printf("stop thread\n"); break; } if (task_queue_.empty()) { - printf("task queue empty\n"); continue; } runnable = task_queue_.front(); @@ -96,7 +89,6 @@ void SampleExecutor::ThreadLoop(SampleExecutor* executor) { executor->RunTasksInQueue(); } void SampleExecutor::Execute(Cronet_RunnablePtr runnable) { - // printf("Execute\n"); { std::lock_guard lock(lock_); if (!stop_thread_loop_) { diff --git a/lib/src/native/wrapper/wrapper.cc b/lib/src/native/wrapper/wrapper.cc index aa9c60d..b2edf1c 100644 --- a/lib/src/native/wrapper/wrapper.cc +++ b/lib/src/native/wrapper/wrapper.cc @@ -31,7 +31,6 @@ //////////////////////////////////////////////////////////////////////////////// // Initialize `dart_api_dl.h` intptr_t InitDartApiDL(void* data) { - printf("Initializing"); return Dart_InitializeApiDL(data); } @@ -201,7 +200,6 @@ void Cronet_Engine_StopNetLog(Cronet_EnginePtr self) {return _Cronet_Engine_Stop /* Engine Cleanup Tasks */ static void HttpClientDestroy(void* isolate_callback_data, void* peer) { - std::cout << "Engine Destroy" << std::endl; Cronet_EnginePtr ce = reinterpret_cast(peer); _Cronet_Engine_Shutdown(ce); _Cronet_Engine_Destroy(ce); @@ -270,8 +268,6 @@ void OnReadCompleted( void OnSucceeded(Cronet_UrlRequestCallbackPtr self, Cronet_UrlRequestPtr request, Cronet_UrlResponseInfoPtr info) { - printf("OnSucceeded"); - std::cout << "OnSucceeded called." << std::endl; dispatchCallback("OnSucceeded",request, callbackArgBuilder(1, info)); } @@ -280,7 +276,6 @@ void OnFailed( Cronet_UrlRequestPtr request, Cronet_UrlResponseInfoPtr info, Cronet_ErrorPtr error) { - printf("OnFailed"); dispatchCallback("OnFailed",request, callbackArgBuilder(1, _Cronet_Error_message_get(error))); } @@ -288,7 +283,6 @@ void OnCanceled( Cronet_UrlRequestCallbackPtr self, Cronet_UrlRequestPtr request, Cronet_UrlResponseInfoPtr info) { - printf("OnCanceled"); dispatchCallback("OnCanceled",request, callbackArgBuilder(0)); } @@ -296,7 +290,6 @@ void OnCanceled( /* Interface */ Cronet_EnginePtr Cronet_Engine_Create() { - printf("Cronet_Engine_Create"); // Checks if cronet is loaded properly // As this is the first function to call, // if this succeeds, every subsequent use diff --git a/pubspec.yaml b/pubspec.yaml index 95d1bf2..78313d5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -62,33 +62,10 @@ ffigen: - '-Ilib/src/native/include/dart/' - '-Ilib/src/native/include/cronet/' - '-DDART_SHARED_LIB' - # To add assets to your plugin package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware. + preamble: | + // Copyright 2017 The Chromium Authors. All rights reserved. + // Use of this source code is governed by a BSD-style license that can be + // found in the LICENSE file. - # To add custom fonts to your plugin package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages + // ignore_for_file: non_constant_identifier_names, camel_case_types + // ignore_for_file: constant_identifier_names diff --git a/test/cronet_test.dart b/test/cronet_test.dart index 7cff67b..7b3bcbc 100644 --- a/test/cronet_test.dart +++ b/test/cronet_test.dart @@ -8,32 +8,34 @@ import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; void main() { - late HttpClient client; - setUp(() { - client = HttpClient(); - }); - - test('Validate static constants', () { - expect(80, equals(HttpClient.defaultHttpPort)); - expect(443, equals(HttpClient.defaultHttpsPort)); - }); - - test('Loads cronet engine and gets the version string', () { - expect(client.httpClientVersion, TypeMatcher()); - }); - - test('Gets the user agent', () { - expect(client.userAgent, equals('Dart/2.12')); - }); - - test('Loads another cronet engine with different config', () { - final client2 = HttpClient(userAgent: 'Dart_Test/1.0'); - expect(client2, TypeMatcher()); - expect(client2.userAgent, equals('Dart_Test/1.0')); - client2.close(); - }); - - tearDown(() { - client.close(); + group('cronet_initialization_test', () { + late HttpClient client; + setUp(() { + client = HttpClient(); + }); + + test('Validate static constants', () { + expect(80, equals(HttpClient.defaultHttpPort)); + expect(443, equals(HttpClient.defaultHttpsPort)); + }); + + test('Gets the version string', () { + expect(client.httpClientVersion, TypeMatcher()); + }); + + test('Gets the user agent', () { + expect(client.userAgent, equals('Dart/2.12')); + }); + + test('Loads another cronet engine with different config', () { + final client2 = HttpClient(userAgent: 'Dart_Test/1.0'); + expect(client2, TypeMatcher()); + expect(client2.userAgent, equals('Dart_Test/1.0')); + client2.close(); + }); + + tearDown(() { + client.close(); + }); }); } diff --git a/test/http_client_close_test.dart b/test/http_client_close_test.dart index 278a7f0..1c80c5d 100644 --- a/test/http_client_close_test.dart +++ b/test/http_client_close_test.dart @@ -8,41 +8,39 @@ import 'dart:io'; import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; -int main() { - late HttpServer server; - final sentData = 'Hello, world!'; - setUp(() async { - server = await HttpServer.bind(InternetAddress.anyIPv6, 5253); - server.listen((HttpRequest request) { - request.response.write(sentData); - request.response.close(); +void main() { + group('client_close_test', () { + late HttpServer server; + final sentData = 'Hello, world!'; + setUp(() async { + server = await HttpServer.bind(InternetAddress.anyIPv6, 5253); + server.listen((HttpRequest request) { + request.response.write(sentData); + request.response.close(); + }); }); - }); - test('Opening new request after client close throws exception', () async { - final client = HttpClient(); - client.close(); - expect( - () async => - await client.openUrl('GET', Uri.parse('http://localhost:5253')), - throwsException); - }); + test('Opening new request afterwards throws exception', () async { + final client = HttpClient(); + client.close(); + expect( + () async => + await client.openUrl('GET', Uri.parse('http://localhost:5253')), + throwsException); + }); - test( - 'Closing the HttpClient after starting a request keeps the previous connection alive', - () async { - final client = HttpClient(); - final request = - await client.openUrl('GET', Uri.parse('http://localhost:5253')); - final resp = await request.close(); - client.close(); - final dataStream = resp.transform(utf8.decoder); - expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); - }); + test('Keeps the previous connection alive, if closed afterwards', () async { + final client = HttpClient(); + final request = + await client.openUrl('GET', Uri.parse('http://localhost:5253')); + final resp = await request.close(); + client.close(); + final dataStream = resp.transform(utf8.decoder); + expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); + }); - tearDown(() { - server.close(); + tearDown(() { + server.close(); + }); }); - - return 0; } diff --git a/test/http_request_exceptions_test.dart b/test/http_request_exceptions_test.dart index d1d6dba..f286e17 100644 --- a/test/http_request_exceptions_test.dart +++ b/test/http_request_exceptions_test.dart @@ -7,38 +7,39 @@ import 'dart:io'; import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; -int main() { - late HttpClient client; - setUp(() async { - client = HttpClient(); - }); +void main() { + group('request_HttpException_test', () { + late HttpClient client; + setUp(() async { + client = HttpClient(); + }); - test('Throws HttpException if url do not exist', () async { - final request = await client.openUrl('GET', - Uri.parse('http://localghost:9999')); // localghost shouln't exist :p - final resp = await request.close(); - expect(resp, - emitsInOrder([emitsError(isA()), emitsDone])); - }); + test('URL do not exist', () async { + final request = await client.openUrl('GET', + Uri.parse('http://localghost:9999')); // localghost shouln't exist :p + final resp = await request.close(); + expect(resp, + emitsInOrder([emitsError(isA()), emitsDone])); + }); - test('Throws HttpException if the port is wrong', () async { - final request = await client.openUrl( - 'GET', Uri.parse('http://localhost:9999')); // port 9999 should be close - final resp = await request.close(); - expect(resp, - emitsInOrder([emitsError(isA()), emitsDone])); - }); + test('The port is wrong', () async { + final request = await client.openUrl('GET', + Uri.parse('http://localhost:9999')); // port 9999 should be close + final resp = await request.close(); + expect(resp, + emitsInOrder([emitsError(isA()), emitsDone])); + }); - test('Throws HttpException if the scheme is wrong', () async { - final request = - await client.openUrl('GET', Uri.parse('random://localhost:5253')); - final resp = await request.close(); - expect(resp, - emitsInOrder([emitsError(isA()), emitsDone])); - }); + test('The scheme is wrong', () async { + final request = + await client.openUrl('GET', Uri.parse('random://localhost:5253')); + final resp = await request.close(); + expect(resp, + emitsInOrder([emitsError(isA()), emitsDone])); + }); - tearDown(() { - client.close(); + tearDown(() { + client.close(); + }); }); - return 0; } diff --git a/test/http_responses_exceptions_test.dart b/test/http_responses_exceptions_test.dart index 17eba4f..a69f204 100644 --- a/test/http_responses_exceptions_test.dart +++ b/test/http_responses_exceptions_test.dart @@ -8,60 +8,63 @@ import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; void main() { - late HttpClient client; - late HttpServer server; - setUp(() async { - client = HttpClient(); - server = await HttpServer.bind(InternetAddress.anyIPv6, 5255); - server.listen((HttpRequest request) { - final paths = request.uri.pathSegments; - request.response.statusCode = int.parse(paths[0]); - request.response.close(); + group('response_HttpException_test', () { + late HttpClient client; + late HttpServer server; + setUp(() async { + client = HttpClient(); + server = await HttpServer.bind(InternetAddress.anyIPv6, 5255); + server.listen((HttpRequest request) { + final paths = request.uri.pathSegments; + request.response.statusCode = int.parse(paths[0]); + request.response.close(); + }); }); - }); - test('Throws a HttpException: Not Found when status code is 404', () async { - final request = await client.getUrl(Uri.parse('http://localhost:5255/404')); - final resp = await request.close(); - expect( - resp, - emitsInOrder([ - emitsError(isA().having( - (exception) => exception.message, 'message', 'Not Found')), - emitsDone - ])); - }); + test('404, Not Found', () async { + final request = + await client.getUrl(Uri.parse('http://localhost:5255/404')); + final resp = await request.close(); + expect( + resp, + emitsInOrder([ + emitsError(isA().having( + (exception) => exception.message, 'message', 'Not Found')), + emitsDone + ])); + }); - test('Throws a HttpException: Unauthorized when status code is 401', - () async { - final request = await client.getUrl(Uri.parse('http://localhost:5255/401')); - final resp = await request.close(); - expect( - resp, - emitsInOrder([ - emitsError(isA().having( - (exception) => exception.message, 'message', 'Unauthorized')), - emitsDone - ])); - }); + test('401, Unauthorized', () async { + final request = + await client.getUrl(Uri.parse('http://localhost:5255/401')); + final resp = await request.close(); + expect( + resp, + emitsInOrder([ + emitsError(isA().having( + (exception) => exception.message, 'message', 'Unauthorized')), + emitsDone + ])); + }); - test('Throws a HttpException: Service Unavailable when status code is 503', - () async { - final request = await client.getUrl(Uri.parse('http://localhost:5255/503')); - final resp = await request.close(); - expect( - resp, - emitsInOrder([ - emitsError(isA().having( - (exception) => exception.message, - 'message', - 'Service Unavailable')), - emitsDone - ])); - }); + test('503, Service Unavailable', () async { + final request = + await client.getUrl(Uri.parse('http://localhost:5255/503')); + final resp = await request.close(); + expect( + resp, + emitsInOrder([ + emitsError(isA().having( + (exception) => exception.message, + 'message', + 'Service Unavailable')), + emitsDone + ])); + }); - tearDown(() { - client.close(); - server.close(); + tearDown(() { + client.close(); + server.close(); + }); }); } diff --git a/test/http_responses_new_api_test.dart b/test/http_responses_new_api_test.dart index 863f49b..2dcaef4 100644 --- a/test/http_responses_new_api_test.dart +++ b/test/http_responses_new_api_test.dart @@ -9,35 +9,37 @@ import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; void main() { - late HttpClient client; - late HttpServer server; - final sentData = 'Hello, world!'; - setUp(() async { - client = HttpClient(); - server = await HttpServer.bind(InternetAddress.anyIPv6, 5256); - server.listen((HttpRequest request) { - if (request.method == 'CUSTOM') { - request.response.write(request.method); - } else { - request.response.write(sentData); - } - request.response.close(); + group('callback_api_response_test', () { + late HttpClient client; + late HttpServer server; + final sentData = 'Hello, world!'; + setUp(() async { + client = HttpClient(); + server = await HttpServer.bind(InternetAddress.anyIPv6, 5256); + server.listen((HttpRequest request) { + if (request.method == 'CUSTOM') { + request.response.write(request.method); + } else { + request.response.write(sentData); + } + request.response.close(); + }); }); - }); - test('New API: Gets Hello, world response from server using getUrl', - () async { - String resp = ''; - final request = await client.getUrl(Uri.parse('http://localhost:5256')); - await request.registerCallbacks((data, bytesRead, responseCode, next) { - resp += utf8.decoder.convert(data); - next(); + test('New API: Gets Hello, world response from server using getUrl', + () async { + String resp = ''; + final request = await client.getUrl(Uri.parse('http://localhost:5256')); + await request.registerCallbacks((data, bytesRead, responseCode, next) { + resp += utf8.decoder.convert(data); + next(); + }); + expect(resp, equals(sentData)); }); - expect(resp, equals(sentData)); - }); - tearDown(() { - client.close(); - server.close(); + tearDown(() { + client.close(); + server.close(); + }); }); } diff --git a/test/http_responses_test.dart b/test/http_responses_test.dart index 9efb7c5..c4c9e7b 100644 --- a/test/http_responses_test.dart +++ b/test/http_responses_test.dart @@ -9,63 +9,67 @@ import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; void main() { - late HttpClient client; - late HttpServer server; - final sentData = 'Hello, world!'; - setUp(() async { - client = HttpClient(); - server = await HttpServer.bind(InternetAddress.anyIPv6, 5252); - server.listen((HttpRequest request) { - if (request.method == 'CUSTOM') { - request.response.write(request.method); - } else { - request.response.write(sentData); - } - request.response.close(); + group('http_responses_test', () { + late HttpClient client; + late HttpServer server; + final sentData = 'Hello, world!'; + setUp(() async { + client = HttpClient(); + server = await HttpServer.bind(InternetAddress.anyIPv6, 5252); + server.listen((HttpRequest request) { + if (request.method == 'CUSTOM') { + request.response.write(request.method); + } else { + request.response.write(sentData); + } + request.response.close(); + }); }); - }); - test('Gets Hello, world response from server using getUrl', () async { - final request = await client.getUrl(Uri.parse('http://localhost:5252')); - final resp = await request.close(); - final dataStream = resp.transform(utf8.decoder); - expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); - }); + test('Gets Hello, world response from server using getUrl', () async { + final request = await client.getUrl(Uri.parse('http://localhost:5252')); + final resp = await request.close(); + final dataStream = resp.transform(utf8.decoder); + expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); + }); - test('Gets Hello, world response from server using get method', () async { - final request = await client.get('localhost', 5252, '/'); - final resp = await request.close(); - final dataStream = resp.transform(utf8.decoder); - expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); - }); + test('Gets Hello, world response from server using get method', () async { + final request = await client.get('localhost', 5252, '/'); + final resp = await request.close(); + final dataStream = resp.transform(utf8.decoder); + expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); + }); - test('Gets Hello, world response from server using openUrl method', () async { - final request = - await client.openUrl('GET', Uri.parse('http://localhost:5252')); - final resp = await request.close(); - final dataStream = resp.transform(utf8.decoder); - expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); - }); + test('Gets Hello, world response from server using openUrl method', + () async { + final request = + await client.openUrl('GET', Uri.parse('http://localhost:5252')); + final resp = await request.close(); + final dataStream = resp.transform(utf8.decoder); + expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); + }); - test( - 'Fetch Hello, world response from server using openUrl, custom method method', - () async { - final request = - await client.openUrl('CUSTOM', Uri.parse('http://localhost:5252')); - final resp = await request.close(); - final dataStream = resp.transform(utf8.decoder); - expect(dataStream, emitsInOrder([equals('CUSTOM'), emitsDone])); - }); + test( + 'Fetch Hello, world response from server using openUrl, custom method method', + () async { + final request = + await client.openUrl('CUSTOM', Uri.parse('http://localhost:5252')); + final resp = await request.close(); + final dataStream = resp.transform(utf8.decoder); + expect(dataStream, emitsInOrder([equals('CUSTOM'), emitsDone])); + }); - test('Fetch Hello, world response from server using POST request', () async { - final request = await client.postUrl(Uri.parse('http://localhost:5252')); - final resp = await request.close(); - final dataStream = resp.transform(utf8.decoder); - expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); - }); + test('Fetch Hello, world response from server using POST request', + () async { + final request = await client.postUrl(Uri.parse('http://localhost:5252')); + final resp = await request.close(); + final dataStream = resp.transform(utf8.decoder); + expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); + }); - tearDown(() { - client.close(); - server.close(); + tearDown(() { + client.close(); + server.close(); + }); }); } From 1ba712d65f17df5851fb0f2d0cf2b7588c072f22 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Mon, 14 Jun 2021 10:35:06 +0530 Subject: [PATCH 06/42] api change: registerCallback's future resolves `bool` and readDataCallback's `next` callback is removed. It is now called directly. refactor: docs and cleaned api detection --- README.md | 11 ++-- example_dart/bin/example_dart.dart | 8 +-- lib/src/http_callback_handler.dart | 86 ++++++++++++++------------- lib/src/http_client_request.dart | 24 +++++++- lib/src/native/wrapper/BUILD.md | 8 +-- test/http_responses_new_api_test.dart | 3 +- 6 files changed, 80 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index dac56ee..96ba4cd 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ This is a [GSoC 2021 project](https://summerofcode.withgoogle.com/projects/#4757 flutter run cronet # Downloads the cronet binaries. ``` - Supported platforms: `linux64` and `windows64` + Supported platforms: `linux64` and `windows64`. 3. Import @@ -32,7 +32,7 @@ This is a [GSoC 2021 project](https://summerofcode.withgoogle.com/projects/#4757 import 'package:cronet/cronet.dart'; ``` -**Note:** Internet connection is required to download cronet binaries +**Note:** Internet connection is required to download cronet binaries. ## Example @@ -60,14 +60,13 @@ This is a [GSoC 2021 project](https://summerofcode.withgoogle.com/projects/#4757 client .getUrl(Uri.parse('http://info.cern.ch/')) .then((HttpClientRequest request) { - request.registerCallbacks((data, bytesRead, responseCode, next) { + request.registerCallbacks((data, bytesRead, responseCode) { print(utf8.decoder.convert(data)); print('Status: $responseCode'); - next(); }, onSuccess: (responseCode) => print('Done with status: $responseCode')).catchError( - (e) => print(e)); + (Object e) {print(e);}); }); ``` @@ -79,7 +78,7 @@ dart run cronet # Downloads the cronet binaries. dart run ``` -Replace `` with `linux64` or `windows64` +Replace `` with `linux64` or `windows64`. ## Run Tests diff --git a/example_dart/bin/example_dart.dart b/example_dart/bin/example_dart.dart index 4fd2f46..6b06ce7 100644 --- a/example_dart/bin/example_dart.dart +++ b/example_dart/bin/example_dart.dart @@ -31,13 +31,13 @@ void main(List args) { client2 .getUrl(Uri.parse('http://info.cern.ch/')) .then((HttpClientRequest request) { - request.registerCallbacks((data, bytesRead, responseCode, next) { + request.registerCallbacks((data, bytesRead, responseCode) { print(utf8.decoder.convert(data)); print('Status: $responseCode'); - next(); }, onSuccess: (responseCode) => - print('Done with status: $responseCode')).catchError( - (Object e) => print(e)); + print('Done with status: $responseCode')).catchError((Object e) { + print(e); + }); }); } diff --git a/lib/src/http_callback_handler.dart b/lib/src/http_callback_handler.dart index 9be5090..67f4efe 100644 --- a/lib/src/http_callback_handler.dart +++ b/lib/src/http_callback_handler.dart @@ -36,7 +36,10 @@ class _CallbackHandler { final _controller = StreamController>(); /// If callback based api is used, completes when receiving data is done. - Completer? _callBackCompleter; + Completer? _callBackCompleter; + + /// Whether callback based api is being used. + bool _newApi = false; RedirectReceivedCallback? _onRedirectReceived; ResponseStartedCallback? _onResponseStarted; @@ -55,17 +58,19 @@ class _CallbackHandler { /// /// If called, the [StreamController] for [HttpClientRequest.close] will be closed. /// Resolves with error if [Stream] already has a listener. - Future registerCallbacks(ReadDataCallback onReadData, + Future registerCallbacks(ReadDataCallback onReadData, [RedirectReceivedCallback? onRedirectReceived, ResponseStartedCallback? onResponseStarted, FailedCallabck? onFailed, CanceledCallabck? onCanceled, SuccessCallabck? onSuccess]) { - _callBackCompleter = Completer(); + _callBackCompleter = Completer(); // If stream based api is already under use, resolve with error. if (_controller.hasListener) { _callBackCompleter!.completeError(ResponseListenerException()); + return _callBackCompleter!.future; } + _newApi = true; _onRedirectReceived = onRedirectReceived; _onResponseStarted = onResponseStarted; _onReadData = onReadData; @@ -75,6 +80,7 @@ class _CallbackHandler { _onFailed = onFailed; _onCanceled = onCanceled; _onSuccess = onSuccess; + return _callBackCompleter!.future; } @@ -177,10 +183,9 @@ class _CallbackHandler { break; // Read a chunk of data. // - // This is where we actually read the response from the server. - // Data gets added to the stream here. - // ReadDataCallback is invoked here with data received, no of bytes read, - // and a function which can be called to continue reading. + // This is where we actually read the response from the server. Data gets added + // to the stream here. ReadDataCallback is invoked here with data received and no + // of bytes read. case 'OnReadCompleted': { final request = Pointer.fromAddress(args[0]); @@ -202,16 +207,14 @@ class _CallbackHandler { // Invoke the callback. if (_onReadData != null) { - _onReadData!(data.toList(growable: false), bytesRead, respCode, - () { - final res = cronet.Cronet_UrlRequest_Read(request, buffer); - if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { - cleanUpRequest( - reqPtr, - ); - _callBackCompleter!.completeError(UrlRequestException(res)); - } - }); + _onReadData!(data.toList(growable: false), bytesRead, respCode); + final res = cronet.Cronet_UrlRequest_Read(request, buffer); + if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { + cleanUpRequest( + reqPtr, + ); + _callBackCompleter!.completeError(UrlRequestException(res)); + } } else { // Or, add data to the stream. _controller.sink.add(data.toList(growable: false)); @@ -234,17 +237,18 @@ class _CallbackHandler { cleanUpRequest( reqPtr, ); - if (_onFailed != null) { - _onFailed!(HttpException(error)); - _callBackCompleter!.complete(); - } - if (_onReadData == null) { - // If callbacks are not registered, stream isn't closed before. So, close here. + + if (_newApi) { + if (_onFailed != null) { + _onFailed!(HttpException(error)); + _callBackCompleter!.complete(false); + } else { + // If callback is registed but onFailed callback is not. + _callBackCompleter!.completeError(HttpException(error)); + } + } else { _controller.addError(HttpException(error)); _controller.close(); - } else { - // If callback is registed but onFailed callback is not. - _callBackCompleter!.completeError(HttpException(error)); } } break; @@ -254,14 +258,14 @@ class _CallbackHandler { cleanUpRequest( reqPtr, ); - if (_onCanceled != null) { - _onCanceled!(); - } - if (_onReadData == null) { + if (_newApi) { + if (_onCanceled != null) { + _onCanceled!(); + } + _callBackCompleter!.complete(false); + } else { // If callbacks are not registered, stream isn't closed before. So, close here. _controller.close(); - } else { - _callBackCompleter!.complete(); } } break; @@ -271,17 +275,17 @@ class _CallbackHandler { cleanUpRequest( reqPtr, ); - if (_onSuccess != null) { - final respInfoPtr = - Pointer.fromAddress(args[0]).cast(); - _onSuccess!(cronet.Cronet_UrlResponseInfo_http_status_code_get( - respInfoPtr)); - } - if (_onReadData == null) { + if (_newApi) { + if (_onSuccess != null) { + final respInfoPtr = + Pointer.fromAddress(args[0]).cast(); + _onSuccess!(cronet.Cronet_UrlResponseInfo_http_status_code_get( + respInfoPtr)); + } + _callBackCompleter!.complete(true); + } else { // If callbacks are not registered, stream isn't closed before. So, close here. _controller.close(); - } else { - _callBackCompleter!.complete(); } } break; diff --git a/lib/src/http_client_request.dart b/lib/src/http_client_request.dart index 1773c68..c8c5c26 100644 --- a/lib/src/http_client_request.dart +++ b/lib/src/http_client_request.dart @@ -24,13 +24,30 @@ part 'http_client_response.dart'; part 'http_callback_handler.dart'; // Type definitions for various callbacks + +/// Called when a redirect is received. Gets new location and response code as +/// arguments. typedef RedirectReceivedCallback = void Function( String newLocationUrl, int responseCode); + +/// Called when server sends a response for the first time. Gets the response code +/// as an argument. typedef ResponseStartedCallback = void Function(int responseCode); + +/// Called when a chunk of data is received from the server. Gets raw bytes as +/// [List], number of bytes read and response code as arguments. typedef ReadDataCallback = void Function(List data, int bytesRead, - int responseCode, Function next); // onReadComplete may confuse people. + int responseCode); // onReadComplete may confuse people. + +/// Called when request is failed due to some reason. Gets [HttpException] as +/// an argument which also contains the reason of failure. typedef FailedCallabck = void Function(HttpException exception); + +/// Called when a request is cancelled. typedef CanceledCallabck = void Function(); + +/// Called when a request is finished with success. Gets the response code as +/// an argument. typedef SuccessCallabck = void Function(int responseCode); /// HTTP request for a client connection. @@ -120,12 +137,13 @@ class HttpClientRequest implements IOSink { /// Registers callbacks for all network events. /// /// Throws [Exception] if callbacks are registered after listening to response [Stream]. + /// Resolves with `true` if request finished successfully and `false` otherwise. /// /// This is one of the methods to get data out of [HttpClientRequest]. /// Accepted callbacks are [RedirectReceivedCallback], [ResponseStartedCallback], /// [ReadDataCallback], [FailedCallabck], [CanceledCallabck] and [SuccessCallabck]. /// Callbacks will be called as per sequence of the events. - Future registerCallbacks(ReadDataCallback onReadData, + Future registerCallbacks(ReadDataCallback onReadData, {RedirectReceivedCallback? onRedirectReceived, ResponseStartedCallback? onResponseStarted, FailedCallabck? onFailed, @@ -146,7 +164,7 @@ class HttpClientRequest implements IOSink { Future close() { return Future(() { // If callback based API is being used, throw Exception. - if (_cbh._onReadData != null) { + if (_cbh._newApi) { throw ResponseListenerException(); } _startRequest(); diff --git a/lib/src/native/wrapper/BUILD.md b/lib/src/native/wrapper/BUILD.md index 4b88835..a529f1a 100644 --- a/lib/src/native/wrapper/BUILD.md +++ b/lib/src/native/wrapper/BUILD.md @@ -4,11 +4,11 @@ Want to build your own? For building cronet: & -For building wrapper: +## For building wrapper *Paths mentioned are relative to project root.* -## For Linux +### For Linux ```bash cd lib/src/native/wrapper @@ -20,7 +20,7 @@ Copy the cronet's binary to the `cronet_binaries/` folder from p *If you are in 64bit linux system, `cronet_binaries/` will be `cronet_binaries/linux64`.* -## For Windows +### For Windows Required: Visual Studio 2019 with C++ Desktop Development tools. @@ -34,4 +34,4 @@ Required: Visual Studio 2019 with C++ Desktop Development tools. cmake --build out ``` -3. From there, go to `out\Debug` folder to get `wrapper.dll` +3. From there, go to `out\Debug` folder to get `wrapper.dll`. diff --git a/test/http_responses_new_api_test.dart b/test/http_responses_new_api_test.dart index 2dcaef4..e873820 100644 --- a/test/http_responses_new_api_test.dart +++ b/test/http_responses_new_api_test.dart @@ -30,9 +30,8 @@ void main() { () async { String resp = ''; final request = await client.getUrl(Uri.parse('http://localhost:5256')); - await request.registerCallbacks((data, bytesRead, responseCode, next) { + await request.registerCallbacks((data, bytesRead, responseCode) { resp += utf8.decoder.convert(data); - next(); }); expect(resp, equals(sentData)); }); From a218ac4b23dd528959db29faf8ccde53d4e206da Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Tue, 15 Jun 2021 11:21:27 +0530 Subject: [PATCH 07/42] tests & bug fix: http response callback api --- lib/src/http_callback_handler.dart | 28 +++++++----- lib/src/http_client_request.dart | 5 ++- test/http_responses_exceptions_test.dart | 13 ++++++ test/http_responses_new_api_test.dart | 54 +++++++++++++++++++++--- test/http_responses_test.dart | 7 +++ 5 files changed, 90 insertions(+), 17 deletions(-) diff --git a/lib/src/http_callback_handler.dart b/lib/src/http_callback_handler.dart index 67f4efe..a3bc2e8 100644 --- a/lib/src/http_callback_handler.dart +++ b/lib/src/http_callback_handler.dart @@ -34,13 +34,11 @@ class _CallbackHandler { /// Stream controller to allow consumption of data like [HttpClientResponse]. final _controller = StreamController>(); + bool _isStreamClaimed = false; // Stream instance should be claimed once. /// If callback based api is used, completes when receiving data is done. Completer? _callBackCompleter; - /// Whether callback based api is being used. - bool _newApi = false; - RedirectReceivedCallback? _onRedirectReceived; ResponseStartedCallback? _onResponseStarted; ReadDataCallback? _onReadData; @@ -52,7 +50,13 @@ class _CallbackHandler { _CallbackHandler(this.cronet, this.executor, this.receivePort); /// [Stream] controller for [HttpClientResponse] - Stream> get stream => _controller.stream; + Stream> get stream { + if (_isStreamClaimed) { + throw ResponseListenerException(); + } + _isStreamClaimed = true; + return _controller.stream; + } /// Sets callbacks that are registered using [HttpClientRequest.registerCallbacks]. /// @@ -66,11 +70,10 @@ class _CallbackHandler { SuccessCallabck? onSuccess]) { _callBackCompleter = Completer(); // If stream based api is already under use, resolve with error. - if (_controller.hasListener) { + if (_isStreamClaimed) { _callBackCompleter!.completeError(ResponseListenerException()); return _callBackCompleter!.future; } - _newApi = true; _onRedirectReceived = onRedirectReceived; _onResponseStarted = onResponseStarted; _onReadData = onReadData; @@ -110,7 +113,12 @@ class _CallbackHandler { if (_callBackCompleter != null) { // If callbacks are registered. - _callBackCompleter!.completeError(exception); + if (_onFailed != null) { + _onFailed!(exception); + _callBackCompleter!.complete(false); + } else { + _callBackCompleter!.completeError(exception); + } } else { _controller.addError(exception); _controller.close(); @@ -238,7 +246,7 @@ class _CallbackHandler { reqPtr, ); - if (_newApi) { + if (_callBackCompleter != null) { if (_onFailed != null) { _onFailed!(HttpException(error)); _callBackCompleter!.complete(false); @@ -258,7 +266,7 @@ class _CallbackHandler { cleanUpRequest( reqPtr, ); - if (_newApi) { + if (_callBackCompleter != null) { if (_onCanceled != null) { _onCanceled!(); } @@ -275,7 +283,7 @@ class _CallbackHandler { cleanUpRequest( reqPtr, ); - if (_newApi) { + if (_callBackCompleter != null) { if (_onSuccess != null) { final respInfoPtr = Pointer.fromAddress(args[0]).cast(); diff --git a/lib/src/http_client_request.dart b/lib/src/http_client_request.dart index c8c5c26..a53cb3f 100644 --- a/lib/src/http_client_request.dart +++ b/lib/src/http_client_request.dart @@ -149,6 +149,9 @@ class HttpClientRequest implements IOSink { FailedCallabck? onFailed, CanceledCallabck? onCanceled, SuccessCallabck? onSuccess}) { + if (_cbh._isStreamClaimed) { + return Future.error(ResponseListenerException()); + } final rc = _cbh.registerCallbacks(onReadData, onRedirectReceived, onResponseStarted, onFailed, onCanceled, onSuccess); _startRequest(); @@ -164,7 +167,7 @@ class HttpClientRequest implements IOSink { Future close() { return Future(() { // If callback based API is being used, throw Exception. - if (_cbh._newApi) { + if (_cbh._callBackCompleter != null) { throw ResponseListenerException(); } _startRequest(); diff --git a/test/http_responses_exceptions_test.dart b/test/http_responses_exceptions_test.dart index a69f204..5630da1 100644 --- a/test/http_responses_exceptions_test.dart +++ b/test/http_responses_exceptions_test.dart @@ -62,6 +62,19 @@ void main() { ])); }); + test('New API: 503, Service Unavailable', () async { + final request = + await client.getUrl(Uri.parse('http://localhost:5255/503')); + final success = await request.registerCallbacks( + (data, bytesRead, responseCode) {}, onFailed: (reason) { + expect( + reason, + isA().having((exception) => exception.message, + 'message', 'Service Unavailable')); + }); + expect(success, equals(false)); + }); + tearDown(() { client.close(); server.close(); diff --git a/test/http_responses_new_api_test.dart b/test/http_responses_new_api_test.dart index e873820..72ace57 100644 --- a/test/http_responses_new_api_test.dart +++ b/test/http_responses_new_api_test.dart @@ -9,7 +9,7 @@ import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; void main() { - group('callback_api_response_test', () { + group('callback_api_response_test New API', () { late HttpClient client; late HttpServer server; final sentData = 'Hello, world!'; @@ -17,8 +17,10 @@ void main() { client = HttpClient(); server = await HttpServer.bind(InternetAddress.anyIPv6, 5256); server.listen((HttpRequest request) { - if (request.method == 'CUSTOM') { - request.response.write(request.method); + if (request.uri.pathSegments.isNotEmpty && + request.uri.pathSegments[0] == '301') { + request.response.statusCode = 301; + request.response.headers.set('Location', '/'); } else { request.response.write(sentData); } @@ -26,14 +28,54 @@ void main() { }); }); - test('New API: Gets Hello, world response from server using getUrl', - () async { + test('Gets Hello, world response from server using getUrl', () async { String resp = ''; final request = await client.getUrl(Uri.parse('http://localhost:5256')); - await request.registerCallbacks((data, bytesRead, responseCode) { + final success = + await request.registerCallbacks((data, bytesRead, responseCode) { + resp += utf8.decoder.convert(data); + }, onSuccess: (responseCode) { + expect(responseCode, equals(200)); + }); + expect(resp, equals(sentData)); + expect(success, equals(true)); + }); + + test('Invalid URLs calls onFailed and returns false', () async { + String resp = ''; + final request = await client.getUrl( + Uri.parse('http://localghost:5256')); // localghost shouldn't exist + final success = + await request.registerCallbacks((data, bytesRead, responseCode) { + resp += utf8.decoder.convert(data); + }, onFailed: (HttpException reason) { + expect(reason, isA()); + }); + expect(resp, equals('')); + expect(success, equals(false)); + }); + + test('URL redirect on 301 and fetch data', () async { + String resp = ''; + final request = + await client.getUrl(Uri.parse('http://localhost:5256/301')); + final success = + await request.registerCallbacks((data, bytesRead, responseCode) { resp += utf8.decoder.convert(data); + }, onRedirectReceived: (location, responseCode) { + expect(responseCode, equals(301)); + expect(location, equals('http://localhost:5256/')); }); expect(resp, equals(sentData)); + expect(success, equals(true)); + }); + + test('registering callbacks after response.close will throw error', + () async { + final request = await client.getUrl(Uri.parse('http://localhost:5256')); + await request.close(); + expect(request.registerCallbacks((data, bytesRead, responseCode) {}), + throwsA(isA())); }); tearDown(() { diff --git a/test/http_responses_test.dart b/test/http_responses_test.dart index c4c9e7b..5bb4ccd 100644 --- a/test/http_responses_test.dart +++ b/test/http_responses_test.dart @@ -67,6 +67,13 @@ void main() { expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); }); + test('response.close after registering callbacks will throw error', + () async { + final request = await client.postUrl(Uri.parse('http://localhost:5252')); + request.registerCallbacks((data, bytesRead, responseCode) {}); + expect(request.close(), throwsA(isA())); + }); + tearDown(() { client.close(); server.close(); From d99c7c3acf35fac58aae74e504e22b2d3f98d9a0 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Tue, 15 Jun 2021 22:49:59 +0530 Subject: [PATCH 08/42] tests: automatic port selection --- README.md | 3 --- test/http_client_close_test.dart | 10 ++++++---- test/http_request_exceptions_test.dart | 11 ++++++++--- test/http_responses_exceptions_test.dart | 13 ++++++++----- test/http_responses_new_api_test.dart | 16 +++++++++------- test/http_responses_test.dart | 18 ++++++++++-------- test/test_utils.dart | 2 ++ 7 files changed, 43 insertions(+), 30 deletions(-) create mode 100644 test/test_utils.dart diff --git a/README.md b/README.md index 96ba4cd..d8b44e4 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,4 @@ dart run cronet # Downloads the cronet binaries. dart test --platform vm ``` -**Note:** Make sure that `52XX` ports are not reserved by any other process. -As some of the tests use ports in this range. - **Wrapper & Cronet binaries build guide**: [BUILD.md](lib/src/native/wrapper/BUILD.md) diff --git a/test/http_client_close_test.dart b/test/http_client_close_test.dart index 1c80c5d..a251f38 100644 --- a/test/http_client_close_test.dart +++ b/test/http_client_close_test.dart @@ -7,13 +7,15 @@ import 'dart:io'; import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; +import 'test_utils.dart'; void main() { group('client_close_test', () { late HttpServer server; - final sentData = 'Hello, world!'; + late int port; setUp(() async { - server = await HttpServer.bind(InternetAddress.anyIPv6, 5253); + server = await HttpServer.bind(InternetAddress.anyIPv6, 0); + port = server.port; server.listen((HttpRequest request) { request.response.write(sentData); request.response.close(); @@ -25,14 +27,14 @@ void main() { client.close(); expect( () async => - await client.openUrl('GET', Uri.parse('http://localhost:5253')), + await client.openUrl('GET', Uri.parse('http://$host:$port')), throwsException); }); test('Keeps the previous connection alive, if closed afterwards', () async { final client = HttpClient(); final request = - await client.openUrl('GET', Uri.parse('http://localhost:5253')); + await client.openUrl('GET', Uri.parse('http://$host:$port')); final resp = await request.close(); client.close(); final dataStream = resp.transform(utf8.decoder); diff --git a/test/http_request_exceptions_test.dart b/test/http_request_exceptions_test.dart index f286e17..63574b3 100644 --- a/test/http_request_exceptions_test.dart +++ b/test/http_request_exceptions_test.dart @@ -6,17 +6,22 @@ import 'dart:io'; import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; +import 'test_utils.dart'; void main() { group('request_HttpException_test', () { late HttpClient client; + late int port; setUp(() async { client = HttpClient(); + final server = await HttpServer.bind(InternetAddress.anyIPv6, 0); + port = server.port; + server.close(); }); test('URL do not exist', () async { final request = await client.openUrl('GET', - Uri.parse('http://localghost:9999')); // localghost shouln't exist :p + Uri.parse('http://localghost:$port')); // localghost shouln't exist :p final resp = await request.close(); expect(resp, emitsInOrder([emitsError(isA()), emitsDone])); @@ -24,7 +29,7 @@ void main() { test('The port is wrong', () async { final request = await client.openUrl('GET', - Uri.parse('http://localhost:9999')); // port 9999 should be close + Uri.parse('http://$host:$port')); // port 9999 should be close final resp = await request.close(); expect(resp, emitsInOrder([emitsError(isA()), emitsDone])); @@ -32,7 +37,7 @@ void main() { test('The scheme is wrong', () async { final request = - await client.openUrl('GET', Uri.parse('random://localhost:5253')); + await client.openUrl('GET', Uri.parse('random://$host:$port')); final resp = await request.close(); expect(resp, emitsInOrder([emitsError(isA()), emitsDone])); diff --git a/test/http_responses_exceptions_test.dart b/test/http_responses_exceptions_test.dart index 5630da1..44d489b 100644 --- a/test/http_responses_exceptions_test.dart +++ b/test/http_responses_exceptions_test.dart @@ -6,14 +6,17 @@ import 'dart:io'; import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; +import 'test_utils.dart'; void main() { group('response_HttpException_test', () { late HttpClient client; late HttpServer server; + late int port; setUp(() async { client = HttpClient(); - server = await HttpServer.bind(InternetAddress.anyIPv6, 5255); + server = await HttpServer.bind(InternetAddress.anyIPv6, 0); + port = server.port; server.listen((HttpRequest request) { final paths = request.uri.pathSegments; request.response.statusCode = int.parse(paths[0]); @@ -23,7 +26,7 @@ void main() { test('404, Not Found', () async { final request = - await client.getUrl(Uri.parse('http://localhost:5255/404')); + await client.getUrl(Uri.parse('http://$host:$port/404')); final resp = await request.close(); expect( resp, @@ -36,7 +39,7 @@ void main() { test('401, Unauthorized', () async { final request = - await client.getUrl(Uri.parse('http://localhost:5255/401')); + await client.getUrl(Uri.parse('http://$host:$port/401')); final resp = await request.close(); expect( resp, @@ -49,7 +52,7 @@ void main() { test('503, Service Unavailable', () async { final request = - await client.getUrl(Uri.parse('http://localhost:5255/503')); + await client.getUrl(Uri.parse('http://$host:$port/503')); final resp = await request.close(); expect( resp, @@ -64,7 +67,7 @@ void main() { test('New API: 503, Service Unavailable', () async { final request = - await client.getUrl(Uri.parse('http://localhost:5255/503')); + await client.getUrl(Uri.parse('http://$host:$port/503')); final success = await request.registerCallbacks( (data, bytesRead, responseCode) {}, onFailed: (reason) { expect( diff --git a/test/http_responses_new_api_test.dart b/test/http_responses_new_api_test.dart index 72ace57..8fa4f5e 100644 --- a/test/http_responses_new_api_test.dart +++ b/test/http_responses_new_api_test.dart @@ -7,15 +7,17 @@ import 'dart:io'; import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; +import 'test_utils.dart'; void main() { group('callback_api_response_test New API', () { late HttpClient client; late HttpServer server; - final sentData = 'Hello, world!'; + late int port; setUp(() async { client = HttpClient(); - server = await HttpServer.bind(InternetAddress.anyIPv6, 5256); + server = await HttpServer.bind(InternetAddress.anyIPv6, 0); + port = server.port; server.listen((HttpRequest request) { if (request.uri.pathSegments.isNotEmpty && request.uri.pathSegments[0] == '301') { @@ -30,7 +32,7 @@ void main() { test('Gets Hello, world response from server using getUrl', () async { String resp = ''; - final request = await client.getUrl(Uri.parse('http://localhost:5256')); + final request = await client.getUrl(Uri.parse('http://$host:$port')); final success = await request.registerCallbacks((data, bytesRead, responseCode) { resp += utf8.decoder.convert(data); @@ -44,7 +46,7 @@ void main() { test('Invalid URLs calls onFailed and returns false', () async { String resp = ''; final request = await client.getUrl( - Uri.parse('http://localghost:5256')); // localghost shouldn't exist + Uri.parse('http://localghost:$port')); // localghost shouldn't exist final success = await request.registerCallbacks((data, bytesRead, responseCode) { resp += utf8.decoder.convert(data); @@ -58,13 +60,13 @@ void main() { test('URL redirect on 301 and fetch data', () async { String resp = ''; final request = - await client.getUrl(Uri.parse('http://localhost:5256/301')); + await client.getUrl(Uri.parse('http://$host:$port')); final success = await request.registerCallbacks((data, bytesRead, responseCode) { resp += utf8.decoder.convert(data); }, onRedirectReceived: (location, responseCode) { expect(responseCode, equals(301)); - expect(location, equals('http://localhost:5256/')); + expect(location, equals('http://$host:$port')); }); expect(resp, equals(sentData)); expect(success, equals(true)); @@ -72,7 +74,7 @@ void main() { test('registering callbacks after response.close will throw error', () async { - final request = await client.getUrl(Uri.parse('http://localhost:5256')); + final request = await client.getUrl(Uri.parse('http://$host:$port')); await request.close(); expect(request.registerCallbacks((data, bytesRead, responseCode) {}), throwsA(isA())); diff --git a/test/http_responses_test.dart b/test/http_responses_test.dart index 5bb4ccd..4cc0a53 100644 --- a/test/http_responses_test.dart +++ b/test/http_responses_test.dart @@ -7,15 +7,17 @@ import 'dart:io'; import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; +import 'test_utils.dart'; void main() { group('http_responses_test', () { late HttpClient client; late HttpServer server; - final sentData = 'Hello, world!'; + late int port; setUp(() async { client = HttpClient(); - server = await HttpServer.bind(InternetAddress.anyIPv6, 5252); + server = await HttpServer.bind(InternetAddress.anyIPv6, 0); + port = server.port; server.listen((HttpRequest request) { if (request.method == 'CUSTOM') { request.response.write(request.method); @@ -27,14 +29,14 @@ void main() { }); test('Gets Hello, world response from server using getUrl', () async { - final request = await client.getUrl(Uri.parse('http://localhost:5252')); + final request = await client.getUrl(Uri.parse('http://$host:$port')); final resp = await request.close(); final dataStream = resp.transform(utf8.decoder); expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); }); test('Gets Hello, world response from server using get method', () async { - final request = await client.get('localhost', 5252, '/'); + final request = await client.get(host, port, '/'); final resp = await request.close(); final dataStream = resp.transform(utf8.decoder); expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); @@ -43,7 +45,7 @@ void main() { test('Gets Hello, world response from server using openUrl method', () async { final request = - await client.openUrl('GET', Uri.parse('http://localhost:5252')); + await client.openUrl('GET', Uri.parse('http://$host:$port')); final resp = await request.close(); final dataStream = resp.transform(utf8.decoder); expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); @@ -53,7 +55,7 @@ void main() { 'Fetch Hello, world response from server using openUrl, custom method method', () async { final request = - await client.openUrl('CUSTOM', Uri.parse('http://localhost:5252')); + await client.openUrl('CUSTOM', Uri.parse('http://$host:$port')); final resp = await request.close(); final dataStream = resp.transform(utf8.decoder); expect(dataStream, emitsInOrder([equals('CUSTOM'), emitsDone])); @@ -61,7 +63,7 @@ void main() { test('Fetch Hello, world response from server using POST request', () async { - final request = await client.postUrl(Uri.parse('http://localhost:5252')); + final request = await client.postUrl(Uri.parse('http://$host:$port')); final resp = await request.close(); final dataStream = resp.transform(utf8.decoder); expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); @@ -69,7 +71,7 @@ void main() { test('response.close after registering callbacks will throw error', () async { - final request = await client.postUrl(Uri.parse('http://localhost:5252')); + final request = await client.postUrl(Uri.parse('http://$host:$port')); request.registerCallbacks((data, bytesRead, responseCode) {}); expect(request.close(), throwsA(isA())); }); diff --git a/test/test_utils.dart b/test/test_utils.dart new file mode 100644 index 0000000..af8b9b8 --- /dev/null +++ b/test/test_utils.dart @@ -0,0 +1,2 @@ +const host = 'localhost'; +const sentData = 'Hello, world!'; From c3da375f624b8a6f8a5365988c4358f09e18ca4f Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Wed, 16 Jun 2021 09:24:51 +0530 Subject: [PATCH 09/42] tests: add license and enforce 80char --- test/http_request_exceptions_test.dart | 4 ++-- test/http_responses_exceptions_test.dart | 12 ++++-------- test/http_responses_new_api_test.dart | 3 +-- test/http_responses_test.dart | 4 ++-- test/test_utils.dart | 4 ++++ 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/test/http_request_exceptions_test.dart b/test/http_request_exceptions_test.dart index 63574b3..dc98219 100644 --- a/test/http_request_exceptions_test.dart +++ b/test/http_request_exceptions_test.dart @@ -28,8 +28,8 @@ void main() { }); test('The port is wrong', () async { - final request = await client.openUrl('GET', - Uri.parse('http://$host:$port')); // port 9999 should be close + final request = await client.openUrl( + 'GET', Uri.parse('http://$host:$port')); // port 9999 should be close final resp = await request.close(); expect(resp, emitsInOrder([emitsError(isA()), emitsDone])); diff --git a/test/http_responses_exceptions_test.dart b/test/http_responses_exceptions_test.dart index 44d489b..28fe723 100644 --- a/test/http_responses_exceptions_test.dart +++ b/test/http_responses_exceptions_test.dart @@ -25,8 +25,7 @@ void main() { }); test('404, Not Found', () async { - final request = - await client.getUrl(Uri.parse('http://$host:$port/404')); + final request = await client.getUrl(Uri.parse('http://$host:$port/404')); final resp = await request.close(); expect( resp, @@ -38,8 +37,7 @@ void main() { }); test('401, Unauthorized', () async { - final request = - await client.getUrl(Uri.parse('http://$host:$port/401')); + final request = await client.getUrl(Uri.parse('http://$host:$port/401')); final resp = await request.close(); expect( resp, @@ -51,8 +49,7 @@ void main() { }); test('503, Service Unavailable', () async { - final request = - await client.getUrl(Uri.parse('http://$host:$port/503')); + final request = await client.getUrl(Uri.parse('http://$host:$port/503')); final resp = await request.close(); expect( resp, @@ -66,8 +63,7 @@ void main() { }); test('New API: 503, Service Unavailable', () async { - final request = - await client.getUrl(Uri.parse('http://$host:$port/503')); + final request = await client.getUrl(Uri.parse('http://$host:$port/503')); final success = await request.registerCallbacks( (data, bytesRead, responseCode) {}, onFailed: (reason) { expect( diff --git a/test/http_responses_new_api_test.dart b/test/http_responses_new_api_test.dart index 8fa4f5e..2305874 100644 --- a/test/http_responses_new_api_test.dart +++ b/test/http_responses_new_api_test.dart @@ -59,8 +59,7 @@ void main() { test('URL redirect on 301 and fetch data', () async { String resp = ''; - final request = - await client.getUrl(Uri.parse('http://$host:$port')); + final request = await client.getUrl(Uri.parse('http://$host:$port')); final success = await request.registerCallbacks((data, bytesRead, responseCode) { resp += utf8.decoder.convert(data); diff --git a/test/http_responses_test.dart b/test/http_responses_test.dart index 4cc0a53..0ab8c60 100644 --- a/test/http_responses_test.dart +++ b/test/http_responses_test.dart @@ -36,7 +36,7 @@ void main() { }); test('Gets Hello, world response from server using get method', () async { - final request = await client.get(host, port, '/'); + final request = await client.get(host, port, '/path'); final resp = await request.close(); final dataStream = resp.transform(utf8.decoder); expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); @@ -45,7 +45,7 @@ void main() { test('Gets Hello, world response from server using openUrl method', () async { final request = - await client.openUrl('GET', Uri.parse('http://$host:$port')); + await client.openUrl('GET', Uri.parse('http://$host:$port/random')); final resp = await request.close(); final dataStream = resp.transform(utf8.decoder); expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); diff --git a/test/test_utils.dart b/test/test_utils.dart index af8b9b8..d57e166 100644 --- a/test/test_utils.dart +++ b/test/test_utils.dart @@ -1,2 +1,6 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + const host = 'localhost'; const sentData = 'Hello, world!'; From ea156b1074305c59eaf17abe8c7fe158515d8b38 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Thu, 17 Jun 2021 20:49:16 +0530 Subject: [PATCH 10/42] remove: flutter support boilerplate --- .pubignore | 55 ------------- README.md | 9 --- android/.gitignore | 8 -- android/build.gradle | 40 ---------- android/gradle.properties | 3 - .../gradle/wrapper/gradle-wrapper.properties | 5 -- android/settings.gradle | 1 - android/src/main/AndroidManifest.xml | 3 - .../kotlin/com/example/cronet/CronetPlugin.kt | 36 --------- cronet.iml | 19 ----- example/.gitignore | 46 ----------- example/.metadata | 10 --- example/README.md | 16 ---- example/android/.gitignore | 11 --- example/android/app/build.gradle | 59 -------------- .../android/app/src/debug/AndroidManifest.xml | 7 -- .../android/app/src/main/AndroidManifest.xml | 41 ---------- .../example/cronet_example/MainActivity.kt | 6 -- .../res/drawable-v21/launch_background.xml | 12 --- .../main/res/drawable/launch_background.xml | 12 --- .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 544 -> 0 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 442 -> 0 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 721 -> 0 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 1031 -> 0 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 1443 -> 0 bytes .../app/src/main/res/values-night/styles.xml | 18 ----- .../app/src/main/res/values/styles.xml | 18 ----- .../app/src/profile/AndroidManifest.xml | 7 -- example/android/build.gradle | 31 -------- example/android/gradle.properties | 3 - .../gradle/wrapper/gradle-wrapper.properties | 6 -- example/android/settings.gradle | 11 --- example/lib/main.dart | 35 --------- example/pubspec.yaml | 72 ------------------ pubspec.yaml | 22 ------ 35 files changed, 622 deletions(-) delete mode 100644 .pubignore delete mode 100644 android/.gitignore delete mode 100644 android/build.gradle delete mode 100644 android/gradle.properties delete mode 100644 android/gradle/wrapper/gradle-wrapper.properties delete mode 100644 android/settings.gradle delete mode 100644 android/src/main/AndroidManifest.xml delete mode 100644 android/src/main/kotlin/com/example/cronet/CronetPlugin.kt delete mode 100644 cronet.iml delete mode 100644 example/.gitignore delete mode 100644 example/.metadata delete mode 100644 example/README.md delete mode 100644 example/android/.gitignore delete mode 100644 example/android/app/build.gradle delete mode 100644 example/android/app/src/debug/AndroidManifest.xml delete mode 100644 example/android/app/src/main/AndroidManifest.xml delete mode 100644 example/android/app/src/main/kotlin/com/example/cronet_example/MainActivity.kt delete mode 100644 example/android/app/src/main/res/drawable-v21/launch_background.xml delete mode 100644 example/android/app/src/main/res/drawable/launch_background.xml delete mode 100644 example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png delete mode 100644 example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png delete mode 100644 example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png delete mode 100644 example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png delete mode 100644 example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png delete mode 100644 example/android/app/src/main/res/values-night/styles.xml delete mode 100644 example/android/app/src/main/res/values/styles.xml delete mode 100644 example/android/app/src/profile/AndroidManifest.xml delete mode 100644 example/android/build.gradle delete mode 100644 example/android/gradle.properties delete mode 100644 example/android/gradle/wrapper/gradle-wrapper.properties delete mode 100644 example/android/settings.gradle delete mode 100644 example/lib/main.dart delete mode 100644 example/pubspec.yaml diff --git a/.pubignore b/.pubignore deleted file mode 100644 index cf8813e..0000000 --- a/.pubignore +++ /dev/null @@ -1,55 +0,0 @@ -# See https://dart.dev/guides/libraries/private-files - -# Files and directories created by pub. -.dart_tool/ -.packages -pubspec.lock - -# IDE and debugger files. -.clangd -.gdb_history -.history -.vscode -compile_commands.json - -# Avoid committing generated Javascript files: -*.dart.js -*.info.json # Produced by the --dump-info flag. -*.js # When generated by dart2js. Don't specify *.js if your - # project includes source files written in JavaScript. -*.js_ -*.js.deps -*.js.map - -# Cronet pre-built binaries -cronet_binaries/ - -# Generated shared libraries. -*.so -*.so.* -*.dylib -*.dll - -# AOT compiled files. -*.exe - -*.jar -*.cxx - -# Jar dependencies should be published to pub -!android/libs/* - -# Cronet binaries for android should be published to pub -!android/src/main/jniLibs/** - -*.flutter-plugins -*.flutter-plugins-dependencies - -*.idea - -# Directory for quick experiments. -experiments/ - -# Files generated by tests for debugging purposes. -test/debug_generated/* -!test/debug_generated/readme.md diff --git a/README.md b/README.md index d8b44e4..d4cc008 100644 --- a/README.md +++ b/README.md @@ -17,15 +17,6 @@ This is a [GSoC 2021 project](https://summerofcode.withgoogle.com/projects/#4757 dart run cronet # Downloads the cronet binaries. ``` - **Flutter** - - ```bash - flutter pub get - flutter run cronet # Downloads the cronet binaries. - ``` - - Supported platforms: `linux64` and `windows64`. - 3. Import ```dart diff --git a/android/.gitignore b/android/.gitignore deleted file mode 100644 index c6cbe56..0000000 --- a/android/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.iml -.gradle -/local.properties -/.idea/workspace.xml -/.idea/libraries -.DS_Store -/build -/captures diff --git a/android/build.gradle b/android/build.gradle deleted file mode 100644 index 03c1436..0000000 --- a/android/build.gradle +++ /dev/null @@ -1,40 +0,0 @@ -group 'com.example.cronet' -version '1.0-SNAPSHOT' - -buildscript { - ext.kotlin_version = '1.3.50' - repositories { - google() - jcenter() - } - - dependencies { - classpath 'com.android.tools.build:gradle:4.1.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - -rootProject.allprojects { - repositories { - google() - jcenter() - } -} - -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' - -android { - compileSdkVersion 30 - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } - defaultConfig { - minSdkVersion 16 - } -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" -} diff --git a/android/gradle.properties b/android/gradle.properties deleted file mode 100644 index 94adc3a..0000000 --- a/android/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -org.gradle.jvmargs=-Xmx1536M -android.useAndroidX=true -android.enableJetifier=true diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 3c9d085..0000000 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/android/settings.gradle b/android/settings.gradle deleted file mode 100644 index 43fd67c..0000000 --- a/android/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'cronet' diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml deleted file mode 100644 index 1f43b5d..0000000 --- a/android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,3 +0,0 @@ - - diff --git a/android/src/main/kotlin/com/example/cronet/CronetPlugin.kt b/android/src/main/kotlin/com/example/cronet/CronetPlugin.kt deleted file mode 100644 index fa41764..0000000 --- a/android/src/main/kotlin/com/example/cronet/CronetPlugin.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.example.cronet - -import androidx.annotation.NonNull - -import io.flutter.embedding.engine.plugins.FlutterPlugin -import io.flutter.plugin.common.MethodCall -import io.flutter.plugin.common.MethodChannel -import io.flutter.plugin.common.MethodChannel.MethodCallHandler -import io.flutter.plugin.common.MethodChannel.Result -import io.flutter.plugin.common.PluginRegistry.Registrar - -/** CronetPlugin */ -class CronetPlugin: FlutterPlugin, MethodCallHandler { - /// The MethodChannel that will the communication between Flutter and native Android - /// - /// This local reference serves to register the plugin with the Flutter Engine and unregister it - /// when the Flutter Engine is detached from the Activity - private lateinit var channel : MethodChannel - - override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { - channel = MethodChannel(flutterPluginBinding.binaryMessenger, "cronet") - channel.setMethodCallHandler(this) - } - - override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { - if (call.method == "getPlatformVersion") { - result.success("Android ${android.os.Build.VERSION.RELEASE}") - } else { - result.notImplemented() - } - } - - override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { - channel.setMethodCallHandler(null) - } -} diff --git a/cronet.iml b/cronet.iml deleted file mode 100644 index 429df7d..0000000 --- a/cronet.iml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/example/.gitignore b/example/.gitignore deleted file mode 100644 index 0fa6b67..0000000 --- a/example/.gitignore +++ /dev/null @@ -1,46 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -**/ios/Flutter/.last_build_id -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -/build/ - -# Web related -lib/generated_plugin_registrant.dart - -# Symbolication related -app.*.symbols - -# Obfuscation related -app.*.map.json - -# Android Studio will place build artifacts here -/android/app/debug -/android/app/profile -/android/app/release diff --git a/example/.metadata b/example/.metadata deleted file mode 100644 index c1ee81b..0000000 --- a/example/.metadata +++ /dev/null @@ -1,10 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled and should not be manually edited. - -version: - revision: 1d9032c7e1d867f071f2277eb1673e8f9b0274e3 - channel: stable - -project_type: app diff --git a/example/README.md b/example/README.md deleted file mode 100644 index aabdd9a..0000000 --- a/example/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# cronet_example - -Demonstrates how to use the cronet plugin. - -## Getting Started - -This project is a starting point for a Flutter application. - -A few resources to get you started if this is your first Flutter project: - -- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) - -For help getting started with Flutter, view our -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. diff --git a/example/android/.gitignore b/example/android/.gitignore deleted file mode 100644 index 0a741cb..0000000 --- a/example/android/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -gradle-wrapper.jar -/.gradle -/captures/ -/gradlew -/gradlew.bat -/local.properties -GeneratedPluginRegistrant.java - -# Remember to never publicly share your keystore. -# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app -key.properties diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle deleted file mode 100644 index 1c9a77f..0000000 --- a/example/android/app/build.gradle +++ /dev/null @@ -1,59 +0,0 @@ -def localProperties = new Properties() -def localPropertiesFile = rootProject.file('local.properties') -if (localPropertiesFile.exists()) { - localPropertiesFile.withReader('UTF-8') { reader -> - localProperties.load(reader) - } -} - -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - -def flutterVersionCode = localProperties.getProperty('flutter.versionCode') -if (flutterVersionCode == null) { - flutterVersionCode = '1' -} - -def flutterVersionName = localProperties.getProperty('flutter.versionName') -if (flutterVersionName == null) { - flutterVersionName = '1.0' -} - -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - -android { - compileSdkVersion 30 - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } - - defaultConfig { - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.example.cronet_example" - minSdkVersion 16 - targetSdkVersion 30 - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName - } - - buildTypes { - release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.debug - } - } -} - -flutter { - source '../..' -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" -} diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml deleted file mode 100644 index 7fb7fb9..0000000 --- a/example/android/app/src/debug/AndroidManifest.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml deleted file mode 100644 index 40925f7..0000000 --- a/example/android/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/example/android/app/src/main/kotlin/com/example/cronet_example/MainActivity.kt b/example/android/app/src/main/kotlin/com/example/cronet_example/MainActivity.kt deleted file mode 100644 index 113f321..0000000 --- a/example/android/app/src/main/kotlin/com/example/cronet_example/MainActivity.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.example.cronet_example - -import io.flutter.embedding.android.FlutterActivity - -class MainActivity: FlutterActivity() { -} diff --git a/example/android/app/src/main/res/drawable-v21/launch_background.xml b/example/android/app/src/main/res/drawable-v21/launch_background.xml deleted file mode 100644 index f74085f..0000000 --- a/example/android/app/src/main/res/drawable-v21/launch_background.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/example/android/app/src/main/res/drawable/launch_background.xml b/example/android/app/src/main/res/drawable/launch_background.xml deleted file mode 100644 index 304732f..0000000 --- a/example/android/app/src/main/res/drawable/launch_background.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index db77bb4b7b0906d62b1847e87f15cdcacf6a4f29..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAj~WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8bpbvhu0Wd6uZuB!w&u2PAxD2eNXD>P5D~Wn-+_Wa#27Xc zC?Zj|6r#X(-D3u$NCt}(Ms06KgJ4FxJVv{GM)!I~&n8Bnc94O7-Hd)cjDZswgC;Qs zO=b+9!WcT8F?0rF7!Uys2bs@gozCP?z~o%U|N3vA*22NaGQG zlg@K`O_XuxvZ&Ks^m&R!`&1=spLvfx7oGDKDwpwW`#iqdw@AL`7MR}m`rwr|mZgU`8P7SBkL78fFf!WnuYWm$5Z0 zNXhDbCv&49sM544K|?c)WrFfiZvCi9h0O)B3Pgg&ebxsLQ05GG~ AQ2+n{ diff --git a/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index 17987b79bb8a35cc66c3c1fd44f5a5526c1b78be..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xx&nMcT!A!W`0S9QKQy;}1Cl^CgaH=;G9cpY;r$Q>i*pfB zP2drbID<_#qf;rPZx^FqH)F_D#*k@@q03KywUtLX8Ua?`H+NMzkczFPK3lFz@i_kW%1NOn0|D2I9n9wzH8m|-tHjsw|9>@K=iMBhxvkv6m8Y-l zytQ?X=U+MF$@3 zt`~i=@j|6y)RWMK--}M|=T`o&^Ni>IoWKHEbBXz7?A@mgWoL>!*SXo`SZH-*HSdS+ yn*9;$7;m`l>wYBC5bq;=U}IMqLzqbYCidGC!)_gkIk_C@Uy!y&wkt5C($~2D>~)O*cj@FGjOCM)M>_ixfudOh)?xMu#Fs z#}Y=@YDTwOM)x{K_j*Q;dPdJ?Mz0n|pLRx{4n|)f>SXlmV)XB04CrSJn#dS5nK2lM zrZ9#~WelCp7&e13Y$jvaEXHskn$2V!!DN-nWS__6T*l;H&Fopn?A6HZ-6WRLFP=R` zqG+CE#d4|IbyAI+rJJ`&x9*T`+a=p|0O(+s{UBcyZdkhj=yS1>AirP+0R;mf2uMgM zC}@~JfByORAh4SyRgi&!(cja>F(l*O+nd+@4m$|6K6KDn_&uvCpV23&>G9HJp{xgg zoq1^2_p9@|WEo z*X_Uko@K)qYYv~>43eQGMdbiGbo>E~Q& zrYBH{QP^@Sti!`2)uG{irBBq@y*$B zi#&(U-*=fp74j)RyIw49+0MRPMRU)+a2r*PJ$L5roHt2$UjExCTZSbq%V!HeS7J$N zdG@vOZB4v_lF7Plrx+hxo7(fCV&}fHq)$ diff --git a/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index d5f1c8d34e7a88e3f88bea192c3a370d44689c3c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1031 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q8Ax83A=Cw=BuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFa`(sgt!6~Yi|1%a`XoT0ojZ}lNrNjb9xjc(B0U1_% zz5^97Xt*%oq$rQy4?0GKNfJ44uvxI)gC`h-NZ|&0-7(qS@?b!5r36oQ}zyZrNO3 zMO=Or+<~>+A&uN&E!^Sl+>xE!QC-|oJv`ApDhqC^EWD|@=#J`=d#Xzxs4ah}w&Jnc z$|q_opQ^2TrnVZ0o~wh<3t%W&flvYGe#$xqda2bR_R zvPYgMcHgjZ5nSA^lJr%;<&0do;O^tDDh~=pIxA#coaCY>&N%M2^tq^U%3DB@ynvKo}b?yu-bFc-u0JHzced$sg7S3zqI(2 z#Km{dPr7I=pQ5>FuK#)QwK?Y`E`B?nP+}U)I#c1+FM*1kNvWG|a(TpksZQ3B@sD~b zpQ2)*V*TdwjFOtHvV|;OsiDqHi=6%)o4b!)x$)%9pGTsE z-JL={-Ffv+T87W(Xpooq<`r*VzWQcgBN$$`u}f>-ZQI1BB8ykN*=e4rIsJx9>z}*o zo~|9I;xof diff --git a/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index 4d6372eebdb28e45604e46eeda8dd24651419bc0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1443 zcmb`G{WsKk6vsdJTdFg%tJav9_E4vzrOaqkWF|A724Nly!y+?N9`YV6wZ}5(X(D_N(?!*n3`|_r0Hc?=PQw&*vnU?QTFY zB_MsH|!j$PP;I}?dppoE_gA(4uc!jV&0!l7_;&p2^pxNo>PEcNJv za5_RT$o2Mf!<+r?&EbHH6nMoTsDOa;mN(wv8RNsHpG)`^ymG-S5By8=l9iVXzN_eG%Xg2@Xeq76tTZ*dGh~Lo9vl;Zfs+W#BydUw zCkZ$o1LqWQO$FC9aKlLl*7x9^0q%0}$OMlp@Kk_jHXOjofdePND+j!A{q!8~Jn+s3 z?~~w@4?egS02}8NuulUA=L~QQfm;MzCGd)XhiftT;+zFO&JVyp2mBww?;QByS_1w! zrQlx%{^cMj0|Bo1FjwY@Q8?Hx0cIPF*@-ZRFpPc#bBw{5@tD(5%sClzIfl8WU~V#u zm5Q;_F!wa$BSpqhN>W@2De?TKWR*!ujY;Yylk_X5#~V!L*Gw~;$%4Q8~Mad z@`-kG?yb$a9cHIApZDVZ^U6Xkp<*4rU82O7%}0jjHlK{id@?-wpN*fCHXyXh(bLt* zPc}H-x0e4E&nQ>y%B-(EL=9}RyC%MyX=upHuFhAk&MLbsF0LP-q`XnH78@fT+pKPW zu72MW`|?8ht^tz$iC}ZwLp4tB;Q49K!QCF3@!iB1qOI=?w z7In!}F~ij(18UYUjnbmC!qKhPo%24?8U1x{7o(+?^Zu0Hx81|FuS?bJ0jgBhEMzf< zCgUq7r2OCB(`XkKcN-TL>u5y#dD6D!)5W?`O5)V^>jb)P)GBdy%t$uUMpf$SNV31$ zb||OojAbvMP?T@$h_ZiFLFVHDmbyMhJF|-_)HX3%m=CDI+ID$0^C>kzxprBW)hw(v zr!Gmda);ICoQyhV_oP5+C%?jcG8v+D@9f?Dk*!BxY}dazmrT@64UrP3hlslANK)bq z$67n83eh}OeW&SV@HG95P|bjfqJ7gw$e+`Hxo!4cx`jdK1bJ>YDSpGKLPZ^1cv$ek zIB?0S<#tX?SJCLWdMd{-ME?$hc7A$zBOdIJ)4!KcAwb=VMov)nK;9z>x~rfT1>dS+ zZ6#`2v@`jgbqq)P22H)Tx2CpmM^o1$B+xT6`(v%5xJ(?j#>Q$+rx_R|7TzDZe{J6q zG1*EcU%tE?!kO%^M;3aM6JN*LAKUVb^xz8-Pxo#jR5(-KBeLJvA@-gxNHx0M-ZJLl z;#JwQoh~9V?`UVo#}{6ka@II>++D@%KqGpMdlQ}?9E*wFcf5(#XQnP$Dk5~%iX^>f z%$y;?M0BLp{O3a(-4A?ewryHrrD%cx#Q^%KY1H zNre$ve+vceSLZcNY4U(RBX&)oZn*Py()h)XkE?PL$!bNb{N5FVI2Y%LKEm%yvpyTP z(1P?z~7YxD~Rf<(a@_y` diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml deleted file mode 100644 index 449a9f9..0000000 --- a/example/android/app/src/main/res/values-night/styles.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml deleted file mode 100644 index d74aa35..0000000 --- a/example/android/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml deleted file mode 100644 index 7fb7fb9..0000000 --- a/example/android/app/src/profile/AndroidManifest.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - diff --git a/example/android/build.gradle b/example/android/build.gradle deleted file mode 100644 index c505a86..0000000 --- a/example/android/build.gradle +++ /dev/null @@ -1,31 +0,0 @@ -buildscript { - ext.kotlin_version = '1.3.50' - repositories { - google() - jcenter() - } - - dependencies { - classpath 'com.android.tools.build:gradle:4.1.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - -allprojects { - repositories { - google() - jcenter() - } -} - -rootProject.buildDir = '../build' -subprojects { - project.buildDir = "${rootProject.buildDir}/${project.name}" -} -subprojects { - project.evaluationDependsOn(':app') -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/example/android/gradle.properties b/example/android/gradle.properties deleted file mode 100644 index 94adc3a..0000000 --- a/example/android/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -org.gradle.jvmargs=-Xmx1536M -android.useAndroidX=true -android.enableJetifier=true diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index bc6a58a..0000000 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Fri Jun 23 08:50:38 CEST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle deleted file mode 100644 index 44e62bc..0000000 --- a/example/android/settings.gradle +++ /dev/null @@ -1,11 +0,0 @@ -include ':app' - -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() - -assert localPropertiesFile.exists() -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } - -def flutterSdkPath = properties.getProperty("flutter.sdk") -assert flutterSdkPath != null, "flutter.sdk not set in local.properties" -apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/example/lib/main.dart b/example/lib/main.dart deleted file mode 100644 index 89b39a6..0000000 --- a/example/lib/main.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'package:flutter/material.dart'; - -// import 'package:cronet/cronet.dart'; - -void main() { - runApp(MyApp()); -} - -class MyApp extends StatefulWidget { - @override - _MyAppState createState() => _MyAppState(); -} - -class _MyAppState extends State { - final _platformVersion = 'Unknown'; - - @override - void initState() { - super.initState(); - } - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - appBar: AppBar( - title: const Text('Plugin example app'), - ), - body: Center( - child: Text('Running on: $_platformVersion\n'), - ), - ), - ); - } -} diff --git a/example/pubspec.yaml b/example/pubspec.yaml deleted file mode 100644 index 714ef67..0000000 --- a/example/pubspec.yaml +++ /dev/null @@ -1,72 +0,0 @@ -name: cronet_example -description: Demonstrates how to use the cronet plugin. - -# The following line prevents the package from being accidentally published to -# pub.dev using `pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev - -environment: - sdk: ">=2.7.0 <3.0.0" - -dependencies: - flutter: - sdk: flutter - - cronet: - # When depending on this package from a real application you should use: - # cronet: ^x.y.z - # See https://dart.dev/tools/pub/dependencies#version-constraints - # The example app is bundled with the plugin so we use a path dependency on - # the parent directory to use the current plugin's version. - path: ../ - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.2 - -dev_dependencies: - flutter_test: - sdk: flutter - lints: ^1.0.1 - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter. -flutter: - - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. - uses-material-design: true - - # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware. - - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages - - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages diff --git a/pubspec.yaml b/pubspec.yaml index 78313d5..9976ed2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,11 +10,8 @@ description: Experimental Cronet dart bindings. environment: sdk: '>=2.12.0 <3.0.0' - # flutter: ">=1.20.0" dependencies: - # flutter: - # sdk: flutter ffi: ^1.0.0 path: ^1.8.0 @@ -23,25 +20,6 @@ dev_dependencies: lints: ^1.0.1 test: ^1.17.5 -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter. -flutter: - # This section identifies this Flutter project as a plugin project. - # The 'pluginClass' and Android 'package' identifiers should not ordinarily - # be modified. They are used by the tooling to maintain consistency when - # adding or updating assets for this project. - plugin: - platforms: - android: - package: com.example.cronet - pluginClass: CronetPlugin - # windows: - # pluginClass: CronetPlugin - # linux: - # pluginClass: CronetPlugin - ffigen: name: 'Cronet' description: 'Bindings to Cronet' From 382be13141f94c5d4f18f5d20a6237135fe4c74b Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Thu, 17 Jun 2021 22:04:59 +0530 Subject: [PATCH 11/42] hint user to get binaries and relocate prepare_cronet --- bin/cronet.dart | 19 ++++++++++++++- {lib/src => bin}/prepare_cronet.dart | 35 ++++++++-------------------- lib/src/constants.dart | 11 +++++++++ lib/src/dylib_handler.dart | 33 +++++++++++++++++++++----- pubspec.yaml | 1 + 5 files changed, 67 insertions(+), 32 deletions(-) rename {lib/src => bin}/prepare_cronet.dart (67%) create mode 100644 lib/src/constants.dart diff --git a/bin/cronet.dart b/bin/cronet.dart index 124c6d1..2c3a9ce 100644 --- a/bin/cronet.dart +++ b/bin/cronet.dart @@ -2,10 +2,27 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:cronet/src/prepare_cronet.dart'; +import 'prepare_cronet.dart'; +import 'package:cronet/src/constants.dart'; + +import 'package:cli_util/cli_logging.dart' show Ansi, Logger; Future main(List platforms) async { + final logger = Logger.standard(); + final ansi = Ansi(Ansi.terminalSupportsAnsi); + for (final platform in platforms) { + if (!validPlatforms.contains(platform)) { + logger + .stderr('${ansi.red}$platform is not a valid platform.${ansi.none}'); + logger.stdout('Valid platfroms are:${ansi.yellow}'); + for (final valid in validPlatforms) { + logger.stdout(valid); + } + logger.stdout(ansi.none); + return; + } + if (platform.startsWith('linux')) { buildWrapper(); } diff --git a/lib/src/prepare_cronet.dart b/bin/prepare_cronet.dart similarity index 67% rename from lib/src/prepare_cronet.dart rename to bin/prepare_cronet.dart index fff7071..21a2b75 100644 --- a/lib/src/prepare_cronet.dart +++ b/bin/prepare_cronet.dart @@ -6,31 +6,18 @@ import 'dart:io' show Directory, File, Process, ProcessResult, ProcessStartMode; -// import 'package:path/path.dart'; +import 'package:cronet/src/find_resource.dart'; -import 'find_resource.dart'; +import 'package:cronet/src/constants.dart'; -// TODO: Change URL and Version - -const _release = '1.0.0'; -const _cronetBinaryUrl = - 'https://github.com/unsuitable001/dart_cronet_sample/releases/download/$_release/'; -final _cBinExtMap = { - 'linux64': '.tar.xz', - 'windows64': '.tar.gz', - 'androidarm64-v8a': '.tar.xz', -}; - -const _cronetVersion = '"86.0.4240.198"'; - -/// Builds the [wrapper] shared library -/// according to [build.sh] file +/// Builds the [wrapper] shared library according to [build.sh] file. void buildWrapper() { final wrapperPath = wrapperSourcePath(); print('Building Wrapper...'); + Process.runSync('chmod', ['+x', '$wrapperPath/build.sh']); var result = - Process.runSync('$wrapperPath/build.sh', [wrapperPath, _cronetVersion]); + Process.runSync('$wrapperPath/build.sh', [wrapperPath, cronetVersion]); print(result.stdout); print(result.stderr); print('Copying wrapper to project root...'); @@ -39,7 +26,7 @@ void buildWrapper() { print(result.stderr); } -/// Place downloaded binaries to proper location +/// Places downloaded binaries to proper location. void placeBinaries(String platform, String fileName) { print('Extracting Cronet for $platform'); ProcessResult res; @@ -49,8 +36,7 @@ void placeBinaries(String platform, String fileName) { } else { Directory('cronet_binaries').createSync(); - // Do we have tar extraction capability - // in dart's built-in libraries? + // Do we have tar extraction capability in dart's built-in libraries? res = Process.runSync('tar', ['-xvf', fileName, '-C', 'cronet_binaries']); } @@ -64,13 +50,12 @@ void placeBinaries(String platform, String fileName) { print('Done! Cronet support for $platform is now available!'); } -/// Download [cronet] library -/// from Github Releases +/// Download [cronet] library from Github Releases. Future downloadCronetBinaries(String platform) async { if (!isCronetAvailable(platform)) { - final fileName = platform + (_cBinExtMap[platform] ?? ''); + final fileName = platform + (cBinExtMap[platform] ?? ''); print('Downloading Cronet for $platform'); - final downloadUrl = _cronetBinaryUrl + fileName; + final downloadUrl = cronetBinaryUrl + fileName; print(downloadUrl); final dProcess = await Process.start('curl', ['-OL', downloadUrl], mode: ProcessStartMode.inheritStdio); diff --git a/lib/src/constants.dart b/lib/src/constants.dart new file mode 100644 index 0000000..8b22d52 --- /dev/null +++ b/lib/src/constants.dart @@ -0,0 +1,11 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +const validPlatforms = ['linux64', 'windows64']; +const release = '1.0.0'; +// TODO: Change URL and Version +const cronetBinaryUrl = + 'https://github.com/unsuitable001/dart_cronet_sample/releases/download/$release/'; +const cBinExtMap = {'linux64': '.tar.xz', 'windows64': '.tar.gz'}; +const cronetVersion = '"86.0.4240.198"'; diff --git a/lib/src/dylib_handler.dart b/lib/src/dylib_handler.dart index f081d7c..4b8e5e0 100644 --- a/lib/src/dylib_handler.dart +++ b/lib/src/dylib_handler.dart @@ -5,8 +5,11 @@ import 'dart:ffi' show DynamicLibrary; import 'dart:io' show Directory, File, Link, Platform; +import 'package:cli_util/cli_logging.dart' show Ansi, Logger; import 'package:path/path.dart'; +import 'constants.dart'; + /// Checks if [File]/[Link] exists for an [uri]. bool _doesFileExist(Uri uri) { return File.fromUri(uri).existsSync() || Link.fromUri(uri).existsSync(); @@ -73,12 +76,13 @@ DynamicLibrary loadWrapper() { // When gradle builds the wrapper, it automatically prepends lib. if (Platform.isAndroid) { prefix = 'lib'; - } - - if (Platform.isWindows) { + } else if (Platform.isWindows) { ext = '.dll'; } else if (Platform.isMacOS) { ext = '.dylib'; + } else if (!Platform.isLinux) { + // If NOT even linux, then unsupported. + throw Exception('Unsupported Platform.'); } var wrapperName = prefix + fileName + ext; @@ -87,7 +91,24 @@ DynamicLibrary loadWrapper() { // If it can't find it, try looking at search paths provided by the system. wrapperName = _resolveLibUri(wrapperName) ?? wrapperName; - return Platform.isIOS - ? DynamicLibrary.process() - : DynamicLibrary.open(wrapperName); + try { + return Platform.isIOS + ? DynamicLibrary.process() + : DynamicLibrary.open(wrapperName); + } catch (exception) { + final logger = Logger.standard(); + final ansi = Ansi(Ansi.terminalSupportsAnsi); + + logger.stderr( + '${ansi.red}Failed to open the library. Make sure that required binaries are in place.${ansi.none}'); + logger.stdout( + 'To download the binaries, please run the following from the root of your project:'); + logger.stdout('${ansi.yellow}dart run cronet ${ansi.none}'); + logger.stdout('${ansi.green}Valid platforms are:'); + for (final platform in validPlatforms) { + logger.stdout(platform); + } + logger.stdout(ansi.none); + rethrow; + } } diff --git a/pubspec.yaml b/pubspec.yaml index 9976ed2..0b9ef94 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,6 +14,7 @@ environment: dependencies: ffi: ^1.0.0 path: ^1.8.0 + cli_util: ^0.3.0 dev_dependencies: ffigen: ^2.4.2 From 82b296acb68df23c33518aebc1e169d8e25292d5 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Fri, 18 Jun 2021 11:14:00 +0530 Subject: [PATCH 12/42] refactor: native code lib/src/native -> src and 3rd_party -> third_party --- .gitignore | 2 +- README.md | 2 +- lib/src/find_resource.dart | 2 +- lib/src/native/wrapper/build.sh | 8 -------- {lib/src/native/wrapper => src}/BUILD.md | 8 ++++---- {lib/src/native/wrapper => src}/CMakeLists.txt | 12 ++++++------ src/build.sh | 8 ++++++++ {lib/src/native/wrapper => src}/wrapper.cc | 8 ++++---- {lib/src/native/wrapper => src}/wrapper.h | 4 ++-- {lib/src/native/wrapper => src}/wrapper_export.h | 0 .../cronet/bidirectional_stream_c.h | 0 .../include => third_party}/cronet/cronet.idl_c.h | 0 .../native/include => third_party}/cronet/cronet_c.h | 0 .../include => third_party}/cronet/cronet_export.h | 0 .../cronet_impl}/sample_executor.cc | 2 +- .../cronet_impl}/sample_executor.h | 2 +- .../include/dart => third_party/dart-sdk}/dart_api.h | 0 .../dart => third_party/dart-sdk}/dart_api_dl.c | 0 .../dart => third_party/dart-sdk}/dart_api_dl.h | 0 .../dart => third_party/dart-sdk}/dart_native_api.h | 0 .../dart => third_party/dart-sdk}/dart_tools_api.h | 0 .../dart => third_party/dart-sdk}/dart_version.h | 0 .../dart-sdk}/runtime/dart_api_dl_impl.h | 0 23 files changed, 29 insertions(+), 29 deletions(-) delete mode 100644 lib/src/native/wrapper/build.sh rename {lib/src/native/wrapper => src}/BUILD.md (88%) rename {lib/src/native/wrapper => src}/CMakeLists.txt (73%) create mode 100644 src/build.sh rename {lib/src/native/wrapper => src}/wrapper.cc (96%) rename {lib/src/native/wrapper => src}/wrapper.h (91%) rename {lib/src/native/wrapper => src}/wrapper_export.h (100%) rename {lib/src/native/include => third_party}/cronet/bidirectional_stream_c.h (100%) rename {lib/src/native/include => third_party}/cronet/cronet.idl_c.h (100%) rename {lib/src/native/include => third_party}/cronet/cronet_c.h (100%) rename {lib/src/native/include => third_party}/cronet/cronet_export.h (100%) rename {lib/src/native/wrapper => third_party/cronet_impl}/sample_executor.cc (99%) rename {lib/src/native/wrapper => third_party/cronet_impl}/sample_executor.h (98%) rename {lib/src/native/include/dart => third_party/dart-sdk}/dart_api.h (100%) rename {lib/src/native/include/dart => third_party/dart-sdk}/dart_api_dl.c (100%) rename {lib/src/native/include/dart => third_party/dart-sdk}/dart_api_dl.h (100%) rename {lib/src/native/include/dart => third_party/dart-sdk}/dart_native_api.h (100%) rename {lib/src/native/include/dart => third_party/dart-sdk}/dart_tools_api.h (100%) rename {lib/src/native/include/dart => third_party/dart-sdk}/dart_version.h (100%) rename {lib/src/native/include/dart => third_party/dart-sdk}/runtime/dart_api_dl_impl.h (100%) diff --git a/.gitignore b/.gitignore index f836d97..f7590c8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ build/ pubspec.lock # wrapper build directory -lib/src/native/wrapper/out +src/out # Directory created by dartdoc. doc/api/ diff --git a/README.md b/README.md index d4cc008..cd06721 100644 --- a/README.md +++ b/README.md @@ -79,4 +79,4 @@ dart run cronet # Downloads the cronet binaries. dart test --platform vm ``` -**Wrapper & Cronet binaries build guide**: [BUILD.md](lib/src/native/wrapper/BUILD.md) +**Wrapper & Cronet binaries build guide**: [BUILD.md](src/BUILD.md) diff --git a/lib/src/find_resource.dart b/lib/src/find_resource.dart index 459686c..5bbea70 100644 --- a/lib/src/find_resource.dart +++ b/lib/src/find_resource.dart @@ -45,7 +45,7 @@ String wrapperSourcePath() { if (packagePath == null) { throw Exception("Cannot resolve package:cronet's rootUri"); } - final wrapperSource = packagePath.resolve('lib/src/native/wrapper'); + final wrapperSource = packagePath.resolve('src'); if (!Directory.fromUri(wrapperSource).existsSync()) { throw Exception('Cannot find wrapper source!'); } diff --git a/lib/src/native/wrapper/build.sh b/lib/src/native/wrapper/build.sh deleted file mode 100644 index c78634d..0000000 --- a/lib/src/native/wrapper/build.sh +++ /dev/null @@ -1,8 +0,0 @@ -# Takes the path to wrapper source code path & cronet version as parameter -if [ $# -le 1 ] - then - echo "Provide '\"\"'" - exit 2 -fi -cd $1 -g++ -std=c++11 -DCRONET_VERSION=$2 -fPIC -rdynamic -shared -W -o wrapper.so wrapper.cc sample_executor.cc ../include/dart/dart_api_dl.c -ldl -I../include/cronet/ -I../include/dart/ -DDART_SHARED_LIB -fpermissive -Wl,-z,origin -Wl,-rpath,'$ORIGIN' -Wl,-rpath,'$ORIGIN/cronet_binaries/linux64/' diff --git a/lib/src/native/wrapper/BUILD.md b/src/BUILD.md similarity index 88% rename from lib/src/native/wrapper/BUILD.md rename to src/BUILD.md index a529f1a..1d5d3f4 100644 --- a/lib/src/native/wrapper/BUILD.md +++ b/src/BUILD.md @@ -6,13 +6,13 @@ For building cronet: ## For building wrapper -*Paths mentioned are relative to project root.* +*Paths mentioned are relative to the repository root.* ### For Linux ```bash -cd lib/src/native/wrapper -./build.sh . '"cronet_version"' +cd src +./build.sh . '"86.0.4240.198"' # Replace version string with own ``` Copy the `wrapper` binary to your project's `root` folder. @@ -29,7 +29,7 @@ Required: Visual Studio 2019 with C++ Desktop Development tools. 2. In the command prompt do - ```dosbatch - cd \lib\src\native\wrapper + cd \src cmake CMakeLists.txt -B out cmake --build out ``` diff --git a/lib/src/native/wrapper/CMakeLists.txt b/src/CMakeLists.txt similarity index 73% rename from lib/src/native/wrapper/CMakeLists.txt rename to src/CMakeLists.txt index fc82c67..3cd8074 100644 --- a/lib/src/native/wrapper/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,7 @@ # CMAKE file for windows build. cmake_minimum_required(VERSION 3.15) -set(PROJECT_NAME "cronet_sample") +set(PROJECT_NAME "cronet") project(${PROJECT_NAME} LANGUAGES C CXX) # This value is used when generating builds using this plugin, so it must @@ -14,8 +14,8 @@ add_compile_definitions(DART_SHARED_LIB) add_library(${PLUGIN_NAME} SHARED "wrapper.cc" - "sample_executor.cc" - "${CMAKE_CURRENT_SOURCE_DIR}/../include/dart/dart_api_dl.c" + "../third_party/cronet_impl/sample_executor.cc" + "${CMAKE_CURRENT_SOURCE_DIR}/../third_party/dart-sdk/dart_api_dl.c" ) # apply_standard_settings(${PLUGIN_NAME}) @@ -25,9 +25,9 @@ set_target_properties(${PLUGIN_NAME} PROPERTIES target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}/../include/dart" - "${CMAKE_CURRENT_SOURCE_DIR}/../include/dart/runtime" - "${CMAKE_CURRENT_SOURCE_DIR}/../include/cronet" + "${CMAKE_CURRENT_SOURCE_DIR}/../third_party/dart-sdk" + "${CMAKE_CURRENT_SOURCE_DIR}/../third_party/dart-sdk/runtime" + "${CMAKE_CURRENT_SOURCE_DIR}/../third_party/cronet" ) diff --git a/src/build.sh b/src/build.sh new file mode 100644 index 0000000..1bfaa9a --- /dev/null +++ b/src/build.sh @@ -0,0 +1,8 @@ +# Takes the path to wrapper source code path & cronet version as parameter +if [ $# -le 1 ] + then + echo "Provide '\"\"'" + exit 2 +fi +cd $1 +g++ -std=c++11 -DCRONET_VERSION=$2 -fPIC -rdynamic -shared -W -o wrapper.so wrapper.cc ../third_party/cronet_impl/sample_executor.cc ../third_party/dart-sdk/dart_api_dl.c -ldl -I../third_party/cronet/ -I../third_party/dart-sdk/ -DDART_SHARED_LIB -fpermissive -Wl,-z,origin -Wl,-rpath,'$ORIGIN' -Wl,-rpath,'$ORIGIN/cronet_binaries/linux64/' diff --git a/lib/src/native/wrapper/wrapper.cc b/src/wrapper.cc similarity index 96% rename from lib/src/native/wrapper/wrapper.cc rename to src/wrapper.cc index b2edf1c..005bb35 100644 --- a/lib/src/native/wrapper/wrapper.cc +++ b/src/wrapper.cc @@ -2,12 +2,12 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -#include "../include/dart/dart_api.h" -#include "../include/dart/dart_native_api.h" -#include "../include/dart/dart_tools_api.h" +#include "../third_party/dart-sdk/dart_api.h" +#include "../third_party/dart-sdk/dart_native_api.h" +#include "../third_party/dart-sdk/dart_tools_api.h" // #include"dart_api_dl.c" #include "wrapper.h" -#include "sample_executor.h" +#include "../third_party/cronet_impl/sample_executor.h" #include #include #include diff --git a/lib/src/native/wrapper/wrapper.h b/src/wrapper.h similarity index 91% rename from lib/src/native/wrapper/wrapper.h rename to src/wrapper.h index a01c713..9598130 100644 --- a/lib/src/native/wrapper/wrapper.h +++ b/src/wrapper.h @@ -5,8 +5,8 @@ #ifndef WRAPPER_H_ #define WRAPPER_H_ -#include "../include/dart/dart_api_dl.h" -#include "../include/cronet/cronet.idl_c.h" +#include "../third_party/dart-sdk/dart_api_dl.h" +#include "../third_party/cronet/cronet.idl_c.h" #include"wrapper_export.h" diff --git a/lib/src/native/wrapper/wrapper_export.h b/src/wrapper_export.h similarity index 100% rename from lib/src/native/wrapper/wrapper_export.h rename to src/wrapper_export.h diff --git a/lib/src/native/include/cronet/bidirectional_stream_c.h b/third_party/cronet/bidirectional_stream_c.h similarity index 100% rename from lib/src/native/include/cronet/bidirectional_stream_c.h rename to third_party/cronet/bidirectional_stream_c.h diff --git a/lib/src/native/include/cronet/cronet.idl_c.h b/third_party/cronet/cronet.idl_c.h similarity index 100% rename from lib/src/native/include/cronet/cronet.idl_c.h rename to third_party/cronet/cronet.idl_c.h diff --git a/lib/src/native/include/cronet/cronet_c.h b/third_party/cronet/cronet_c.h similarity index 100% rename from lib/src/native/include/cronet/cronet_c.h rename to third_party/cronet/cronet_c.h diff --git a/lib/src/native/include/cronet/cronet_export.h b/third_party/cronet/cronet_export.h similarity index 100% rename from lib/src/native/include/cronet/cronet_export.h rename to third_party/cronet/cronet_export.h diff --git a/lib/src/native/wrapper/sample_executor.cc b/third_party/cronet_impl/sample_executor.cc similarity index 99% rename from lib/src/native/wrapper/sample_executor.cc rename to third_party/cronet_impl/sample_executor.cc index 3416c3f..0581835 100644 --- a/lib/src/native/wrapper/sample_executor.cc +++ b/third_party/cronet_impl/sample_executor.cc @@ -108,4 +108,4 @@ void SampleExecutor::Execute(Cronet_ExecutorPtr self, auto* executor = static_cast(Cronet_Executor_GetClientContext(self)); executor->Execute(runnable); -} \ No newline at end of file +} diff --git a/lib/src/native/wrapper/sample_executor.h b/third_party/cronet_impl/sample_executor.h similarity index 98% rename from lib/src/native/wrapper/sample_executor.h rename to third_party/cronet_impl/sample_executor.h index 56285db..3b5fa3d 100644 --- a/lib/src/native/wrapper/sample_executor.h +++ b/third_party/cronet_impl/sample_executor.h @@ -9,7 +9,7 @@ #include #include #include -#include "wrapper.h" +#include "../../src/wrapper.h" // Sample implementation of Cronet_Executor interface using static // methods to map C API into instance of C++ class. class SampleExecutor { diff --git a/lib/src/native/include/dart/dart_api.h b/third_party/dart-sdk/dart_api.h similarity index 100% rename from lib/src/native/include/dart/dart_api.h rename to third_party/dart-sdk/dart_api.h diff --git a/lib/src/native/include/dart/dart_api_dl.c b/third_party/dart-sdk/dart_api_dl.c similarity index 100% rename from lib/src/native/include/dart/dart_api_dl.c rename to third_party/dart-sdk/dart_api_dl.c diff --git a/lib/src/native/include/dart/dart_api_dl.h b/third_party/dart-sdk/dart_api_dl.h similarity index 100% rename from lib/src/native/include/dart/dart_api_dl.h rename to third_party/dart-sdk/dart_api_dl.h diff --git a/lib/src/native/include/dart/dart_native_api.h b/third_party/dart-sdk/dart_native_api.h similarity index 100% rename from lib/src/native/include/dart/dart_native_api.h rename to third_party/dart-sdk/dart_native_api.h diff --git a/lib/src/native/include/dart/dart_tools_api.h b/third_party/dart-sdk/dart_tools_api.h similarity index 100% rename from lib/src/native/include/dart/dart_tools_api.h rename to third_party/dart-sdk/dart_tools_api.h diff --git a/lib/src/native/include/dart/dart_version.h b/third_party/dart-sdk/dart_version.h similarity index 100% rename from lib/src/native/include/dart/dart_version.h rename to third_party/dart-sdk/dart_version.h diff --git a/lib/src/native/include/dart/runtime/dart_api_dl_impl.h b/third_party/dart-sdk/runtime/dart_api_dl_impl.h similarity index 100% rename from lib/src/native/include/dart/runtime/dart_api_dl_impl.h rename to third_party/dart-sdk/runtime/dart_api_dl_impl.h From a667deb0b290986f69004242dd876fd0f0047a2b Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Fri, 18 Jun 2021 18:43:05 +0530 Subject: [PATCH 13/42] rewrite build.sh in dart --- bin/prepare_cronet.dart | 38 +++++++++++++++++++++++++++++++++----- lib/src/constants.dart | 2 +- src/BUILD.md | 37 ------------------------------------- src/build.sh | 8 -------- 4 files changed, 34 insertions(+), 51 deletions(-) delete mode 100644 src/BUILD.md delete mode 100644 src/build.sh diff --git a/bin/prepare_cronet.dart b/bin/prepare_cronet.dart index 21a2b75..2196bd3 100644 --- a/bin/prepare_cronet.dart +++ b/bin/prepare_cronet.dart @@ -7,19 +7,47 @@ import 'dart:io' show Directory, File, Process, ProcessResult, ProcessStartMode; import 'package:cronet/src/find_resource.dart'; - import 'package:cronet/src/constants.dart'; -/// Builds the [wrapper] shared library according to [build.sh] file. +/// Builds the [wrapper] shared library for linux. void buildWrapper() { final wrapperPath = wrapperSourcePath(); + final pwd = Directory.current; + const compiler = 'g++'; + const cppV = '-std=c++11'; + const options = [ + '-DCRONET_VERSION="$cronetVersion"', + '-fPIC', + '-rdynamic', + '-shared', + '-W', + '-ldl', + '-DDART_SHARED_LIB', + '-Wl,-z,origin', + "-Wl,-rpath,\$ORIGIN", + "-Wl,-rpath,\$ORIGIN/cronet_binaries/linux64/" + ]; + const outputName = 'wrapper.so'; + const sources = [ + 'wrapper.cc', + '../third_party/cronet_impl/sample_executor.cc', + '../third_party/dart-sdk/dart_api_dl.c', + ]; + const includes = [ + '-I../third_party/cronet/', + '-I../third_party/dart-sdk/', + ]; + Directory.current = Directory(wrapperPath); + var result = Process.runSync( + compiler, [cppV] + options + sources + ['-o', outputName] + includes); print('Building Wrapper...'); - Process.runSync('chmod', ['+x', '$wrapperPath/build.sh']); - var result = - Process.runSync('$wrapperPath/build.sh', [wrapperPath, cronetVersion]); + // Process.runSync('chmod', ['+x', '$wrapperPath/build.sh']); + // var result = + // Process.runSync('$wrapperPath/build.sh', [wrapperPath, cronetVersion]); print(result.stdout); print(result.stderr); + Directory.current = pwd; print('Copying wrapper to project root...'); result = Process.runSync('cp', ['$wrapperPath/wrapper.so', '.']); print(result.stdout); diff --git a/lib/src/constants.dart b/lib/src/constants.dart index 8b22d52..831ba54 100644 --- a/lib/src/constants.dart +++ b/lib/src/constants.dart @@ -8,4 +8,4 @@ const release = '1.0.0'; const cronetBinaryUrl = 'https://github.com/unsuitable001/dart_cronet_sample/releases/download/$release/'; const cBinExtMap = {'linux64': '.tar.xz', 'windows64': '.tar.gz'}; -const cronetVersion = '"86.0.4240.198"'; +const cronetVersion = "86.0.4240.198"; diff --git a/src/BUILD.md b/src/BUILD.md deleted file mode 100644 index 1d5d3f4..0000000 --- a/src/BUILD.md +++ /dev/null @@ -1,37 +0,0 @@ -# Build Guide - -Want to build your own? - -For building cronet: & - -## For building wrapper - -*Paths mentioned are relative to the repository root.* - -### For Linux - -```bash -cd src -./build.sh . '"86.0.4240.198"' # Replace version string with own -``` - -Copy the `wrapper` binary to your project's `root` folder. -Copy the cronet's binary to the `cronet_binaries/` folder from project's `root` folder. (Except on Windows. There, everything will be on root dir only.) - -*If you are in 64bit linux system, `cronet_binaries/` will be `cronet_binaries/linux64`.* - -### For Windows - -Required: Visual Studio 2019 with C++ Desktop Development tools. - -1. Make sure that you have `cmake` for Visual Studio 2019 is available in your command line. If not, you should open something like `x64 Native Tools Command Prompt for VS 2019` from your start menu which will open a command prompt with required path set. - -2. In the command prompt do - - - ```dosbatch - cd \src - cmake CMakeLists.txt -B out - cmake --build out - ``` - -3. From there, go to `out\Debug` folder to get `wrapper.dll`. diff --git a/src/build.sh b/src/build.sh deleted file mode 100644 index 1bfaa9a..0000000 --- a/src/build.sh +++ /dev/null @@ -1,8 +0,0 @@ -# Takes the path to wrapper source code path & cronet version as parameter -if [ $# -le 1 ] - then - echo "Provide '\"\"'" - exit 2 -fi -cd $1 -g++ -std=c++11 -DCRONET_VERSION=$2 -fPIC -rdynamic -shared -W -o wrapper.so wrapper.cc ../third_party/cronet_impl/sample_executor.cc ../third_party/dart-sdk/dart_api_dl.c -ldl -I../third_party/cronet/ -I../third_party/dart-sdk/ -DDART_SHARED_LIB -fpermissive -Wl,-z,origin -Wl,-rpath,'$ORIGIN' -Wl,-rpath,'$ORIGIN/cronet_binaries/linux64/' From 7df55225a9a9c7321b76519b96c85a124b1d3507 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Fri, 18 Jun 2021 21:57:31 +0530 Subject: [PATCH 14/42] add build_cronet executable for user customization --- README.md | 9 ++++- bin/build_cronet.dart | 21 ++++++++++++ bin/cronet.dart | 8 +++-- bin/prepare_cronet.dart | 68 +++++++++++++++++++++++++++++--------- lib/src/find_resource.dart | 4 +-- pubspec.yaml | 3 ++ 6 files changed, 93 insertions(+), 20 deletions(-) create mode 100644 bin/build_cronet.dart diff --git a/README.md b/README.md index cd06721..1742971 100644 --- a/README.md +++ b/README.md @@ -79,4 +79,11 @@ dart run cronet # Downloads the cronet binaries. dart test --platform vm ``` -**Wrapper & Cronet binaries build guide**: [BUILD.md](src/BUILD.md) +## Building Your Own + +1. Make sure you've downloaded your custom version of cronet shared library and filename follows the pattern `cronet..`. Default is: `cronet.86.0.4240.198.so` for linux. Else, you can build cronet from [source](https://www.chromium.org/developers/how-tos/get-the-code) using the [provided instuctions](https://chromium.googlesource.com/chromium/src/+/master/components/cronet/build_instructions.md). Then copy the library to the root of your project. For linux, you can also place the files under `cronet_binaries/linux64` for 64bit linux systems. + +2. Activate `cronet.dart` package using `dart pub global activate`. +3. Run `build_cronet ` from the root of your project. + +**Note for Windows:** Run `step 3` from `x64 Native Tools Command Prompt for VS 2019` shell. diff --git a/bin/build_cronet.dart b/bin/build_cronet.dart new file mode 100644 index 0000000..3564c30 --- /dev/null +++ b/bin/build_cronet.dart @@ -0,0 +1,21 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'prepare_cronet.dart'; + +void main(List args) { + if (args.contains('-h')) { + print('build_cronet [cronet_version]'); + } + final version = args.isEmpty ? null : args[0]; + if (Platform.isLinux) { + buildWrapperLinux(version); + } else if (Platform.isWindows) { + buildWrapperWindows(version); + } else { + print("Unsupported platform."); + } +} diff --git a/bin/cronet.dart b/bin/cronet.dart index 2c3a9ce..d2d9848 100644 --- a/bin/cronet.dart +++ b/bin/cronet.dart @@ -10,7 +10,11 @@ import 'package:cli_util/cli_logging.dart' show Ansi, Logger; Future main(List platforms) async { final logger = Logger.standard(); final ansi = Ansi(Ansi.terminalSupportsAnsi); - + if (platforms.isEmpty || platforms.contains('-h')) { + logger.stderr( + 'Please run: dart run cronet ${ansi.red}.${ansi.none}'); + return; + } for (final platform in platforms) { if (!validPlatforms.contains(platform)) { logger @@ -24,7 +28,7 @@ Future main(List platforms) async { } if (platform.startsWith('linux')) { - buildWrapper(); + if (!buildWrapperLinux()) return; } await downloadCronetBinaries(platform); } diff --git a/bin/prepare_cronet.dart b/bin/prepare_cronet.dart index 2196bd3..ef0d847 100644 --- a/bin/prepare_cronet.dart +++ b/bin/prepare_cronet.dart @@ -4,20 +4,20 @@ // Contains the nessesary setup code only. Not meant to be exposed. -import 'dart:io' show Directory, File, Process, ProcessResult, ProcessStartMode; +import 'dart:io' show Directory, File, HttpClient, Process, ProcessResult; import 'package:cronet/src/find_resource.dart'; import 'package:cronet/src/constants.dart'; -/// Builds the [wrapper] shared library for linux. -void buildWrapper() { +import 'package:cli_util/cli_logging.dart' show Ansi, Logger; + +/// Builds the `wrapper` shared library for linux. +bool buildWrapperLinux([String? version]) { final wrapperPath = wrapperSourcePath(); final pwd = Directory.current; - const compiler = 'g++'; const cppV = '-std=c++11'; const options = [ - '-DCRONET_VERSION="$cronetVersion"', '-fPIC', '-rdynamic', '-shared', @@ -40,25 +40,60 @@ void buildWrapper() { ]; Directory.current = Directory(wrapperPath); var result = Process.runSync( - compiler, [cppV] + options + sources + ['-o', outputName] + includes); + compiler, + [cppV] + + ['-DCRONET_VERSION="${version ?? cronetVersion}"'] + + options + + sources + + ['-o', outputName] + + includes); print('Building Wrapper...'); - // Process.runSync('chmod', ['+x', '$wrapperPath/build.sh']); - // var result = - // Process.runSync('$wrapperPath/build.sh', [wrapperPath, cronetVersion]); print(result.stdout); print(result.stderr); + if (result.exitCode != 0) return false; Directory.current = pwd; print('Copying wrapper to project root...'); - result = Process.runSync('cp', ['$wrapperPath/wrapper.so', '.']); + File('$wrapperPath/wrapper.so').copySync('wrapper.so'); + if (result.exitCode != 0) return false; + return true; +} + +/// Builds the `wrapper` shared library for windows. +bool buildWrapperWindows([String? version]) { + final logger = Logger.standard(); + final ansi = Ansi(Ansi.terminalSupportsAnsi); + final wrapperPath = wrapperSourcePath(); + final pwd = Directory.current; + final environment = { + 'CL': '/DCRONET_VERSION="""${version ?? cronetVersion}"""' + }; + Directory.current = Directory(wrapperPath); + try { + final result = Process.runSync('cmake', ['CMakeLists.txt', '-B', 'out'], + environment: environment); + print(result.stdout); + print(result.stderr); + } catch (error) { + logger.stdout("${ansi.red}Build failed.${ansi.none}"); + logger.stdout( + 'Open ${ansi.yellow}x64 Native Tools Command Prompt for VS 2019.${ansi.none} Then run:\n'); + logger.stdout('cd ${pwd.path}\nbuild_cronet ${version ?? cronetVersion}'); + return false; + } + var result = + Process.runSync('cmake', ['--build', 'out'], environment: environment); print(result.stdout); print(result.stderr); + if (result.exitCode != 0) return false; + Directory.current = pwd; + File('$wrapperPath\\out\\Debug\\wrapper.dll').copySync('wrapper.dll'); + return true; } /// Places downloaded binaries to proper location. void placeBinaries(String platform, String fileName) { print('Extracting Cronet for $platform'); ProcessResult res; - // Process.runSync('mkdir', ['-p', 'cronet_binaries']); if (platform.startsWith('windows')) { res = Process.runSync('tar', ['-xvf', fileName]); } else { @@ -85,11 +120,14 @@ Future downloadCronetBinaries(String platform) async { print('Downloading Cronet for $platform'); final downloadUrl = cronetBinaryUrl + fileName; print(downloadUrl); - final dProcess = await Process.start('curl', ['-OL', downloadUrl], - mode: ProcessStartMode.inheritStdio); - if (await dProcess.exitCode != 0) { - throw Exception("Can't download. Check your network connection!"); + try { + final request = await HttpClient().getUrl(Uri.parse(downloadUrl)); + final response = await request.close(); + await response.pipe(File(fileName).openWrite()); + } catch (error) { + Exception("Can't download. Check your network connection!"); } + placeBinaries(platform, fileName); } else { print("Cronet $platform is already available. No need to download."); diff --git a/lib/src/find_resource.dart b/lib/src/find_resource.dart index 5bbea70..09021ab 100644 --- a/lib/src/find_resource.dart +++ b/lib/src/find_resource.dart @@ -6,7 +6,7 @@ // This code is a modified version from ffigen package's old commit. import 'dart:convert'; -import 'dart:io' show File, Directory; +import 'dart:io' show Directory, File, Platform; /// Finds the root [Uri] of our package. Uri? findPackageRoot() { @@ -49,7 +49,7 @@ String wrapperSourcePath() { if (!Directory.fromUri(wrapperSource).existsSync()) { throw Exception('Cannot find wrapper source!'); } - return wrapperSource.toFilePath(); + return wrapperSource.toFilePath(windows: Platform.isWindows); } /// Checks if cronet binaries are already available in the project. diff --git a/pubspec.yaml b/pubspec.yaml index 0b9ef94..c604d72 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,6 +21,9 @@ dev_dependencies: lints: ^1.0.1 test: ^1.17.5 +executables: + build_cronet: + ffigen: name: 'Cronet' description: 'Bindings to Cronet' From 9e7836a676bac28023fcf7c54cf029fc028b427b Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Sat, 19 Jun 2021 12:43:05 +0530 Subject: [PATCH 15/42] tar -> package:archive and cronet binary detection improvements --- bin/build_cronet.dart | 22 +++++++++++++++-- bin/prepare_cronet.dart | 50 ++++++++++++++++++++++++++------------ lib/src/constants.dart | 33 ++++++++++++++++++++++--- lib/src/dylib_handler.dart | 18 +------------- lib/src/find_resource.dart | 13 ++++++++-- pubspec.yaml | 1 + 6 files changed, 97 insertions(+), 40 deletions(-) diff --git a/bin/build_cronet.dart b/bin/build_cronet.dart index 3564c30..e9b21b3 100644 --- a/bin/build_cronet.dart +++ b/bin/build_cronet.dart @@ -4,18 +4,36 @@ import 'dart:io'; +import 'package:cli_util/cli_logging.dart' show Ansi, Logger; + +import 'package:cronet/src/constants.dart'; +import 'package:cronet/src/find_resource.dart'; + import 'prepare_cronet.dart'; void main(List args) { + final logger = Logger.standard(); + final ansi = Ansi(Ansi.terminalSupportsAnsi); + if (args.contains('-h')) { print('build_cronet [cronet_version]'); } - final version = args.isEmpty ? null : args[0]; + final version = args.isEmpty ? cronetVersion : args[0]; if (Platform.isLinux) { buildWrapperLinux(version); } else if (Platform.isWindows) { buildWrapperWindows(version); } else { - print("Unsupported platform."); + logger.stderr('${ansi.red}Unsupported platform.${ansi.none}'); + return; + } + final cronetName = getDylibName('cronet.$version'); + if (!isCronetAvailable(Platform.isLinux ? 'linux64' : 'windows64')) { + logger.stderr('${ansi.yellow}Make sure that your cronet shared library' + ' is named as $cronetName and either placed in ${Directory.current.path}' + ' or, available in your system\'s shared library search path.${ansi.none}'); + + logger.stdout('For more info and build instructions, go to: ' + 'https://github.com/google/cronet.dart/#building-your-own'); } } diff --git a/bin/prepare_cronet.dart b/bin/prepare_cronet.dart index ef0d847..3158593 100644 --- a/bin/prepare_cronet.dart +++ b/bin/prepare_cronet.dart @@ -4,8 +4,10 @@ // Contains the nessesary setup code only. Not meant to be exposed. -import 'dart:io' show Directory, File, HttpClient, Process, ProcessResult; +import 'dart:io' show Directory, File, HttpClient, Process; +import 'package:archive/archive.dart'; +import 'package:archive/archive_io.dart'; import 'package:cronet/src/find_resource.dart'; import 'package:cronet/src/constants.dart'; @@ -39,6 +41,7 @@ bool buildWrapperLinux([String? version]) { '-I../third_party/dart-sdk/', ]; Directory.current = Directory(wrapperPath); + print('Building Wrapper...'); var result = Process.runSync( compiler, [cppV] + @@ -47,11 +50,10 @@ bool buildWrapperLinux([String? version]) { sources + ['-o', outputName] + includes); - print('Building Wrapper...'); + Directory.current = pwd; print(result.stdout); print(result.stderr); if (result.exitCode != 0) return false; - Directory.current = pwd; print('Copying wrapper to project root...'); File('$wrapperPath/wrapper.so').copySync('wrapper.so'); if (result.exitCode != 0) return false; @@ -68,6 +70,7 @@ bool buildWrapperWindows([String? version]) { 'CL': '/DCRONET_VERSION="""${version ?? cronetVersion}"""' }; Directory.current = Directory(wrapperPath); + logger.stdout('Building Wrapper...'); try { final result = Process.runSync('cmake', ['CMakeLists.txt', '-B', 'out'], environment: environment); @@ -78,6 +81,7 @@ bool buildWrapperWindows([String? version]) { logger.stdout( 'Open ${ansi.yellow}x64 Native Tools Command Prompt for VS 2019.${ansi.none} Then run:\n'); logger.stdout('cd ${pwd.path}\nbuild_cronet ${version ?? cronetVersion}'); + Directory.current = pwd; return false; } var result = @@ -90,22 +94,33 @@ bool buildWrapperWindows([String? version]) { return true; } +// Extracts a tar.gz file. +void extract(String fileName, [String dir = '']) { + final tarGzFile = File(fileName).readAsBytesSync(); + final archive = GZipDecoder().decodeBytes(tarGzFile, verify: true); + final tarData = TarDecoder().decodeBytes(archive, verify: true); + for (final file in tarData) { + final filename = file.name; + if (file.isFile) { + final data = file.content as List; + File(dir + filename) + ..createSync(recursive: true) + ..writeAsBytesSync(data); + } else { + Directory(dir + filename).create(recursive: true); + } + } +} + /// Places downloaded binaries to proper location. void placeBinaries(String platform, String fileName) { print('Extracting Cronet for $platform'); - ProcessResult res; + if (platform.startsWith('windows')) { - res = Process.runSync('tar', ['-xvf', fileName]); + extract(fileName); } else { Directory('cronet_binaries').createSync(); - - // Do we have tar extraction capability in dart's built-in libraries? - res = Process.runSync('tar', ['-xvf', fileName, '-C', 'cronet_binaries']); - } - - if (res.exitCode != 0) { - throw Exception( - "Can't unzip. Check if the downloaded file isn't corrupted"); + extract(fileName, 'cronet_binaries/'); } print('Done! Cleaning up...'); @@ -113,17 +128,20 @@ void placeBinaries(String platform, String fileName) { print('Done! Cronet support for $platform is now available!'); } -/// Download [cronet] library from Github Releases. +/// Download `cronet` library from Github Releases. Future downloadCronetBinaries(String platform) async { if (!isCronetAvailable(platform)) { - final fileName = platform + (cBinExtMap[platform] ?? ''); + final fileName = platform + '.tar.gz'; print('Downloading Cronet for $platform'); final downloadUrl = cronetBinaryUrl + fileName; print(downloadUrl); try { final request = await HttpClient().getUrl(Uri.parse(downloadUrl)); final response = await request.close(); - await response.pipe(File(fileName).openWrite()); + final fileSink = File(fileName).openWrite(); + await response.pipe(fileSink); + await fileSink.flush(); + await fileSink.close(); } catch (error) { Exception("Can't download. Check your network connection!"); } diff --git a/lib/src/constants.dart b/lib/src/constants.dart index 831ba54..e67b110 100644 --- a/lib/src/constants.dart +++ b/lib/src/constants.dart @@ -2,10 +2,37 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'dart:io' show Platform; + const validPlatforms = ['linux64', 'windows64']; -const release = '1.0.0'; +const release = '0.0.1'; // TODO: Change URL and Version const cronetBinaryUrl = - 'https://github.com/unsuitable001/dart_cronet_sample/releases/download/$release/'; -const cBinExtMap = {'linux64': '.tar.xz', 'windows64': '.tar.gz'}; + 'https://github.com/unsuitable001/cronet.dart/releases/download/$release/'; const cronetVersion = "86.0.4240.198"; + +String getDylibName(String name, [String platform = '']) { + var ext = '.so'; + var prefix = ''; + + // When gradle builds the wrapper, it automatically prepends lib. + if (Platform.isAndroid || platform.startsWith('android')) { + prefix = 'lib'; + } else if (Platform.isWindows || platform.startsWith('windows')) { + ext = '.dll'; + } else if (Platform.isMacOS || platform.startsWith('macos')) { + ext = '.dylib'; + } else if (!(Platform.isLinux || platform.startsWith('linux'))) { + // If NOT even linux, then unsupported. + throw Exception('Unsupported Platform.'); + } + return prefix + name + ext; +} + +String getWrapperName([String platform = '']) { + return getDylibName('wrapper', platform); +} + +String getCronetName([String platform = '']) { + return getDylibName('cronet.$cronetVersion', platform); +} diff --git a/lib/src/dylib_handler.dart b/lib/src/dylib_handler.dart index 4b8e5e0..a13c306 100644 --- a/lib/src/dylib_handler.dart +++ b/lib/src/dylib_handler.dart @@ -69,23 +69,7 @@ String? _resolveLibUri(String name) { /// This loaded [wrapper] will then load [cronet]. /// Throws an [ArgumentError] if library can't be loaded. DynamicLibrary loadWrapper() { - const fileName = 'wrapper'; - var ext = '.so'; - var prefix = ''; - - // When gradle builds the wrapper, it automatically prepends lib. - if (Platform.isAndroid) { - prefix = 'lib'; - } else if (Platform.isWindows) { - ext = '.dll'; - } else if (Platform.isMacOS) { - ext = '.dylib'; - } else if (!Platform.isLinux) { - // If NOT even linux, then unsupported. - throw Exception('Unsupported Platform.'); - } - - var wrapperName = prefix + fileName + ext; + var wrapperName = getWrapperName(); // _resolveLibUri() will try to resolve wrapper's absolute path. // If it can't find it, try looking at search paths provided by the system. diff --git a/lib/src/find_resource.dart b/lib/src/find_resource.dart index 09021ab..1b9a495 100644 --- a/lib/src/find_resource.dart +++ b/lib/src/find_resource.dart @@ -8,6 +8,8 @@ import 'dart:convert'; import 'dart:io' show Directory, File, Platform; +import 'package:cronet/src/constants.dart'; + /// Finds the root [Uri] of our package. Uri? findPackageRoot() { var root = Directory.current.uri; @@ -54,6 +56,13 @@ String wrapperSourcePath() { /// Checks if cronet binaries are already available in the project. bool isCronetAvailable(String platform) { - final cronetDir = Directory.current.uri.resolve('cronet_binaries/$platform/'); - return Directory.fromUri(cronetDir).existsSync(); + final cronetBinaries = Directory.fromUri( + Directory.current.uri.resolve('cronet_binaries/$platform/')) + .existsSync(); + final inRoot = + File.fromUri(Directory.current.uri.resolve(getWrapperName(platform))) + .existsSync() && + File.fromUri(Directory.current.uri.resolve(getCronetName(platform))) + .existsSync(); + return cronetBinaries || inRoot; } diff --git a/pubspec.yaml b/pubspec.yaml index c604d72..163465e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,6 +15,7 @@ dependencies: ffi: ^1.0.0 path: ^1.8.0 cli_util: ^0.3.0 + archive: ^3.1.2 dev_dependencies: ffigen: ^2.4.2 From 5b921cf0a8bdecf88cbcf893b281cc442432f23e Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Sat, 19 Jun 2021 21:23:53 +0530 Subject: [PATCH 16/42] info: display command to get cronet library when wrapper can't load it --- src/wrapper.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wrapper.cc b/src/wrapper.cc index 005bb35..ae85e05 100644 --- a/src/wrapper.cc +++ b/src/wrapper.cc @@ -295,6 +295,8 @@ Cronet_EnginePtr Cronet_Engine_Create() { // if this succeeds, every subsequent use // of cronet [handle] should. if (!handle) { + std::cout << "Can't locate cronet library. Make sure that they are available." << std::endl; + std::cout << "Try Running this from the root of your project:\ndart run cronet " << std::endl; std::clog << dlerror() << std::endl; exit(EXIT_FAILURE); } From 0303b71ffd0333378afc6b67768caad3eb819210 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Sat, 19 Jun 2021 22:04:54 +0530 Subject: [PATCH 17/42] test: remove unused imports --- example_dart/bin/example_dart.dart | 1 - test/cronet_test.dart | 2 -- 2 files changed, 3 deletions(-) diff --git a/example_dart/bin/example_dart.dart b/example_dart/bin/example_dart.dart index 6b06ce7..1084b88 100644 --- a/example_dart/bin/example_dart.dart +++ b/example_dart/bin/example_dart.dart @@ -1,5 +1,4 @@ import 'dart:convert'; -import 'dart:io'; import 'package:cronet/cronet.dart'; /* Trying to re-impliment: https://chromium.googlesource.com/chromium/src/+/master/components/cronet/native/sample/main.cc */ diff --git a/test/cronet_test.dart b/test/cronet_test.dart index 7b3bcbc..c13cc29 100644 --- a/test/cronet_test.dart +++ b/test/cronet_test.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'dart:io'; - import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; From 5d4c6986c326ede0178083bc6e3c2f6f76a9d597 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Sun, 20 Jun 2021 11:19:55 +0530 Subject: [PATCH 18/42] refactor: wrapper.cc & improve: destroying unused requests --- lib/src/http_callback_handler.dart | 49 ++--- lib/src/http_client.dart | 10 +- lib/src/http_client_request.dart | 8 +- src/wrapper.cc | 334 ++++++++++++++--------------- 4 files changed, 188 insertions(+), 213 deletions(-) diff --git a/lib/src/http_callback_handler.dart b/lib/src/http_callback_handler.dart index a3bc2e8..34bf33e 100644 --- a/lib/src/http_callback_handler.dart +++ b/lib/src/http_callback_handler.dart @@ -90,12 +90,11 @@ class _CallbackHandler { // Clean up tasks for a request. // // We need to call this then whenever we are done with the request. - - // TODO: Take cleanup client as param. (to be implemented by htto_client) - void cleanUpRequest(Pointer reqPtr) { + void cleanUpRequest( + Pointer reqPtr, Function cleanUpClient) { receivePort.close(); cronet.removeRequest(reqPtr); - // cleanUpClient(); + cleanUpClient(); } /// Checks status of an URL response. @@ -131,9 +130,7 @@ class _CallbackHandler { /// /// This also invokes the appropriate callbacks that are registered, /// according to the network events sent from cronet side. - void listen(Pointer reqPtr) { - // TODO: add Function cleanUpClient when logging and storage api is implemneted - + void listen(Pointer reqPtr, Function cleanUpClient) { // Registers the listener on the receivePort. // // The message parameter contains both the name of the event and @@ -154,12 +151,12 @@ class _CallbackHandler { Pointer.fromAddress(args[1]).cast(), 300, 399, - () => cleanUpRequest( - reqPtr)); // If NOT a 3XX status code, throw Exception. + () => cleanUpRequest(reqPtr, + cleanUpClient)); // If NOT a 3XX status code, throw Exception. if (followRedirects && maxRedirects > 0) { final res = cronet.Cronet_UrlRequest_FollowRedirect(reqPtr); if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { - cleanUpRequest(reqPtr); + cleanUpRequest(reqPtr, cleanUpClient); throw UrlRequestException(res); } maxRedirects--; @@ -181,8 +178,8 @@ class _CallbackHandler { Pointer.fromAddress(args[0]).cast(), 100, 299, - () => cleanUpRequest( - reqPtr)); // If NOT a 1XX or 2XX status code, throw Exception. + () => cleanUpRequest(reqPtr, + cleanUpClient)); // If NOT a 1XX or 2XX status code, throw Exception. log('Response started'); if (_onResponseStarted != null) { _onResponseStarted!(respCode); @@ -206,9 +203,8 @@ class _CallbackHandler { info, 100, 299, - () => cleanUpRequest( - reqPtr, - )); // If NOT a 1XX or 2XX status code, throw Exception. + () => cleanUpRequest(reqPtr, + cleanUpClient)); // If NOT a 1XX or 2XX status code, throw Exception. final data = cronet.Cronet_Buffer_GetData(buffer) .cast() .asTypedList(bytesRead); @@ -218,9 +214,7 @@ class _CallbackHandler { _onReadData!(data.toList(growable: false), bytesRead, respCode); final res = cronet.Cronet_UrlRequest_Read(request, buffer); if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { - cleanUpRequest( - reqPtr, - ); + cleanUpRequest(reqPtr, cleanUpClient); _callBackCompleter!.completeError(UrlRequestException(res)); } } else { @@ -228,9 +222,7 @@ class _CallbackHandler { _controller.sink.add(data.toList(growable: false)); final res = cronet.Cronet_UrlRequest_Read(request, buffer); if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { - cleanUpRequest( - reqPtr, - ); + cleanUpRequest(reqPtr, cleanUpClient); _controller.addError(UrlRequestException(res)); _controller.close(); } @@ -242,9 +234,7 @@ class _CallbackHandler { { final error = Pointer.fromAddress(args[0]).cast().toDartString(); - cleanUpRequest( - reqPtr, - ); + cleanUpRequest(reqPtr, cleanUpClient); if (_callBackCompleter != null) { if (_onFailed != null) { @@ -258,14 +248,13 @@ class _CallbackHandler { _controller.addError(HttpException(error)); _controller.close(); } + cronet.Cronet_UrlRequest_Destroy(reqPtr); } break; // when the request is cancelled, we will shut everything down after this. case 'OnCanceled': { - cleanUpRequest( - reqPtr, - ); + cleanUpRequest(reqPtr, cleanUpClient); if (_callBackCompleter != null) { if (_onCanceled != null) { _onCanceled!(); @@ -275,14 +264,13 @@ class _CallbackHandler { // If callbacks are not registered, stream isn't closed before. So, close here. _controller.close(); } + cronet.Cronet_UrlRequest_Destroy(reqPtr); } break; // When the request is succesfully done, we will shut everything down after this. case 'OnSucceeded': { - cleanUpRequest( - reqPtr, - ); + cleanUpRequest(reqPtr, cleanUpClient); if (_callBackCompleter != null) { if (_onSuccess != null) { final respInfoPtr = @@ -295,6 +283,7 @@ class _CallbackHandler { // If callbacks are not registered, stream isn't closed before. So, close here. _controller.close(); } + cronet.Cronet_UrlRequest_Destroy(reqPtr); } break; default: diff --git a/lib/src/http_client.dart b/lib/src/http_client.dart index eb758cc..1e3bccc 100644 --- a/lib/src/http_client.dart +++ b/lib/src/http_client.dart @@ -124,9 +124,9 @@ class HttpClient { _cronet.Cronet_EngineParams_Destroy(engineParams); } - // void _cleanUpRequests(HttpClientRequest hcr) { - // _requests.remove(hcr); - // } + void _cleanUpRequests(HttpClientRequest hcr) { + _requests.remove(hcr); + } /// Shuts down the HTTP client. /// @@ -164,8 +164,8 @@ class HttpClient { if (_stop) { throw Exception("Client is closed. Can't open new connections"); } - // TODO: Add clean up function when logging and storage apis are migrated - _requests.add(HttpClientRequest(url, method, _cronet, _cronetEngine)); + _requests.add(HttpClientRequest( + url, method, _cronet, _cronetEngine, _cleanUpRequests)); return _requests.last; }); } diff --git a/lib/src/http_client_request.dart b/lib/src/http_client_request.dart index a53cb3f..6029ad3 100644 --- a/lib/src/http_client_request.dart +++ b/lib/src/http_client_request.dart @@ -76,7 +76,7 @@ class HttpClientRequest implements IOSink { final Pointer _cronetEngine; final _CallbackHandler _cbh; final Pointer _request; - // final Function _clientCleanup; // Holds the function to clean up storage after + final Function _clientCleanup; // Holds the function to clean up after // // the request is done (if nessesary). // // implemented in: http_client.dart // TODO: Enable with abort API @@ -91,7 +91,7 @@ class HttpClientRequest implements IOSink { /// Initiates a [HttpClientRequest]. It is meant to be used by a [HttpClient]. HttpClientRequest(this._uri, this._method, this._cronet, this._cronetEngine, - // this._clientCleanup, + this._clientCleanup, {this.encoding = utf8}) : _cbh = _CallbackHandler(_cronet, _cronet.Create_Executor(), ReceivePort()), @@ -129,9 +129,7 @@ class HttpClientRequest implements IOSink { if (res2 != Cronet_RESULT.Cronet_RESULT_SUCCESS) { throw UrlRequestException(res2); } - _cbh.listen(_request); - // TODO: Enable with storage and logging api - // _cbh.listen(_request, () => _clientCleanup(this)); + _cbh.listen(_request, () => _clientCleanup(this)); } /// Registers callbacks for all network events. diff --git a/src/wrapper.cc b/src/wrapper.cc index ae85e05..845c3af 100644 --- a/src/wrapper.cc +++ b/src/wrapper.cc @@ -40,73 +40,6 @@ intptr_t InitDartApiDL(void* data) { LIBTYPE handle = OPENLIB(CRONET_LIB_NAME); std::unordered_map requestNativePorts; -static void FreeFinalizer(void*, void* value) { - free(value); -} - - -/* Callback Helpers */ - -// Registers the Dart side's -// ReceievePort's NativePort component -// -// This is required to send the data -void registerCallbackHandler(Dart_Port send_port, Cronet_UrlRequestPtr rp) { - requestNativePorts[rp] = send_port; -} - -// This sends the callback name and the associated data -// with it to the Dart side via NativePort -// -// Sent data is broken into 3 parts. -// message[0] is the method name, which is a string -// message[1] contains all the data to pass to that method -void dispatchCallback(const char* methodname, Cronet_UrlRequestPtr request, Dart_CObject args) { - Dart_CObject c_method_name; - c_method_name.type = Dart_CObject_kString; - c_method_name.value.as_string = const_cast(methodname); - - Dart_CObject* c_request_arr[] = {&c_method_name, &args}; - Dart_CObject c_request; - - c_request.type = Dart_CObject_kArray; - c_request.value.as_array.values = c_request_arr; - c_request.value.as_array.length = - sizeof(c_request_arr) / sizeof(c_request_arr[0]); - - Dart_PostCObject_DL(requestNativePorts[request], &c_request); -} - -// Builds the arguments to pass to the Dart side -// as a parameter to the callbacks -// Data processed here are -// consumed as from message[2] if -// message is the name of the data -// receieved by the ReceievePort -Dart_CObject callbackArgBuilder(int num, ...) { - Dart_CObject c_request_data; - va_list valist; - va_start(valist, num); - void* request_buffer = malloc(sizeof(uint64_t) * num); - uint64_t* buf = reinterpret_cast(request_buffer); - - for(int i = 0; i < num; i++) { - buf[i] = va_arg(valist,uint64_t); - } - - c_request_data.type = Dart_CObject_kExternalTypedData; - c_request_data.value.as_external_typed_data.type = Dart_TypedData_kUint64; - c_request_data.value.as_external_typed_data.length = sizeof(uint64_t) * num; // 4 args to pass - c_request_data.value.as_external_typed_data.data = static_cast(request_buffer); - c_request_data.value.as_external_typed_data.peer = request_buffer; - c_request_data.value.as_external_typed_data.callback = FreeFinalizer; - - va_end(valist); - - return c_request_data; -} - - /* Getting Cronet's Functions */ P_IMPORT(Cronet_EnginePtr,Cronet_Engine_Create , void); P_IMPORT(void, Cronet_Engine_Destroy, Cronet_EnginePtr); @@ -197,31 +130,6 @@ bool Cronet_Engine_StartNetLogToFile(Cronet_EnginePtr self, void Cronet_Engine_StopNetLog(Cronet_EnginePtr self) {return _Cronet_Engine_StopNetLog(self);} -/* Engine Cleanup Tasks */ -static void HttpClientDestroy(void* isolate_callback_data, - void* peer) { - Cronet_EnginePtr ce = reinterpret_cast(peer); - _Cronet_Engine_Shutdown(ce); - _Cronet_Engine_Destroy(ce); -} - -void unloadCronet() { - CLOSELIB(handle); -} - -void removeRequest(Cronet_UrlRequestPtr rp) { - requestNativePorts.erase(rp); -} - -// Register our HttpClient object from dart side -void registerHttpClient(Dart_Handle h, Cronet_EnginePtr ce) { - void* peer = ce; - intptr_t size = 8; - Dart_NewFinalizableHandle_DL(h, peer, size, HttpClientDestroy); -} - - - P_IMPORT(int32_t, Cronet_UrlResponseInfo_http_status_code_get, const Cronet_UrlResponseInfoPtr); int32_t Cronet_UrlResponseInfo_http_status_code_get(const Cronet_UrlResponseInfoPtr self) {return _Cronet_UrlResponseInfo_http_status_code_get(self);} @@ -229,86 +137,9 @@ int32_t Cronet_UrlResponseInfo_http_status_code_get(const Cronet_UrlResponseInfo P_IMPORT(Cronet_String, Cronet_UrlResponseInfo_http_status_text_get, const Cronet_UrlResponseInfoPtr); Cronet_String Cronet_UrlResponseInfo_http_status_text_get(const Cronet_UrlResponseInfoPtr self) {return _Cronet_UrlResponseInfo_http_status_text_get(self);} - -/* URL Callbacks Implementations */ - -void OnRedirectReceived( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info, - Cronet_String newLocationUrl) { - dispatchCallback("OnRedirectReceived",request, callbackArgBuilder(2, newLocationUrl, info)); -} - -void OnResponseStarted( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info) { - - // Create and allocate 32kb buffer. - Cronet_BufferPtr buffer = _Cronet_Buffer_Create(); - _Cronet_Buffer_InitWithAlloc(buffer, 32 * 1024); - - dispatchCallback("OnResponseStarted",request, callbackArgBuilder(1, info)); - - // Started reading the response. - _Cronet_UrlRequest_Read(request, buffer); - -} - - -void OnReadCompleted( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info, - Cronet_BufferPtr buffer, - uint64_t bytes_read) { - dispatchCallback("OnReadCompleted",request, callbackArgBuilder(4, request, info, buffer, bytes_read)); -} - - -void OnSucceeded(Cronet_UrlRequestCallbackPtr self, Cronet_UrlRequestPtr request, Cronet_UrlResponseInfoPtr info) { - dispatchCallback("OnSucceeded",request, callbackArgBuilder(1, info)); -} - -void OnFailed( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info, - Cronet_ErrorPtr error) { - dispatchCallback("OnFailed",request, callbackArgBuilder(1, _Cronet_Error_message_get(error))); -} - -void OnCanceled( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info) { - dispatchCallback("OnCanceled",request, callbackArgBuilder(0)); -} - - -/* Interface */ - -Cronet_EnginePtr Cronet_Engine_Create() { - // Checks if cronet is loaded properly - // As this is the first function to call, - // if this succeeds, every subsequent use - // of cronet [handle] should. - if (!handle) { - std::cout << "Can't locate cronet library. Make sure that they are available." << std::endl; - std::cout << "Try Running this from the root of your project:\ndart run cronet " << std::endl; - std::clog << dlerror() << std::endl; - exit(EXIT_FAILURE); - } - return _Cronet_Engine_Create(); -} - -Cronet_RESULT Cronet_Engine_Shutdown(Cronet_EnginePtr self) { return _Cronet_Engine_Shutdown(self); } - -// Mapping Cronet Function -> Wrapper function -// Most of them are unchanged, except some. -// Note: Can someone suggest a better way to -// map unchanged APIs? +// Mapping Cronet Function -> Wrapper function. Most of them are unchanged, except some. +// +// Note: Can someone suggest a better way to map unchanged APIs? Cronet_String Cronet_Engine_GetVersionString(Cronet_EnginePtr ce) {return _Cronet_Engine_GetVersionString(ce);} Cronet_EngineParamsPtr Cronet_EngineParams_Create(void) {return _Cronet_EngineParams_Create();} void Cronet_EngineParams_Destroy(Cronet_EngineParamsPtr self) {} @@ -403,6 +234,164 @@ Cronet_RESULT Cronet_UrlRequest_Read(Cronet_UrlRequestPtr self, Cronet_BufferPtr Cronet_RawDataPtr Cronet_Buffer_GetData(Cronet_BufferPtr buffer) {return _Cronet_Buffer_GetData(buffer);} uint64_t Cronet_Buffer_GetSize(Cronet_BufferPtr self) {return _Cronet_Buffer_GetSize(self);} +/* Wrapper implemented APIs from here */ + +static void FreeFinalizer(void*, void* value) { + free(value); +} + +/* Callback Helpers */ + +// Registers the Dart side's +// ReceievePort's NativePort component +// +// This is required to send the data +void registerCallbackHandler(Dart_Port send_port, Cronet_UrlRequestPtr rp) { + requestNativePorts[rp] = send_port; +} + +// This sends the callback name and the associated data +// with it to the Dart side via NativePort +// +// Sent data is broken into 3 parts. +// message[0] is the method name, which is a string +// message[1] contains all the data to pass to that method +void dispatchCallback(const char* methodname, Cronet_UrlRequestPtr request, Dart_CObject args) { + Dart_CObject c_method_name; + c_method_name.type = Dart_CObject_kString; + c_method_name.value.as_string = const_cast(methodname); + + Dart_CObject* c_request_arr[] = {&c_method_name, &args}; + Dart_CObject c_request; + + c_request.type = Dart_CObject_kArray; + c_request.value.as_array.values = c_request_arr; + c_request.value.as_array.length = + sizeof(c_request_arr) / sizeof(c_request_arr[0]); + + Dart_PostCObject_DL(requestNativePorts[request], &c_request); +} + +// Builds the arguments to pass to the Dart side as a parameter to the callbacks. +// [num] is the number of arguments to be passed and rest are the arguments. +Dart_CObject callbackArgBuilder(int num, ...) { + Dart_CObject c_request_data; + va_list valist; + va_start(valist, num); + void* request_buffer = malloc(sizeof(uint64_t) * num); + uint64_t* buf = reinterpret_cast(request_buffer); + + for(int i = 0; i < num; i++) { + buf[i] = va_arg(valist,uint64_t); + } + + c_request_data.type = Dart_CObject_kExternalTypedData; + c_request_data.value.as_external_typed_data.type = Dart_TypedData_kUint64; + c_request_data.value.as_external_typed_data.length = sizeof(uint64_t) * num; // 4 args to pass + c_request_data.value.as_external_typed_data.data = static_cast(request_buffer); + c_request_data.value.as_external_typed_data.peer = request_buffer; + c_request_data.value.as_external_typed_data.callback = FreeFinalizer; + + va_end(valist); + + return c_request_data; +} + + + +/* Engine Cleanup Tasks */ +static void HttpClientDestroy(void* isolate_callback_data, + void* peer) { + Cronet_EnginePtr ce = reinterpret_cast(peer); + _Cronet_Engine_Shutdown(ce); + _Cronet_Engine_Destroy(ce); +} + +void unloadCronet() { + CLOSELIB(handle); +} + +void removeRequest(Cronet_UrlRequestPtr rp) { + requestNativePorts.erase(rp); +} + +// Register our HttpClient object from dart side +void registerHttpClient(Dart_Handle h, Cronet_EnginePtr ce) { + void* peer = ce; + intptr_t size = 8; + Dart_NewFinalizableHandle_DL(h, peer, size, HttpClientDestroy); +} + +/* URL Callbacks Implementations */ + +void OnRedirectReceived( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_String newLocationUrl) { + dispatchCallback("OnRedirectReceived",request, callbackArgBuilder(2, newLocationUrl, info)); +} + +void OnResponseStarted( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info) { + + // Create and allocate 32kb buffer. + Cronet_BufferPtr buffer = _Cronet_Buffer_Create(); + _Cronet_Buffer_InitWithAlloc(buffer, 32 * 1024); + + dispatchCallback("OnResponseStarted",request, callbackArgBuilder(1, info)); + + // Started reading the response. + _Cronet_UrlRequest_Read(request, buffer); + +} + +void OnReadCompleted( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_BufferPtr buffer, + uint64_t bytes_read) { + dispatchCallback("OnReadCompleted",request, callbackArgBuilder(4, request, info, buffer, bytes_read)); +} + + +void OnSucceeded(Cronet_UrlRequestCallbackPtr self, Cronet_UrlRequestPtr request, Cronet_UrlResponseInfoPtr info) { + dispatchCallback("OnSucceeded",request, callbackArgBuilder(1, info)); +} + +void OnFailed( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_ErrorPtr error) { + dispatchCallback("OnFailed",request, callbackArgBuilder(1, _Cronet_Error_message_get(error))); +} + +void OnCanceled( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info) { + dispatchCallback("OnCanceled",request, callbackArgBuilder(0)); +} + +Cronet_EnginePtr Cronet_Engine_Create() { + // Checks if cronet is loaded properly + // As this is the first function to call, + // if this succeeds, every subsequent use + // of cronet [handle] should. + if (!handle) { + std::cout << "Can't locate cronet library. Make sure that they are available." << std::endl; + std::cout << "Try Running this from the root of your project:\ndart run cronet " << std::endl; + std::clog << dlerror() << std::endl; + exit(EXIT_FAILURE); + } + return _Cronet_Engine_Create(); +} + +Cronet_RESULT Cronet_Engine_Shutdown(Cronet_EnginePtr self) { return _Cronet_Engine_Shutdown(self); } ExecutorPtr Create_Executor() { return new SampleExecutor(); @@ -422,4 +411,3 @@ Cronet_RESULT Cronet_UrlRequest_Init(Cronet_UrlRequestPtr self, Cronet_EnginePtr return _Cronet_UrlRequest_InitWithParams(self, engine, url, params, urCallback, executor->GetExecutor()); } - From 088b9fba7ca115f2b4cb832618aabc53056bdd14 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Mon, 21 Jun 2021 11:55:20 +0530 Subject: [PATCH 19/42] include: cronet c++ sample --- .gitignore | 4 + README.md | 2 + third_party/cronet_sample/BUILD.md | 15 +++ .../cronet_sample/cronet.idl_c.extras.h | 106 +++++++++++++++ third_party/cronet_sample/main.cc | 49 +++++++ third_party/cronet_sample/sample_executor.cc | 81 ++++++++++++ third_party/cronet_sample/sample_executor.h | 44 +++++++ .../sample_url_request_callback.cc | 121 ++++++++++++++++++ .../sample_url_request_callback.h | 79 ++++++++++++ 9 files changed, 501 insertions(+) create mode 100644 third_party/cronet_sample/BUILD.md create mode 100644 third_party/cronet_sample/cronet.idl_c.extras.h create mode 100644 third_party/cronet_sample/main.cc create mode 100644 third_party/cronet_sample/sample_executor.cc create mode 100644 third_party/cronet_sample/sample_executor.h create mode 100644 third_party/cronet_sample/sample_url_request_callback.cc create mode 100644 third_party/cronet_sample/sample_url_request_callback.h diff --git a/.gitignore b/.gitignore index f7590c8..6ff88c4 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,10 @@ cronet_binaries/ *.dylib *.dll +# Compiled executables. +*.o +*.out + # AOT compiled files. *.exe diff --git a/README.md b/README.md index 1742971..0b8c2e6 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,8 @@ dart run cronet # Downloads the cronet binaries. dart test --platform vm ``` +Test your cronet build by following [BUILD.md](third_party/cronet_sample/BUILD.md). + ## Building Your Own 1. Make sure you've downloaded your custom version of cronet shared library and filename follows the pattern `cronet..`. Default is: `cronet.86.0.4240.198.so` for linux. Else, you can build cronet from [source](https://www.chromium.org/developers/how-tos/get-the-code) using the [provided instuctions](https://chromium.googlesource.com/chromium/src/+/master/components/cronet/build_instructions.md). Then copy the library to the root of your project. For linux, you can also place the files under `cronet_binaries/linux64` for 64bit linux systems. diff --git a/third_party/cronet_sample/BUILD.md b/third_party/cronet_sample/BUILD.md new file mode 100644 index 0000000..1fa31ce --- /dev/null +++ b/third_party/cronet_sample/BUILD.md @@ -0,0 +1,15 @@ +# Build Cronet Sample + +Source: [Chromium Cronet Sample](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/components/cronet/native/sample). + +**Note:** Code here aren't used by the Dart code by any means. It is only to test if the downloaded/built cronet library is working and major apis are compatible with this package. + +## Compilation Instruction + +```bash +g++ -std=c++11 main.cc sample_executor.cc sample_url_request_callback.cc -o sample.out -ldl -lpthread -L. -l:libcronet.86.0.4240.198.so -Wl,-z,origin -Wl,-rpath,'$ORIGIN' +``` + +Put the compiled `sample.out` and `libcronet.86.0.4240.198.so` in the same folder and execute `./sample.out`. + +Replace `libcronet.86.0.4240.198.so` with your cronet dylib's name. diff --git a/third_party/cronet_sample/cronet.idl_c.extras.h b/third_party/cronet_sample/cronet.idl_c.extras.h new file mode 100644 index 0000000..825bca5 --- /dev/null +++ b/third_party/cronet_sample/cronet.idl_c.extras.h @@ -0,0 +1,106 @@ +// Contains functions those are not exposed to dart but required to run this +// sample. + +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CRONET_IDL_EXTRA_SAMPLE_ +#define CRONET_IDL_EXTRA_SAMPLE_ + +#include "../cronet/cronet_c.h" + +#ifdef __cplusplus +extern "C" { +#endif + Cronet_RESULT Cronet_UrlRequest_InitWithParams( + Cronet_UrlRequestPtr self, + Cronet_EnginePtr engine, + Cronet_String url, + Cronet_UrlRequestParamsPtr params, + Cronet_UrlRequestCallbackPtr callback, + Cronet_ExecutorPtr executor); + + void Cronet_Engine_Destroy(Cronet_EnginePtr self); + + Cronet_UrlRequestCallbackPtr Cronet_UrlRequestCallback_CreateWith( + Cronet_UrlRequestCallback_OnRedirectReceivedFunc OnRedirectReceivedFunc, + Cronet_UrlRequestCallback_OnResponseStartedFunc OnResponseStartedFunc, + Cronet_UrlRequestCallback_OnReadCompletedFunc OnReadCompletedFunc, + Cronet_UrlRequestCallback_OnSucceededFunc OnSucceededFunc, + Cronet_UrlRequestCallback_OnFailedFunc OnFailedFunc, + Cronet_UrlRequestCallback_OnCanceledFunc OnCanceledFunc); + + void Cronet_UrlRequestCallback_SetClientContext( + Cronet_UrlRequestCallbackPtr self, + Cronet_ClientContext client_context); + + void Cronet_UrlRequestCallback_Destroy( + Cronet_UrlRequestCallbackPtr self); + + Cronet_BufferPtr Cronet_Buffer_Create(void); + + void Cronet_Buffer_InitWithAlloc(Cronet_BufferPtr self, uint64_t size); + + Cronet_String Cronet_Error_message_get(const Cronet_ErrorPtr self); + + Cronet_ClientContext Cronet_UrlRequestCallback_GetClientContext(Cronet_UrlRequestCallbackPtr self); + + /////////////////////// + // Abstract interface Cronet_Executor is implemented by the app. + + // There is no method to create a concrete implementation. + + // Destroy an instance of Cronet_Executor. + CRONET_EXPORT void Cronet_Executor_Destroy(Cronet_ExecutorPtr self); + // Set and get app-specific Cronet_ClientContext. + CRONET_EXPORT void Cronet_Executor_SetClientContext( + Cronet_ExecutorPtr self, + Cronet_ClientContext client_context); + CRONET_EXPORT Cronet_ClientContext + Cronet_Executor_GetClientContext(Cronet_ExecutorPtr self); + // Abstract interface Cronet_Executor is implemented by the app. + // The following concrete methods forward call to app implementation. + // The app doesn't normally call them. + CRONET_EXPORT + void Cronet_Executor_Execute(Cronet_ExecutorPtr self, + Cronet_RunnablePtr command); + // The app implements abstract interface Cronet_Executor by defining custom + // functions for each method. + typedef void (*Cronet_Executor_ExecuteFunc)(Cronet_ExecutorPtr self, + Cronet_RunnablePtr command); + // The app creates an instance of Cronet_Executor by providing custom functions + // for each method. + CRONET_EXPORT Cronet_ExecutorPtr + Cronet_Executor_CreateWith(Cronet_Executor_ExecuteFunc ExecuteFunc); + + /////////////////////// + // Abstract interface Cronet_Runnable is implemented by the app. + + // There is no method to create a concrete implementation. + + // Destroy an instance of Cronet_Runnable. + CRONET_EXPORT void Cronet_Runnable_Destroy(Cronet_RunnablePtr self); + // Set and get app-specific Cronet_ClientContext. + CRONET_EXPORT void Cronet_Runnable_SetClientContext( + Cronet_RunnablePtr self, + Cronet_ClientContext client_context); + CRONET_EXPORT Cronet_ClientContext + Cronet_Runnable_GetClientContext(Cronet_RunnablePtr self); + // Abstract interface Cronet_Runnable is implemented by the app. + // The following concrete methods forward call to app implementation. + // The app doesn't normally call them. + CRONET_EXPORT + void Cronet_Runnable_Run(Cronet_RunnablePtr self); + // The app implements abstract interface Cronet_Runnable by defining custom + // functions for each method. + typedef void (*Cronet_Runnable_RunFunc)(Cronet_RunnablePtr self); + // The app creates an instance of Cronet_Runnable by providing custom functions + // for each method. + CRONET_EXPORT Cronet_RunnablePtr + Cronet_Runnable_CreateWith(Cronet_Runnable_RunFunc RunFunc); +#ifdef __cplusplus +} +#endif + +#endif // CRONET_IDL_EXTRA_SAMPLE_ diff --git a/third_party/cronet_sample/main.cc b/third_party/cronet_sample/main.cc new file mode 100644 index 0000000..55fbf5e --- /dev/null +++ b/third_party/cronet_sample/main.cc @@ -0,0 +1,49 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#include +#include "../cronet/cronet_c.h" +#include "cronet.idl_c.extras.h" +#include "sample_executor.h" +#include "sample_url_request_callback.h" +Cronet_EnginePtr CreateCronetEngine() { + Cronet_EnginePtr cronet_engine = Cronet_Engine_Create(); + Cronet_EngineParamsPtr engine_params = Cronet_EngineParams_Create(); + Cronet_EngineParams_user_agent_set(engine_params, "CronetSample/1"); + Cronet_EngineParams_enable_quic_set(engine_params, true); + Cronet_Engine_StartWithParams(cronet_engine, engine_params); + Cronet_EngineParams_Destroy(engine_params); + return cronet_engine; +} +void PerformRequest(Cronet_EnginePtr cronet_engine, + const std::string& url, + Cronet_ExecutorPtr executor) { + SampleUrlRequestCallback url_request_callback; + Cronet_UrlRequestPtr request = Cronet_UrlRequest_Create(); + Cronet_UrlRequestParamsPtr request_params = Cronet_UrlRequestParams_Create(); + Cronet_UrlRequestParams_http_method_set(request_params, "GET"); + Cronet_UrlRequest_InitWithParams( + request, cronet_engine, url.c_str(), request_params, + url_request_callback.GetUrlRequestCallback(), executor); + Cronet_UrlRequestParams_Destroy(request_params); + Cronet_UrlRequest_Start(request); + url_request_callback.WaitForDone(); + Cronet_UrlRequest_Destroy(request); + std::cout << "Response Data:" << std::endl + << url_request_callback.response_as_string() << std::endl; +} +// Download a resource from the Internet. Optional argument must specify +// a valid URL. +int main(int argc, const char* argv[]) { + std::cout << "Hello from Cronet!\n"; + Cronet_EnginePtr cronet_engine = CreateCronetEngine(); + std::cout << "Cronet version: " + << Cronet_Engine_GetVersionString(cronet_engine) << std::endl; + std::string url(argc > 1 ? argv[1] : "https://www.example.com"); + std::cout << "URL: " << url << std::endl; + SampleExecutor executor; + PerformRequest(cronet_engine, url, executor.GetExecutor()); + Cronet_Engine_Shutdown(cronet_engine); + Cronet_Engine_Destroy(cronet_engine); + return 0; +} diff --git a/third_party/cronet_sample/sample_executor.cc b/third_party/cronet_sample/sample_executor.cc new file mode 100644 index 0000000..81bab31 --- /dev/null +++ b/third_party/cronet_sample/sample_executor.cc @@ -0,0 +1,81 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#include "sample_executor.h" +SampleExecutor::SampleExecutor() + : executor_thread_(SampleExecutor::ThreadLoop, this), + executor_(Cronet_Executor_CreateWith(SampleExecutor::Execute)) { + Cronet_Executor_SetClientContext(executor_, this); +} +SampleExecutor::~SampleExecutor() { + ShutdownExecutor(); + Cronet_Executor_Destroy(executor_); +} +Cronet_ExecutorPtr SampleExecutor::GetExecutor() { + return executor_; +} +void SampleExecutor::ShutdownExecutor() { + // Break tasks loop. + { + std::lock_guard lock(lock_); + stop_thread_loop_ = true; + } + task_available_.notify_one(); + // Wait for executor thread. + executor_thread_.join(); +} +void SampleExecutor::RunTasksInQueue() { + // Process runnables in |task_queue_|. + while (true) { + Cronet_RunnablePtr runnable = nullptr; + { + // Wait for a task to run or stop signal. + std::unique_lock lock(lock_); + while (task_queue_.empty() && !stop_thread_loop_) + task_available_.wait(lock); + if (stop_thread_loop_) + break; + if (task_queue_.empty()) + continue; + runnable = task_queue_.front(); + task_queue_.pop(); + } + Cronet_Runnable_Run(runnable); + Cronet_Runnable_Destroy(runnable); + } + // Delete remaining tasks. + std::queue tasks_to_destroy; + { + std::unique_lock lock(lock_); + tasks_to_destroy.swap(task_queue_); + } + while (!tasks_to_destroy.empty()) { + Cronet_Runnable_Destroy(tasks_to_destroy.front()); + tasks_to_destroy.pop(); + } +} +/* static */ +void SampleExecutor::ThreadLoop(SampleExecutor* executor) { + executor->RunTasksInQueue(); +} +void SampleExecutor::Execute(Cronet_RunnablePtr runnable) { + { + std::lock_guard lock(lock_); + if (!stop_thread_loop_) { + task_queue_.push(runnable); + runnable = nullptr; + } + } + if (runnable) { + Cronet_Runnable_Destroy(runnable); + } else { + task_available_.notify_one(); + } +} +/* static */ +void SampleExecutor::Execute(Cronet_ExecutorPtr self, + Cronet_RunnablePtr runnable) { + auto* executor = + static_cast(Cronet_Executor_GetClientContext(self)); + executor->Execute(runnable); +} diff --git a/third_party/cronet_sample/sample_executor.h b/third_party/cronet_sample/sample_executor.h new file mode 100644 index 0000000..c15bdeb --- /dev/null +++ b/third_party/cronet_sample/sample_executor.h @@ -0,0 +1,44 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#ifndef COMPONENTS_CRONET_NATIVE_SAMPLE_SAMPLE_EXECUTOR_H_ +#define COMPONENTS_CRONET_NATIVE_SAMPLE_SAMPLE_EXECUTOR_H_ +// Cronet sample is expected to be used outside of Chromium infrastructure, +// and as such has to rely on STL directly instead of //base alternatives. +#include +#include +#include +#include +#include "cronet.idl_c.extras.h" +// Sample implementation of Cronet_Executor interface using static +// methods to map C API into instance of C++ class. +class SampleExecutor { + public: + SampleExecutor(); + ~SampleExecutor(); + // Gets Cronet_ExecutorPtr implemented by |this|. + Cronet_ExecutorPtr GetExecutor(); + // Shuts down the executor, so all pending tasks are destroyed without + // getting executed. + void ShutdownExecutor(); + private: + // Runs tasks in |task_queue_| until |stop_thread_loop_| is set to true. + void RunTasksInQueue(); + static void ThreadLoop(SampleExecutor* executor); + // Adds |runnable| to |task_queue_| to execute on |executor_thread_|. + void Execute(Cronet_RunnablePtr runnable); + // Implementation of Cronet_Executor methods. + static void Execute(Cronet_ExecutorPtr self, Cronet_RunnablePtr runnable); + // Synchronise access to |task_queue_| and |stop_thread_loop_|; + std::mutex lock_; + // Tasks to run. + std::queue task_queue_; + // Notified if task is added to |task_queue_| or |stop_thread_loop_| is set. + std::condition_variable task_available_; + // Set to true to stop running tasks. + bool stop_thread_loop_ = false; + // Thread on which tasks are executed. + std::thread executor_thread_; + Cronet_ExecutorPtr const executor_; +}; +#endif // COMPONENTS_CRONET_NATIVE_SAMPLE_SAMPLE_EXECUTOR_H_ diff --git a/third_party/cronet_sample/sample_url_request_callback.cc b/third_party/cronet_sample/sample_url_request_callback.cc new file mode 100644 index 0000000..f12061e --- /dev/null +++ b/third_party/cronet_sample/sample_url_request_callback.cc @@ -0,0 +1,121 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#include "cronet.idl_c.extras.h" +#include "sample_url_request_callback.h" +#include +SampleUrlRequestCallback::SampleUrlRequestCallback() + : callback_(Cronet_UrlRequestCallback_CreateWith( + SampleUrlRequestCallback::OnRedirectReceived, + SampleUrlRequestCallback::OnResponseStarted, + SampleUrlRequestCallback::OnReadCompleted, + SampleUrlRequestCallback::OnSucceeded, + SampleUrlRequestCallback::OnFailed, + SampleUrlRequestCallback::OnCanceled)) { + Cronet_UrlRequestCallback_SetClientContext(callback_, this); +} +SampleUrlRequestCallback::~SampleUrlRequestCallback() { + Cronet_UrlRequestCallback_Destroy(callback_); +} +Cronet_UrlRequestCallbackPtr SampleUrlRequestCallback::GetUrlRequestCallback() { + return callback_; +} +void SampleUrlRequestCallback::OnRedirectReceived( + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_String newLocationUrl) { + std::cout << "OnRedirectReceived called: " << newLocationUrl << std::endl; + Cronet_UrlRequest_FollowRedirect(request); +} +void SampleUrlRequestCallback::OnResponseStarted( + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info) { + std::cout << "OnResponseStarted called." << std::endl; + std::cout << "HTTP Status: " + << Cronet_UrlResponseInfo_http_status_code_get(info) << " " + << Cronet_UrlResponseInfo_http_status_text_get(info) << std::endl; + // Create and allocate 32kb buffer. + Cronet_BufferPtr buffer = Cronet_Buffer_Create(); + Cronet_Buffer_InitWithAlloc(buffer, 32 * 1024); + // Started reading the response. + Cronet_UrlRequest_Read(request, buffer); +} +void SampleUrlRequestCallback::OnReadCompleted(Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_BufferPtr buffer, + uint64_t bytes_read) { + std::cout << "OnReadCompleted called: " << bytes_read << " bytes read." + << std::endl; + std::string last_read_data( + reinterpret_cast(Cronet_Buffer_GetData(buffer)), bytes_read); + response_as_string_ += last_read_data; + // Continue reading the response. + Cronet_UrlRequest_Read(request, buffer); +} +void SampleUrlRequestCallback::OnSucceeded(Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info) { + std::cout << "OnSucceeded called." << std::endl; + SignalDone(true); +} +void SampleUrlRequestCallback::OnFailed(Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_ErrorPtr error) { + std::cout << "OnFailed called: " << Cronet_Error_message_get(error) + << std::endl; + last_error_message_ = Cronet_Error_message_get(error); + SignalDone(false); +} +void SampleUrlRequestCallback::OnCanceled(Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info) { + std::cout << "OnCanceled called." << std::endl; + SignalDone(false); +} +/* static */ +SampleUrlRequestCallback* SampleUrlRequestCallback::GetThis( + Cronet_UrlRequestCallbackPtr self) { + return static_cast( + Cronet_UrlRequestCallback_GetClientContext(self)); +} +/* static */ +void SampleUrlRequestCallback::OnRedirectReceived( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_String newLocationUrl) { + GetThis(self)->OnRedirectReceived(request, info, newLocationUrl); +} +/* static */ +void SampleUrlRequestCallback::OnResponseStarted( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info) { + GetThis(self)->OnResponseStarted(request, info); +} +/* static */ +void SampleUrlRequestCallback::OnReadCompleted( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_BufferPtr buffer, + uint64_t bytesRead) { + GetThis(self)->OnReadCompleted(request, info, buffer, bytesRead); +} +/* static */ +void SampleUrlRequestCallback::OnSucceeded(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info) { + GetThis(self)->OnSucceeded(request, info); +} +/* static */ +void SampleUrlRequestCallback::OnFailed(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_ErrorPtr error) { + GetThis(self)->OnFailed(request, info, error); +} +/* static */ +void SampleUrlRequestCallback::OnCanceled(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info) { + GetThis(self)->OnCanceled(request, info); +} diff --git a/third_party/cronet_sample/sample_url_request_callback.h b/third_party/cronet_sample/sample_url_request_callback.h new file mode 100644 index 0000000..615237d --- /dev/null +++ b/third_party/cronet_sample/sample_url_request_callback.h @@ -0,0 +1,79 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#ifndef COMPONENTS_CRONET_NATIVE_SAMPLE_SAMPLE_URL_REQUEST_CALLBACK_H_ +#define COMPONENTS_CRONET_NATIVE_SAMPLE_SAMPLE_URL_REQUEST_CALLBACK_H_ +// Cronet sample is expected to be used outside of Chromium infrastructure, +// and as such has to rely on STL directly instead of //base alternatives. +#include +#include +#include +#include +#include +#include "cronet.idl_c.extras.h" +// Sample implementation of Cronet_UrlRequestCallback interface using static +// methods to map C API into instance of C++ class. +class SampleUrlRequestCallback { + public: + SampleUrlRequestCallback(); + ~SampleUrlRequestCallback(); + // Gets Cronet_UrlRequestCallbackPtr implemented by |this|. + Cronet_UrlRequestCallbackPtr GetUrlRequestCallback(); + // Waits until request is done. + void WaitForDone() { is_done_.wait(); } + // Returns error message if OnFailed callback is invoked. + std::string last_error_message() const { return last_error_message_; } + // Returns string representation of the received response. + std::string response_as_string() const { return response_as_string_; } + protected: + void OnRedirectReceived(Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_String newLocationUrl); + void OnResponseStarted(Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); + void OnReadCompleted(Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_BufferPtr buffer, + uint64_t bytes_read); + void OnSucceeded(Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); + void OnFailed(Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_ErrorPtr error); + void OnCanceled(Cronet_UrlRequestPtr request, Cronet_UrlResponseInfoPtr info); + void SignalDone(bool success) { done_with_success_.set_value(success); } + static SampleUrlRequestCallback* GetThis(Cronet_UrlRequestCallbackPtr self); + // Implementation of Cronet_UrlRequestCallback methods. + static void OnRedirectReceived(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_String newLocationUrl); + static void OnResponseStarted(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); + static void OnReadCompleted(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_BufferPtr buffer, + uint64_t bytesRead); + static void OnSucceeded(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); + static void OnFailed(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_ErrorPtr error); + static void OnCanceled(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); + // Error message copied from |error| if OnFailed callback is invoked. + std::string last_error_message_; + // Accumulated string representation of the received response. + std::string response_as_string_; + // Promise that is set when request is done. + std::promise done_with_success_; + // Future that is signalled when request is done. + std::future is_done_ = done_with_success_.get_future(); + Cronet_UrlRequestCallbackPtr const callback_; +}; +#endif // COMPONENTS_CRONET_NATIVE_SAMPLE_SAMPLE_URL_REQUEST_CALLBACK_H_ From c88867e9c82efcf1541e64d46021eb7a3dfa0993 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Wed, 23 Jun 2021 22:49:47 +0530 Subject: [PATCH 20/42] refactoring, added new tests and api comparisons --- README.md | 7 +- bin/{build_cronet.dart => build.dart} | 2 +- bin/prepare_cronet.dart | 5 +- dart_io_comparison.md | 18 ++++ lib/src/exceptions.dart | 13 ++- lib/src/http_client.dart | 99 ++++++-------------- lib/src/http_client_request.dart | 111 ++++++----------------- lib/src/http_client_response.dart | 5 +- pubspec.yaml | 3 - src/wrapper.cc | 11 ++- test/cronet_test.dart | 2 +- test/http_client_close_test.dart | 14 +-- test/http_request_exceptions_test.dart | 23 +++-- test/http_responses_exceptions_test.dart | 14 +-- test/http_responses_new_api_test.dart | 14 +-- test/http_responses_test.dart | 54 +++++++---- test/test_utils.dart | 3 - 17 files changed, 179 insertions(+), 219 deletions(-) rename bin/{build_cronet.dart => build.dart} (96%) create mode 100644 dart_io_comparison.md diff --git a/README.md b/README.md index 0b8c2e6..845cff2 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,8 @@ This is a [GSoC 2021 project](https://summerofcode.withgoogle.com/projects/#4757 }); ``` +[See the API comparison with dart:io.]('dart_io_comparison.md') + ## Run Example ```bash @@ -79,13 +81,12 @@ dart run cronet # Downloads the cronet binaries. dart test --platform vm ``` -Test your cronet build by following [BUILD.md](third_party/cronet_sample/BUILD.md). +You can also test your cronet build independently by following [BUILD.md](third_party/cronet_sample/BUILD.md). ## Building Your Own 1. Make sure you've downloaded your custom version of cronet shared library and filename follows the pattern `cronet..`. Default is: `cronet.86.0.4240.198.so` for linux. Else, you can build cronet from [source](https://www.chromium.org/developers/how-tos/get-the-code) using the [provided instuctions](https://chromium.googlesource.com/chromium/src/+/master/components/cronet/build_instructions.md). Then copy the library to the root of your project. For linux, you can also place the files under `cronet_binaries/linux64` for 64bit linux systems. -2. Activate `cronet.dart` package using `dart pub global activate`. -3. Run `build_cronet ` from the root of your project. +2. Run `dart run cronet:build` from the root of your project. **Note for Windows:** Run `step 3` from `x64 Native Tools Command Prompt for VS 2019` shell. diff --git a/bin/build_cronet.dart b/bin/build.dart similarity index 96% rename from bin/build_cronet.dart rename to bin/build.dart index e9b21b3..f5f7725 100644 --- a/bin/build_cronet.dart +++ b/bin/build.dart @@ -16,7 +16,7 @@ void main(List args) { final ansi = Ansi(Ansi.terminalSupportsAnsi); if (args.contains('-h')) { - print('build_cronet [cronet_version]'); + print('dart run cronet:build [cronet_version]'); } final version = args.isEmpty ? cronetVersion : args[0]; if (Platform.isLinux) { diff --git a/bin/prepare_cronet.dart b/bin/prepare_cronet.dart index 3158593..00d847b 100644 --- a/bin/prepare_cronet.dart +++ b/bin/prepare_cronet.dart @@ -77,11 +77,12 @@ bool buildWrapperWindows([String? version]) { print(result.stdout); print(result.stderr); } catch (error) { + Directory.current = pwd; logger.stdout("${ansi.red}Build failed.${ansi.none}"); logger.stdout( 'Open ${ansi.yellow}x64 Native Tools Command Prompt for VS 2019.${ansi.none} Then run:\n'); - logger.stdout('cd ${pwd.path}\nbuild_cronet ${version ?? cronetVersion}'); - Directory.current = pwd; + logger.stdout( + 'cd ${pwd.path}\ndart run cronet:build ${version ?? cronetVersion}'); return false; } var result = diff --git a/dart_io_comparison.md b/dart_io_comparison.md new file mode 100644 index 0000000..b15b8f4 --- /dev/null +++ b/dart_io_comparison.md @@ -0,0 +1,18 @@ +# Comparing APIs with dart:io + +## userAgent + +### dart:io + + ```dart + final client = HttpClient(); + client.userAgent = 'myUA/1.0'; // using custom UA string. + print(client.userAgent); // Will print myUA/1.0. + ``` + +### Cronet + + ```dart + final client = HttpClient(userAgent: 'myUA/1.0'); // using custom UA string. + print(client.userAgent); // Will print myUA/1.0. + ``` diff --git a/lib/src/exceptions.dart b/lib/src/exceptions.dart index e640ac6..ca58ee3 100644 --- a/lib/src/exceptions.dart +++ b/lib/src/exceptions.dart @@ -25,20 +25,25 @@ class HttpException implements IOException { } } -class CronetException implements Exception { +/// Errors/Exceptions from Cronet Native Library. +class CronetNativeException implements Exception { final int val; - const CronetException(this.val); + const CronetNativeException(this.val); @override String toString() { final b = StringBuffer() - ..write('CronetException: Cronet Result: ') + ..write('CronetNativeException: Cronet Result: ') ..write(val); return b.toString(); } } -class UrlRequestException extends CronetException { +/// Exceptions occured while performing a request. +/// +/// Failing to start a request or failing to complete +/// with a proper server response will throw this exception. +class UrlRequestException extends CronetNativeException { const UrlRequestException(int val) : super(val); } diff --git a/lib/src/http_client.dart b/lib/src/http_client.dart index 1e3bccc..961e758 100644 --- a/lib/src/http_client.dart +++ b/lib/src/http_client.dart @@ -4,13 +4,11 @@ import 'dart:async'; import 'dart:ffi'; -import 'dart:io' as io; import 'package:cronet/src/exceptions.dart'; import 'package:ffi/ffi.dart'; import 'dylib_handler.dart'; -import 'enums.dart'; import 'generated_bindings.dart'; import 'quic_hint.dart'; import 'http_client_request.dart'; @@ -22,11 +20,11 @@ final _cronet = Cronet(loadWrapper()); /// from a server using the HTTP, HTTPS, HTTP2, Quic etc. protocol. /// /// HttpClient contains a number of methods to send an [HttpClientRequest] to an -/// Http server and receive an [Stream] of [List] of [int], analogus to [HttpClientResponse] back. -/// Alternatively, you can also register callbacks for different network events including -/// but not limited to receiving the raw bytes sent by the server. -/// For example, you can use the -/// [get], [getUrl], [post], and [postUrl] methods for GET and POST requests, respectively. +/// Http server and receive an [HttpClientResponse] back which is a [Stream]. +/// Alternatively, you can also register callbacks for different network events +/// including but not limited to receiving the raw bytes sent by the server. +/// For example, you can use the [get], [getUrl], [post], and [postUrl] methods +/// for GET and POST requests, respectively. /// /// Example Usage: /// ```dart @@ -42,11 +40,7 @@ class HttpClient { final bool http2; final bool brotli; final String acceptLanguage; - // final CacheMode cacheMode; - // final int? maxCache; - final List? quicHints; - - // TODO: Migrate enableTimelineLogging API here + final List quicHints; final Pointer _cronetEngine; // Keep all the request reference in a list so if the client is being explicitly closed, @@ -54,34 +48,20 @@ class HttpClient { final _requests = List.empty(growable: true); var _stop = false; - // Uri? _temp; - static const int defaultHttpPort = 80; static const int defaultHttpsPort = 443; - /// Initiates a [HttpClient]. + /// Initiates an [HttpClient] with the settings provided in the arguments. /// - /// An optional parameters - - /// 1. [quic] use QUIC protocol. Default - true. You can also pass [quicHints]. - /// 2. [http2] use HTTP2 protocol. Default - true - /// 3. [brotli] use brotli compression. Default - true - /// 4. [acceptLanguage] - Default - 'en_US' - /// 5. [cacheMode] - Choose from [CacheMode]. Default - [CacheMode.inMemory] (TODO) - /// 6. [maxCache] - Set maximum cache size in bytes. Set to `null` to let the system decide. Default - `10KB`. (TODO) - /// 7. If caches and cookies should persist, provide a directory using [cronetStorage]. Keeping it null will use - /// a temporary, non persistant storage. - /// - /// NOTE: For [CacheMode.inMemory], [maxCache] must not be null. For any other mode, it can be. + /// The settings control whether this client supports [quic], [brotli] and + /// [http2]. If [quic] is enabled, then [quicHints] can be provided. + /// [userAgent] and [acceptLanguage] can also be provided. /// /// Throws [CronetException] if [HttpClient] can't be created. - /// - /// Breaking Changes from `dart:io` based library: - /// - /// 1. [userAgent] property must be set when constructing [HttpClient] and can't be changed afterwards. HttpClient({ this.userAgent = 'Dart/2.12', this.quic = true, - this.quicHints, + this.quicHints = const [], this.http2 = true, this.brotli = true, this.acceptLanguage = 'en_US', @@ -95,18 +75,17 @@ class HttpClient { _cronet.Cronet_EngineParams_user_agent_set( engineParams, userAgent.toNativeUtf8().cast()); _cronet.Cronet_EngineParams_enable_quic_set(engineParams, quic); - - if (quicHints != null) { - for (final quicHint in quicHints!) { - final hint = _cronet.Cronet_QuicHint_Create(); - _cronet.Cronet_QuicHint_host_set( - hint, quicHint.host.toNativeUtf8().cast()); - _cronet.Cronet_QuicHint_port_set(hint, quicHint.port); - _cronet.Cronet_QuicHint_alternate_port_set( - hint, quicHint.alternatePort); - _cronet.Cronet_EngineParams_quic_hints_add(engineParams, hint); - _cronet.Cronet_QuicHint_Destroy(hint); - } + if (!quic && quicHints.isNotEmpty) { + throw ArgumentError('Quic is not enabled but quic hints are provided.'); + } + for (final quicHint in quicHints) { + final hint = _cronet.Cronet_QuicHint_Create(); + _cronet.Cronet_QuicHint_host_set( + hint, quicHint.host.toNativeUtf8().cast()); + _cronet.Cronet_QuicHint_port_set(hint, quicHint.port); + _cronet.Cronet_QuicHint_alternate_port_set(hint, quicHint.alternatePort); + _cronet.Cronet_EngineParams_quic_hints_add(engineParams, hint); + _cronet.Cronet_QuicHint_Destroy(hint); } _cronet.Cronet_EngineParams_enable_http2_set(engineParams, http2); @@ -114,12 +93,10 @@ class HttpClient { _cronet.Cronet_EngineParams_accept_language_set( engineParams, acceptLanguage.toNativeUtf8().cast()); - // TODO: Storage and cache mode change code goes here - final res = _cronet.Cronet_Engine_StartWithParams(_cronetEngine, engineParams); if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { - throw CronetException(res); + throw CronetNativeException(res); } _cronet.Cronet_EngineParams_Destroy(engineParams); } @@ -128,23 +105,15 @@ class HttpClient { _requests.remove(hcr); } - /// Shuts down the HTTP client. + /// Shuts down the [HttpClient]. /// - /// If [force] is `false` (the default) the HttpClient will be kept alive until all - /// active connections are done. If [force] is `true` any active connections - /// will be closed to immediately release all resources. These closed connections - /// will receive an ~error~ cancel event to indicate that the client was shut down. - /// In both cases trying to establish a new connection after calling close, - /// will throw an exception. - void close({bool force = false}) { - if (_stop) { - // If already stopped, return immediately. - return; - } + /// The HttpClient will be kept alive until all active connections are done. + /// Trying to establish a new connection after calling close, will throw an exception. + void close() { _stop = true; - // TODO: add force stop code here (with abort api) } + /// Constructs [Uri] from [host], [port] & [path]. Uri _getUri(String host, int port, String path) { final _host = Uri.parse(host); if (!_host.hasScheme) { @@ -263,17 +232,7 @@ class HttpClient { return deleteUrl(_getUri(host, port, path)); } - /// Function for resolving the proxy server to be used for a HTTP connection from - /// the proxy configuration specified through environment variables. - /// - /// Note: It just returns `dart:io` [HttpClient.findProxyFromEnvironment]. - static String findProxyFromEnvironment(Uri url, - {Map? environment}) { - return io.HttpClient.findProxyFromEnvironment(url, - environment: environment); - } - - /// Gets Cronet's version + /// Version string of the Cronet Shared Library currently in use. String get httpClientVersion => _cronet.Cronet_Engine_GetVersionString(_cronetEngine) .cast() diff --git a/lib/src/http_client_request.dart b/lib/src/http_client_request.dart index 6029ad3..00093f2 100644 --- a/lib/src/http_client_request.dart +++ b/lib/src/http_client_request.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:async'; -// import 'dart:collection'; import 'dart:convert'; import 'dart:developer'; import 'dart:ffi'; @@ -14,40 +13,20 @@ import 'dart:typed_data'; import 'package:ffi/ffi.dart'; import 'exceptions.dart'; - import 'generated_bindings.dart'; - -// TODO: Enable these when Headers are implemented -// part '../third_party/http_headers.dart'; -// part '../third_party/http_date.dart'; part 'http_client_response.dart'; part 'http_callback_handler.dart'; -// Type definitions for various callbacks - -/// Called when a redirect is received. Gets new location and response code as -/// arguments. +// Function signature for callbacks called on redirects. typedef RedirectReceivedCallback = void Function( String newLocationUrl, int responseCode); - -/// Called when server sends a response for the first time. Gets the response code -/// as an argument. typedef ResponseStartedCallback = void Function(int responseCode); -/// Called when a chunk of data is received from the server. Gets raw bytes as -/// [List], number of bytes read and response code as arguments. -typedef ReadDataCallback = void Function(List data, int bytesRead, - int responseCode); // onReadComplete may confuse people. - -/// Called when request is failed due to some reason. Gets [HttpException] as -/// an argument which also contains the reason of failure. +/// Called when a chunk of data is received from the server. +typedef ReadDataCallback = void Function( + List data, int bytesRead, int responseCode); typedef FailedCallabck = void Function(HttpException exception); - -/// Called when a request is cancelled. typedef CanceledCallabck = void Function(); - -/// Called when a request is finished with success. Gets the response code as -/// an argument. typedef SuccessCallabck = void Function(int responseCode); /// HTTP request for a client connection. @@ -68,7 +47,6 @@ typedef SuccessCallabck = void Function(int responseCode); /// // Use it as you like. /// }); /// ``` -// TODO: Implement other functions class HttpClientRequest implements IOSink { final Uri _uri; final String _method; @@ -76,15 +54,11 @@ class HttpClientRequest implements IOSink { final Pointer _cronetEngine; final _CallbackHandler _cbh; final Pointer _request; - final Function _clientCleanup; // Holds the function to clean up after - // // the request is done (if nessesary). - // // implemented in: http_client.dart - // TODO: Enable with abort API - // bool _isAborted = false; - // TODO: See how that affects and do we need to change - // Negotiated protocol info is only available via Cronet_UrlResponseInfo - // final _headers = _HttpHeaders('1.1'); // Setting it to HTTP/1.1 + /// Holds the function to clean up after the request is done (if nessesary). + /// + /// Implemented by: http_client.dart. + final Function _clientCleanup; @override Encoding encoding; @@ -103,17 +77,10 @@ class HttpClientRequest implements IOSink { // Starts the request. void _startRequest() { - // TODO: Enable with abort API - // if (_isAborted) { - // throw Exception('Request is already aborted'); - // } - // _headers._finalize(); // making headers immutable final requestParams = _cronet.Cronet_UrlRequestParams_Create(); _cronet.Cronet_UrlRequestParams_http_method_set( requestParams, _method.toNativeUtf8().cast()); - // TODO: Setting headers go here - final res = _cronet.Cronet_UrlRequest_Init( _request, _cronetEngine, @@ -173,51 +140,50 @@ class HttpClientRequest implements IOSink { }); } - /// Aborts the client connection. - /// - /// If the connection has not yet completed, the request is aborted - /// and closes the [Stream] with onDone callback you may have - /// registered. The [Exception] passed to it is thrown and - /// [StackTrace] is printed. If there is no [StackTrace] provided, - /// [StackTrace.empty] will be shown. If no [Exception] is provided, - /// no exception is thrown. - /// If the [Stream] is closed, aborting has no effect. - void abort([Object? exception, StackTrace? stackTrace]) { - // TODO: Migrate abort code - throw UnimplementedError(); - } - /// Done is same as [close]. A [HttpClientResponse] future that will complete once the response is available. /// /// If an error occurs before the response is available, this future will complete with an error. @override Future get done => close(); + /// Follow the redirects. + bool get followRedirects => _cbh.followRedirects; + set followRedirects(bool follow) { + _cbh.followRedirects = follow; + } + + /// Maximum numbers of redirects to follow. + /// Have no effect if [followRedirects] is set to false. + int get maxRedirects => _cbh.maxRedirects; + set maxRedirects(int redirects) { + _cbh.maxRedirects = redirects; + } + + /// The uri of the request. + Uri get uri => _uri; + @override void add(List data) { - // TODO: Implement this with POST request - throw UnimplementedError(); + // TODO: implement add } @override void addError(Object error, [StackTrace? stackTrace]) { - // TODO: Implement this with POST request - throw UnimplementedError(); + // TODO: implement addError } @override Future addStream(Stream> stream) { - // TODO: Implement this with POST request + // TODO: implement addStream throw UnimplementedError(); } @override Future flush() { - // TODO: Implement this with POST request + // TODO: implement flush throw UnimplementedError(); } - // Implementation taken from `dart:io`. @override void write(Object? object) { final string = '$object'; @@ -225,7 +191,6 @@ class HttpClientRequest implements IOSink { add(encoding.encode(string)); } - // Implementation taken from `dart:io`. @override void writeAll(Iterable objects, [String separator = '']) { final iterator = objects.iterator; @@ -243,34 +208,14 @@ class HttpClientRequest implements IOSink { } } - // Implementation taken from `dart:io`. @override void writeCharCode(int charCode) { write(String.fromCharCode(charCode)); } - // Implementation taken from `dart:io`. @override void writeln([Object? object = '']) { write(object); write('\n'); } - - /// Follow the redirects. - bool get followRedirects => _cbh.followRedirects; - set followRedirects(bool follow) { - _cbh.followRedirects = follow; - } - - /// Maximum numbers of redirects to follow. - /// Have no effect if [followRedirects] is set to false. - int get maxRedirects => _cbh.maxRedirects; - set maxRedirects(int redirects) { - _cbh.maxRedirects = redirects; - } - - /// The uri of the request. - Uri get uri => _uri; - - // HttpHeaders get headers => _headers; } diff --git a/lib/src/http_client_response.dart b/lib/src/http_client_response.dart index bf2cc95..0e0c618 100644 --- a/lib/src/http_client_response.dart +++ b/lib/src/http_client_response.dart @@ -4,8 +4,11 @@ part of '../src/http_client_request.dart'; +/// Represents the server's response to a request. +/// /// The body of a [HttpClientResponse] object is a [Stream] of data from the server. -/// Listen to the body to handle the data and be notified when the entire body is received. +/// Listen to the body to handle the data and be notified when the entire body +/// is received. abstract class HttpClientResponse extends Stream> { HttpClientResponse(); diff --git a/pubspec.yaml b/pubspec.yaml index 163465e..97d3373 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -22,9 +22,6 @@ dev_dependencies: lints: ^1.0.1 test: ^1.17.5 -executables: - build_cronet: - ffigen: name: 'Cronet' description: 'Bindings to Cronet' diff --git a/src/wrapper.cc b/src/wrapper.cc index 845c3af..5fd322d 100644 --- a/src/wrapper.cc +++ b/src/wrapper.cc @@ -250,12 +250,15 @@ void registerCallbackHandler(Dart_Port send_port, Cronet_UrlRequestPtr rp) { requestNativePorts[rp] = send_port; } -// This sends the callback name and the associated data -// with it to the Dart side via NativePort +// This sends the callback name and the associated data with it to the Dart +// side via NativePort. // // Sent data is broken into 3 parts. -// message[0] is the method name, which is a string -// message[1] contains all the data to pass to that method +// message[0] is the method name, which is a string. +// message[1] contains all the data to pass to that method. +// +// Using this due to the lack of support for asynchronous callbacks in dart:ffi. +// See Issue: dart-lang/sdk#37022. void dispatchCallback(const char* methodname, Cronet_UrlRequestPtr request, Dart_CObject args) { Dart_CObject c_method_name; c_method_name.type = Dart_CObject_kString; diff --git a/test/cronet_test.dart b/test/cronet_test.dart index c13cc29..b7bb175 100644 --- a/test/cronet_test.dart +++ b/test/cronet_test.dart @@ -6,7 +6,7 @@ import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; void main() { - group('cronet_initialization_test', () { + group('Cronet Initialization', () { late HttpClient client; setUp(() { client = HttpClient(); diff --git a/test/http_client_close_test.dart b/test/http_client_close_test.dart index a251f38..8ab8a15 100644 --- a/test/http_client_close_test.dart +++ b/test/http_client_close_test.dart @@ -3,20 +3,22 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:convert'; -import 'dart:io'; +import 'dart:io' as io; import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; -import 'test_utils.dart'; + +const host = 'localhost'; +const sentData = 'Hello, world!'; void main() { - group('client_close_test', () { - late HttpServer server; + group('HttpClient Close', () { + late io.HttpServer server; late int port; setUp(() async { - server = await HttpServer.bind(InternetAddress.anyIPv6, 0); + server = await io.HttpServer.bind(io.InternetAddress.anyIPv6, 0); port = server.port; - server.listen((HttpRequest request) { + server.listen((io.HttpRequest request) { request.response.write(sentData); request.response.close(); }); diff --git a/test/http_request_exceptions_test.dart b/test/http_request_exceptions_test.dart index dc98219..ad37df0 100644 --- a/test/http_request_exceptions_test.dart +++ b/test/http_request_exceptions_test.dart @@ -2,34 +2,37 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'dart:io'; +import 'dart:io' as io; import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; -import 'test_utils.dart'; + +const host = 'localhost'; void main() { - group('request_HttpException_test', () { + group('Request exceptions', () { late HttpClient client; late int port; setUp(() async { client = HttpClient(); - final server = await HttpServer.bind(InternetAddress.anyIPv6, 0); + final server = await io.HttpServer.bind(io.InternetAddress.anyIPv6, 0); port = server.port; server.close(); }); - test('URL do not exist', () async { - final request = await client.openUrl('GET', - Uri.parse('http://localghost:$port')); // localghost shouln't exist :p + test('URL does not exist', () async { + // Using non-existent url. + final request = + await client.openUrl('GET', Uri.parse('http://localghost:$port')); final resp = await request.close(); expect(resp, emitsInOrder([emitsError(isA()), emitsDone])); }); test('The port is wrong', () async { - final request = await client.openUrl( - 'GET', Uri.parse('http://$host:$port')); // port 9999 should be close + // This port is already closed by the server. + final request = + await client.openUrl('GET', Uri.parse('http://$host:$port')); final resp = await request.close(); expect(resp, emitsInOrder([emitsError(isA()), emitsDone])); @@ -37,7 +40,7 @@ void main() { test('The scheme is wrong', () async { final request = - await client.openUrl('GET', Uri.parse('random://$host:$port')); + await client.openUrl('GET', Uri.parse('nonExistent://$host:$port')); final resp = await request.close(); expect(resp, emitsInOrder([emitsError(isA()), emitsDone])); diff --git a/test/http_responses_exceptions_test.dart b/test/http_responses_exceptions_test.dart index 28fe723..c9cfc6b 100644 --- a/test/http_responses_exceptions_test.dart +++ b/test/http_responses_exceptions_test.dart @@ -2,23 +2,25 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'dart:io'; +import 'dart:io' as io; import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; -import 'test_utils.dart'; + +const host = 'localhost'; void main() { - group('response_HttpException_test', () { + group('Server Response Exceptions', () { late HttpClient client; - late HttpServer server; + late io.HttpServer server; late int port; setUp(() async { client = HttpClient(); - server = await HttpServer.bind(InternetAddress.anyIPv6, 0); + server = await io.HttpServer.bind(io.InternetAddress.anyIPv6, 0); port = server.port; - server.listen((HttpRequest request) { + server.listen((io.HttpRequest request) { final paths = request.uri.pathSegments; + assert(paths.isNotEmpty); request.response.statusCode = int.parse(paths[0]); request.response.close(); }); diff --git a/test/http_responses_new_api_test.dart b/test/http_responses_new_api_test.dart index 2305874..d6b724f 100644 --- a/test/http_responses_new_api_test.dart +++ b/test/http_responses_new_api_test.dart @@ -3,22 +3,24 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:convert'; -import 'dart:io'; +import 'dart:io' as io; import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; -import 'test_utils.dart'; + +const host = 'localhost'; +const sentData = 'Hello, world!'; void main() { - group('callback_api_response_test New API', () { + group('Callback based api', () { late HttpClient client; - late HttpServer server; + late io.HttpServer server; late int port; setUp(() async { client = HttpClient(); - server = await HttpServer.bind(InternetAddress.anyIPv6, 0); + server = await io.HttpServer.bind(io.InternetAddress.anyIPv6, 0); port = server.port; - server.listen((HttpRequest request) { + server.listen((io.HttpRequest request) { if (request.uri.pathSegments.isNotEmpty && request.uri.pathSegments[0] == '301') { request.response.statusCode = 301; diff --git a/test/http_responses_test.dart b/test/http_responses_test.dart index 0ab8c60..3c210c3 100644 --- a/test/http_responses_test.dart +++ b/test/http_responses_test.dart @@ -3,23 +3,25 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:convert'; -import 'dart:io'; +import 'dart:io' as io; import 'package:cronet/cronet.dart'; import 'package:test/test.dart'; -import 'test_utils.dart'; + +const host = 'localhost'; +const sentData = 'Hello, world!'; void main() { - group('http_responses_test', () { + group('Server Responses', () { late HttpClient client; - late HttpServer server; + late io.HttpServer server; late int port; setUp(() async { client = HttpClient(); - server = await HttpServer.bind(InternetAddress.anyIPv6, 0); + server = await io.HttpServer.bind(io.InternetAddress.anyIPv6, 0); port = server.port; - server.listen((HttpRequest request) { - if (request.method == 'CUSTOM') { + server.listen((io.HttpRequest request) { + if (request.method != 'GET' && request.method != 'POST') { request.response.write(request.method); } else { request.response.write(sentData); @@ -44,15 +46,14 @@ void main() { test('Gets Hello, world response from server using openUrl method', () async { - final request = - await client.openUrl('GET', Uri.parse('http://$host:$port/random')); + final request = await client.openUrl( + 'GET', Uri.parse('http://$host:$port/some/path')); final resp = await request.close(); final dataStream = resp.transform(utf8.decoder); expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); }); - test( - 'Fetch Hello, world response from server using openUrl, custom method method', + test('Fetch Hello, world response from server using openUrl, custom method', () async { final request = await client.openUrl('CUSTOM', Uri.parse('http://$host:$port')); @@ -69,11 +70,32 @@ void main() { expect(dataStream, emitsInOrder([equals(sentData), emitsDone])); }); - test('response.close after registering callbacks will throw error', - () async { - final request = await client.postUrl(Uri.parse('http://$host:$port')); - request.registerCallbacks((data, bytesRead, responseCode) {}); - expect(request.close(), throwsA(isA())); + test('Sending a HEAD request to server should send no body', () async { + final request = await client.head(host, port, '/path'); + final resp = await request.close(); + final dataStream = resp.transform(utf8.decoder); + expect(dataStream, emitsInOrder([emitsDone])); + }); + + test('Do a PUT request to the server', () async { + final request = await client.put(host, port, '/path'); + final resp = await request.close(); + final dataStream = resp.transform(utf8.decoder); + expect(dataStream, emitsInOrder([equals('PUT'), emitsDone])); + }); + + test('Do a PATCH request to the server', () async { + final request = await client.patch(host, port, '/path'); + final resp = await request.close(); + final dataStream = resp.transform(utf8.decoder); + expect(dataStream, emitsInOrder([equals('PATCH'), emitsDone])); + }); + + test('Do a DELETE request to the server', () async { + final request = await client.delete(host, port, '/path'); + final resp = await request.close(); + final dataStream = resp.transform(utf8.decoder); + expect(dataStream, emitsInOrder([equals('DELETE'), emitsDone])); }); tearDown(() { diff --git a/test/test_utils.dart b/test/test_utils.dart index d57e166..213d311 100644 --- a/test/test_utils.dart +++ b/test/test_utils.dart @@ -1,6 +1,3 @@ // Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. - -const host = 'localhost'; -const sentData = 'Hello, world!'; From f6ae319fb1cba2776e2b711f6021a78218b0c910 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Thu, 24 Jun 2021 13:56:30 +0530 Subject: [PATCH 21/42] move find_resource.dart -> third_party and fix readme --- README.md | 2 +- bin/build.dart | 2 +- bin/prepare_cronet.dart | 2 +- lib/src/{ => third_party/ffigen}/find_resource.dart | 5 +---- test/test_utils.dart | 3 --- 5 files changed, 4 insertions(+), 10 deletions(-) rename lib/src/{ => third_party/ffigen}/find_resource.dart (91%) delete mode 100644 test/test_utils.dart diff --git a/README.md b/README.md index 845cff2..1ca7c56 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ This is a [GSoC 2021 project](https://summerofcode.withgoogle.com/projects/#4757 }); ``` -[See the API comparison with dart:io.]('dart_io_comparison.md') +[See the API comparison with dart:io.](dart_io_comparison.md) ## Run Example diff --git a/bin/build.dart b/bin/build.dart index f5f7725..b1b91b6 100644 --- a/bin/build.dart +++ b/bin/build.dart @@ -7,7 +7,7 @@ import 'dart:io'; import 'package:cli_util/cli_logging.dart' show Ansi, Logger; import 'package:cronet/src/constants.dart'; -import 'package:cronet/src/find_resource.dart'; +import 'package:cronet/src/third_party/ffigen/find_resource.dart'; import 'prepare_cronet.dart'; diff --git a/bin/prepare_cronet.dart b/bin/prepare_cronet.dart index 00d847b..a9a49e8 100644 --- a/bin/prepare_cronet.dart +++ b/bin/prepare_cronet.dart @@ -8,7 +8,7 @@ import 'dart:io' show Directory, File, HttpClient, Process; import 'package:archive/archive.dart'; import 'package:archive/archive_io.dart'; -import 'package:cronet/src/find_resource.dart'; +import 'package:cronet/src/third_party/ffigen/find_resource.dart'; import 'package:cronet/src/constants.dart'; import 'package:cli_util/cli_logging.dart' show Ansi, Logger; diff --git a/lib/src/find_resource.dart b/lib/src/third_party/ffigen/find_resource.dart similarity index 91% rename from lib/src/find_resource.dart rename to lib/src/third_party/ffigen/find_resource.dart index 1b9a495..4ef1ca2 100644 --- a/lib/src/find_resource.dart +++ b/lib/src/third_party/ffigen/find_resource.dart @@ -1,10 +1,7 @@ -// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// Contains code related to asset path resolution only. Not meant to be exposed. -// This code is a modified version from ffigen package's old commit. - import 'dart:convert'; import 'dart:io' show Directory, File, Platform; diff --git a/test/test_utils.dart b/test/test_utils.dart deleted file mode 100644 index 213d311..0000000 --- a/test/test_utils.dart +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. From 5eba348771f145f708b6d805dea77183d3ed000c Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Thu, 24 Jun 2021 19:25:47 +0530 Subject: [PATCH 22/42] remove: alternate callback based API --- README.md | 21 +--- dart_io_comparison.md | 18 +-- example_dart/bin/example_dart.dart | 16 --- lib/src/exceptions.dart | 4 - lib/src/http_callback_handler.dart | 148 +++-------------------- lib/src/http_client_request.dart | 48 +------- test/http_responses_exceptions_test.dart | 12 -- test/http_responses_new_api_test.dart | 89 -------------- 8 files changed, 33 insertions(+), 323 deletions(-) delete mode 100644 test/http_responses_new_api_test.dart diff --git a/README.md b/README.md index 1ca7c56..5e8efba 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,6 @@ This is a [GSoC 2021 project](https://summerofcode.withgoogle.com/projects/#4757 ## Example -### `dart:io` style API - ```dart final client = HttpClient(); client @@ -44,24 +42,7 @@ This is a [GSoC 2021 project](https://summerofcode.withgoogle.com/projects/#4757 }); ``` -### Alternate API - -```dart - final client = HttpClient(); - client - .getUrl(Uri.parse('http://info.cern.ch/')) - .then((HttpClientRequest request) { - request.registerCallbacks((data, bytesRead, responseCode) { - print(utf8.decoder.convert(data)); - print('Status: $responseCode'); - }, - onSuccess: (responseCode) => - print('Done with status: $responseCode')).catchError( - (Object e) {print(e);}); - }); -``` - -[See the API comparison with dart:io.](dart_io_comparison.md) +[See the API comparison with `dart:io`.](dart_io_comparison.md) ## Run Example diff --git a/dart_io_comparison.md b/dart_io_comparison.md index b15b8f4..4f01d86 100644 --- a/dart_io_comparison.md +++ b/dart_io_comparison.md @@ -4,15 +4,15 @@ ### dart:io - ```dart - final client = HttpClient(); - client.userAgent = 'myUA/1.0'; // using custom UA string. - print(client.userAgent); // Will print myUA/1.0. - ``` +```dart +final client = HttpClient(); +client.userAgent = 'myUA/1.0'; // using custom UA string. +print(client.userAgent); // Will print myUA/1.0. +``` ### Cronet - ```dart - final client = HttpClient(userAgent: 'myUA/1.0'); // using custom UA string. - print(client.userAgent); // Will print myUA/1.0. - ``` +```dart +final client = HttpClient(userAgent: 'myUA/1.0'); // using custom UA string. +print(client.userAgent); // Will print myUA/1.0. +``` diff --git a/example_dart/bin/example_dart.dart b/example_dart/bin/example_dart.dart index 1084b88..0a084d2 100644 --- a/example_dart/bin/example_dart.dart +++ b/example_dart/bin/example_dart.dart @@ -23,20 +23,4 @@ void main(List args) { }); }); } - - // Alternate API - - final client2 = HttpClient(); - client2 - .getUrl(Uri.parse('http://info.cern.ch/')) - .then((HttpClientRequest request) { - request.registerCallbacks((data, bytesRead, responseCode) { - print(utf8.decoder.convert(data)); - print('Status: $responseCode'); - }, - onSuccess: (responseCode) => - print('Done with status: $responseCode')).catchError((Object e) { - print(e); - }); - }); } diff --git a/lib/src/exceptions.dart b/lib/src/exceptions.dart index ca58ee3..5f9dfb6 100644 --- a/lib/src/exceptions.dart +++ b/lib/src/exceptions.dart @@ -46,7 +46,3 @@ class CronetNativeException implements Exception { class UrlRequestException extends CronetNativeException { const UrlRequestException(int val) : super(val); } - -class ResponseListenerException implements Exception { - ResponseListenerException(); -} diff --git a/lib/src/http_callback_handler.dart b/lib/src/http_callback_handler.dart index 34bf33e..d42c4e5 100644 --- a/lib/src/http_callback_handler.dart +++ b/lib/src/http_callback_handler.dart @@ -34,59 +34,15 @@ class _CallbackHandler { /// Stream controller to allow consumption of data like [HttpClientResponse]. final _controller = StreamController>(); - bool _isStreamClaimed = false; // Stream instance should be claimed once. - - /// If callback based api is used, completes when receiving data is done. - Completer? _callBackCompleter; - - RedirectReceivedCallback? _onRedirectReceived; - ResponseStartedCallback? _onResponseStarted; - ReadDataCallback? _onReadData; - FailedCallabck? _onFailed; - CanceledCallabck? _onCanceled; - SuccessCallabck? _onSuccess; /// Registers the [NativePort] to the cronet side. _CallbackHandler(this.cronet, this.executor, this.receivePort); /// [Stream] controller for [HttpClientResponse] Stream> get stream { - if (_isStreamClaimed) { - throw ResponseListenerException(); - } - _isStreamClaimed = true; return _controller.stream; } - /// Sets callbacks that are registered using [HttpClientRequest.registerCallbacks]. - /// - /// If called, the [StreamController] for [HttpClientRequest.close] will be closed. - /// Resolves with error if [Stream] already has a listener. - Future registerCallbacks(ReadDataCallback onReadData, - [RedirectReceivedCallback? onRedirectReceived, - ResponseStartedCallback? onResponseStarted, - FailedCallabck? onFailed, - CanceledCallabck? onCanceled, - SuccessCallabck? onSuccess]) { - _callBackCompleter = Completer(); - // If stream based api is already under use, resolve with error. - if (_isStreamClaimed) { - _callBackCompleter!.completeError(ResponseListenerException()); - return _callBackCompleter!.future; - } - _onRedirectReceived = onRedirectReceived; - _onResponseStarted = onResponseStarted; - _onReadData = onReadData; - // If callbacks are registered, close the contoller. - _controller.close(); - - _onFailed = onFailed; - _onCanceled = onCanceled; - _onSuccess = onSuccess; - - return _callBackCompleter!.future; - } - // Clean up tasks for a request. // // We need to call this then whenever we are done with the request. @@ -109,19 +65,8 @@ class _CallbackHandler { cronet.Cronet_UrlResponseInfo_http_status_text_get(respInfoPtr) .cast() .toDartString()); - - if (_callBackCompleter != null) { - // If callbacks are registered. - if (_onFailed != null) { - _onFailed!(exception); - _callBackCompleter!.complete(false); - } else { - _callBackCompleter!.completeError(exception); - } - } else { - _controller.addError(exception); - _controller.close(); - } + _controller.addError(exception); + _controller.close(); } return respCode; } @@ -142,12 +87,10 @@ class _CallbackHandler { args = reqMessage.data.buffer.asInt64List(); switch (reqMessage.method) { - // Invoked when a redirect is received. - // Passes the new location's url and response code as parameter. case 'OnRedirectReceived': { log('New Location: ${Pointer.fromAddress(args[0]).cast().toDartString()}'); - final respCode = statusChecker( + statusChecker( Pointer.fromAddress(args[1]).cast(), 300, 399, @@ -163,27 +106,19 @@ class _CallbackHandler { } else { cronet.Cronet_UrlRequest_Cancel(reqPtr); } - if (_onRedirectReceived != null) { - _onRedirectReceived!( - Pointer.fromAddress(args[0]).cast().toDartString(), - respCode); - } } break; // When server has sent the initial response. case 'OnResponseStarted': { - final respCode = statusChecker( + // If NOT a 1XX or 2XX status code, throw Exception. + statusChecker( Pointer.fromAddress(args[0]).cast(), 100, 299, - () => cleanUpRequest(reqPtr, - cleanUpClient)); // If NOT a 1XX or 2XX status code, throw Exception. + () => cleanUpRequest(reqPtr, cleanUpClient)); log('Response started'); - if (_onResponseStarted != null) { - _onResponseStarted!(respCode); - } } break; // Read a chunk of data. @@ -199,33 +134,18 @@ class _CallbackHandler { final bytesRead = args[3]; log('Recieved: $bytesRead'); - final respCode = statusChecker( - info, - 100, - 299, - () => cleanUpRequest(reqPtr, - cleanUpClient)); // If NOT a 1XX or 2XX status code, throw Exception. + // If NOT a 1XX or 2XX status code, throw Exception. + statusChecker( + info, 100, 299, () => cleanUpRequest(reqPtr, cleanUpClient)); final data = cronet.Cronet_Buffer_GetData(buffer) .cast() .asTypedList(bytesRead); - - // Invoke the callback. - if (_onReadData != null) { - _onReadData!(data.toList(growable: false), bytesRead, respCode); - final res = cronet.Cronet_UrlRequest_Read(request, buffer); - if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { - cleanUpRequest(reqPtr, cleanUpClient); - _callBackCompleter!.completeError(UrlRequestException(res)); - } - } else { - // Or, add data to the stream. - _controller.sink.add(data.toList(growable: false)); - final res = cronet.Cronet_UrlRequest_Read(request, buffer); - if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { - cleanUpRequest(reqPtr, cleanUpClient); - _controller.addError(UrlRequestException(res)); - _controller.close(); - } + _controller.sink.add(data.toList(growable: false)); + final res = cronet.Cronet_UrlRequest_Read(request, buffer); + if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { + cleanUpRequest(reqPtr, cleanUpClient); + _controller.addError(UrlRequestException(res)); + _controller.close(); } } break; @@ -235,19 +155,8 @@ class _CallbackHandler { final error = Pointer.fromAddress(args[0]).cast().toDartString(); cleanUpRequest(reqPtr, cleanUpClient); - - if (_callBackCompleter != null) { - if (_onFailed != null) { - _onFailed!(HttpException(error)); - _callBackCompleter!.complete(false); - } else { - // If callback is registed but onFailed callback is not. - _callBackCompleter!.completeError(HttpException(error)); - } - } else { - _controller.addError(HttpException(error)); - _controller.close(); - } + _controller.addError(HttpException(error)); + _controller.close(); cronet.Cronet_UrlRequest_Destroy(reqPtr); } break; @@ -255,15 +164,7 @@ class _CallbackHandler { case 'OnCanceled': { cleanUpRequest(reqPtr, cleanUpClient); - if (_callBackCompleter != null) { - if (_onCanceled != null) { - _onCanceled!(); - } - _callBackCompleter!.complete(false); - } else { - // If callbacks are not registered, stream isn't closed before. So, close here. - _controller.close(); - } + _controller.close(); cronet.Cronet_UrlRequest_Destroy(reqPtr); } break; @@ -271,18 +172,7 @@ class _CallbackHandler { case 'OnSucceeded': { cleanUpRequest(reqPtr, cleanUpClient); - if (_callBackCompleter != null) { - if (_onSuccess != null) { - final respInfoPtr = - Pointer.fromAddress(args[0]).cast(); - _onSuccess!(cronet.Cronet_UrlResponseInfo_http_status_code_get( - respInfoPtr)); - } - _callBackCompleter!.complete(true); - } else { - // If callbacks are not registered, stream isn't closed before. So, close here. - _controller.close(); - } + _controller.close(); cronet.Cronet_UrlRequest_Destroy(reqPtr); } break; diff --git a/lib/src/http_client_request.dart b/lib/src/http_client_request.dart index 00093f2..4e1bff2 100644 --- a/lib/src/http_client_request.dart +++ b/lib/src/http_client_request.dart @@ -17,18 +17,6 @@ import 'generated_bindings.dart'; part 'http_client_response.dart'; part 'http_callback_handler.dart'; -// Function signature for callbacks called on redirects. -typedef RedirectReceivedCallback = void Function( - String newLocationUrl, int responseCode); -typedef ResponseStartedCallback = void Function(int responseCode); - -/// Called when a chunk of data is received from the server. -typedef ReadDataCallback = void Function( - List data, int bytesRead, int responseCode); -typedef FailedCallabck = void Function(HttpException exception); -typedef CanceledCallabck = void Function(); -typedef SuccessCallabck = void Function(int responseCode); - /// HTTP request for a client connection. /// /// It handles all of the Http Requests made by [HttpClient]. @@ -99,50 +87,22 @@ class HttpClientRequest implements IOSink { _cbh.listen(_request, () => _clientCleanup(this)); } - /// Registers callbacks for all network events. - /// - /// Throws [Exception] if callbacks are registered after listening to response [Stream]. - /// Resolves with `true` if request finished successfully and `false` otherwise. - /// - /// This is one of the methods to get data out of [HttpClientRequest]. - /// Accepted callbacks are [RedirectReceivedCallback], [ResponseStartedCallback], - /// [ReadDataCallback], [FailedCallabck], [CanceledCallabck] and [SuccessCallabck]. - /// Callbacks will be called as per sequence of the events. - Future registerCallbacks(ReadDataCallback onReadData, - {RedirectReceivedCallback? onRedirectReceived, - ResponseStartedCallback? onResponseStarted, - FailedCallabck? onFailed, - CanceledCallabck? onCanceled, - SuccessCallabck? onSuccess}) { - if (_cbh._isStreamClaimed) { - return Future.error(ResponseListenerException()); - } - final rc = _cbh.registerCallbacks(onReadData, onRedirectReceived, - onResponseStarted, onFailed, onCanceled, onSuccess); - _startRequest(); - return rc; - } - /// Returns [Future] of [HttpClientResponse] which can be listened for server response. /// - /// Throws [Exception] if callback based api is in use. /// Throws [UrlRequestException] if request can't be initiated. - /// Consumable similar to [HttpClientResponse]. @override Future close() { return Future(() { - // If callback based API is being used, throw Exception. - if (_cbh._callBackCompleter != null) { - throw ResponseListenerException(); - } _startRequest(); return HttpClientResponse._(_cbh.stream); }); } - /// Done is same as [close]. A [HttpClientResponse] future that will complete once the response is available. + /// This is same as [close]. A [HttpClientResponse] future that will complete + /// once the request is successfully made. /// - /// If an error occurs before the response is available, this future will complete with an error. + /// If any problems occurs before the response is available, this future will + /// completes with an [UrlRequestException]. @override Future get done => close(); diff --git a/test/http_responses_exceptions_test.dart b/test/http_responses_exceptions_test.dart index c9cfc6b..741c786 100644 --- a/test/http_responses_exceptions_test.dart +++ b/test/http_responses_exceptions_test.dart @@ -64,18 +64,6 @@ void main() { ])); }); - test('New API: 503, Service Unavailable', () async { - final request = await client.getUrl(Uri.parse('http://$host:$port/503')); - final success = await request.registerCallbacks( - (data, bytesRead, responseCode) {}, onFailed: (reason) { - expect( - reason, - isA().having((exception) => exception.message, - 'message', 'Service Unavailable')); - }); - expect(success, equals(false)); - }); - tearDown(() { client.close(); server.close(); diff --git a/test/http_responses_new_api_test.dart b/test/http_responses_new_api_test.dart deleted file mode 100644 index d6b724f..0000000 --- a/test/http_responses_new_api_test.dart +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'dart:convert'; -import 'dart:io' as io; - -import 'package:cronet/cronet.dart'; -import 'package:test/test.dart'; - -const host = 'localhost'; -const sentData = 'Hello, world!'; - -void main() { - group('Callback based api', () { - late HttpClient client; - late io.HttpServer server; - late int port; - setUp(() async { - client = HttpClient(); - server = await io.HttpServer.bind(io.InternetAddress.anyIPv6, 0); - port = server.port; - server.listen((io.HttpRequest request) { - if (request.uri.pathSegments.isNotEmpty && - request.uri.pathSegments[0] == '301') { - request.response.statusCode = 301; - request.response.headers.set('Location', '/'); - } else { - request.response.write(sentData); - } - request.response.close(); - }); - }); - - test('Gets Hello, world response from server using getUrl', () async { - String resp = ''; - final request = await client.getUrl(Uri.parse('http://$host:$port')); - final success = - await request.registerCallbacks((data, bytesRead, responseCode) { - resp += utf8.decoder.convert(data); - }, onSuccess: (responseCode) { - expect(responseCode, equals(200)); - }); - expect(resp, equals(sentData)); - expect(success, equals(true)); - }); - - test('Invalid URLs calls onFailed and returns false', () async { - String resp = ''; - final request = await client.getUrl( - Uri.parse('http://localghost:$port')); // localghost shouldn't exist - final success = - await request.registerCallbacks((data, bytesRead, responseCode) { - resp += utf8.decoder.convert(data); - }, onFailed: (HttpException reason) { - expect(reason, isA()); - }); - expect(resp, equals('')); - expect(success, equals(false)); - }); - - test('URL redirect on 301 and fetch data', () async { - String resp = ''; - final request = await client.getUrl(Uri.parse('http://$host:$port')); - final success = - await request.registerCallbacks((data, bytesRead, responseCode) { - resp += utf8.decoder.convert(data); - }, onRedirectReceived: (location, responseCode) { - expect(responseCode, equals(301)); - expect(location, equals('http://$host:$port')); - }); - expect(resp, equals(sentData)); - expect(success, equals(true)); - }); - - test('registering callbacks after response.close will throw error', - () async { - final request = await client.getUrl(Uri.parse('http://$host:$port')); - await request.close(); - expect(request.registerCallbacks((data, bytesRead, responseCode) {}), - throwsA(isA())); - }); - - tearDown(() { - client.close(); - server.close(); - }); - }); -} From dd2490fbdbf5bbc53846cebdb769418b1f715552 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Thu, 24 Jun 2021 23:22:47 +0530 Subject: [PATCH 23/42] refactor: remove part directives --- lib/cronet.dart | 3 +- lib/src/http_callback_handler.dart | 15 +++++++-- lib/src/http_client.dart | 2 +- lib/src/http_client_request.dart | 52 +++++++++++++++++++++++------- lib/src/http_client_response.dart | 14 +++----- 5 files changed, 59 insertions(+), 27 deletions(-) diff --git a/lib/cronet.dart b/lib/cronet.dart index 91809c7..3e3b219 100644 --- a/lib/cronet.dart +++ b/lib/cronet.dart @@ -3,7 +3,8 @@ // BSD-style license that can be found in the LICENSE file. export 'src/http_client.dart'; -export 'src/http_client_request.dart'; +export 'src/http_client_request.dart' hide HttpClientRequestImpl; +export 'src/http_client_response.dart' hide HttpClientResponseImpl; export 'src/quic_hint.dart'; export 'src/enums.dart'; export 'src/exceptions.dart'; diff --git a/lib/src/http_callback_handler.dart b/lib/src/http_callback_handler.dart index d42c4e5..c3446a1 100644 --- a/lib/src/http_callback_handler.dart +++ b/lib/src/http_callback_handler.dart @@ -2,7 +2,16 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -part of 'http_client_request.dart'; +import 'dart:async'; +import 'dart:developer'; +import 'dart:ffi'; +import 'dart:isolate'; +import 'dart:typed_data'; + +import 'package:ffi/ffi.dart'; + +import 'exceptions.dart'; +import 'generated_bindings.dart'; /// Deserializes the message sent by cronet and it's wrapper. class _CallbackRequestMessage { @@ -23,7 +32,7 @@ class _CallbackRequestMessage { /// Handles every kind of callbacks that are invoked by messages and /// data that are sent by [NativePort] from native cronet library. -class _CallbackHandler { +class CallbackHandler { final ReceivePort receivePort; final Cronet cronet; final Pointer executor; @@ -36,7 +45,7 @@ class _CallbackHandler { final _controller = StreamController>(); /// Registers the [NativePort] to the cronet side. - _CallbackHandler(this.cronet, this.executor, this.receivePort); + CallbackHandler(this.cronet, this.executor, this.receivePort); /// [Stream] controller for [HttpClientResponse] Stream> get stream { diff --git a/lib/src/http_client.dart b/lib/src/http_client.dart index 961e758..848508a 100644 --- a/lib/src/http_client.dart +++ b/lib/src/http_client.dart @@ -133,7 +133,7 @@ class HttpClient { if (_stop) { throw Exception("Client is closed. Can't open new connections"); } - _requests.add(HttpClientRequest( + _requests.add(HttpClientRequestImpl( url, method, _cronet, _cronetEngine, _cleanUpRequests)); return _requests.last; }); diff --git a/lib/src/http_client_request.dart b/lib/src/http_client_request.dart index 4e1bff2..57d73cd 100644 --- a/lib/src/http_client_request.dart +++ b/lib/src/http_client_request.dart @@ -4,18 +4,16 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:developer'; import 'dart:ffi'; -import 'dart:io'; +import 'dart:io' as io; import 'dart:isolate'; -import 'dart:typed_data'; import 'package:ffi/ffi.dart'; import 'exceptions.dart'; import 'generated_bindings.dart'; -part 'http_client_response.dart'; -part 'http_callback_handler.dart'; +import 'http_client_response.dart'; +import 'http_callback_handler.dart'; /// HTTP request for a client connection. /// @@ -35,12 +33,39 @@ part 'http_callback_handler.dart'; /// // Use it as you like. /// }); /// ``` -class HttpClientRequest implements IOSink { +abstract class HttpClientRequest implements io.IOSink { + /// Returns [Future] of [HttpClientResponse] which can be listened for server response. + /// + /// Throws [UrlRequestException] if request can't be initiated. + @override + Future close(); + + /// This is same as [close]. A [HttpClientResponse] future that will complete + /// once the request is successfully made. + /// + /// If any problems occurs before the response is available, this future will + /// completes with an [UrlRequestException]. + @override + Future get done; + + /// Follow the redirects. + bool get followRedirects; + + /// Maximum numbers of redirects to follow. + /// Have no effect if [followRedirects] is set to false. + int get maxRedirects; + + /// The uri of the request. + Uri get uri; +} + +/// Implementation of [HttpClientRequest]. +class HttpClientRequestImpl implements HttpClientRequest { final Uri _uri; final String _method; final Cronet _cronet; final Pointer _cronetEngine; - final _CallbackHandler _cbh; + final CallbackHandler _cbh; final Pointer _request; /// Holds the function to clean up after the request is done (if nessesary). @@ -51,12 +76,12 @@ class HttpClientRequest implements IOSink { @override Encoding encoding; - /// Initiates a [HttpClientRequest]. It is meant to be used by a [HttpClient]. - HttpClientRequest(this._uri, this._method, this._cronet, this._cronetEngine, - this._clientCleanup, + /// Initiates a [HttpClientRequestImpl]. It is meant to be used by a [HttpClient]. + HttpClientRequestImpl(this._uri, this._method, this._cronet, + this._cronetEngine, this._clientCleanup, {this.encoding = utf8}) : _cbh = - _CallbackHandler(_cronet, _cronet.Create_Executor(), ReceivePort()), + CallbackHandler(_cronet, _cronet.Create_Executor(), ReceivePort()), _request = _cronet.Cronet_UrlRequest_Create() { // Register the native port to C side. _cronet.registerCallbackHandler( @@ -94,7 +119,7 @@ class HttpClientRequest implements IOSink { Future close() { return Future(() { _startRequest(); - return HttpClientResponse._(_cbh.stream); + return HttpClientResponseImpl(_cbh.stream); }); } @@ -107,6 +132,7 @@ class HttpClientRequest implements IOSink { Future get done => close(); /// Follow the redirects. + @override bool get followRedirects => _cbh.followRedirects; set followRedirects(bool follow) { _cbh.followRedirects = follow; @@ -114,12 +140,14 @@ class HttpClientRequest implements IOSink { /// Maximum numbers of redirects to follow. /// Have no effect if [followRedirects] is set to false. + @override int get maxRedirects => _cbh.maxRedirects; set maxRedirects(int redirects) { _cbh.maxRedirects = redirects; } /// The uri of the request. + @override Uri get uri => _uri; @override diff --git a/lib/src/http_client_response.dart b/lib/src/http_client_response.dart index 0e0c618..2465a25 100644 --- a/lib/src/http_client_response.dart +++ b/lib/src/http_client_response.dart @@ -2,27 +2,21 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -part of '../src/http_client_request.dart'; +import 'dart:async'; /// Represents the server's response to a request. /// /// The body of a [HttpClientResponse] object is a [Stream] of data from the server. /// Listen to the body to handle the data and be notified when the entire body /// is received. -abstract class HttpClientResponse extends Stream> { - HttpClientResponse(); - - factory HttpClientResponse._(Stream> cbhStream) { - return _HttpClientResponse(cbhStream); - } -} +abstract class HttpClientResponse extends Stream> {} /// Implementation of [HttpClientResponse]. /// /// Takes instance of callback handler and registers [listen] callbacks to the stream. -class _HttpClientResponse extends HttpClientResponse { +class HttpClientResponseImpl extends HttpClientResponse { final Stream> cbhStream; - _HttpClientResponse(this.cbhStream); + HttpClientResponseImpl(this.cbhStream); @override StreamSubscription> listen(void Function(List event)? onData, From f4cbd245688355929afbeca02e9be1b6a6b03932 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Fri, 25 Jun 2021 21:10:13 +0530 Subject: [PATCH 24/42] merge quic & http2 options into protocol using enum HttpProtocol --- lib/src/enums.dart | 3 ++- lib/src/http_client.dart | 40 +++++++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/lib/src/enums.dart b/lib/src/enums.dart index 1961fb0..5fd6d55 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -2,4 +2,5 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -enum CacheMode { disabled, inMemory, diskNoHttp, disk } +/// Defines the available http protocols supported by cronet. +enum HttpProtocol { quic, http2, http } diff --git a/lib/src/http_client.dart b/lib/src/http_client.dart index 848508a..54f7846 100644 --- a/lib/src/http_client.dart +++ b/lib/src/http_client.dart @@ -5,13 +5,14 @@ import 'dart:async'; import 'dart:ffi'; -import 'package:cronet/src/exceptions.dart'; import 'package:ffi/ffi.dart'; import 'dylib_handler.dart'; +import 'enums.dart'; +import 'exceptions.dart'; import 'generated_bindings.dart'; -import 'quic_hint.dart'; import 'http_client_request.dart'; +import 'quic_hint.dart'; // Cronet library is loaded in global scope. final _cronet = Cronet(loadWrapper()); @@ -36,8 +37,7 @@ final _cronet = Cronet(loadWrapper()); /// ``` class HttpClient { final String userAgent; - final bool quic; - final bool http2; + final HttpProtocol protocol; final bool brotli; final String acceptLanguage; final List quicHints; @@ -53,16 +53,16 @@ class HttpClient { /// Initiates an [HttpClient] with the settings provided in the arguments. /// - /// The settings control whether this client supports [quic], [brotli] and - /// [http2]. If [quic] is enabled, then [quicHints] can be provided. - /// [userAgent] and [acceptLanguage] can also be provided. + /// The settings control whether this client supports [brotli] and + /// [HttpProtocol]s like `quic`, `http2` and `http/1.1`. If `quic` is + /// enabled, then [quicHints] can be provided. [userAgent] and + /// [acceptLanguage] can also be provided. /// - /// Throws [CronetException] if [HttpClient] can't be created. + /// Throws [CronetNativeException] if [HttpClient] can't be created. HttpClient({ this.userAgent = 'Dart/2.12', - this.quic = true, + this.protocol = HttpProtocol.quic, this.quicHints = const [], - this.http2 = true, this.brotli = true, this.acceptLanguage = 'en_US', }) : _cronetEngine = _cronet.Cronet_Engine_Create() { @@ -74,8 +74,23 @@ class HttpClient { final engineParams = _cronet.Cronet_EngineParams_Create(); _cronet.Cronet_EngineParams_user_agent_set( engineParams, userAgent.toNativeUtf8().cast()); - _cronet.Cronet_EngineParams_enable_quic_set(engineParams, quic); - if (!quic && quicHints.isNotEmpty) { + + switch (protocol) { + case HttpProtocol.quic: + _cronet.Cronet_EngineParams_enable_quic_set(engineParams, true); + break; + case HttpProtocol.http2: + _cronet.Cronet_EngineParams_enable_http2_set(engineParams, true); + _cronet.Cronet_EngineParams_enable_quic_set(engineParams, false); + break; + case HttpProtocol.http: + _cronet.Cronet_EngineParams_enable_quic_set(engineParams, false); + _cronet.Cronet_EngineParams_enable_http2_set(engineParams, false); + break; + default: + break; + } + if (protocol != HttpProtocol.quic && quicHints.isNotEmpty) { throw ArgumentError('Quic is not enabled but quic hints are provided.'); } for (final quicHint in quicHints) { @@ -88,7 +103,6 @@ class HttpClient { _cronet.Cronet_QuicHint_Destroy(hint); } - _cronet.Cronet_EngineParams_enable_http2_set(engineParams, http2); _cronet.Cronet_EngineParams_enable_brotli_set(engineParams, brotli); _cronet.Cronet_EngineParams_accept_language_set( engineParams, acceptLanguage.toNativeUtf8().cast()); From 12499c3cc97a092730d3086fb5902adef957e274 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Fri, 25 Jun 2021 22:06:25 +0530 Subject: [PATCH 25/42] initial splitting of cronet and wrapper bindings --- lib/src/third_party/cronet/ffigen.yaml | 32 + .../cronet/generated_bindings.dart | 1099 +++++++++++++++++ lib/src/wrapper/ffigen.yaml | 40 + lib/src/wrapper/generated_bindings.dart | 232 ++++ pubspec.yaml | 28 - tool/update_bindings.dart | 29 + 6 files changed, 1432 insertions(+), 28 deletions(-) create mode 100644 lib/src/third_party/cronet/ffigen.yaml create mode 100644 lib/src/third_party/cronet/generated_bindings.dart create mode 100644 lib/src/wrapper/ffigen.yaml create mode 100644 lib/src/wrapper/generated_bindings.dart create mode 100644 tool/update_bindings.dart diff --git a/lib/src/third_party/cronet/ffigen.yaml b/lib/src/third_party/cronet/ffigen.yaml new file mode 100644 index 0000000..5664fa2 --- /dev/null +++ b/lib/src/third_party/cronet/ffigen.yaml @@ -0,0 +1,32 @@ +name: 'Cronet' +description: 'Bindings to Cronet' +output: 'lib/src/third_party/cronet/generated_bindings.dart' +array-workaround: true +headers: + entry-points: + - 'third_party/cronet/cronet.idl_c.h' +compiler-opts: + - '-Ithird_party/cronet/' +macros: + include: + - nothing +enums: + include: + - nothing +unnamed-enums: + include: + - nothing +globals: + include: + - nothing +structs: + include: + - nothing + dependency-only: opaque +preamble: | + // Copyright 2017 The Chromium Authors. All rights reserved. + // Use of this source code is governed by a BSD-style license that can be + // found in the LICENSE file. + + // ignore_for_file: non_constant_identifier_names, camel_case_types + // ignore_for_file: constant_identifier_names diff --git a/lib/src/third_party/cronet/generated_bindings.dart b/lib/src/third_party/cronet/generated_bindings.dart new file mode 100644 index 0000000..474ab4a --- /dev/null +++ b/lib/src/third_party/cronet/generated_bindings.dart @@ -0,0 +1,1099 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// ignore_for_file: non_constant_identifier_names, camel_case_types +// ignore_for_file: constant_identifier_names + +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +import 'dart:ffi' as ffi; + +/// Bindings to Cronet +class Cronet { + /// Holds the symbol lookup function. + final ffi.Pointer Function(String symbolName) + _lookup; + + /// The symbols are looked up in [dynamicLibrary]. + Cronet(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; + + /// The symbols are looked up with [lookup]. + Cronet.fromLookup( + ffi.Pointer Function(String symbolName) + lookup) + : _lookup = lookup; + + int Cronet_Buffer_GetSize( + ffi.Pointer self, + ) { + return _Cronet_Buffer_GetSize( + self, + ); + } + + late final _Cronet_Buffer_GetSize_ptr = + _lookup>( + 'Cronet_Buffer_GetSize'); + late final _dart_Cronet_Buffer_GetSize _Cronet_Buffer_GetSize = + _Cronet_Buffer_GetSize_ptr.asFunction<_dart_Cronet_Buffer_GetSize>(); + + ffi.Pointer Cronet_Buffer_GetData( + ffi.Pointer self, + ) { + return _Cronet_Buffer_GetData( + self, + ); + } + + late final _Cronet_Buffer_GetData_ptr = + _lookup>( + 'Cronet_Buffer_GetData'); + late final _dart_Cronet_Buffer_GetData _Cronet_Buffer_GetData = + _Cronet_Buffer_GetData_ptr.asFunction<_dart_Cronet_Buffer_GetData>(); + + ffi.Pointer Cronet_Engine_Create() { + return _Cronet_Engine_Create(); + } + + late final _Cronet_Engine_Create_ptr = + _lookup>( + 'Cronet_Engine_Create'); + late final _dart_Cronet_Engine_Create _Cronet_Engine_Create = + _Cronet_Engine_Create_ptr.asFunction<_dart_Cronet_Engine_Create>(); + + int Cronet_Engine_StartWithParams( + ffi.Pointer self, + ffi.Pointer params, + ) { + return _Cronet_Engine_StartWithParams( + self, + params, + ); + } + + late final _Cronet_Engine_StartWithParams_ptr = + _lookup>( + 'Cronet_Engine_StartWithParams'); + late final _dart_Cronet_Engine_StartWithParams + _Cronet_Engine_StartWithParams = _Cronet_Engine_StartWithParams_ptr + .asFunction<_dart_Cronet_Engine_StartWithParams>(); + + bool Cronet_Engine_StartNetLogToFile( + ffi.Pointer self, + ffi.Pointer file_name, + bool log_all, + ) { + return _Cronet_Engine_StartNetLogToFile( + self, + file_name, + log_all ? 1 : 0, + ) != + 0; + } + + late final _Cronet_Engine_StartNetLogToFile_ptr = + _lookup>( + 'Cronet_Engine_StartNetLogToFile'); + late final _dart_Cronet_Engine_StartNetLogToFile + _Cronet_Engine_StartNetLogToFile = _Cronet_Engine_StartNetLogToFile_ptr + .asFunction<_dart_Cronet_Engine_StartNetLogToFile>(); + + void Cronet_Engine_StopNetLog( + ffi.Pointer self, + ) { + return _Cronet_Engine_StopNetLog( + self, + ); + } + + late final _Cronet_Engine_StopNetLog_ptr = + _lookup>( + 'Cronet_Engine_StopNetLog'); + late final _dart_Cronet_Engine_StopNetLog _Cronet_Engine_StopNetLog = + _Cronet_Engine_StopNetLog_ptr.asFunction< + _dart_Cronet_Engine_StopNetLog>(); + + int Cronet_Engine_Shutdown( + ffi.Pointer self, + ) { + return _Cronet_Engine_Shutdown( + self, + ); + } + + late final _Cronet_Engine_Shutdown_ptr = + _lookup>( + 'Cronet_Engine_Shutdown'); + late final _dart_Cronet_Engine_Shutdown _Cronet_Engine_Shutdown = + _Cronet_Engine_Shutdown_ptr.asFunction<_dart_Cronet_Engine_Shutdown>(); + + ffi.Pointer Cronet_Engine_GetVersionString( + ffi.Pointer self, + ) { + return _Cronet_Engine_GetVersionString( + self, + ); + } + + late final _Cronet_Engine_GetVersionString_ptr = + _lookup>( + 'Cronet_Engine_GetVersionString'); + late final _dart_Cronet_Engine_GetVersionString + _Cronet_Engine_GetVersionString = _Cronet_Engine_GetVersionString_ptr + .asFunction<_dart_Cronet_Engine_GetVersionString>(); + + /// //////////////////// + ffi.Pointer Cronet_UrlRequest_Create() { + return _Cronet_UrlRequest_Create(); + } + + late final _Cronet_UrlRequest_Create_ptr = + _lookup>( + 'Cronet_UrlRequest_Create'); + late final _dart_Cronet_UrlRequest_Create _Cronet_UrlRequest_Create = + _Cronet_UrlRequest_Create_ptr.asFunction< + _dart_Cronet_UrlRequest_Create>(); + + void Cronet_UrlRequest_Destroy( + ffi.Pointer self, + ) { + return _Cronet_UrlRequest_Destroy( + self, + ); + } + + late final _Cronet_UrlRequest_Destroy_ptr = + _lookup>( + 'Cronet_UrlRequest_Destroy'); + late final _dart_Cronet_UrlRequest_Destroy _Cronet_UrlRequest_Destroy = + _Cronet_UrlRequest_Destroy_ptr.asFunction< + _dart_Cronet_UrlRequest_Destroy>(); + + void Cronet_UrlRequest_SetClientContext( + ffi.Pointer self, + ffi.Pointer client_context, + ) { + return _Cronet_UrlRequest_SetClientContext( + self, + client_context, + ); + } + + late final _Cronet_UrlRequest_SetClientContext_ptr = + _lookup>( + 'Cronet_UrlRequest_SetClientContext'); + late final _dart_Cronet_UrlRequest_SetClientContext + _Cronet_UrlRequest_SetClientContext = + _Cronet_UrlRequest_SetClientContext_ptr.asFunction< + _dart_Cronet_UrlRequest_SetClientContext>(); + + ffi.Pointer Cronet_UrlRequest_GetClientContext( + ffi.Pointer self, + ) { + return _Cronet_UrlRequest_GetClientContext( + self, + ); + } + + late final _Cronet_UrlRequest_GetClientContext_ptr = + _lookup>( + 'Cronet_UrlRequest_GetClientContext'); + late final _dart_Cronet_UrlRequest_GetClientContext + _Cronet_UrlRequest_GetClientContext = + _Cronet_UrlRequest_GetClientContext_ptr.asFunction< + _dart_Cronet_UrlRequest_GetClientContext>(); + + int Cronet_UrlRequest_Start( + ffi.Pointer self, + ) { + return _Cronet_UrlRequest_Start( + self, + ); + } + + late final _Cronet_UrlRequest_Start_ptr = + _lookup>( + 'Cronet_UrlRequest_Start'); + late final _dart_Cronet_UrlRequest_Start _Cronet_UrlRequest_Start = + _Cronet_UrlRequest_Start_ptr.asFunction<_dart_Cronet_UrlRequest_Start>(); + + int Cronet_UrlRequest_FollowRedirect( + ffi.Pointer self, + ) { + return _Cronet_UrlRequest_FollowRedirect( + self, + ); + } + + late final _Cronet_UrlRequest_FollowRedirect_ptr = + _lookup>( + 'Cronet_UrlRequest_FollowRedirect'); + late final _dart_Cronet_UrlRequest_FollowRedirect + _Cronet_UrlRequest_FollowRedirect = _Cronet_UrlRequest_FollowRedirect_ptr + .asFunction<_dart_Cronet_UrlRequest_FollowRedirect>(); + + int Cronet_UrlRequest_Read( + ffi.Pointer self, + ffi.Pointer buffer, + ) { + return _Cronet_UrlRequest_Read( + self, + buffer, + ); + } + + late final _Cronet_UrlRequest_Read_ptr = + _lookup>( + 'Cronet_UrlRequest_Read'); + late final _dart_Cronet_UrlRequest_Read _Cronet_UrlRequest_Read = + _Cronet_UrlRequest_Read_ptr.asFunction<_dart_Cronet_UrlRequest_Read>(); + + void Cronet_UrlRequest_Cancel( + ffi.Pointer self, + ) { + return _Cronet_UrlRequest_Cancel( + self, + ); + } + + late final _Cronet_UrlRequest_Cancel_ptr = + _lookup>( + 'Cronet_UrlRequest_Cancel'); + late final _dart_Cronet_UrlRequest_Cancel _Cronet_UrlRequest_Cancel = + _Cronet_UrlRequest_Cancel_ptr.asFunction< + _dart_Cronet_UrlRequest_Cancel>(); + + /// //////////////////// + ffi.Pointer Cronet_QuicHint_Create() { + return _Cronet_QuicHint_Create(); + } + + late final _Cronet_QuicHint_Create_ptr = + _lookup>( + 'Cronet_QuicHint_Create'); + late final _dart_Cronet_QuicHint_Create _Cronet_QuicHint_Create = + _Cronet_QuicHint_Create_ptr.asFunction<_dart_Cronet_QuicHint_Create>(); + + void Cronet_QuicHint_Destroy( + ffi.Pointer self, + ) { + return _Cronet_QuicHint_Destroy( + self, + ); + } + + late final _Cronet_QuicHint_Destroy_ptr = + _lookup>( + 'Cronet_QuicHint_Destroy'); + late final _dart_Cronet_QuicHint_Destroy _Cronet_QuicHint_Destroy = + _Cronet_QuicHint_Destroy_ptr.asFunction<_dart_Cronet_QuicHint_Destroy>(); + + void Cronet_QuicHint_host_set( + ffi.Pointer self, + ffi.Pointer host, + ) { + return _Cronet_QuicHint_host_set( + self, + host, + ); + } + + late final _Cronet_QuicHint_host_set_ptr = + _lookup>( + 'Cronet_QuicHint_host_set'); + late final _dart_Cronet_QuicHint_host_set _Cronet_QuicHint_host_set = + _Cronet_QuicHint_host_set_ptr.asFunction< + _dart_Cronet_QuicHint_host_set>(); + + void Cronet_QuicHint_port_set( + ffi.Pointer self, + int port, + ) { + return _Cronet_QuicHint_port_set( + self, + port, + ); + } + + late final _Cronet_QuicHint_port_set_ptr = + _lookup>( + 'Cronet_QuicHint_port_set'); + late final _dart_Cronet_QuicHint_port_set _Cronet_QuicHint_port_set = + _Cronet_QuicHint_port_set_ptr.asFunction< + _dart_Cronet_QuicHint_port_set>(); + + void Cronet_QuicHint_alternate_port_set( + ffi.Pointer self, + int alternate_port, + ) { + return _Cronet_QuicHint_alternate_port_set( + self, + alternate_port, + ); + } + + late final _Cronet_QuicHint_alternate_port_set_ptr = + _lookup>( + 'Cronet_QuicHint_alternate_port_set'); + late final _dart_Cronet_QuicHint_alternate_port_set + _Cronet_QuicHint_alternate_port_set = + _Cronet_QuicHint_alternate_port_set_ptr.asFunction< + _dart_Cronet_QuicHint_alternate_port_set>(); + + /// //////////////////// + ffi.Pointer Cronet_EngineParams_Create() { + return _Cronet_EngineParams_Create(); + } + + late final _Cronet_EngineParams_Create_ptr = + _lookup>( + 'Cronet_EngineParams_Create'); + late final _dart_Cronet_EngineParams_Create _Cronet_EngineParams_Create = + _Cronet_EngineParams_Create_ptr.asFunction< + _dart_Cronet_EngineParams_Create>(); + + void Cronet_EngineParams_Destroy( + ffi.Pointer self, + ) { + return _Cronet_EngineParams_Destroy( + self, + ); + } + + late final _Cronet_EngineParams_Destroy_ptr = + _lookup>( + 'Cronet_EngineParams_Destroy'); + late final _dart_Cronet_EngineParams_Destroy _Cronet_EngineParams_Destroy = + _Cronet_EngineParams_Destroy_ptr.asFunction< + _dart_Cronet_EngineParams_Destroy>(); + + void Cronet_EngineParams_enable_check_result_set( + ffi.Pointer self, + bool enable_check_result, + ) { + return _Cronet_EngineParams_enable_check_result_set( + self, + enable_check_result ? 1 : 0, + ); + } + + late final _Cronet_EngineParams_enable_check_result_set_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_EngineParams_enable_check_result_set>>( + 'Cronet_EngineParams_enable_check_result_set'); + late final _dart_Cronet_EngineParams_enable_check_result_set + _Cronet_EngineParams_enable_check_result_set = + _Cronet_EngineParams_enable_check_result_set_ptr.asFunction< + _dart_Cronet_EngineParams_enable_check_result_set>(); + + void Cronet_EngineParams_user_agent_set( + ffi.Pointer self, + ffi.Pointer user_agent, + ) { + return _Cronet_EngineParams_user_agent_set( + self, + user_agent, + ); + } + + late final _Cronet_EngineParams_user_agent_set_ptr = + _lookup>( + 'Cronet_EngineParams_user_agent_set'); + late final _dart_Cronet_EngineParams_user_agent_set + _Cronet_EngineParams_user_agent_set = + _Cronet_EngineParams_user_agent_set_ptr.asFunction< + _dart_Cronet_EngineParams_user_agent_set>(); + + void Cronet_EngineParams_accept_language_set( + ffi.Pointer self, + ffi.Pointer accept_language, + ) { + return _Cronet_EngineParams_accept_language_set( + self, + accept_language, + ); + } + + late final _Cronet_EngineParams_accept_language_set_ptr = + _lookup>( + 'Cronet_EngineParams_accept_language_set'); + late final _dart_Cronet_EngineParams_accept_language_set + _Cronet_EngineParams_accept_language_set = + _Cronet_EngineParams_accept_language_set_ptr.asFunction< + _dart_Cronet_EngineParams_accept_language_set>(); + + void Cronet_EngineParams_storage_path_set( + ffi.Pointer self, + ffi.Pointer storage_path, + ) { + return _Cronet_EngineParams_storage_path_set( + self, + storage_path, + ); + } + + late final _Cronet_EngineParams_storage_path_set_ptr = + _lookup>( + 'Cronet_EngineParams_storage_path_set'); + late final _dart_Cronet_EngineParams_storage_path_set + _Cronet_EngineParams_storage_path_set = + _Cronet_EngineParams_storage_path_set_ptr.asFunction< + _dart_Cronet_EngineParams_storage_path_set>(); + + void Cronet_EngineParams_enable_quic_set( + ffi.Pointer self, + bool enable_quic, + ) { + return _Cronet_EngineParams_enable_quic_set( + self, + enable_quic ? 1 : 0, + ); + } + + late final _Cronet_EngineParams_enable_quic_set_ptr = + _lookup>( + 'Cronet_EngineParams_enable_quic_set'); + late final _dart_Cronet_EngineParams_enable_quic_set + _Cronet_EngineParams_enable_quic_set = + _Cronet_EngineParams_enable_quic_set_ptr.asFunction< + _dart_Cronet_EngineParams_enable_quic_set>(); + + void Cronet_EngineParams_enable_http2_set( + ffi.Pointer self, + bool enable_http2, + ) { + return _Cronet_EngineParams_enable_http2_set( + self, + enable_http2 ? 1 : 0, + ); + } + + late final _Cronet_EngineParams_enable_http2_set_ptr = + _lookup>( + 'Cronet_EngineParams_enable_http2_set'); + late final _dart_Cronet_EngineParams_enable_http2_set + _Cronet_EngineParams_enable_http2_set = + _Cronet_EngineParams_enable_http2_set_ptr.asFunction< + _dart_Cronet_EngineParams_enable_http2_set>(); + + void Cronet_EngineParams_enable_brotli_set( + ffi.Pointer self, + bool enable_brotli, + ) { + return _Cronet_EngineParams_enable_brotli_set( + self, + enable_brotli ? 1 : 0, + ); + } + + late final _Cronet_EngineParams_enable_brotli_set_ptr = + _lookup>( + 'Cronet_EngineParams_enable_brotli_set'); + late final _dart_Cronet_EngineParams_enable_brotli_set + _Cronet_EngineParams_enable_brotli_set = + _Cronet_EngineParams_enable_brotli_set_ptr.asFunction< + _dart_Cronet_EngineParams_enable_brotli_set>(); + + void Cronet_EngineParams_http_cache_mode_set( + ffi.Pointer self, + int http_cache_mode, + ) { + return _Cronet_EngineParams_http_cache_mode_set( + self, + http_cache_mode, + ); + } + + late final _Cronet_EngineParams_http_cache_mode_set_ptr = + _lookup>( + 'Cronet_EngineParams_http_cache_mode_set'); + late final _dart_Cronet_EngineParams_http_cache_mode_set + _Cronet_EngineParams_http_cache_mode_set = + _Cronet_EngineParams_http_cache_mode_set_ptr.asFunction< + _dart_Cronet_EngineParams_http_cache_mode_set>(); + + void Cronet_EngineParams_http_cache_max_size_set( + ffi.Pointer self, + int http_cache_max_size, + ) { + return _Cronet_EngineParams_http_cache_max_size_set( + self, + http_cache_max_size, + ); + } + + late final _Cronet_EngineParams_http_cache_max_size_set_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_EngineParams_http_cache_max_size_set>>( + 'Cronet_EngineParams_http_cache_max_size_set'); + late final _dart_Cronet_EngineParams_http_cache_max_size_set + _Cronet_EngineParams_http_cache_max_size_set = + _Cronet_EngineParams_http_cache_max_size_set_ptr.asFunction< + _dart_Cronet_EngineParams_http_cache_max_size_set>(); + + void Cronet_EngineParams_quic_hints_add( + ffi.Pointer self, + ffi.Pointer element, + ) { + return _Cronet_EngineParams_quic_hints_add( + self, + element, + ); + } + + late final _Cronet_EngineParams_quic_hints_add_ptr = + _lookup>( + 'Cronet_EngineParams_quic_hints_add'); + late final _dart_Cronet_EngineParams_quic_hints_add + _Cronet_EngineParams_quic_hints_add = + _Cronet_EngineParams_quic_hints_add_ptr.asFunction< + _dart_Cronet_EngineParams_quic_hints_add>(); + + /// //////////////////// + ffi.Pointer Cronet_HttpHeader_Create() { + return _Cronet_HttpHeader_Create(); + } + + late final _Cronet_HttpHeader_Create_ptr = + _lookup>( + 'Cronet_HttpHeader_Create'); + late final _dart_Cronet_HttpHeader_Create _Cronet_HttpHeader_Create = + _Cronet_HttpHeader_Create_ptr.asFunction< + _dart_Cronet_HttpHeader_Create>(); + + void Cronet_HttpHeader_Destroy( + ffi.Pointer self, + ) { + return _Cronet_HttpHeader_Destroy( + self, + ); + } + + late final _Cronet_HttpHeader_Destroy_ptr = + _lookup>( + 'Cronet_HttpHeader_Destroy'); + late final _dart_Cronet_HttpHeader_Destroy _Cronet_HttpHeader_Destroy = + _Cronet_HttpHeader_Destroy_ptr.asFunction< + _dart_Cronet_HttpHeader_Destroy>(); + + void Cronet_HttpHeader_name_set( + ffi.Pointer self, + ffi.Pointer name, + ) { + return _Cronet_HttpHeader_name_set( + self, + name, + ); + } + + late final _Cronet_HttpHeader_name_set_ptr = + _lookup>( + 'Cronet_HttpHeader_name_set'); + late final _dart_Cronet_HttpHeader_name_set _Cronet_HttpHeader_name_set = + _Cronet_HttpHeader_name_set_ptr.asFunction< + _dart_Cronet_HttpHeader_name_set>(); + + void Cronet_HttpHeader_value_set( + ffi.Pointer self, + ffi.Pointer value, + ) { + return _Cronet_HttpHeader_value_set( + self, + value, + ); + } + + late final _Cronet_HttpHeader_value_set_ptr = + _lookup>( + 'Cronet_HttpHeader_value_set'); + late final _dart_Cronet_HttpHeader_value_set _Cronet_HttpHeader_value_set = + _Cronet_HttpHeader_value_set_ptr.asFunction< + _dart_Cronet_HttpHeader_value_set>(); + + int Cronet_UrlResponseInfo_http_status_code_get( + ffi.Pointer self, + ) { + return _Cronet_UrlResponseInfo_http_status_code_get( + self, + ); + } + + late final _Cronet_UrlResponseInfo_http_status_code_get_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlResponseInfo_http_status_code_get>>( + 'Cronet_UrlResponseInfo_http_status_code_get'); + late final _dart_Cronet_UrlResponseInfo_http_status_code_get + _Cronet_UrlResponseInfo_http_status_code_get = + _Cronet_UrlResponseInfo_http_status_code_get_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_http_status_code_get>(); + + ffi.Pointer Cronet_UrlResponseInfo_http_status_text_get( + ffi.Pointer self, + ) { + return _Cronet_UrlResponseInfo_http_status_text_get( + self, + ); + } + + late final _Cronet_UrlResponseInfo_http_status_text_get_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlResponseInfo_http_status_text_get>>( + 'Cronet_UrlResponseInfo_http_status_text_get'); + late final _dart_Cronet_UrlResponseInfo_http_status_text_get + _Cronet_UrlResponseInfo_http_status_text_get = + _Cronet_UrlResponseInfo_http_status_text_get_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_http_status_text_get>(); + + /// //////////////////// + ffi.Pointer Cronet_UrlRequestParams_Create() { + return _Cronet_UrlRequestParams_Create(); + } + + late final _Cronet_UrlRequestParams_Create_ptr = + _lookup>( + 'Cronet_UrlRequestParams_Create'); + late final _dart_Cronet_UrlRequestParams_Create + _Cronet_UrlRequestParams_Create = _Cronet_UrlRequestParams_Create_ptr + .asFunction<_dart_Cronet_UrlRequestParams_Create>(); + + void Cronet_UrlRequestParams_Destroy( + ffi.Pointer self, + ) { + return _Cronet_UrlRequestParams_Destroy( + self, + ); + } + + late final _Cronet_UrlRequestParams_Destroy_ptr = + _lookup>( + 'Cronet_UrlRequestParams_Destroy'); + late final _dart_Cronet_UrlRequestParams_Destroy + _Cronet_UrlRequestParams_Destroy = _Cronet_UrlRequestParams_Destroy_ptr + .asFunction<_dart_Cronet_UrlRequestParams_Destroy>(); + + void Cronet_UrlRequestParams_http_method_set( + ffi.Pointer self, + ffi.Pointer http_method, + ) { + return _Cronet_UrlRequestParams_http_method_set( + self, + http_method, + ); + } + + late final _Cronet_UrlRequestParams_http_method_set_ptr = + _lookup>( + 'Cronet_UrlRequestParams_http_method_set'); + late final _dart_Cronet_UrlRequestParams_http_method_set + _Cronet_UrlRequestParams_http_method_set = + _Cronet_UrlRequestParams_http_method_set_ptr.asFunction< + _dart_Cronet_UrlRequestParams_http_method_set>(); + + void Cronet_UrlRequestParams_request_headers_add( + ffi.Pointer self, + ffi.Pointer element, + ) { + return _Cronet_UrlRequestParams_request_headers_add( + self, + element, + ); + } + + late final _Cronet_UrlRequestParams_request_headers_add_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlRequestParams_request_headers_add>>( + 'Cronet_UrlRequestParams_request_headers_add'); + late final _dart_Cronet_UrlRequestParams_request_headers_add + _Cronet_UrlRequestParams_request_headers_add = + _Cronet_UrlRequestParams_request_headers_add_ptr.asFunction< + _dart_Cronet_UrlRequestParams_request_headers_add>(); +} + +class Cronet_BufferPtr extends ffi.Opaque {} + +class Cronet_EnginePtr extends ffi.Opaque {} + +class Cronet_EngineParamsPtr extends ffi.Opaque {} + +class Cronet_UrlRequestPtr extends ffi.Opaque {} + +class Cronet_QuicHintPtr extends ffi.Opaque {} + +class Cronet_HttpHeaderPtr extends ffi.Opaque {} + +class Cronet_UrlResponseInfoPtr extends ffi.Opaque {} + +class Cronet_UrlRequestParamsPtr extends ffi.Opaque {} + +typedef _c_Cronet_Buffer_GetSize = ffi.Uint64 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Buffer_GetSize = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Buffer_GetData = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Buffer_GetData = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Engine_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_Engine_Create = ffi.Pointer Function(); + +typedef _c_Cronet_Engine_StartWithParams = ffi.Int32 Function( + ffi.Pointer self, + ffi.Pointer params, +); + +typedef _dart_Cronet_Engine_StartWithParams = int Function( + ffi.Pointer self, + ffi.Pointer params, +); + +typedef _c_Cronet_Engine_StartNetLogToFile = ffi.Uint8 Function( + ffi.Pointer self, + ffi.Pointer file_name, + ffi.Uint8 log_all, +); + +typedef _dart_Cronet_Engine_StartNetLogToFile = int Function( + ffi.Pointer self, + ffi.Pointer file_name, + int log_all, +); + +typedef _c_Cronet_Engine_StopNetLog = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Engine_StopNetLog = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Engine_Shutdown = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Engine_Shutdown = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Engine_GetVersionString = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Engine_GetVersionString = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequest_Create = ffi.Pointer + Function(); + +typedef _dart_Cronet_UrlRequest_Create = ffi.Pointer + Function(); + +typedef _c_Cronet_UrlRequest_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequest_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequest_SetClientContext = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _dart_Cronet_UrlRequest_SetClientContext = void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _c_Cronet_UrlRequest_GetClientContext = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequest_GetClientContext = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequest_Start = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequest_Start = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequest_FollowRedirect = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequest_FollowRedirect = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequest_Read = ffi.Int32 Function( + ffi.Pointer self, + ffi.Pointer buffer, +); + +typedef _dart_Cronet_UrlRequest_Read = int Function( + ffi.Pointer self, + ffi.Pointer buffer, +); + +typedef _c_Cronet_UrlRequest_Cancel = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequest_Cancel = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_QuicHint_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_QuicHint_Create = ffi.Pointer + Function(); + +typedef _c_Cronet_QuicHint_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_QuicHint_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_QuicHint_host_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer host, +); + +typedef _dart_Cronet_QuicHint_host_set = void Function( + ffi.Pointer self, + ffi.Pointer host, +); + +typedef _c_Cronet_QuicHint_port_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int32 port, +); + +typedef _dart_Cronet_QuicHint_port_set = void Function( + ffi.Pointer self, + int port, +); + +typedef _c_Cronet_QuicHint_alternate_port_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int32 alternate_port, +); + +typedef _dart_Cronet_QuicHint_alternate_port_set = void Function( + ffi.Pointer self, + int alternate_port, +); + +typedef _c_Cronet_EngineParams_Create = ffi.Pointer + Function(); + +typedef _dart_Cronet_EngineParams_Create = ffi.Pointer + Function(); + +typedef _c_Cronet_EngineParams_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_enable_check_result_set = ffi.Void Function( + ffi.Pointer self, + ffi.Uint8 enable_check_result, +); + +typedef _dart_Cronet_EngineParams_enable_check_result_set = void Function( + ffi.Pointer self, + int enable_check_result, +); + +typedef _c_Cronet_EngineParams_user_agent_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer user_agent, +); + +typedef _dart_Cronet_EngineParams_user_agent_set = void Function( + ffi.Pointer self, + ffi.Pointer user_agent, +); + +typedef _c_Cronet_EngineParams_accept_language_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer accept_language, +); + +typedef _dart_Cronet_EngineParams_accept_language_set = void Function( + ffi.Pointer self, + ffi.Pointer accept_language, +); + +typedef _c_Cronet_EngineParams_storage_path_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer storage_path, +); + +typedef _dart_Cronet_EngineParams_storage_path_set = void Function( + ffi.Pointer self, + ffi.Pointer storage_path, +); + +typedef _c_Cronet_EngineParams_enable_quic_set = ffi.Void Function( + ffi.Pointer self, + ffi.Uint8 enable_quic, +); + +typedef _dart_Cronet_EngineParams_enable_quic_set = void Function( + ffi.Pointer self, + int enable_quic, +); + +typedef _c_Cronet_EngineParams_enable_http2_set = ffi.Void Function( + ffi.Pointer self, + ffi.Uint8 enable_http2, +); + +typedef _dart_Cronet_EngineParams_enable_http2_set = void Function( + ffi.Pointer self, + int enable_http2, +); + +typedef _c_Cronet_EngineParams_enable_brotli_set = ffi.Void Function( + ffi.Pointer self, + ffi.Uint8 enable_brotli, +); + +typedef _dart_Cronet_EngineParams_enable_brotli_set = void Function( + ffi.Pointer self, + int enable_brotli, +); + +typedef _c_Cronet_EngineParams_http_cache_mode_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int32 http_cache_mode, +); + +typedef _dart_Cronet_EngineParams_http_cache_mode_set = void Function( + ffi.Pointer self, + int http_cache_mode, +); + +typedef _c_Cronet_EngineParams_http_cache_max_size_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int64 http_cache_max_size, +); + +typedef _dart_Cronet_EngineParams_http_cache_max_size_set = void Function( + ffi.Pointer self, + int http_cache_max_size, +); + +typedef _c_Cronet_EngineParams_quic_hints_add = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _dart_Cronet_EngineParams_quic_hints_add = void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _c_Cronet_HttpHeader_Create = ffi.Pointer + Function(); + +typedef _dart_Cronet_HttpHeader_Create = ffi.Pointer + Function(); + +typedef _c_Cronet_HttpHeader_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_HttpHeader_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_HttpHeader_name_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer name, +); + +typedef _dart_Cronet_HttpHeader_name_set = void Function( + ffi.Pointer self, + ffi.Pointer name, +); + +typedef _c_Cronet_HttpHeader_value_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer value, +); + +typedef _dart_Cronet_HttpHeader_value_set = void Function( + ffi.Pointer self, + ffi.Pointer value, +); + +typedef _c_Cronet_UrlResponseInfo_http_status_code_get = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlResponseInfo_http_status_code_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlResponseInfo_http_status_text_get = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlResponseInfo_http_status_text_get + = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequestParams_Create + = ffi.Pointer Function(); + +typedef _dart_Cronet_UrlRequestParams_Create + = ffi.Pointer Function(); + +typedef _c_Cronet_UrlRequestParams_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequestParams_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequestParams_http_method_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer http_method, +); + +typedef _dart_Cronet_UrlRequestParams_http_method_set = void Function( + ffi.Pointer self, + ffi.Pointer http_method, +); + +typedef _c_Cronet_UrlRequestParams_request_headers_add = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _dart_Cronet_UrlRequestParams_request_headers_add = void Function( + ffi.Pointer self, + ffi.Pointer element, +); diff --git a/lib/src/wrapper/ffigen.yaml b/lib/src/wrapper/ffigen.yaml new file mode 100644 index 0000000..49cc5f1 --- /dev/null +++ b/lib/src/wrapper/ffigen.yaml @@ -0,0 +1,40 @@ +name: 'Wrapper' +description: 'Bindings to Wrapper for Cronet' +output: 'lib/src/wrapper/generated_bindings.dart' +array-workaround: true +headers: + entry-points: + - 'src/wrapper.h' + include-directives: + - 'src/wrapper.h' + - 'src/wrapper_export.h' +compiler-opts: + - '-Isrc/' + - '-Ithird_party/dart-sdk/' + - '-DDART_SHARED_LIB' +macros: + include: + - nothing +enums: + include: + - nothing +unnamed-enums: + include: + - nothing +globals: + include: + - nothing +structs: + include: + - nothing + dependency-only: opaque +comments: + style: any + length: full +preamble: | + // Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file + // for details. All rights reserved. Use of this source code is governed by a + // BSD-style license that can be found in the LICENSE file. + + // ignore_for_file: non_constant_identifier_names, camel_case_types + // ignore_for_file: constant_identifier_names diff --git a/lib/src/wrapper/generated_bindings.dart b/lib/src/wrapper/generated_bindings.dart new file mode 100644 index 0000000..be3910f --- /dev/null +++ b/lib/src/wrapper/generated_bindings.dart @@ -0,0 +1,232 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// ignore_for_file: non_constant_identifier_names, camel_case_types +// ignore_for_file: constant_identifier_names + +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +import 'dart:ffi' as ffi; + +/// Bindings to Wrapper for Cronet +class Wrapper { + /// Holds the symbol lookup function. + final ffi.Pointer Function(String symbolName) + _lookup; + + /// The symbols are looked up in [dynamicLibrary]. + Wrapper(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; + + /// The symbols are looked up with [lookup]. + Wrapper.fromLookup( + ffi.Pointer Function(String symbolName) + lookup) + : _lookup = lookup; + + void dispatchCallback( + ffi.Pointer methodname, + ) { + return _dispatchCallback( + methodname, + ); + } + + late final _dispatchCallback_ptr = + _lookup>('dispatchCallback'); + late final _dart_dispatchCallback _dispatchCallback = + _dispatchCallback_ptr.asFunction<_dart_dispatchCallback>(); + + int InitDartApiDL( + ffi.Pointer data, + ) { + return _InitDartApiDL( + data, + ); + } + + late final _InitDartApiDL_ptr = + _lookup>('InitDartApiDL'); + late final _dart_InitDartApiDL _InitDartApiDL = + _InitDartApiDL_ptr.asFunction<_dart_InitDartApiDL>(); + + void unloadCronet() { + return _unloadCronet(); + } + + late final _unloadCronet_ptr = + _lookup>('unloadCronet'); + late final _dart_unloadCronet _unloadCronet = + _unloadCronet_ptr.asFunction<_dart_unloadCronet>(); + + ffi.Pointer Create_Executor() { + return _Create_Executor(); + } + + late final _Create_Executor_ptr = + _lookup>('Create_Executor'); + late final _dart_Create_Executor _Create_Executor = + _Create_Executor_ptr.asFunction<_dart_Create_Executor>(); + + void Destroy_Executor( + ffi.Pointer executor, + ) { + return _Destroy_Executor( + executor, + ); + } + + late final _Destroy_Executor_ptr = + _lookup>('Destroy_Executor'); + late final _dart_Destroy_Executor _Destroy_Executor = + _Destroy_Executor_ptr.asFunction<_dart_Destroy_Executor>(); + + void registerHttpClient( + Object h, + ffi.Pointer ce, + ) { + return _registerHttpClient( + h, + ce, + ); + } + + late final _registerHttpClient_ptr = + _lookup>('registerHttpClient'); + late final _dart_registerHttpClient _registerHttpClient = + _registerHttpClient_ptr.asFunction<_dart_registerHttpClient>(); + + void registerCallbackHandler( + int nativePort, + ffi.Pointer rp, + ) { + return _registerCallbackHandler( + nativePort, + rp, + ); + } + + late final _registerCallbackHandler_ptr = + _lookup>( + 'registerCallbackHandler'); + late final _dart_registerCallbackHandler _registerCallbackHandler = + _registerCallbackHandler_ptr.asFunction<_dart_registerCallbackHandler>(); + + void removeRequest( + ffi.Pointer rp, + ) { + return _removeRequest( + rp, + ); + } + + late final _removeRequest_ptr = + _lookup>('removeRequest'); + late final _dart_removeRequest _removeRequest = + _removeRequest_ptr.asFunction<_dart_removeRequest>(); + + int Cronet_UrlRequest_Init( + ffi.Pointer self, + ffi.Pointer engine, + ffi.Pointer url, + ffi.Pointer params, + ffi.Pointer _executor, + ) { + return _Cronet_UrlRequest_Init( + self, + engine, + url, + params, + _executor, + ); + } + + late final _Cronet_UrlRequest_Init_ptr = + _lookup>( + 'Cronet_UrlRequest_Init'); + late final _dart_Cronet_UrlRequest_Init _Cronet_UrlRequest_Init = + _Cronet_UrlRequest_Init_ptr.asFunction<_dart_Cronet_UrlRequest_Init>(); +} + +class Cronet_EnginePtr extends ffi.Opaque {} + +class Cronet_UrlRequestPtr extends ffi.Opaque {} + +class Cronet_UrlRequestParamsPtr extends ffi.Opaque {} + +typedef _c_dispatchCallback = ffi.Void Function( + ffi.Pointer methodname, +); + +typedef _dart_dispatchCallback = void Function( + ffi.Pointer methodname, +); + +typedef _c_InitDartApiDL = ffi.IntPtr Function( + ffi.Pointer data, +); + +typedef _dart_InitDartApiDL = int Function( + ffi.Pointer data, +); + +typedef _c_unloadCronet = ffi.Void Function(); + +typedef _dart_unloadCronet = void Function(); + +typedef _c_Create_Executor = ffi.Pointer Function(); + +typedef _dart_Create_Executor = ffi.Pointer Function(); + +typedef _c_Destroy_Executor = ffi.Void Function( + ffi.Pointer executor, +); + +typedef _dart_Destroy_Executor = void Function( + ffi.Pointer executor, +); + +typedef _c_registerHttpClient = ffi.Void Function( + ffi.Handle h, + ffi.Pointer ce, +); + +typedef _dart_registerHttpClient = void Function( + Object h, + ffi.Pointer ce, +); + +typedef _c_registerCallbackHandler = ffi.Void Function( + ffi.Int64 nativePort, + ffi.Pointer rp, +); + +typedef _dart_registerCallbackHandler = void Function( + int nativePort, + ffi.Pointer rp, +); + +typedef _c_removeRequest = ffi.Void Function( + ffi.Pointer rp, +); + +typedef _dart_removeRequest = void Function( + ffi.Pointer rp, +); + +typedef _c_Cronet_UrlRequest_Init = ffi.Int32 Function( + ffi.Pointer self, + ffi.Pointer engine, + ffi.Pointer url, + ffi.Pointer params, + ffi.Pointer _executor, +); + +typedef _dart_Cronet_UrlRequest_Init = int Function( + ffi.Pointer self, + ffi.Pointer engine, + ffi.Pointer url, + ffi.Pointer params, + ffi.Pointer _executor, +); diff --git a/pubspec.yaml b/pubspec.yaml index 97d3373..39b16c6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,31 +21,3 @@ dev_dependencies: ffigen: ^2.4.2 lints: ^1.0.1 test: ^1.17.5 - -ffigen: - name: 'Cronet' - description: 'Bindings to Cronet' - output: 'lib/src/generated_bindings.dart' - array-workaround: true - headers: - entry-points: - - 'lib/src/native/wrapper/wrapper.h' - - 'lib/src/native/include/cronet/cronet.idl_c.h' - include-directives: - - 'lib/src/native/wrapper/wrapper.h' - - 'lib/src/native/include/cronet/cronet.idl_c.h' - - 'dart_api.h' - - 'dart_native_api.h' - - 'dart_api_dl.h' - - 'lib/src/native/wrapper/wrapper_export.h' - compiler-opts: - - '-Ilib/src/native/include/dart/' - - '-Ilib/src/native/include/cronet/' - - '-DDART_SHARED_LIB' - preamble: | - // Copyright 2017 The Chromium Authors. All rights reserved. - // Use of this source code is governed by a BSD-style license that can be - // found in the LICENSE file. - - // ignore_for_file: non_constant_identifier_names, camel_case_types - // ignore_for_file: constant_identifier_names diff --git a/tool/update_bindings.dart b/tool/update_bindings.dart new file mode 100644 index 0000000..8fbed3e --- /dev/null +++ b/tool/update_bindings.dart @@ -0,0 +1,29 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +void main(List args) async { + final root = + Directory.fromUri(Platform.script).parent.parent.uri.toFilePath(); + + final generateCronet = Process.run('dart', [ + 'run', + 'ffigen', + '--config=$root/lib/src/third_party/cronet/ffigen.yaml', + ]); + + final generateWrapper = Process.run('dart', [ + 'run', + 'ffigen', + '--config=$root/lib/src/wrapper/ffigen.yaml', + ]); + + final result1 = await generateCronet; + print(result1.stdout); + print(result1.stderr); + final result2 = await generateWrapper; + print(result2.stdout); + print(result2.stderr); +} From 783a6cebc31932b790d1418c134f6c2aa320abc3 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Sun, 27 Jun 2021 13:49:16 +0530 Subject: [PATCH 26/42] spliting wrapper and cronet bindings --- bin/prepare_cronet.dart | 26 +- lib/src/constants.dart | 8 +- lib/src/dylib_handler.dart | 21 +- lib/src/generated_bindings.dart | 1439 ----------------- lib/src/http_callback_handler.dart | 17 +- lib/src/http_client.dart | 31 +- lib/src/http_client_request.dart | 22 +- lib/src/third_party/cronet/ffigen.yaml | 34 +- .../cronet/generated_bindings.dart | 1021 ++++++++++-- lib/src/wrapper/ffigen.yaml | 16 - lib/src/wrapper/generated_bindings.dart | 128 +- src/wrapper.cc | 285 +--- src/wrapper.h | 39 +- third_party/cronet/cronet.idl_c.h | 142 +- third_party/cronet_impl/sample_executor.cc | 61 +- 15 files changed, 1224 insertions(+), 2066 deletions(-) delete mode 100644 lib/src/generated_bindings.dart diff --git a/bin/prepare_cronet.dart b/bin/prepare_cronet.dart index a9a49e8..53bd5fe 100644 --- a/bin/prepare_cronet.dart +++ b/bin/prepare_cronet.dart @@ -25,12 +25,9 @@ bool buildWrapperLinux([String? version]) { '-shared', '-W', '-ldl', - '-DDART_SHARED_LIB', - '-Wl,-z,origin', - "-Wl,-rpath,\$ORIGIN", - "-Wl,-rpath,\$ORIGIN/cronet_binaries/linux64/" + '-DDART_SHARED_LIB' ]; - const outputName = 'wrapper.so'; + const outputName = 'libwrapper.so'; const sources = [ 'wrapper.cc', '../third_party/cronet_impl/sample_executor.cc', @@ -43,19 +40,13 @@ bool buildWrapperLinux([String? version]) { Directory.current = Directory(wrapperPath); print('Building Wrapper...'); var result = Process.runSync( - compiler, - [cppV] + - ['-DCRONET_VERSION="${version ?? cronetVersion}"'] + - options + - sources + - ['-o', outputName] + - includes); + compiler, [cppV] + options + sources + ['-o', outputName] + includes); Directory.current = pwd; print(result.stdout); print(result.stderr); if (result.exitCode != 0) return false; print('Copying wrapper to project root...'); - File('$wrapperPath/wrapper.so').copySync('wrapper.so'); + File('$wrapperPath/$outputName').copySync(outputName); if (result.exitCode != 0) return false; return true; } @@ -66,14 +57,10 @@ bool buildWrapperWindows([String? version]) { final ansi = Ansi(Ansi.terminalSupportsAnsi); final wrapperPath = wrapperSourcePath(); final pwd = Directory.current; - final environment = { - 'CL': '/DCRONET_VERSION="""${version ?? cronetVersion}"""' - }; Directory.current = Directory(wrapperPath); logger.stdout('Building Wrapper...'); try { - final result = Process.runSync('cmake', ['CMakeLists.txt', '-B', 'out'], - environment: environment); + final result = Process.runSync('cmake', ['CMakeLists.txt', '-B', 'out']); print(result.stdout); print(result.stderr); } catch (error) { @@ -85,8 +72,7 @@ bool buildWrapperWindows([String? version]) { 'cd ${pwd.path}\ndart run cronet:build ${version ?? cronetVersion}'); return false; } - var result = - Process.runSync('cmake', ['--build', 'out'], environment: environment); + var result = Process.runSync('cmake', ['--build', 'out']); print(result.stdout); print(result.stderr); if (result.exitCode != 0) return false; diff --git a/lib/src/constants.dart b/lib/src/constants.dart index e67b110..0c8052d 100644 --- a/lib/src/constants.dart +++ b/lib/src/constants.dart @@ -13,12 +13,10 @@ const cronetVersion = "86.0.4240.198"; String getDylibName(String name, [String platform = '']) { var ext = '.so'; - var prefix = ''; + var prefix = 'lib'; - // When gradle builds the wrapper, it automatically prepends lib. - if (Platform.isAndroid || platform.startsWith('android')) { - prefix = 'lib'; - } else if (Platform.isWindows || platform.startsWith('windows')) { + if (Platform.isWindows || platform.startsWith('windows')) { + prefix = ''; ext = '.dll'; } else if (Platform.isMacOS || platform.startsWith('macos')) { ext = '.dylib'; diff --git a/lib/src/dylib_handler.dart b/lib/src/dylib_handler.dart index a13c306..63bc25c 100644 --- a/lib/src/dylib_handler.dart +++ b/lib/src/dylib_handler.dart @@ -64,21 +64,18 @@ String? _resolveLibUri(String name) { return null; } -/// Loads [wrapper] dynamic library depending on the platform. +/// Loads dynamic library depending on the platform. /// -/// This loaded [wrapper] will then load [cronet]. /// Throws an [ArgumentError] if library can't be loaded. -DynamicLibrary loadWrapper() { - var wrapperName = getWrapperName(); - +DynamicLibrary loadDylib(String name) { // _resolveLibUri() will try to resolve wrapper's absolute path. // If it can't find it, try looking at search paths provided by the system. - wrapperName = _resolveLibUri(wrapperName) ?? wrapperName; + name = _resolveLibUri(name) ?? name; try { return Platform.isIOS ? DynamicLibrary.process() - : DynamicLibrary.open(wrapperName); + : DynamicLibrary.open(name); } catch (exception) { final logger = Logger.standard(); final ansi = Ansi(Ansi.terminalSupportsAnsi); @@ -96,3 +93,13 @@ DynamicLibrary loadWrapper() { rethrow; } } + +/// Loads `wrapper` dynamic library depending on the platform. +DynamicLibrary loadWrapper() { + return loadDylib(getWrapperName()); +} + +/// Loads `cronet` dynamic library depending on the platform. +DynamicLibrary loadCronet() { + return loadDylib(getCronetName()); +} diff --git a/lib/src/generated_bindings.dart b/lib/src/generated_bindings.dart deleted file mode 100644 index b6ee5df..0000000 --- a/lib/src/generated_bindings.dart +++ /dev/null @@ -1,1439 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// ignore_for_file: non_constant_identifier_names, camel_case_types -// ignore_for_file: constant_identifier_names - -// AUTO GENERATED FILE, DO NOT EDIT. -// -// Generated by `package:ffigen`. -import 'dart:ffi' as ffi; - -/// Bindings to Cronet -class Cronet { - /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) - _lookup; - - /// The symbols are looked up in [dynamicLibrary]. - Cronet(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; - - /// The symbols are looked up with [lookup]. - Cronet.fromLookup( - ffi.Pointer Function(String symbolName) - lookup) - : _lookup = lookup; - - void dispatchCallback( - ffi.Pointer methodname, - ) { - return _dispatchCallback( - methodname, - ); - } - - late final _dispatchCallback_ptr = - _lookup>('dispatchCallback'); - late final _dart_dispatchCallback _dispatchCallback = - _dispatchCallback_ptr.asFunction<_dart_dispatchCallback>(); - - int InitDartApiDL( - ffi.Pointer data, - ) { - return _InitDartApiDL( - data, - ); - } - - late final _InitDartApiDL_ptr = - _lookup>('InitDartApiDL'); - late final _dart_InitDartApiDL _InitDartApiDL = - _InitDartApiDL_ptr.asFunction<_dart_InitDartApiDL>(); - - void unloadCronet() { - return _unloadCronet(); - } - - late final _unloadCronet_ptr = - _lookup>('unloadCronet'); - late final _dart_unloadCronet _unloadCronet = - _unloadCronet_ptr.asFunction<_dart_unloadCronet>(); - - ffi.Pointer Create_Executor() { - return _Create_Executor(); - } - - late final _Create_Executor_ptr = - _lookup>('Create_Executor'); - late final _dart_Create_Executor _Create_Executor = - _Create_Executor_ptr.asFunction<_dart_Create_Executor>(); - - void Destroy_Executor( - ffi.Pointer executor, - ) { - return _Destroy_Executor( - executor, - ); - } - - late final _Destroy_Executor_ptr = - _lookup>('Destroy_Executor'); - late final _dart_Destroy_Executor _Destroy_Executor = - _Destroy_Executor_ptr.asFunction<_dart_Destroy_Executor>(); - - void registerHttpClient( - Object h, - ffi.Pointer ce, - ) { - return _registerHttpClient( - h, - ce, - ); - } - - late final _registerHttpClient_ptr = - _lookup>('registerHttpClient'); - late final _dart_registerHttpClient _registerHttpClient = - _registerHttpClient_ptr.asFunction<_dart_registerHttpClient>(); - - void registerCallbackHandler( - int nativePort, - ffi.Pointer rp, - ) { - return _registerCallbackHandler( - nativePort, - rp, - ); - } - - late final _registerCallbackHandler_ptr = - _lookup>( - 'registerCallbackHandler'); - late final _dart_registerCallbackHandler _registerCallbackHandler = - _registerCallbackHandler_ptr.asFunction<_dart_registerCallbackHandler>(); - - void removeRequest( - ffi.Pointer rp, - ) { - return _removeRequest( - rp, - ); - } - - late final _removeRequest_ptr = - _lookup>('removeRequest'); - late final _dart_removeRequest _removeRequest = - _removeRequest_ptr.asFunction<_dart_removeRequest>(); - - int Cronet_UrlRequest_Init( - ffi.Pointer self, - ffi.Pointer engine, - ffi.Pointer url, - ffi.Pointer params, - ffi.Pointer _executor, - ) { - return _Cronet_UrlRequest_Init( - self, - engine, - url, - params, - _executor, - ); - } - - late final _Cronet_UrlRequest_Init_ptr = - _lookup>( - 'Cronet_UrlRequest_Init'); - late final _dart_Cronet_UrlRequest_Init _Cronet_UrlRequest_Init = - _Cronet_UrlRequest_Init_ptr.asFunction<_dart_Cronet_UrlRequest_Init>(); - - int Cronet_Buffer_GetSize( - ffi.Pointer self, - ) { - return _Cronet_Buffer_GetSize( - self, - ); - } - - late final _Cronet_Buffer_GetSize_ptr = - _lookup>( - 'Cronet_Buffer_GetSize'); - late final _dart_Cronet_Buffer_GetSize _Cronet_Buffer_GetSize = - _Cronet_Buffer_GetSize_ptr.asFunction<_dart_Cronet_Buffer_GetSize>(); - - ffi.Pointer Cronet_Buffer_GetData( - ffi.Pointer self, - ) { - return _Cronet_Buffer_GetData( - self, - ); - } - - late final _Cronet_Buffer_GetData_ptr = - _lookup>( - 'Cronet_Buffer_GetData'); - late final _dart_Cronet_Buffer_GetData _Cronet_Buffer_GetData = - _Cronet_Buffer_GetData_ptr.asFunction<_dart_Cronet_Buffer_GetData>(); - - ffi.Pointer Cronet_Engine_Create() { - return _Cronet_Engine_Create(); - } - - late final _Cronet_Engine_Create_ptr = - _lookup>( - 'Cronet_Engine_Create'); - late final _dart_Cronet_Engine_Create _Cronet_Engine_Create = - _Cronet_Engine_Create_ptr.asFunction<_dart_Cronet_Engine_Create>(); - - int Cronet_Engine_StartWithParams( - ffi.Pointer self, - ffi.Pointer params, - ) { - return _Cronet_Engine_StartWithParams( - self, - params, - ); - } - - late final _Cronet_Engine_StartWithParams_ptr = - _lookup>( - 'Cronet_Engine_StartWithParams'); - late final _dart_Cronet_Engine_StartWithParams - _Cronet_Engine_StartWithParams = _Cronet_Engine_StartWithParams_ptr - .asFunction<_dart_Cronet_Engine_StartWithParams>(); - - bool Cronet_Engine_StartNetLogToFile( - ffi.Pointer self, - ffi.Pointer file_name, - bool log_all, - ) { - return _Cronet_Engine_StartNetLogToFile( - self, - file_name, - log_all ? 1 : 0, - ) != - 0; - } - - late final _Cronet_Engine_StartNetLogToFile_ptr = - _lookup>( - 'Cronet_Engine_StartNetLogToFile'); - late final _dart_Cronet_Engine_StartNetLogToFile - _Cronet_Engine_StartNetLogToFile = _Cronet_Engine_StartNetLogToFile_ptr - .asFunction<_dart_Cronet_Engine_StartNetLogToFile>(); - - void Cronet_Engine_StopNetLog( - ffi.Pointer self, - ) { - return _Cronet_Engine_StopNetLog( - self, - ); - } - - late final _Cronet_Engine_StopNetLog_ptr = - _lookup>( - 'Cronet_Engine_StopNetLog'); - late final _dart_Cronet_Engine_StopNetLog _Cronet_Engine_StopNetLog = - _Cronet_Engine_StopNetLog_ptr.asFunction< - _dart_Cronet_Engine_StopNetLog>(); - - int Cronet_Engine_Shutdown( - ffi.Pointer self, - ) { - return _Cronet_Engine_Shutdown( - self, - ); - } - - late final _Cronet_Engine_Shutdown_ptr = - _lookup>( - 'Cronet_Engine_Shutdown'); - late final _dart_Cronet_Engine_Shutdown _Cronet_Engine_Shutdown = - _Cronet_Engine_Shutdown_ptr.asFunction<_dart_Cronet_Engine_Shutdown>(); - - ffi.Pointer Cronet_Engine_GetVersionString( - ffi.Pointer self, - ) { - return _Cronet_Engine_GetVersionString( - self, - ); - } - - late final _Cronet_Engine_GetVersionString_ptr = - _lookup>( - 'Cronet_Engine_GetVersionString'); - late final _dart_Cronet_Engine_GetVersionString - _Cronet_Engine_GetVersionString = _Cronet_Engine_GetVersionString_ptr - .asFunction<_dart_Cronet_Engine_GetVersionString>(); - - /// //////////////////// - ffi.Pointer Cronet_UrlRequest_Create() { - return _Cronet_UrlRequest_Create(); - } - - late final _Cronet_UrlRequest_Create_ptr = - _lookup>( - 'Cronet_UrlRequest_Create'); - late final _dart_Cronet_UrlRequest_Create _Cronet_UrlRequest_Create = - _Cronet_UrlRequest_Create_ptr.asFunction< - _dart_Cronet_UrlRequest_Create>(); - - void Cronet_UrlRequest_Destroy( - ffi.Pointer self, - ) { - return _Cronet_UrlRequest_Destroy( - self, - ); - } - - late final _Cronet_UrlRequest_Destroy_ptr = - _lookup>( - 'Cronet_UrlRequest_Destroy'); - late final _dart_Cronet_UrlRequest_Destroy _Cronet_UrlRequest_Destroy = - _Cronet_UrlRequest_Destroy_ptr.asFunction< - _dart_Cronet_UrlRequest_Destroy>(); - - void Cronet_UrlRequest_SetClientContext( - ffi.Pointer self, - ffi.Pointer client_context, - ) { - return _Cronet_UrlRequest_SetClientContext( - self, - client_context, - ); - } - - late final _Cronet_UrlRequest_SetClientContext_ptr = - _lookup>( - 'Cronet_UrlRequest_SetClientContext'); - late final _dart_Cronet_UrlRequest_SetClientContext - _Cronet_UrlRequest_SetClientContext = - _Cronet_UrlRequest_SetClientContext_ptr.asFunction< - _dart_Cronet_UrlRequest_SetClientContext>(); - - ffi.Pointer Cronet_UrlRequest_GetClientContext( - ffi.Pointer self, - ) { - return _Cronet_UrlRequest_GetClientContext( - self, - ); - } - - late final _Cronet_UrlRequest_GetClientContext_ptr = - _lookup>( - 'Cronet_UrlRequest_GetClientContext'); - late final _dart_Cronet_UrlRequest_GetClientContext - _Cronet_UrlRequest_GetClientContext = - _Cronet_UrlRequest_GetClientContext_ptr.asFunction< - _dart_Cronet_UrlRequest_GetClientContext>(); - - int Cronet_UrlRequest_Start( - ffi.Pointer self, - ) { - return _Cronet_UrlRequest_Start( - self, - ); - } - - late final _Cronet_UrlRequest_Start_ptr = - _lookup>( - 'Cronet_UrlRequest_Start'); - late final _dart_Cronet_UrlRequest_Start _Cronet_UrlRequest_Start = - _Cronet_UrlRequest_Start_ptr.asFunction<_dart_Cronet_UrlRequest_Start>(); - - int Cronet_UrlRequest_FollowRedirect( - ffi.Pointer self, - ) { - return _Cronet_UrlRequest_FollowRedirect( - self, - ); - } - - late final _Cronet_UrlRequest_FollowRedirect_ptr = - _lookup>( - 'Cronet_UrlRequest_FollowRedirect'); - late final _dart_Cronet_UrlRequest_FollowRedirect - _Cronet_UrlRequest_FollowRedirect = _Cronet_UrlRequest_FollowRedirect_ptr - .asFunction<_dart_Cronet_UrlRequest_FollowRedirect>(); - - int Cronet_UrlRequest_Read( - ffi.Pointer self, - ffi.Pointer buffer, - ) { - return _Cronet_UrlRequest_Read( - self, - buffer, - ); - } - - late final _Cronet_UrlRequest_Read_ptr = - _lookup>( - 'Cronet_UrlRequest_Read'); - late final _dart_Cronet_UrlRequest_Read _Cronet_UrlRequest_Read = - _Cronet_UrlRequest_Read_ptr.asFunction<_dart_Cronet_UrlRequest_Read>(); - - void Cronet_UrlRequest_Cancel( - ffi.Pointer self, - ) { - return _Cronet_UrlRequest_Cancel( - self, - ); - } - - late final _Cronet_UrlRequest_Cancel_ptr = - _lookup>( - 'Cronet_UrlRequest_Cancel'); - late final _dart_Cronet_UrlRequest_Cancel _Cronet_UrlRequest_Cancel = - _Cronet_UrlRequest_Cancel_ptr.asFunction< - _dart_Cronet_UrlRequest_Cancel>(); - - /// //////////////////// - ffi.Pointer Cronet_QuicHint_Create() { - return _Cronet_QuicHint_Create(); - } - - late final _Cronet_QuicHint_Create_ptr = - _lookup>( - 'Cronet_QuicHint_Create'); - late final _dart_Cronet_QuicHint_Create _Cronet_QuicHint_Create = - _Cronet_QuicHint_Create_ptr.asFunction<_dart_Cronet_QuicHint_Create>(); - - void Cronet_QuicHint_Destroy( - ffi.Pointer self, - ) { - return _Cronet_QuicHint_Destroy( - self, - ); - } - - late final _Cronet_QuicHint_Destroy_ptr = - _lookup>( - 'Cronet_QuicHint_Destroy'); - late final _dart_Cronet_QuicHint_Destroy _Cronet_QuicHint_Destroy = - _Cronet_QuicHint_Destroy_ptr.asFunction<_dart_Cronet_QuicHint_Destroy>(); - - void Cronet_QuicHint_host_set( - ffi.Pointer self, - ffi.Pointer host, - ) { - return _Cronet_QuicHint_host_set( - self, - host, - ); - } - - late final _Cronet_QuicHint_host_set_ptr = - _lookup>( - 'Cronet_QuicHint_host_set'); - late final _dart_Cronet_QuicHint_host_set _Cronet_QuicHint_host_set = - _Cronet_QuicHint_host_set_ptr.asFunction< - _dart_Cronet_QuicHint_host_set>(); - - void Cronet_QuicHint_port_set( - ffi.Pointer self, - int port, - ) { - return _Cronet_QuicHint_port_set( - self, - port, - ); - } - - late final _Cronet_QuicHint_port_set_ptr = - _lookup>( - 'Cronet_QuicHint_port_set'); - late final _dart_Cronet_QuicHint_port_set _Cronet_QuicHint_port_set = - _Cronet_QuicHint_port_set_ptr.asFunction< - _dart_Cronet_QuicHint_port_set>(); - - void Cronet_QuicHint_alternate_port_set( - ffi.Pointer self, - int alternate_port, - ) { - return _Cronet_QuicHint_alternate_port_set( - self, - alternate_port, - ); - } - - late final _Cronet_QuicHint_alternate_port_set_ptr = - _lookup>( - 'Cronet_QuicHint_alternate_port_set'); - late final _dart_Cronet_QuicHint_alternate_port_set - _Cronet_QuicHint_alternate_port_set = - _Cronet_QuicHint_alternate_port_set_ptr.asFunction< - _dart_Cronet_QuicHint_alternate_port_set>(); - - /// //////////////////// - ffi.Pointer Cronet_EngineParams_Create() { - return _Cronet_EngineParams_Create(); - } - - late final _Cronet_EngineParams_Create_ptr = - _lookup>( - 'Cronet_EngineParams_Create'); - late final _dart_Cronet_EngineParams_Create _Cronet_EngineParams_Create = - _Cronet_EngineParams_Create_ptr.asFunction< - _dart_Cronet_EngineParams_Create>(); - - void Cronet_EngineParams_Destroy( - ffi.Pointer self, - ) { - return _Cronet_EngineParams_Destroy( - self, - ); - } - - late final _Cronet_EngineParams_Destroy_ptr = - _lookup>( - 'Cronet_EngineParams_Destroy'); - late final _dart_Cronet_EngineParams_Destroy _Cronet_EngineParams_Destroy = - _Cronet_EngineParams_Destroy_ptr.asFunction< - _dart_Cronet_EngineParams_Destroy>(); - - void Cronet_EngineParams_enable_check_result_set( - ffi.Pointer self, - bool enable_check_result, - ) { - return _Cronet_EngineParams_enable_check_result_set( - self, - enable_check_result ? 1 : 0, - ); - } - - late final _Cronet_EngineParams_enable_check_result_set_ptr = _lookup< - ffi.NativeFunction<_c_Cronet_EngineParams_enable_check_result_set>>( - 'Cronet_EngineParams_enable_check_result_set'); - late final _dart_Cronet_EngineParams_enable_check_result_set - _Cronet_EngineParams_enable_check_result_set = - _Cronet_EngineParams_enable_check_result_set_ptr.asFunction< - _dart_Cronet_EngineParams_enable_check_result_set>(); - - void Cronet_EngineParams_user_agent_set( - ffi.Pointer self, - ffi.Pointer user_agent, - ) { - return _Cronet_EngineParams_user_agent_set( - self, - user_agent, - ); - } - - late final _Cronet_EngineParams_user_agent_set_ptr = - _lookup>( - 'Cronet_EngineParams_user_agent_set'); - late final _dart_Cronet_EngineParams_user_agent_set - _Cronet_EngineParams_user_agent_set = - _Cronet_EngineParams_user_agent_set_ptr.asFunction< - _dart_Cronet_EngineParams_user_agent_set>(); - - void Cronet_EngineParams_accept_language_set( - ffi.Pointer self, - ffi.Pointer accept_language, - ) { - return _Cronet_EngineParams_accept_language_set( - self, - accept_language, - ); - } - - late final _Cronet_EngineParams_accept_language_set_ptr = - _lookup>( - 'Cronet_EngineParams_accept_language_set'); - late final _dart_Cronet_EngineParams_accept_language_set - _Cronet_EngineParams_accept_language_set = - _Cronet_EngineParams_accept_language_set_ptr.asFunction< - _dart_Cronet_EngineParams_accept_language_set>(); - - void Cronet_EngineParams_storage_path_set( - ffi.Pointer self, - ffi.Pointer storage_path, - ) { - return _Cronet_EngineParams_storage_path_set( - self, - storage_path, - ); - } - - late final _Cronet_EngineParams_storage_path_set_ptr = - _lookup>( - 'Cronet_EngineParams_storage_path_set'); - late final _dart_Cronet_EngineParams_storage_path_set - _Cronet_EngineParams_storage_path_set = - _Cronet_EngineParams_storage_path_set_ptr.asFunction< - _dart_Cronet_EngineParams_storage_path_set>(); - - void Cronet_EngineParams_enable_quic_set( - ffi.Pointer self, - bool enable_quic, - ) { - return _Cronet_EngineParams_enable_quic_set( - self, - enable_quic ? 1 : 0, - ); - } - - late final _Cronet_EngineParams_enable_quic_set_ptr = - _lookup>( - 'Cronet_EngineParams_enable_quic_set'); - late final _dart_Cronet_EngineParams_enable_quic_set - _Cronet_EngineParams_enable_quic_set = - _Cronet_EngineParams_enable_quic_set_ptr.asFunction< - _dart_Cronet_EngineParams_enable_quic_set>(); - - void Cronet_EngineParams_enable_http2_set( - ffi.Pointer self, - bool enable_http2, - ) { - return _Cronet_EngineParams_enable_http2_set( - self, - enable_http2 ? 1 : 0, - ); - } - - late final _Cronet_EngineParams_enable_http2_set_ptr = - _lookup>( - 'Cronet_EngineParams_enable_http2_set'); - late final _dart_Cronet_EngineParams_enable_http2_set - _Cronet_EngineParams_enable_http2_set = - _Cronet_EngineParams_enable_http2_set_ptr.asFunction< - _dart_Cronet_EngineParams_enable_http2_set>(); - - void Cronet_EngineParams_enable_brotli_set( - ffi.Pointer self, - bool enable_brotli, - ) { - return _Cronet_EngineParams_enable_brotli_set( - self, - enable_brotli ? 1 : 0, - ); - } - - late final _Cronet_EngineParams_enable_brotli_set_ptr = - _lookup>( - 'Cronet_EngineParams_enable_brotli_set'); - late final _dart_Cronet_EngineParams_enable_brotli_set - _Cronet_EngineParams_enable_brotli_set = - _Cronet_EngineParams_enable_brotli_set_ptr.asFunction< - _dart_Cronet_EngineParams_enable_brotli_set>(); - - void Cronet_EngineParams_http_cache_mode_set( - ffi.Pointer self, - int http_cache_mode, - ) { - return _Cronet_EngineParams_http_cache_mode_set( - self, - http_cache_mode, - ); - } - - late final _Cronet_EngineParams_http_cache_mode_set_ptr = - _lookup>( - 'Cronet_EngineParams_http_cache_mode_set'); - late final _dart_Cronet_EngineParams_http_cache_mode_set - _Cronet_EngineParams_http_cache_mode_set = - _Cronet_EngineParams_http_cache_mode_set_ptr.asFunction< - _dart_Cronet_EngineParams_http_cache_mode_set>(); - - void Cronet_EngineParams_http_cache_max_size_set( - ffi.Pointer self, - int http_cache_max_size, - ) { - return _Cronet_EngineParams_http_cache_max_size_set( - self, - http_cache_max_size, - ); - } - - late final _Cronet_EngineParams_http_cache_max_size_set_ptr = _lookup< - ffi.NativeFunction<_c_Cronet_EngineParams_http_cache_max_size_set>>( - 'Cronet_EngineParams_http_cache_max_size_set'); - late final _dart_Cronet_EngineParams_http_cache_max_size_set - _Cronet_EngineParams_http_cache_max_size_set = - _Cronet_EngineParams_http_cache_max_size_set_ptr.asFunction< - _dart_Cronet_EngineParams_http_cache_max_size_set>(); - - void Cronet_EngineParams_quic_hints_add( - ffi.Pointer self, - ffi.Pointer element, - ) { - return _Cronet_EngineParams_quic_hints_add( - self, - element, - ); - } - - late final _Cronet_EngineParams_quic_hints_add_ptr = - _lookup>( - 'Cronet_EngineParams_quic_hints_add'); - late final _dart_Cronet_EngineParams_quic_hints_add - _Cronet_EngineParams_quic_hints_add = - _Cronet_EngineParams_quic_hints_add_ptr.asFunction< - _dart_Cronet_EngineParams_quic_hints_add>(); - - /// //////////////////// - ffi.Pointer Cronet_HttpHeader_Create() { - return _Cronet_HttpHeader_Create(); - } - - late final _Cronet_HttpHeader_Create_ptr = - _lookup>( - 'Cronet_HttpHeader_Create'); - late final _dart_Cronet_HttpHeader_Create _Cronet_HttpHeader_Create = - _Cronet_HttpHeader_Create_ptr.asFunction< - _dart_Cronet_HttpHeader_Create>(); - - void Cronet_HttpHeader_Destroy( - ffi.Pointer self, - ) { - return _Cronet_HttpHeader_Destroy( - self, - ); - } - - late final _Cronet_HttpHeader_Destroy_ptr = - _lookup>( - 'Cronet_HttpHeader_Destroy'); - late final _dart_Cronet_HttpHeader_Destroy _Cronet_HttpHeader_Destroy = - _Cronet_HttpHeader_Destroy_ptr.asFunction< - _dart_Cronet_HttpHeader_Destroy>(); - - void Cronet_HttpHeader_name_set( - ffi.Pointer self, - ffi.Pointer name, - ) { - return _Cronet_HttpHeader_name_set( - self, - name, - ); - } - - late final _Cronet_HttpHeader_name_set_ptr = - _lookup>( - 'Cronet_HttpHeader_name_set'); - late final _dart_Cronet_HttpHeader_name_set _Cronet_HttpHeader_name_set = - _Cronet_HttpHeader_name_set_ptr.asFunction< - _dart_Cronet_HttpHeader_name_set>(); - - void Cronet_HttpHeader_value_set( - ffi.Pointer self, - ffi.Pointer value, - ) { - return _Cronet_HttpHeader_value_set( - self, - value, - ); - } - - late final _Cronet_HttpHeader_value_set_ptr = - _lookup>( - 'Cronet_HttpHeader_value_set'); - late final _dart_Cronet_HttpHeader_value_set _Cronet_HttpHeader_value_set = - _Cronet_HttpHeader_value_set_ptr.asFunction< - _dart_Cronet_HttpHeader_value_set>(); - - int Cronet_UrlResponseInfo_http_status_code_get( - ffi.Pointer self, - ) { - return _Cronet_UrlResponseInfo_http_status_code_get( - self, - ); - } - - late final _Cronet_UrlResponseInfo_http_status_code_get_ptr = _lookup< - ffi.NativeFunction<_c_Cronet_UrlResponseInfo_http_status_code_get>>( - 'Cronet_UrlResponseInfo_http_status_code_get'); - late final _dart_Cronet_UrlResponseInfo_http_status_code_get - _Cronet_UrlResponseInfo_http_status_code_get = - _Cronet_UrlResponseInfo_http_status_code_get_ptr.asFunction< - _dart_Cronet_UrlResponseInfo_http_status_code_get>(); - - ffi.Pointer Cronet_UrlResponseInfo_http_status_text_get( - ffi.Pointer self, - ) { - return _Cronet_UrlResponseInfo_http_status_text_get( - self, - ); - } - - late final _Cronet_UrlResponseInfo_http_status_text_get_ptr = _lookup< - ffi.NativeFunction<_c_Cronet_UrlResponseInfo_http_status_text_get>>( - 'Cronet_UrlResponseInfo_http_status_text_get'); - late final _dart_Cronet_UrlResponseInfo_http_status_text_get - _Cronet_UrlResponseInfo_http_status_text_get = - _Cronet_UrlResponseInfo_http_status_text_get_ptr.asFunction< - _dart_Cronet_UrlResponseInfo_http_status_text_get>(); - - /// //////////////////// - ffi.Pointer Cronet_UrlRequestParams_Create() { - return _Cronet_UrlRequestParams_Create(); - } - - late final _Cronet_UrlRequestParams_Create_ptr = - _lookup>( - 'Cronet_UrlRequestParams_Create'); - late final _dart_Cronet_UrlRequestParams_Create - _Cronet_UrlRequestParams_Create = _Cronet_UrlRequestParams_Create_ptr - .asFunction<_dart_Cronet_UrlRequestParams_Create>(); - - void Cronet_UrlRequestParams_Destroy( - ffi.Pointer self, - ) { - return _Cronet_UrlRequestParams_Destroy( - self, - ); - } - - late final _Cronet_UrlRequestParams_Destroy_ptr = - _lookup>( - 'Cronet_UrlRequestParams_Destroy'); - late final _dart_Cronet_UrlRequestParams_Destroy - _Cronet_UrlRequestParams_Destroy = _Cronet_UrlRequestParams_Destroy_ptr - .asFunction<_dart_Cronet_UrlRequestParams_Destroy>(); - - void Cronet_UrlRequestParams_http_method_set( - ffi.Pointer self, - ffi.Pointer http_method, - ) { - return _Cronet_UrlRequestParams_http_method_set( - self, - http_method, - ); - } - - late final _Cronet_UrlRequestParams_http_method_set_ptr = - _lookup>( - 'Cronet_UrlRequestParams_http_method_set'); - late final _dart_Cronet_UrlRequestParams_http_method_set - _Cronet_UrlRequestParams_http_method_set = - _Cronet_UrlRequestParams_http_method_set_ptr.asFunction< - _dart_Cronet_UrlRequestParams_http_method_set>(); - - void Cronet_UrlRequestParams_request_headers_add( - ffi.Pointer self, - ffi.Pointer element, - ) { - return _Cronet_UrlRequestParams_request_headers_add( - self, - element, - ); - } - - late final _Cronet_UrlRequestParams_request_headers_add_ptr = _lookup< - ffi.NativeFunction<_c_Cronet_UrlRequestParams_request_headers_add>>( - 'Cronet_UrlRequestParams_request_headers_add'); - late final _dart_Cronet_UrlRequestParams_request_headers_add - _Cronet_UrlRequestParams_request_headers_add = - _Cronet_UrlRequestParams_request_headers_add_ptr.asFunction< - _dart_Cronet_UrlRequestParams_request_headers_add>(); -} - -class Cronet_Engine extends ffi.Opaque {} - -class Cronet_UrlRequest extends ffi.Opaque {} - -class Cronet_UrlRequestParams extends ffi.Opaque {} - -class Cronet_Buffer extends ffi.Opaque {} - -class Cronet_BufferCallback extends ffi.Opaque {} - -class Cronet_Runnable extends ffi.Opaque {} - -class Cronet_Executor extends ffi.Opaque {} - -class Cronet_UrlRequestStatusListener extends ffi.Opaque {} - -class Cronet_UrlRequestCallback extends ffi.Opaque {} - -class Cronet_UploadDataSink extends ffi.Opaque {} - -class Cronet_UploadDataProvider extends ffi.Opaque {} - -class Cronet_RequestFinishedInfoListener extends ffi.Opaque {} - -class Cronet_Error extends ffi.Opaque {} - -class Cronet_QuicHint extends ffi.Opaque {} - -class Cronet_PublicKeyPins extends ffi.Opaque {} - -class Cronet_EngineParams extends ffi.Opaque {} - -class Cronet_HttpHeader extends ffi.Opaque {} - -class Cronet_UrlResponseInfo extends ffi.Opaque {} - -class Cronet_DateTime extends ffi.Opaque {} - -class Cronet_Metrics extends ffi.Opaque {} - -class Cronet_RequestFinishedInfo extends ffi.Opaque {} - -abstract class Cronet_RESULT { - static const int Cronet_RESULT_SUCCESS = 0; - static const int Cronet_RESULT_ILLEGAL_ARGUMENT = -100; - static const int Cronet_RESULT_ILLEGAL_ARGUMENT_STORAGE_PATH_MUST_EXIST = - -101; - static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_PIN = -102; - static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HOSTNAME = -103; - static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HTTP_METHOD = -104; - static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HTTP_HEADER = -105; - static const int Cronet_RESULT_ILLEGAL_STATE = -200; - static const int Cronet_RESULT_ILLEGAL_STATE_STORAGE_PATH_IN_USE = -201; - static const int - Cronet_RESULT_ILLEGAL_STATE_CANNOT_SHUTDOWN_ENGINE_FROM_NETWORK_THREAD = - -202; - static const int Cronet_RESULT_ILLEGAL_STATE_ENGINE_ALREADY_STARTED = -203; - static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_ALREADY_STARTED = -204; - static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_NOT_INITIALIZED = -205; - static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_ALREADY_INITIALIZED = - -206; - static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_NOT_STARTED = -207; - static const int Cronet_RESULT_ILLEGAL_STATE_UNEXPECTED_REDIRECT = -208; - static const int Cronet_RESULT_ILLEGAL_STATE_UNEXPECTED_READ = -209; - static const int Cronet_RESULT_ILLEGAL_STATE_READ_FAILED = -210; - static const int Cronet_RESULT_NULL_POINTER = -300; - static const int Cronet_RESULT_NULL_POINTER_HOSTNAME = -301; - static const int Cronet_RESULT_NULL_POINTER_SHA256_PINS = -302; - static const int Cronet_RESULT_NULL_POINTER_EXPIRATION_DATE = -303; - static const int Cronet_RESULT_NULL_POINTER_ENGINE = -304; - static const int Cronet_RESULT_NULL_POINTER_URL = -305; - static const int Cronet_RESULT_NULL_POINTER_CALLBACK = -306; - static const int Cronet_RESULT_NULL_POINTER_EXECUTOR = -307; - static const int Cronet_RESULT_NULL_POINTER_METHOD = -308; - static const int Cronet_RESULT_NULL_POINTER_HEADER_NAME = -309; - static const int Cronet_RESULT_NULL_POINTER_HEADER_VALUE = -310; - static const int Cronet_RESULT_NULL_POINTER_PARAMS = -311; - static const int - Cronet_RESULT_NULL_POINTER_REQUEST_FINISHED_INFO_LISTENER_EXECUTOR = -312; -} - -abstract class Cronet_Error_ERROR_CODE { - static const int Cronet_Error_ERROR_CODE_ERROR_CALLBACK = 0; - static const int Cronet_Error_ERROR_CODE_ERROR_HOSTNAME_NOT_RESOLVED = 1; - static const int Cronet_Error_ERROR_CODE_ERROR_INTERNET_DISCONNECTED = 2; - static const int Cronet_Error_ERROR_CODE_ERROR_NETWORK_CHANGED = 3; - static const int Cronet_Error_ERROR_CODE_ERROR_TIMED_OUT = 4; - static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_CLOSED = 5; - static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_TIMED_OUT = 6; - static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_REFUSED = 7; - static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_RESET = 8; - static const int Cronet_Error_ERROR_CODE_ERROR_ADDRESS_UNREACHABLE = 9; - static const int Cronet_Error_ERROR_CODE_ERROR_QUIC_PROTOCOL_FAILED = 10; - static const int Cronet_Error_ERROR_CODE_ERROR_OTHER = 11; -} - -abstract class Cronet_EngineParams_HTTP_CACHE_MODE { - static const int Cronet_EngineParams_HTTP_CACHE_MODE_DISABLED = 0; - static const int Cronet_EngineParams_HTTP_CACHE_MODE_IN_MEMORY = 1; - static const int Cronet_EngineParams_HTTP_CACHE_MODE_DISK_NO_HTTP = 2; - static const int Cronet_EngineParams_HTTP_CACHE_MODE_DISK = 3; -} - -abstract class Cronet_UrlRequestParams_REQUEST_PRIORITY { - static const int - Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_IDLE = 0; - static const int - Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_LOWEST = 1; - static const int - Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_LOW = 2; - static const int - Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_MEDIUM = 3; - static const int - Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_HIGHEST = 4; -} - -abstract class Cronet_UrlRequestParams_IDEMPOTENCY { - static const int Cronet_UrlRequestParams_IDEMPOTENCY_DEFAULT_IDEMPOTENCY = 0; - static const int Cronet_UrlRequestParams_IDEMPOTENCY_IDEMPOTENT = 1; - static const int Cronet_UrlRequestParams_IDEMPOTENCY_NOT_IDEMPOTENT = 2; -} - -abstract class Cronet_RequestFinishedInfo_FINISHED_REASON { - static const int Cronet_RequestFinishedInfo_FINISHED_REASON_SUCCEEDED = 0; - static const int Cronet_RequestFinishedInfo_FINISHED_REASON_FAILED = 1; - static const int Cronet_RequestFinishedInfo_FINISHED_REASON_CANCELED = 2; -} - -abstract class Cronet_UrlRequestStatusListener_Status { - static const int Cronet_UrlRequestStatusListener_Status_INVALID = -1; - static const int Cronet_UrlRequestStatusListener_Status_IDLE = 0; - static const int - Cronet_UrlRequestStatusListener_Status_WAITING_FOR_STALLED_SOCKET_POOL = - 1; - static const int - Cronet_UrlRequestStatusListener_Status_WAITING_FOR_AVAILABLE_SOCKET = 2; - static const int Cronet_UrlRequestStatusListener_Status_WAITING_FOR_DELEGATE = - 3; - static const int Cronet_UrlRequestStatusListener_Status_WAITING_FOR_CACHE = 4; - static const int Cronet_UrlRequestStatusListener_Status_DOWNLOADING_PAC_FILE = - 5; - static const int - Cronet_UrlRequestStatusListener_Status_RESOLVING_PROXY_FOR_URL = 6; - static const int - Cronet_UrlRequestStatusListener_Status_RESOLVING_HOST_IN_PAC_FILE = 7; - static const int - Cronet_UrlRequestStatusListener_Status_ESTABLISHING_PROXY_TUNNEL = 8; - static const int Cronet_UrlRequestStatusListener_Status_RESOLVING_HOST = 9; - static const int Cronet_UrlRequestStatusListener_Status_CONNECTING = 10; - static const int Cronet_UrlRequestStatusListener_Status_SSL_HANDSHAKE = 11; - static const int Cronet_UrlRequestStatusListener_Status_SENDING_REQUEST = 12; - static const int Cronet_UrlRequestStatusListener_Status_WAITING_FOR_RESPONSE = - 13; - static const int Cronet_UrlRequestStatusListener_Status_READING_RESPONSE = 14; -} - -const String CRONET_LIB_PREFIX = 'libcronet'; - -const String CRONET_LIB_EXTENSION = '.so'; - -typedef _c_dispatchCallback = ffi.Void Function( - ffi.Pointer methodname, -); - -typedef _dart_dispatchCallback = void Function( - ffi.Pointer methodname, -); - -typedef _c_InitDartApiDL = ffi.IntPtr Function( - ffi.Pointer data, -); - -typedef _dart_InitDartApiDL = int Function( - ffi.Pointer data, -); - -typedef _c_unloadCronet = ffi.Void Function(); - -typedef _dart_unloadCronet = void Function(); - -typedef _c_Create_Executor = ffi.Pointer Function(); - -typedef _dart_Create_Executor = ffi.Pointer Function(); - -typedef _c_Destroy_Executor = ffi.Void Function( - ffi.Pointer executor, -); - -typedef _dart_Destroy_Executor = void Function( - ffi.Pointer executor, -); - -typedef _c_registerHttpClient = ffi.Void Function( - ffi.Handle h, - ffi.Pointer ce, -); - -typedef _dart_registerHttpClient = void Function( - Object h, - ffi.Pointer ce, -); - -typedef _c_registerCallbackHandler = ffi.Void Function( - ffi.Int64 nativePort, - ffi.Pointer rp, -); - -typedef _dart_registerCallbackHandler = void Function( - int nativePort, - ffi.Pointer rp, -); - -typedef _c_removeRequest = ffi.Void Function( - ffi.Pointer rp, -); - -typedef _dart_removeRequest = void Function( - ffi.Pointer rp, -); - -typedef _c_Cronet_UrlRequest_Init = ffi.Int32 Function( - ffi.Pointer self, - ffi.Pointer engine, - ffi.Pointer url, - ffi.Pointer params, - ffi.Pointer _executor, -); - -typedef _dart_Cronet_UrlRequest_Init = int Function( - ffi.Pointer self, - ffi.Pointer engine, - ffi.Pointer url, - ffi.Pointer params, - ffi.Pointer _executor, -); - -typedef _c_Cronet_Buffer_GetSize = ffi.Uint64 Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_Buffer_GetSize = int Function( - ffi.Pointer self, -); - -typedef _c_Cronet_Buffer_GetData = ffi.Pointer Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_Buffer_GetData = ffi.Pointer Function( - ffi.Pointer self, -); - -typedef _c_Cronet_Engine_Create = ffi.Pointer Function(); - -typedef _dart_Cronet_Engine_Create = ffi.Pointer Function(); - -typedef _c_Cronet_Engine_StartWithParams = ffi.Int32 Function( - ffi.Pointer self, - ffi.Pointer params, -); - -typedef _dart_Cronet_Engine_StartWithParams = int Function( - ffi.Pointer self, - ffi.Pointer params, -); - -typedef _c_Cronet_Engine_StartNetLogToFile = ffi.Uint8 Function( - ffi.Pointer self, - ffi.Pointer file_name, - ffi.Uint8 log_all, -); - -typedef _dart_Cronet_Engine_StartNetLogToFile = int Function( - ffi.Pointer self, - ffi.Pointer file_name, - int log_all, -); - -typedef _c_Cronet_Engine_StopNetLog = ffi.Void Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_Engine_StopNetLog = void Function( - ffi.Pointer self, -); - -typedef _c_Cronet_Engine_Shutdown = ffi.Int32 Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_Engine_Shutdown = int Function( - ffi.Pointer self, -); - -typedef _c_Cronet_Engine_GetVersionString = ffi.Pointer Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_Engine_GetVersionString = ffi.Pointer Function( - ffi.Pointer self, -); - -typedef _c_Cronet_UrlRequest_Create = ffi.Pointer Function(); - -typedef _dart_Cronet_UrlRequest_Create = ffi.Pointer - Function(); - -typedef _c_Cronet_UrlRequest_Destroy = ffi.Void Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_UrlRequest_Destroy = void Function( - ffi.Pointer self, -); - -typedef _c_Cronet_UrlRequest_SetClientContext = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer client_context, -); - -typedef _dart_Cronet_UrlRequest_SetClientContext = void Function( - ffi.Pointer self, - ffi.Pointer client_context, -); - -typedef _c_Cronet_UrlRequest_GetClientContext = ffi.Pointer Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_UrlRequest_GetClientContext = ffi.Pointer - Function( - ffi.Pointer self, -); - -typedef _c_Cronet_UrlRequest_Start = ffi.Int32 Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_UrlRequest_Start = int Function( - ffi.Pointer self, -); - -typedef _c_Cronet_UrlRequest_FollowRedirect = ffi.Int32 Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_UrlRequest_FollowRedirect = int Function( - ffi.Pointer self, -); - -typedef _c_Cronet_UrlRequest_Read = ffi.Int32 Function( - ffi.Pointer self, - ffi.Pointer buffer, -); - -typedef _dart_Cronet_UrlRequest_Read = int Function( - ffi.Pointer self, - ffi.Pointer buffer, -); - -typedef _c_Cronet_UrlRequest_Cancel = ffi.Void Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_UrlRequest_Cancel = void Function( - ffi.Pointer self, -); - -typedef _c_Cronet_QuicHint_Create = ffi.Pointer Function(); - -typedef _dart_Cronet_QuicHint_Create = ffi.Pointer Function(); - -typedef _c_Cronet_QuicHint_Destroy = ffi.Void Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_QuicHint_Destroy = void Function( - ffi.Pointer self, -); - -typedef _c_Cronet_QuicHint_host_set = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer host, -); - -typedef _dart_Cronet_QuicHint_host_set = void Function( - ffi.Pointer self, - ffi.Pointer host, -); - -typedef _c_Cronet_QuicHint_port_set = ffi.Void Function( - ffi.Pointer self, - ffi.Int32 port, -); - -typedef _dart_Cronet_QuicHint_port_set = void Function( - ffi.Pointer self, - int port, -); - -typedef _c_Cronet_QuicHint_alternate_port_set = ffi.Void Function( - ffi.Pointer self, - ffi.Int32 alternate_port, -); - -typedef _dart_Cronet_QuicHint_alternate_port_set = void Function( - ffi.Pointer self, - int alternate_port, -); - -typedef _c_Cronet_EngineParams_Create = ffi.Pointer - Function(); - -typedef _dart_Cronet_EngineParams_Create = ffi.Pointer - Function(); - -typedef _c_Cronet_EngineParams_Destroy = ffi.Void Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_EngineParams_Destroy = void Function( - ffi.Pointer self, -); - -typedef _c_Cronet_EngineParams_enable_check_result_set = ffi.Void Function( - ffi.Pointer self, - ffi.Uint8 enable_check_result, -); - -typedef _dart_Cronet_EngineParams_enable_check_result_set = void Function( - ffi.Pointer self, - int enable_check_result, -); - -typedef _c_Cronet_EngineParams_user_agent_set = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer user_agent, -); - -typedef _dart_Cronet_EngineParams_user_agent_set = void Function( - ffi.Pointer self, - ffi.Pointer user_agent, -); - -typedef _c_Cronet_EngineParams_accept_language_set = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer accept_language, -); - -typedef _dart_Cronet_EngineParams_accept_language_set = void Function( - ffi.Pointer self, - ffi.Pointer accept_language, -); - -typedef _c_Cronet_EngineParams_storage_path_set = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer storage_path, -); - -typedef _dart_Cronet_EngineParams_storage_path_set = void Function( - ffi.Pointer self, - ffi.Pointer storage_path, -); - -typedef _c_Cronet_EngineParams_enable_quic_set = ffi.Void Function( - ffi.Pointer self, - ffi.Uint8 enable_quic, -); - -typedef _dart_Cronet_EngineParams_enable_quic_set = void Function( - ffi.Pointer self, - int enable_quic, -); - -typedef _c_Cronet_EngineParams_enable_http2_set = ffi.Void Function( - ffi.Pointer self, - ffi.Uint8 enable_http2, -); - -typedef _dart_Cronet_EngineParams_enable_http2_set = void Function( - ffi.Pointer self, - int enable_http2, -); - -typedef _c_Cronet_EngineParams_enable_brotli_set = ffi.Void Function( - ffi.Pointer self, - ffi.Uint8 enable_brotli, -); - -typedef _dart_Cronet_EngineParams_enable_brotli_set = void Function( - ffi.Pointer self, - int enable_brotli, -); - -typedef _c_Cronet_EngineParams_http_cache_mode_set = ffi.Void Function( - ffi.Pointer self, - ffi.Int32 http_cache_mode, -); - -typedef _dart_Cronet_EngineParams_http_cache_mode_set = void Function( - ffi.Pointer self, - int http_cache_mode, -); - -typedef _c_Cronet_EngineParams_http_cache_max_size_set = ffi.Void Function( - ffi.Pointer self, - ffi.Int64 http_cache_max_size, -); - -typedef _dart_Cronet_EngineParams_http_cache_max_size_set = void Function( - ffi.Pointer self, - int http_cache_max_size, -); - -typedef _c_Cronet_EngineParams_quic_hints_add = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer element, -); - -typedef _dart_Cronet_EngineParams_quic_hints_add = void Function( - ffi.Pointer self, - ffi.Pointer element, -); - -typedef _c_Cronet_HttpHeader_Create = ffi.Pointer Function(); - -typedef _dart_Cronet_HttpHeader_Create = ffi.Pointer - Function(); - -typedef _c_Cronet_HttpHeader_Destroy = ffi.Void Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_HttpHeader_Destroy = void Function( - ffi.Pointer self, -); - -typedef _c_Cronet_HttpHeader_name_set = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer name, -); - -typedef _dart_Cronet_HttpHeader_name_set = void Function( - ffi.Pointer self, - ffi.Pointer name, -); - -typedef _c_Cronet_HttpHeader_value_set = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer value, -); - -typedef _dart_Cronet_HttpHeader_value_set = void Function( - ffi.Pointer self, - ffi.Pointer value, -); - -typedef _c_Cronet_UrlResponseInfo_http_status_code_get = ffi.Int32 Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_UrlResponseInfo_http_status_code_get = int Function( - ffi.Pointer self, -); - -typedef _c_Cronet_UrlResponseInfo_http_status_text_get = ffi.Pointer - Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_UrlResponseInfo_http_status_text_get - = ffi.Pointer Function( - ffi.Pointer self, -); - -typedef _c_Cronet_UrlRequestParams_Create = ffi.Pointer - Function(); - -typedef _dart_Cronet_UrlRequestParams_Create - = ffi.Pointer Function(); - -typedef _c_Cronet_UrlRequestParams_Destroy = ffi.Void Function( - ffi.Pointer self, -); - -typedef _dart_Cronet_UrlRequestParams_Destroy = void Function( - ffi.Pointer self, -); - -typedef _c_Cronet_UrlRequestParams_http_method_set = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer http_method, -); - -typedef _dart_Cronet_UrlRequestParams_http_method_set = void Function( - ffi.Pointer self, - ffi.Pointer http_method, -); - -typedef _c_Cronet_UrlRequestParams_request_headers_add = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer element, -); - -typedef _dart_Cronet_UrlRequestParams_request_headers_add = void Function( - ffi.Pointer self, - ffi.Pointer element, -); diff --git a/lib/src/http_callback_handler.dart b/lib/src/http_callback_handler.dart index c3446a1..23796fb 100644 --- a/lib/src/http_callback_handler.dart +++ b/lib/src/http_callback_handler.dart @@ -11,7 +11,8 @@ import 'dart:typed_data'; import 'package:ffi/ffi.dart'; import 'exceptions.dart'; -import 'generated_bindings.dart'; +import 'third_party/cronet/generated_bindings.dart'; +import 'wrapper/generated_bindings.dart' as wrpr; /// Deserializes the message sent by cronet and it's wrapper. class _CallbackRequestMessage { @@ -35,6 +36,7 @@ class _CallbackRequestMessage { class CallbackHandler { final ReceivePort receivePort; final Cronet cronet; + final wrpr.Wrapper wrapper; final Pointer executor; // These are a part of HttpClientRequest Public API. @@ -45,7 +47,7 @@ class CallbackHandler { final _controller = StreamController>(); /// Registers the [NativePort] to the cronet side. - CallbackHandler(this.cronet, this.executor, this.receivePort); + CallbackHandler(this.cronet, this.wrapper, this.executor, this.receivePort); /// [Stream] controller for [HttpClientResponse] Stream> get stream { @@ -58,7 +60,7 @@ class CallbackHandler { void cleanUpRequest( Pointer reqPtr, Function cleanUpClient) { receivePort.close(); - cronet.removeRequest(reqPtr); + wrapper.removeRequest(reqPtr.cast()); cleanUpClient(); } @@ -128,6 +130,8 @@ class CallbackHandler { 299, () => cleanUpRequest(reqPtr, cleanUpClient)); log('Response started'); + cronet.Cronet_UrlRequest_Read( + reqPtr, Pointer.fromAddress(args[1]).cast()); } break; // Read a chunk of data. @@ -161,8 +165,11 @@ class CallbackHandler { // In case of network error, we will shut everything down after this. case 'OnFailed': { - final error = - Pointer.fromAddress(args[0]).cast().toDartString(); + final errorPtr = Pointer.fromAddress(args[0]).cast(); + final error = Pointer.fromAddress( + cronet.Cronet_Error_message_get(errorPtr).address) + .cast() + .toDartString(); cleanUpRequest(reqPtr, cleanUpClient); _controller.addError(HttpException(error)); _controller.close(); diff --git a/lib/src/http_client.dart b/lib/src/http_client.dart index 54f7846..8026c74 100644 --- a/lib/src/http_client.dart +++ b/lib/src/http_client.dart @@ -10,12 +10,14 @@ import 'package:ffi/ffi.dart'; import 'dylib_handler.dart'; import 'enums.dart'; import 'exceptions.dart'; -import 'generated_bindings.dart'; +import 'third_party/cronet/generated_bindings.dart'; +import 'wrapper/generated_bindings.dart' as wrapper; import 'http_client_request.dart'; import 'quic_hint.dart'; // Cronet library is loaded in global scope. -final _cronet = Cronet(loadWrapper()); +final _cronet = Cronet(loadCronet()); +final _wrapper = wrapper.Wrapper(loadWrapper()); /// A client that receives content, such as web pages, /// from a server using the HTTP, HTTPS, HTTP2, Quic etc. protocol. @@ -67,9 +69,26 @@ class HttpClient { this.acceptLanguage = 'en_US', }) : _cronetEngine = _cronet.Cronet_Engine_Create() { // Initialize Dart Native API dynamically. - _cronet.InitDartApiDL(NativeApi.initializeApiDLData); - _cronet.registerHttpClient(this, _cronetEngine); - + _wrapper.InitDartApiDL(NativeApi.initializeApiDLData); + _wrapper.registerHttpClient( + this, _cronetEngine.cast()); + // Registers few cronet functions that are required by the wrapper. + _wrapper.InitCronetApi( + _cronet.addresses.Cronet_Engine_Shutdown.cast(), + _cronet.addresses.Cronet_Engine_Destroy.cast(), + _cronet.addresses.Cronet_Buffer_Create.cast(), + _cronet.addresses.Cronet_Buffer_InitWithAlloc.cast(), + _cronet.addresses.Cronet_UrlRequestCallback_CreateWith.cast(), + _cronet.addresses.Cronet_UrlRequest_InitWithParams.cast()); + // Registers few cronet functions that are required by the executor + // run from the wrapper for executing network requests. + _wrapper.InitCronetExecutorApi( + _cronet.addresses.Cronet_Executor_CreateWith.cast(), + _cronet.addresses.Cronet_Executor_SetClientContext.cast(), + _cronet.addresses.Cronet_Executor_GetClientContext.cast(), + _cronet.addresses.Cronet_Executor_Destroy.cast(), + _cronet.addresses.Cronet_Runnable_Run.cast(), + _cronet.addresses.Cronet_Runnable_Destroy.cast()); // Starting the engine with parameters. final engineParams = _cronet.Cronet_EngineParams_Create(); _cronet.Cronet_EngineParams_user_agent_set( @@ -148,7 +167,7 @@ class HttpClient { throw Exception("Client is closed. Can't open new connections"); } _requests.add(HttpClientRequestImpl( - url, method, _cronet, _cronetEngine, _cleanUpRequests)); + url, method, _cronet, _wrapper, _cronetEngine, _cleanUpRequests)); return _requests.last; }); } diff --git a/lib/src/http_client_request.dart b/lib/src/http_client_request.dart index 57d73cd..6ab7dc5 100644 --- a/lib/src/http_client_request.dart +++ b/lib/src/http_client_request.dart @@ -11,7 +11,8 @@ import 'dart:isolate'; import 'package:ffi/ffi.dart'; import 'exceptions.dart'; -import 'generated_bindings.dart'; +import 'third_party/cronet/generated_bindings.dart'; +import 'wrapper/generated_bindings.dart' as wrapper; import 'http_client_response.dart'; import 'http_callback_handler.dart'; @@ -64,6 +65,7 @@ class HttpClientRequestImpl implements HttpClientRequest { final Uri _uri; final String _method; final Cronet _cronet; + final wrapper.Wrapper _wrapper; final Pointer _cronetEngine; final CallbackHandler _cbh; final Pointer _request; @@ -77,15 +79,15 @@ class HttpClientRequestImpl implements HttpClientRequest { Encoding encoding; /// Initiates a [HttpClientRequestImpl]. It is meant to be used by a [HttpClient]. - HttpClientRequestImpl(this._uri, this._method, this._cronet, + HttpClientRequestImpl(this._uri, this._method, this._cronet, this._wrapper, this._cronetEngine, this._clientCleanup, {this.encoding = utf8}) - : _cbh = - CallbackHandler(_cronet, _cronet.Create_Executor(), ReceivePort()), + : _cbh = CallbackHandler( + _cronet, _wrapper, _wrapper.Create_Executor(), ReceivePort()), _request = _cronet.Cronet_UrlRequest_Create() { // Register the native port to C side. - _cronet.registerCallbackHandler( - _cbh.receivePort.sendPort.nativePort, _request); + _wrapper.registerCallbackHandler(_cbh.receivePort.sendPort.nativePort, + _request.cast()); } // Starts the request. @@ -94,11 +96,11 @@ class HttpClientRequestImpl implements HttpClientRequest { _cronet.Cronet_UrlRequestParams_http_method_set( requestParams, _method.toNativeUtf8().cast()); - final res = _cronet.Cronet_UrlRequest_Init( - _request, - _cronetEngine, + final res = _wrapper.Cronet_UrlRequest_Init( + _request.cast(), + _cronetEngine.cast(), _uri.toString().toNativeUtf8().cast(), - requestParams, + requestParams.cast(), _cbh.executor); if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { diff --git a/lib/src/third_party/cronet/ffigen.yaml b/lib/src/third_party/cronet/ffigen.yaml index 5664fa2..62d0588 100644 --- a/lib/src/third_party/cronet/ffigen.yaml +++ b/lib/src/third_party/cronet/ffigen.yaml @@ -5,24 +5,26 @@ array-workaround: true headers: entry-points: - 'third_party/cronet/cronet.idl_c.h' + include-directives: + - 'third_party/cronet/cronet.idl_c.h' + - 'third_party/cronet/cronet_export.h' compiler-opts: - '-Ithird_party/cronet/' -macros: - include: - - nothing -enums: - include: - - nothing -unnamed-enums: - include: - - nothing -globals: - include: - - nothing -structs: - include: - - nothing - dependency-only: opaque +functions: + symbol-address: + include: + - 'Cronet_Engine_Shutdown' # For wrapper. + - 'Cronet_Engine_Destroy' + - 'Cronet_Buffer_Create' + - 'Cronet_Buffer_InitWithAlloc' + - 'Cronet_UrlRequestCallback_CreateWith' + - 'Cronet_UrlRequest_InitWithParams' + - 'Cronet_Executor_CreateWith' # For executor. + - 'Cronet_Executor_SetClientContext' + - 'Cronet_Executor_GetClientContext' + - 'Cronet_Executor_Destroy' + - 'Cronet_Runnable_Run' + - 'Cronet_Runnable_Destroy' preamble: | // Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be diff --git a/lib/src/third_party/cronet/generated_bindings.dart b/lib/src/third_party/cronet/generated_bindings.dart index 474ab4a..ad90121 100644 --- a/lib/src/third_party/cronet/generated_bindings.dart +++ b/lib/src/third_party/cronet/generated_bindings.dart @@ -25,8 +25,35 @@ class Cronet { lookup) : _lookup = lookup; + ffi.Pointer Cronet_Buffer_Create() { + return _Cronet_Buffer_Create(); + } + + late final _Cronet_Buffer_Create_ptr = + _lookup>( + 'Cronet_Buffer_Create'); + late final _dart_Cronet_Buffer_Create _Cronet_Buffer_Create = + _Cronet_Buffer_Create_ptr.asFunction<_dart_Cronet_Buffer_Create>(); + + void Cronet_Buffer_InitWithAlloc( + ffi.Pointer self, + int size, + ) { + return _Cronet_Buffer_InitWithAlloc( + self, + size, + ); + } + + late final _Cronet_Buffer_InitWithAlloc_ptr = + _lookup>( + 'Cronet_Buffer_InitWithAlloc'); + late final _dart_Cronet_Buffer_InitWithAlloc _Cronet_Buffer_InitWithAlloc = + _Cronet_Buffer_InitWithAlloc_ptr.asFunction< + _dart_Cronet_Buffer_InitWithAlloc>(); + int Cronet_Buffer_GetSize( - ffi.Pointer self, + ffi.Pointer self, ) { return _Cronet_Buffer_GetSize( self, @@ -40,7 +67,7 @@ class Cronet { _Cronet_Buffer_GetSize_ptr.asFunction<_dart_Cronet_Buffer_GetSize>(); ffi.Pointer Cronet_Buffer_GetData( - ffi.Pointer self, + ffi.Pointer self, ) { return _Cronet_Buffer_GetData( self, @@ -53,7 +80,112 @@ class Cronet { late final _dart_Cronet_Buffer_GetData _Cronet_Buffer_GetData = _Cronet_Buffer_GetData_ptr.asFunction<_dart_Cronet_Buffer_GetData>(); - ffi.Pointer Cronet_Engine_Create() { + void Cronet_Runnable_Destroy( + ffi.Pointer self, + ) { + return _Cronet_Runnable_Destroy( + self, + ); + } + + late final _Cronet_Runnable_Destroy_ptr = + _lookup>( + 'Cronet_Runnable_Destroy'); + late final _dart_Cronet_Runnable_Destroy _Cronet_Runnable_Destroy = + _Cronet_Runnable_Destroy_ptr.asFunction<_dart_Cronet_Runnable_Destroy>(); + + void Cronet_Runnable_Run( + ffi.Pointer self, + ) { + return _Cronet_Runnable_Run( + self, + ); + } + + late final _Cronet_Runnable_Run_ptr = + _lookup>( + 'Cronet_Runnable_Run'); + late final _dart_Cronet_Runnable_Run _Cronet_Runnable_Run = + _Cronet_Runnable_Run_ptr.asFunction<_dart_Cronet_Runnable_Run>(); + + void Cronet_Executor_Destroy( + ffi.Pointer self, + ) { + return _Cronet_Executor_Destroy( + self, + ); + } + + late final _Cronet_Executor_Destroy_ptr = + _lookup>( + 'Cronet_Executor_Destroy'); + late final _dart_Cronet_Executor_Destroy _Cronet_Executor_Destroy = + _Cronet_Executor_Destroy_ptr.asFunction<_dart_Cronet_Executor_Destroy>(); + + void Cronet_Executor_SetClientContext( + ffi.Pointer self, + ffi.Pointer client_context, + ) { + return _Cronet_Executor_SetClientContext( + self, + client_context, + ); + } + + late final _Cronet_Executor_SetClientContext_ptr = + _lookup>( + 'Cronet_Executor_SetClientContext'); + late final _dart_Cronet_Executor_SetClientContext + _Cronet_Executor_SetClientContext = _Cronet_Executor_SetClientContext_ptr + .asFunction<_dart_Cronet_Executor_SetClientContext>(); + + ffi.Pointer Cronet_Executor_GetClientContext( + ffi.Pointer self, + ) { + return _Cronet_Executor_GetClientContext( + self, + ); + } + + late final _Cronet_Executor_GetClientContext_ptr = + _lookup>( + 'Cronet_Executor_GetClientContext'); + late final _dart_Cronet_Executor_GetClientContext + _Cronet_Executor_GetClientContext = _Cronet_Executor_GetClientContext_ptr + .asFunction<_dart_Cronet_Executor_GetClientContext>(); + + void Cronet_Executor_Execute( + ffi.Pointer self, + ffi.Pointer command, + ) { + return _Cronet_Executor_Execute( + self, + command, + ); + } + + late final _Cronet_Executor_Execute_ptr = + _lookup>( + 'Cronet_Executor_Execute'); + late final _dart_Cronet_Executor_Execute _Cronet_Executor_Execute = + _Cronet_Executor_Execute_ptr.asFunction<_dart_Cronet_Executor_Execute>(); + + ffi.Pointer Cronet_Executor_CreateWith( + ffi.Pointer> ExecuteFunc, + ) { + return _Cronet_Executor_CreateWith( + ExecuteFunc, + ); + } + + late final _Cronet_Executor_CreateWith_ptr = + _lookup>( + 'Cronet_Executor_CreateWith'); + late final _dart_Cronet_Executor_CreateWith _Cronet_Executor_CreateWith = + _Cronet_Executor_CreateWith_ptr.asFunction< + _dart_Cronet_Executor_CreateWith>(); + + ffi.Pointer Cronet_Engine_Create() { return _Cronet_Engine_Create(); } @@ -63,9 +195,23 @@ class Cronet { late final _dart_Cronet_Engine_Create _Cronet_Engine_Create = _Cronet_Engine_Create_ptr.asFunction<_dart_Cronet_Engine_Create>(); + void Cronet_Engine_Destroy( + ffi.Pointer self, + ) { + return _Cronet_Engine_Destroy( + self, + ); + } + + late final _Cronet_Engine_Destroy_ptr = + _lookup>( + 'Cronet_Engine_Destroy'); + late final _dart_Cronet_Engine_Destroy _Cronet_Engine_Destroy = + _Cronet_Engine_Destroy_ptr.asFunction<_dart_Cronet_Engine_Destroy>(); + int Cronet_Engine_StartWithParams( - ffi.Pointer self, - ffi.Pointer params, + ffi.Pointer self, + ffi.Pointer params, ) { return _Cronet_Engine_StartWithParams( self, @@ -81,7 +227,7 @@ class Cronet { .asFunction<_dart_Cronet_Engine_StartWithParams>(); bool Cronet_Engine_StartNetLogToFile( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer file_name, bool log_all, ) { @@ -101,7 +247,7 @@ class Cronet { .asFunction<_dart_Cronet_Engine_StartNetLogToFile>(); void Cronet_Engine_StopNetLog( - ffi.Pointer self, + ffi.Pointer self, ) { return _Cronet_Engine_StopNetLog( self, @@ -116,7 +262,7 @@ class Cronet { _dart_Cronet_Engine_StopNetLog>(); int Cronet_Engine_Shutdown( - ffi.Pointer self, + ffi.Pointer self, ) { return _Cronet_Engine_Shutdown( self, @@ -124,13 +270,13 @@ class Cronet { } late final _Cronet_Engine_Shutdown_ptr = - _lookup>( + _lookup>( 'Cronet_Engine_Shutdown'); late final _dart_Cronet_Engine_Shutdown _Cronet_Engine_Shutdown = _Cronet_Engine_Shutdown_ptr.asFunction<_dart_Cronet_Engine_Shutdown>(); ffi.Pointer Cronet_Engine_GetVersionString( - ffi.Pointer self, + ffi.Pointer self, ) { return _Cronet_Engine_GetVersionString( self, @@ -144,8 +290,44 @@ class Cronet { _Cronet_Engine_GetVersionString = _Cronet_Engine_GetVersionString_ptr .asFunction<_dart_Cronet_Engine_GetVersionString>(); + ffi.Pointer Cronet_UrlRequestCallback_CreateWith( + ffi.Pointer< + ffi.NativeFunction< + Cronet_UrlRequestCallback_OnRedirectReceivedFunc>> + OnRedirectReceivedFunc, + ffi.Pointer< + ffi.NativeFunction> + OnResponseStartedFunc, + ffi.Pointer< + ffi.NativeFunction> + OnReadCompletedFunc, + ffi.Pointer> + OnSucceededFunc, + ffi.Pointer> + OnFailedFunc, + ffi.Pointer> + OnCanceledFunc, + ) { + return _Cronet_UrlRequestCallback_CreateWith( + OnRedirectReceivedFunc, + OnResponseStartedFunc, + OnReadCompletedFunc, + OnSucceededFunc, + OnFailedFunc, + OnCanceledFunc, + ); + } + + late final _Cronet_UrlRequestCallback_CreateWith_ptr = + _lookup>( + 'Cronet_UrlRequestCallback_CreateWith'); + late final _dart_Cronet_UrlRequestCallback_CreateWith + _Cronet_UrlRequestCallback_CreateWith = + _Cronet_UrlRequestCallback_CreateWith_ptr.asFunction< + _dart_Cronet_UrlRequestCallback_CreateWith>(); + /// //////////////////// - ffi.Pointer Cronet_UrlRequest_Create() { + ffi.Pointer Cronet_UrlRequest_Create() { return _Cronet_UrlRequest_Create(); } @@ -157,7 +339,7 @@ class Cronet { _dart_Cronet_UrlRequest_Create>(); void Cronet_UrlRequest_Destroy( - ffi.Pointer self, + ffi.Pointer self, ) { return _Cronet_UrlRequest_Destroy( self, @@ -172,7 +354,7 @@ class Cronet { _dart_Cronet_UrlRequest_Destroy>(); void Cronet_UrlRequest_SetClientContext( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer client_context, ) { return _Cronet_UrlRequest_SetClientContext( @@ -190,7 +372,7 @@ class Cronet { _dart_Cronet_UrlRequest_SetClientContext>(); ffi.Pointer Cronet_UrlRequest_GetClientContext( - ffi.Pointer self, + ffi.Pointer self, ) { return _Cronet_UrlRequest_GetClientContext( self, @@ -205,8 +387,33 @@ class Cronet { _Cronet_UrlRequest_GetClientContext_ptr.asFunction< _dart_Cronet_UrlRequest_GetClientContext>(); + int Cronet_UrlRequest_InitWithParams( + ffi.Pointer self, + ffi.Pointer engine, + ffi.Pointer url, + ffi.Pointer params, + ffi.Pointer callback, + ffi.Pointer executor, + ) { + return _Cronet_UrlRequest_InitWithParams( + self, + engine, + url, + params, + callback, + executor, + ); + } + + late final _Cronet_UrlRequest_InitWithParams_ptr = + _lookup>( + 'Cronet_UrlRequest_InitWithParams'); + late final _dart_Cronet_UrlRequest_InitWithParams + _Cronet_UrlRequest_InitWithParams = _Cronet_UrlRequest_InitWithParams_ptr + .asFunction<_dart_Cronet_UrlRequest_InitWithParams>(); + int Cronet_UrlRequest_Start( - ffi.Pointer self, + ffi.Pointer self, ) { return _Cronet_UrlRequest_Start( self, @@ -220,7 +427,7 @@ class Cronet { _Cronet_UrlRequest_Start_ptr.asFunction<_dart_Cronet_UrlRequest_Start>(); int Cronet_UrlRequest_FollowRedirect( - ffi.Pointer self, + ffi.Pointer self, ) { return _Cronet_UrlRequest_FollowRedirect( self, @@ -235,8 +442,8 @@ class Cronet { .asFunction<_dart_Cronet_UrlRequest_FollowRedirect>(); int Cronet_UrlRequest_Read( - ffi.Pointer self, - ffi.Pointer buffer, + ffi.Pointer self, + ffi.Pointer buffer, ) { return _Cronet_UrlRequest_Read( self, @@ -251,7 +458,7 @@ class Cronet { _Cronet_UrlRequest_Read_ptr.asFunction<_dart_Cronet_UrlRequest_Read>(); void Cronet_UrlRequest_Cancel( - ffi.Pointer self, + ffi.Pointer self, ) { return _Cronet_UrlRequest_Cancel( self, @@ -265,8 +472,69 @@ class Cronet { _Cronet_UrlRequest_Cancel_ptr.asFunction< _dart_Cronet_UrlRequest_Cancel>(); + ffi.Pointer Cronet_UrlRequest_CreateWith( + ffi.Pointer> + InitWithParamsFunc, + ffi.Pointer> StartFunc, + ffi.Pointer> + FollowRedirectFunc, + ffi.Pointer> ReadFunc, + ffi.Pointer> CancelFunc, + ffi.Pointer> IsDoneFunc, + ffi.Pointer> + GetStatusFunc, + ) { + return _Cronet_UrlRequest_CreateWith( + InitWithParamsFunc, + StartFunc, + FollowRedirectFunc, + ReadFunc, + CancelFunc, + IsDoneFunc, + GetStatusFunc, + ); + } + + late final _Cronet_UrlRequest_CreateWith_ptr = + _lookup>( + 'Cronet_UrlRequest_CreateWith'); + late final _dart_Cronet_UrlRequest_CreateWith _Cronet_UrlRequest_CreateWith = + _Cronet_UrlRequest_CreateWith_ptr.asFunction< + _dart_Cronet_UrlRequest_CreateWith>(); + + ffi.Pointer Cronet_Error_message_get( + ffi.Pointer self, + ) { + return _Cronet_Error_message_get( + self, + ); + } + + late final _Cronet_Error_message_get_ptr = + _lookup>( + 'Cronet_Error_message_get'); + late final _dart_Cronet_Error_message_get _Cronet_Error_message_get = + _Cronet_Error_message_get_ptr.asFunction< + _dart_Cronet_Error_message_get>(); + + int Cronet_Error_internal_error_code_get( + ffi.Pointer self, + ) { + return _Cronet_Error_internal_error_code_get( + self, + ); + } + + late final _Cronet_Error_internal_error_code_get_ptr = + _lookup>( + 'Cronet_Error_internal_error_code_get'); + late final _dart_Cronet_Error_internal_error_code_get + _Cronet_Error_internal_error_code_get = + _Cronet_Error_internal_error_code_get_ptr.asFunction< + _dart_Cronet_Error_internal_error_code_get>(); + /// //////////////////// - ffi.Pointer Cronet_QuicHint_Create() { + ffi.Pointer Cronet_QuicHint_Create() { return _Cronet_QuicHint_Create(); } @@ -277,7 +545,7 @@ class Cronet { _Cronet_QuicHint_Create_ptr.asFunction<_dart_Cronet_QuicHint_Create>(); void Cronet_QuicHint_Destroy( - ffi.Pointer self, + ffi.Pointer self, ) { return _Cronet_QuicHint_Destroy( self, @@ -291,7 +559,7 @@ class Cronet { _Cronet_QuicHint_Destroy_ptr.asFunction<_dart_Cronet_QuicHint_Destroy>(); void Cronet_QuicHint_host_set( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer host, ) { return _Cronet_QuicHint_host_set( @@ -308,7 +576,7 @@ class Cronet { _dart_Cronet_QuicHint_host_set>(); void Cronet_QuicHint_port_set( - ffi.Pointer self, + ffi.Pointer self, int port, ) { return _Cronet_QuicHint_port_set( @@ -325,7 +593,7 @@ class Cronet { _dart_Cronet_QuicHint_port_set>(); void Cronet_QuicHint_alternate_port_set( - ffi.Pointer self, + ffi.Pointer self, int alternate_port, ) { return _Cronet_QuicHint_alternate_port_set( @@ -343,7 +611,7 @@ class Cronet { _dart_Cronet_QuicHint_alternate_port_set>(); /// //////////////////// - ffi.Pointer Cronet_EngineParams_Create() { + ffi.Pointer Cronet_EngineParams_Create() { return _Cronet_EngineParams_Create(); } @@ -355,7 +623,7 @@ class Cronet { _dart_Cronet_EngineParams_Create>(); void Cronet_EngineParams_Destroy( - ffi.Pointer self, + ffi.Pointer self, ) { return _Cronet_EngineParams_Destroy( self, @@ -370,7 +638,7 @@ class Cronet { _dart_Cronet_EngineParams_Destroy>(); void Cronet_EngineParams_enable_check_result_set( - ffi.Pointer self, + ffi.Pointer self, bool enable_check_result, ) { return _Cronet_EngineParams_enable_check_result_set( @@ -388,7 +656,7 @@ class Cronet { _dart_Cronet_EngineParams_enable_check_result_set>(); void Cronet_EngineParams_user_agent_set( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer user_agent, ) { return _Cronet_EngineParams_user_agent_set( @@ -406,7 +674,7 @@ class Cronet { _dart_Cronet_EngineParams_user_agent_set>(); void Cronet_EngineParams_accept_language_set( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer accept_language, ) { return _Cronet_EngineParams_accept_language_set( @@ -424,7 +692,7 @@ class Cronet { _dart_Cronet_EngineParams_accept_language_set>(); void Cronet_EngineParams_storage_path_set( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer storage_path, ) { return _Cronet_EngineParams_storage_path_set( @@ -442,7 +710,7 @@ class Cronet { _dart_Cronet_EngineParams_storage_path_set>(); void Cronet_EngineParams_enable_quic_set( - ffi.Pointer self, + ffi.Pointer self, bool enable_quic, ) { return _Cronet_EngineParams_enable_quic_set( @@ -460,7 +728,7 @@ class Cronet { _dart_Cronet_EngineParams_enable_quic_set>(); void Cronet_EngineParams_enable_http2_set( - ffi.Pointer self, + ffi.Pointer self, bool enable_http2, ) { return _Cronet_EngineParams_enable_http2_set( @@ -478,7 +746,7 @@ class Cronet { _dart_Cronet_EngineParams_enable_http2_set>(); void Cronet_EngineParams_enable_brotli_set( - ffi.Pointer self, + ffi.Pointer self, bool enable_brotli, ) { return _Cronet_EngineParams_enable_brotli_set( @@ -496,7 +764,7 @@ class Cronet { _dart_Cronet_EngineParams_enable_brotli_set>(); void Cronet_EngineParams_http_cache_mode_set( - ffi.Pointer self, + ffi.Pointer self, int http_cache_mode, ) { return _Cronet_EngineParams_http_cache_mode_set( @@ -514,7 +782,7 @@ class Cronet { _dart_Cronet_EngineParams_http_cache_mode_set>(); void Cronet_EngineParams_http_cache_max_size_set( - ffi.Pointer self, + ffi.Pointer self, int http_cache_max_size, ) { return _Cronet_EngineParams_http_cache_max_size_set( @@ -532,8 +800,8 @@ class Cronet { _dart_Cronet_EngineParams_http_cache_max_size_set>(); void Cronet_EngineParams_quic_hints_add( - ffi.Pointer self, - ffi.Pointer element, + ffi.Pointer self, + ffi.Pointer element, ) { return _Cronet_EngineParams_quic_hints_add( self, @@ -550,7 +818,7 @@ class Cronet { _dart_Cronet_EngineParams_quic_hints_add>(); /// //////////////////// - ffi.Pointer Cronet_HttpHeader_Create() { + ffi.Pointer Cronet_HttpHeader_Create() { return _Cronet_HttpHeader_Create(); } @@ -562,7 +830,7 @@ class Cronet { _dart_Cronet_HttpHeader_Create>(); void Cronet_HttpHeader_Destroy( - ffi.Pointer self, + ffi.Pointer self, ) { return _Cronet_HttpHeader_Destroy( self, @@ -577,7 +845,7 @@ class Cronet { _dart_Cronet_HttpHeader_Destroy>(); void Cronet_HttpHeader_name_set( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer name, ) { return _Cronet_HttpHeader_name_set( @@ -594,7 +862,7 @@ class Cronet { _dart_Cronet_HttpHeader_name_set>(); void Cronet_HttpHeader_value_set( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer value, ) { return _Cronet_HttpHeader_value_set( @@ -611,7 +879,7 @@ class Cronet { _dart_Cronet_HttpHeader_value_set>(); int Cronet_UrlResponseInfo_http_status_code_get( - ffi.Pointer self, + ffi.Pointer self, ) { return _Cronet_UrlResponseInfo_http_status_code_get( self, @@ -627,7 +895,7 @@ class Cronet { _dart_Cronet_UrlResponseInfo_http_status_code_get>(); ffi.Pointer Cronet_UrlResponseInfo_http_status_text_get( - ffi.Pointer self, + ffi.Pointer self, ) { return _Cronet_UrlResponseInfo_http_status_text_get( self, @@ -643,7 +911,7 @@ class Cronet { _dart_Cronet_UrlResponseInfo_http_status_text_get>(); /// //////////////////// - ffi.Pointer Cronet_UrlRequestParams_Create() { + ffi.Pointer Cronet_UrlRequestParams_Create() { return _Cronet_UrlRequestParams_Create(); } @@ -655,7 +923,7 @@ class Cronet { .asFunction<_dart_Cronet_UrlRequestParams_Create>(); void Cronet_UrlRequestParams_Destroy( - ffi.Pointer self, + ffi.Pointer self, ) { return _Cronet_UrlRequestParams_Destroy( self, @@ -670,7 +938,7 @@ class Cronet { .asFunction<_dart_Cronet_UrlRequestParams_Destroy>(); void Cronet_UrlRequestParams_http_method_set( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer http_method, ) { return _Cronet_UrlRequestParams_http_method_set( @@ -688,8 +956,8 @@ class Cronet { _dart_Cronet_UrlRequestParams_http_method_set>(); void Cronet_UrlRequestParams_request_headers_add( - ffi.Pointer self, - ffi.Pointer element, + ffi.Pointer self, + ffi.Pointer element, ) { return _Cronet_UrlRequestParams_request_headers_add( self, @@ -704,396 +972,833 @@ class Cronet { _Cronet_UrlRequestParams_request_headers_add = _Cronet_UrlRequestParams_request_headers_add_ptr.asFunction< _dart_Cronet_UrlRequestParams_request_headers_add>(); + + late final addresses = _SymbolAddresses(this); } -class Cronet_BufferPtr extends ffi.Opaque {} +class _SymbolAddresses { + final Cronet _library; + _SymbolAddresses(this._library); + ffi.Pointer> + get Cronet_Buffer_Create => _library._Cronet_Buffer_Create_ptr; + ffi.Pointer> + get Cronet_Buffer_InitWithAlloc => + _library._Cronet_Buffer_InitWithAlloc_ptr; + ffi.Pointer> + get Cronet_Runnable_Destroy => _library._Cronet_Runnable_Destroy_ptr; + ffi.Pointer> + get Cronet_Runnable_Run => _library._Cronet_Runnable_Run_ptr; + ffi.Pointer> + get Cronet_Executor_Destroy => _library._Cronet_Executor_Destroy_ptr; + ffi.Pointer> + get Cronet_Executor_SetClientContext => + _library._Cronet_Executor_SetClientContext_ptr; + ffi.Pointer> + get Cronet_Executor_GetClientContext => + _library._Cronet_Executor_GetClientContext_ptr; + ffi.Pointer> + get Cronet_Executor_CreateWith => + _library._Cronet_Executor_CreateWith_ptr; + ffi.Pointer> + get Cronet_Engine_Destroy => _library._Cronet_Engine_Destroy_ptr; + ffi.Pointer> + get Cronet_Engine_Shutdown => _library._Cronet_Engine_Shutdown_ptr; + ffi.Pointer> + get Cronet_UrlRequestCallback_CreateWith => + _library._Cronet_UrlRequestCallback_CreateWith_ptr; + ffi.Pointer> + get Cronet_UrlRequest_InitWithParams => + _library._Cronet_UrlRequest_InitWithParams_ptr; +} + +class Cronet_Buffer extends ffi.Opaque {} + +class Cronet_BufferCallback extends ffi.Opaque {} + +class Cronet_Runnable extends ffi.Opaque {} + +class Cronet_Executor extends ffi.Opaque {} + +class Cronet_Engine extends ffi.Opaque {} + +class Cronet_UrlRequestStatusListener extends ffi.Opaque {} + +class Cronet_UrlRequestCallback extends ffi.Opaque {} + +class Cronet_UploadDataSink extends ffi.Opaque {} + +class Cronet_UploadDataProvider extends ffi.Opaque {} + +class Cronet_UrlRequest extends ffi.Opaque {} + +class Cronet_RequestFinishedInfoListener extends ffi.Opaque {} -class Cronet_EnginePtr extends ffi.Opaque {} +class Cronet_Error extends ffi.Opaque {} -class Cronet_EngineParamsPtr extends ffi.Opaque {} +class Cronet_QuicHint extends ffi.Opaque {} -class Cronet_UrlRequestPtr extends ffi.Opaque {} +class Cronet_PublicKeyPins extends ffi.Opaque {} -class Cronet_QuicHintPtr extends ffi.Opaque {} +class Cronet_EngineParams extends ffi.Opaque {} -class Cronet_HttpHeaderPtr extends ffi.Opaque {} +class Cronet_HttpHeader extends ffi.Opaque {} -class Cronet_UrlResponseInfoPtr extends ffi.Opaque {} +class Cronet_UrlResponseInfo extends ffi.Opaque {} -class Cronet_UrlRequestParamsPtr extends ffi.Opaque {} +class Cronet_UrlRequestParams extends ffi.Opaque {} + +class Cronet_DateTime extends ffi.Opaque {} + +class Cronet_Metrics extends ffi.Opaque {} + +class Cronet_RequestFinishedInfo extends ffi.Opaque {} + +abstract class Cronet_RESULT { + static const int Cronet_RESULT_SUCCESS = 0; + static const int Cronet_RESULT_ILLEGAL_ARGUMENT = -100; + static const int Cronet_RESULT_ILLEGAL_ARGUMENT_STORAGE_PATH_MUST_EXIST = + -101; + static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_PIN = -102; + static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HOSTNAME = -103; + static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HTTP_METHOD = -104; + static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HTTP_HEADER = -105; + static const int Cronet_RESULT_ILLEGAL_STATE = -200; + static const int Cronet_RESULT_ILLEGAL_STATE_STORAGE_PATH_IN_USE = -201; + static const int + Cronet_RESULT_ILLEGAL_STATE_CANNOT_SHUTDOWN_ENGINE_FROM_NETWORK_THREAD = + -202; + static const int Cronet_RESULT_ILLEGAL_STATE_ENGINE_ALREADY_STARTED = -203; + static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_ALREADY_STARTED = -204; + static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_NOT_INITIALIZED = -205; + static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_ALREADY_INITIALIZED = + -206; + static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_NOT_STARTED = -207; + static const int Cronet_RESULT_ILLEGAL_STATE_UNEXPECTED_REDIRECT = -208; + static const int Cronet_RESULT_ILLEGAL_STATE_UNEXPECTED_READ = -209; + static const int Cronet_RESULT_ILLEGAL_STATE_READ_FAILED = -210; + static const int Cronet_RESULT_NULL_POINTER = -300; + static const int Cronet_RESULT_NULL_POINTER_HOSTNAME = -301; + static const int Cronet_RESULT_NULL_POINTER_SHA256_PINS = -302; + static const int Cronet_RESULT_NULL_POINTER_EXPIRATION_DATE = -303; + static const int Cronet_RESULT_NULL_POINTER_ENGINE = -304; + static const int Cronet_RESULT_NULL_POINTER_URL = -305; + static const int Cronet_RESULT_NULL_POINTER_CALLBACK = -306; + static const int Cronet_RESULT_NULL_POINTER_EXECUTOR = -307; + static const int Cronet_RESULT_NULL_POINTER_METHOD = -308; + static const int Cronet_RESULT_NULL_POINTER_HEADER_NAME = -309; + static const int Cronet_RESULT_NULL_POINTER_HEADER_VALUE = -310; + static const int Cronet_RESULT_NULL_POINTER_PARAMS = -311; + static const int + Cronet_RESULT_NULL_POINTER_REQUEST_FINISHED_INFO_LISTENER_EXECUTOR = -312; +} + +abstract class Cronet_Error_ERROR_CODE { + static const int Cronet_Error_ERROR_CODE_ERROR_CALLBACK = 0; + static const int Cronet_Error_ERROR_CODE_ERROR_HOSTNAME_NOT_RESOLVED = 1; + static const int Cronet_Error_ERROR_CODE_ERROR_INTERNET_DISCONNECTED = 2; + static const int Cronet_Error_ERROR_CODE_ERROR_NETWORK_CHANGED = 3; + static const int Cronet_Error_ERROR_CODE_ERROR_TIMED_OUT = 4; + static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_CLOSED = 5; + static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_TIMED_OUT = 6; + static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_REFUSED = 7; + static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_RESET = 8; + static const int Cronet_Error_ERROR_CODE_ERROR_ADDRESS_UNREACHABLE = 9; + static const int Cronet_Error_ERROR_CODE_ERROR_QUIC_PROTOCOL_FAILED = 10; + static const int Cronet_Error_ERROR_CODE_ERROR_OTHER = 11; +} + +abstract class Cronet_EngineParams_HTTP_CACHE_MODE { + static const int Cronet_EngineParams_HTTP_CACHE_MODE_DISABLED = 0; + static const int Cronet_EngineParams_HTTP_CACHE_MODE_IN_MEMORY = 1; + static const int Cronet_EngineParams_HTTP_CACHE_MODE_DISK_NO_HTTP = 2; + static const int Cronet_EngineParams_HTTP_CACHE_MODE_DISK = 3; +} + +abstract class Cronet_UrlRequestParams_REQUEST_PRIORITY { + static const int + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_IDLE = 0; + static const int + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_LOWEST = 1; + static const int + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_LOW = 2; + static const int + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_MEDIUM = 3; + static const int + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_HIGHEST = 4; +} + +abstract class Cronet_UrlRequestParams_IDEMPOTENCY { + static const int Cronet_UrlRequestParams_IDEMPOTENCY_DEFAULT_IDEMPOTENCY = 0; + static const int Cronet_UrlRequestParams_IDEMPOTENCY_IDEMPOTENT = 1; + static const int Cronet_UrlRequestParams_IDEMPOTENCY_NOT_IDEMPOTENT = 2; +} + +abstract class Cronet_RequestFinishedInfo_FINISHED_REASON { + static const int Cronet_RequestFinishedInfo_FINISHED_REASON_SUCCEEDED = 0; + static const int Cronet_RequestFinishedInfo_FINISHED_REASON_FAILED = 1; + static const int Cronet_RequestFinishedInfo_FINISHED_REASON_CANCELED = 2; +} + +abstract class Cronet_UrlRequestStatusListener_Status { + static const int Cronet_UrlRequestStatusListener_Status_INVALID = -1; + static const int Cronet_UrlRequestStatusListener_Status_IDLE = 0; + static const int + Cronet_UrlRequestStatusListener_Status_WAITING_FOR_STALLED_SOCKET_POOL = + 1; + static const int + Cronet_UrlRequestStatusListener_Status_WAITING_FOR_AVAILABLE_SOCKET = 2; + static const int Cronet_UrlRequestStatusListener_Status_WAITING_FOR_DELEGATE = + 3; + static const int Cronet_UrlRequestStatusListener_Status_WAITING_FOR_CACHE = 4; + static const int Cronet_UrlRequestStatusListener_Status_DOWNLOADING_PAC_FILE = + 5; + static const int + Cronet_UrlRequestStatusListener_Status_RESOLVING_PROXY_FOR_URL = 6; + static const int + Cronet_UrlRequestStatusListener_Status_RESOLVING_HOST_IN_PAC_FILE = 7; + static const int + Cronet_UrlRequestStatusListener_Status_ESTABLISHING_PROXY_TUNNEL = 8; + static const int Cronet_UrlRequestStatusListener_Status_RESOLVING_HOST = 9; + static const int Cronet_UrlRequestStatusListener_Status_CONNECTING = 10; + static const int Cronet_UrlRequestStatusListener_Status_SSL_HANDSHAKE = 11; + static const int Cronet_UrlRequestStatusListener_Status_SENDING_REQUEST = 12; + static const int Cronet_UrlRequestStatusListener_Status_WAITING_FOR_RESPONSE = + 13; + static const int Cronet_UrlRequestStatusListener_Status_READING_RESPONSE = 14; +} + +typedef Native_Cronet_Buffer_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_Buffer_Create = ffi.Pointer Function(); + +typedef Native_Cronet_Buffer_InitWithAlloc = ffi.Void Function( + ffi.Pointer self, + ffi.Uint64 size, +); + +typedef _dart_Cronet_Buffer_InitWithAlloc = void Function( + ffi.Pointer self, + int size, +); typedef _c_Cronet_Buffer_GetSize = ffi.Uint64 Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _dart_Cronet_Buffer_GetSize = int Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _c_Cronet_Buffer_GetData = ffi.Pointer Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _dart_Cronet_Buffer_GetData = ffi.Pointer Function( - ffi.Pointer self, + ffi.Pointer self, +); + +typedef Native_Cronet_Runnable_Destroy = ffi.Void Function( + ffi.Pointer self, ); -typedef _c_Cronet_Engine_Create = ffi.Pointer Function(); +typedef _dart_Cronet_Runnable_Destroy = void Function( + ffi.Pointer self, +); + +typedef Native_Cronet_Runnable_Run = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Runnable_Run = void Function( + ffi.Pointer self, +); + +typedef Native_Cronet_Executor_Destroy = ffi.Void Function( + ffi.Pointer self, +); -typedef _dart_Cronet_Engine_Create = ffi.Pointer Function(); +typedef _dart_Cronet_Executor_Destroy = void Function( + ffi.Pointer self, +); + +typedef Native_Cronet_Executor_SetClientContext = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _dart_Cronet_Executor_SetClientContext = void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef Native_Cronet_Executor_GetClientContext = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Executor_GetClientContext = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Executor_Execute = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer command, +); + +typedef _dart_Cronet_Executor_Execute = void Function( + ffi.Pointer self, + ffi.Pointer command, +); + +typedef Cronet_Executor_ExecuteFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, +); + +typedef Native_Cronet_Executor_CreateWith = ffi.Pointer + Function( + ffi.Pointer> ExecuteFunc, +); + +typedef _dart_Cronet_Executor_CreateWith = ffi.Pointer + Function( + ffi.Pointer> ExecuteFunc, +); + +typedef _c_Cronet_Engine_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_Engine_Create = ffi.Pointer Function(); + +typedef Native_Cronet_Engine_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Engine_Destroy = void Function( + ffi.Pointer self, +); typedef _c_Cronet_Engine_StartWithParams = ffi.Int32 Function( - ffi.Pointer self, - ffi.Pointer params, + ffi.Pointer self, + ffi.Pointer params, ); typedef _dart_Cronet_Engine_StartWithParams = int Function( - ffi.Pointer self, - ffi.Pointer params, + ffi.Pointer self, + ffi.Pointer params, ); typedef _c_Cronet_Engine_StartNetLogToFile = ffi.Uint8 Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer file_name, ffi.Uint8 log_all, ); typedef _dart_Cronet_Engine_StartNetLogToFile = int Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer file_name, int log_all, ); typedef _c_Cronet_Engine_StopNetLog = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _dart_Cronet_Engine_StopNetLog = void Function( - ffi.Pointer self, + ffi.Pointer self, ); -typedef _c_Cronet_Engine_Shutdown = ffi.Int32 Function( - ffi.Pointer self, +typedef Native_Cronet_Engine_Shutdown = ffi.Int32 Function( + ffi.Pointer self, ); typedef _dart_Cronet_Engine_Shutdown = int Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _c_Cronet_Engine_GetVersionString = ffi.Pointer Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _dart_Cronet_Engine_GetVersionString = ffi.Pointer Function( - ffi.Pointer self, -); - -typedef _c_Cronet_UrlRequest_Create = ffi.Pointer - Function(); - -typedef _dart_Cronet_UrlRequest_Create = ffi.Pointer + ffi.Pointer self, +); + +typedef Cronet_UrlRequestCallback_OnRedirectReceivedFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_UrlRequestCallback_OnResponseStartedFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_UrlRequestCallback_OnReadCompletedFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Uint64, +); + +typedef Cronet_UrlRequestCallback_OnSucceededFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_UrlRequestCallback_OnFailedFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_UrlRequestCallback_OnCanceledFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef Native_Cronet_UrlRequestCallback_CreateWith + = ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction> + OnRedirectReceivedFunc, + ffi.Pointer< + ffi.NativeFunction> + OnResponseStartedFunc, + ffi.Pointer> + OnReadCompletedFunc, + ffi.Pointer> + OnSucceededFunc, + ffi.Pointer> + OnFailedFunc, + ffi.Pointer> + OnCanceledFunc, +); + +typedef _dart_Cronet_UrlRequestCallback_CreateWith + = ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction> + OnRedirectReceivedFunc, + ffi.Pointer< + ffi.NativeFunction> + OnResponseStartedFunc, + ffi.Pointer> + OnReadCompletedFunc, + ffi.Pointer> + OnSucceededFunc, + ffi.Pointer> + OnFailedFunc, + ffi.Pointer> + OnCanceledFunc, +); + +typedef _c_Cronet_UrlRequest_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_UrlRequest_Create = ffi.Pointer Function(); typedef _c_Cronet_UrlRequest_Destroy = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _dart_Cronet_UrlRequest_Destroy = void Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _c_Cronet_UrlRequest_SetClientContext = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer client_context, ); typedef _dart_Cronet_UrlRequest_SetClientContext = void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer client_context, ); typedef _c_Cronet_UrlRequest_GetClientContext = ffi.Pointer Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _dart_Cronet_UrlRequest_GetClientContext = ffi.Pointer Function( - ffi.Pointer self, + ffi.Pointer self, +); + +typedef Native_Cronet_UrlRequest_InitWithParams = ffi.Int32 Function( + ffi.Pointer self, + ffi.Pointer engine, + ffi.Pointer url, + ffi.Pointer params, + ffi.Pointer callback, + ffi.Pointer executor, +); + +typedef _dart_Cronet_UrlRequest_InitWithParams = int Function( + ffi.Pointer self, + ffi.Pointer engine, + ffi.Pointer url, + ffi.Pointer params, + ffi.Pointer callback, + ffi.Pointer executor, ); typedef _c_Cronet_UrlRequest_Start = ffi.Int32 Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _dart_Cronet_UrlRequest_Start = int Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _c_Cronet_UrlRequest_FollowRedirect = ffi.Int32 Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _dart_Cronet_UrlRequest_FollowRedirect = int Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _c_Cronet_UrlRequest_Read = ffi.Int32 Function( - ffi.Pointer self, - ffi.Pointer buffer, + ffi.Pointer self, + ffi.Pointer buffer, ); typedef _dart_Cronet_UrlRequest_Read = int Function( - ffi.Pointer self, - ffi.Pointer buffer, + ffi.Pointer self, + ffi.Pointer buffer, ); typedef _c_Cronet_UrlRequest_Cancel = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _dart_Cronet_UrlRequest_Cancel = void Function( - ffi.Pointer self, + ffi.Pointer self, ); -typedef _c_Cronet_QuicHint_Create = ffi.Pointer Function(); +typedef Cronet_UrlRequest_InitWithParamsFunc = ffi.Int32 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); -typedef _dart_Cronet_QuicHint_Create = ffi.Pointer - Function(); +typedef Cronet_UrlRequest_StartFunc = ffi.Int32 Function( + ffi.Pointer, +); + +typedef Cronet_UrlRequest_FollowRedirectFunc = ffi.Int32 Function( + ffi.Pointer, +); + +typedef Cronet_UrlRequest_ReadFunc = ffi.Int32 Function( + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_UrlRequest_CancelFunc = ffi.Void Function( + ffi.Pointer, +); + +typedef Cronet_UrlRequest_IsDoneFunc = ffi.Uint8 Function( + ffi.Pointer, +); + +typedef Cronet_UrlRequest_GetStatusFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, +); + +typedef _c_Cronet_UrlRequest_CreateWith = ffi.Pointer + Function( + ffi.Pointer> + InitWithParamsFunc, + ffi.Pointer> StartFunc, + ffi.Pointer> + FollowRedirectFunc, + ffi.Pointer> ReadFunc, + ffi.Pointer> CancelFunc, + ffi.Pointer> IsDoneFunc, + ffi.Pointer> + GetStatusFunc, +); + +typedef _dart_Cronet_UrlRequest_CreateWith = ffi.Pointer + Function( + ffi.Pointer> + InitWithParamsFunc, + ffi.Pointer> StartFunc, + ffi.Pointer> + FollowRedirectFunc, + ffi.Pointer> ReadFunc, + ffi.Pointer> CancelFunc, + ffi.Pointer> IsDoneFunc, + ffi.Pointer> + GetStatusFunc, +); + +typedef _c_Cronet_Error_message_get = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Error_message_get = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Error_internal_error_code_get = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Error_internal_error_code_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_QuicHint_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_QuicHint_Create = ffi.Pointer Function(); typedef _c_Cronet_QuicHint_Destroy = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _dart_Cronet_QuicHint_Destroy = void Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _c_Cronet_QuicHint_host_set = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer host, ); typedef _dart_Cronet_QuicHint_host_set = void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer host, ); typedef _c_Cronet_QuicHint_port_set = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Int32 port, ); typedef _dart_Cronet_QuicHint_port_set = void Function( - ffi.Pointer self, + ffi.Pointer self, int port, ); typedef _c_Cronet_QuicHint_alternate_port_set = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Int32 alternate_port, ); typedef _dart_Cronet_QuicHint_alternate_port_set = void Function( - ffi.Pointer self, + ffi.Pointer self, int alternate_port, ); -typedef _c_Cronet_EngineParams_Create = ffi.Pointer +typedef _c_Cronet_EngineParams_Create = ffi.Pointer Function(); -typedef _dart_Cronet_EngineParams_Create = ffi.Pointer +typedef _dart_Cronet_EngineParams_Create = ffi.Pointer Function(); typedef _c_Cronet_EngineParams_Destroy = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _dart_Cronet_EngineParams_Destroy = void Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _c_Cronet_EngineParams_enable_check_result_set = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Uint8 enable_check_result, ); typedef _dart_Cronet_EngineParams_enable_check_result_set = void Function( - ffi.Pointer self, + ffi.Pointer self, int enable_check_result, ); typedef _c_Cronet_EngineParams_user_agent_set = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer user_agent, ); typedef _dart_Cronet_EngineParams_user_agent_set = void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer user_agent, ); typedef _c_Cronet_EngineParams_accept_language_set = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer accept_language, ); typedef _dart_Cronet_EngineParams_accept_language_set = void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer accept_language, ); typedef _c_Cronet_EngineParams_storage_path_set = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer storage_path, ); typedef _dart_Cronet_EngineParams_storage_path_set = void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer storage_path, ); typedef _c_Cronet_EngineParams_enable_quic_set = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Uint8 enable_quic, ); typedef _dart_Cronet_EngineParams_enable_quic_set = void Function( - ffi.Pointer self, + ffi.Pointer self, int enable_quic, ); typedef _c_Cronet_EngineParams_enable_http2_set = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Uint8 enable_http2, ); typedef _dart_Cronet_EngineParams_enable_http2_set = void Function( - ffi.Pointer self, + ffi.Pointer self, int enable_http2, ); typedef _c_Cronet_EngineParams_enable_brotli_set = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Uint8 enable_brotli, ); typedef _dart_Cronet_EngineParams_enable_brotli_set = void Function( - ffi.Pointer self, + ffi.Pointer self, int enable_brotli, ); typedef _c_Cronet_EngineParams_http_cache_mode_set = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Int32 http_cache_mode, ); typedef _dart_Cronet_EngineParams_http_cache_mode_set = void Function( - ffi.Pointer self, + ffi.Pointer self, int http_cache_mode, ); typedef _c_Cronet_EngineParams_http_cache_max_size_set = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Int64 http_cache_max_size, ); typedef _dart_Cronet_EngineParams_http_cache_max_size_set = void Function( - ffi.Pointer self, + ffi.Pointer self, int http_cache_max_size, ); typedef _c_Cronet_EngineParams_quic_hints_add = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer element, + ffi.Pointer self, + ffi.Pointer element, ); typedef _dart_Cronet_EngineParams_quic_hints_add = void Function( - ffi.Pointer self, - ffi.Pointer element, + ffi.Pointer self, + ffi.Pointer element, ); -typedef _c_Cronet_HttpHeader_Create = ffi.Pointer - Function(); +typedef _c_Cronet_HttpHeader_Create = ffi.Pointer Function(); -typedef _dart_Cronet_HttpHeader_Create = ffi.Pointer +typedef _dart_Cronet_HttpHeader_Create = ffi.Pointer Function(); typedef _c_Cronet_HttpHeader_Destroy = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _dart_Cronet_HttpHeader_Destroy = void Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _c_Cronet_HttpHeader_name_set = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer name, ); typedef _dart_Cronet_HttpHeader_name_set = void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer name, ); typedef _c_Cronet_HttpHeader_value_set = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer value, ); typedef _dart_Cronet_HttpHeader_value_set = void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer value, ); typedef _c_Cronet_UrlResponseInfo_http_status_code_get = ffi.Int32 Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _dart_Cronet_UrlResponseInfo_http_status_code_get = int Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _c_Cronet_UrlResponseInfo_http_status_text_get = ffi.Pointer Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _dart_Cronet_UrlResponseInfo_http_status_text_get = ffi.Pointer Function( - ffi.Pointer self, + ffi.Pointer self, ); -typedef _c_Cronet_UrlRequestParams_Create - = ffi.Pointer Function(); +typedef _c_Cronet_UrlRequestParams_Create = ffi.Pointer + Function(); typedef _dart_Cronet_UrlRequestParams_Create - = ffi.Pointer Function(); + = ffi.Pointer Function(); typedef _c_Cronet_UrlRequestParams_Destroy = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _dart_Cronet_UrlRequestParams_Destroy = void Function( - ffi.Pointer self, + ffi.Pointer self, ); typedef _c_Cronet_UrlRequestParams_http_method_set = ffi.Void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer http_method, ); typedef _dart_Cronet_UrlRequestParams_http_method_set = void Function( - ffi.Pointer self, + ffi.Pointer self, ffi.Pointer http_method, ); typedef _c_Cronet_UrlRequestParams_request_headers_add = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer element, + ffi.Pointer self, + ffi.Pointer element, ); typedef _dart_Cronet_UrlRequestParams_request_headers_add = void Function( - ffi.Pointer self, - ffi.Pointer element, + ffi.Pointer self, + ffi.Pointer element, ); diff --git a/lib/src/wrapper/ffigen.yaml b/lib/src/wrapper/ffigen.yaml index 49cc5f1..bfe7300 100644 --- a/lib/src/wrapper/ffigen.yaml +++ b/lib/src/wrapper/ffigen.yaml @@ -12,22 +12,6 @@ compiler-opts: - '-Isrc/' - '-Ithird_party/dart-sdk/' - '-DDART_SHARED_LIB' -macros: - include: - - nothing -enums: - include: - - nothing -unnamed-enums: - include: - - nothing -globals: - include: - - nothing -structs: - include: - - nothing - dependency-only: opaque comments: style: any length: full diff --git a/lib/src/wrapper/generated_bindings.dart b/lib/src/wrapper/generated_bindings.dart index be3910f..a0192b9 100644 --- a/lib/src/wrapper/generated_bindings.dart +++ b/lib/src/wrapper/generated_bindings.dart @@ -51,14 +51,52 @@ class Wrapper { late final _dart_InitDartApiDL _InitDartApiDL = _InitDartApiDL_ptr.asFunction<_dart_InitDartApiDL>(); - void unloadCronet() { - return _unloadCronet(); + void InitCronetApi( + ffi.Pointer shutdown, + ffi.Pointer destroy, + ffi.Pointer buffer_create, + ffi.Pointer buffer_InitWithAlloc, + ffi.Pointer UrlRequestCallback_CreateWith, + ffi.Pointer UrlRequest_InitWithParams, + ) { + return _InitCronetApi( + shutdown, + destroy, + buffer_create, + buffer_InitWithAlloc, + UrlRequestCallback_CreateWith, + UrlRequest_InitWithParams, + ); + } + + late final _InitCronetApi_ptr = + _lookup>('InitCronetApi'); + late final _dart_InitCronetApi _InitCronetApi = + _InitCronetApi_ptr.asFunction<_dart_InitCronetApi>(); + + void InitCronetExecutorApi( + ffi.Pointer executor_createWith, + ffi.Pointer executor_setClientContext, + ffi.Pointer executor_getClientContext, + ffi.Pointer executor_destroy, + ffi.Pointer runnable_run, + ffi.Pointer runnable_destroy, + ) { + return _InitCronetExecutorApi( + executor_createWith, + executor_setClientContext, + executor_getClientContext, + executor_destroy, + runnable_run, + runnable_destroy, + ); } - late final _unloadCronet_ptr = - _lookup>('unloadCronet'); - late final _dart_unloadCronet _unloadCronet = - _unloadCronet_ptr.asFunction<_dart_unloadCronet>(); + late final _InitCronetExecutorApi_ptr = + _lookup>( + 'InitCronetExecutorApi'); + late final _dart_InitCronetExecutorApi _InitCronetExecutorApi = + _InitCronetExecutorApi_ptr.asFunction<_dart_InitCronetExecutorApi>(); ffi.Pointer Create_Executor() { return _Create_Executor(); @@ -84,7 +122,7 @@ class Wrapper { void registerHttpClient( Object h, - ffi.Pointer ce, + ffi.Pointer ce, ) { return _registerHttpClient( h, @@ -99,7 +137,7 @@ class Wrapper { void registerCallbackHandler( int nativePort, - ffi.Pointer rp, + ffi.Pointer rp, ) { return _registerCallbackHandler( nativePort, @@ -114,7 +152,7 @@ class Wrapper { _registerCallbackHandler_ptr.asFunction<_dart_registerCallbackHandler>(); void removeRequest( - ffi.Pointer rp, + ffi.Pointer rp, ) { return _removeRequest( rp, @@ -127,10 +165,10 @@ class Wrapper { _removeRequest_ptr.asFunction<_dart_removeRequest>(); int Cronet_UrlRequest_Init( - ffi.Pointer self, - ffi.Pointer engine, + ffi.Pointer self, + ffi.Pointer engine, ffi.Pointer url, - ffi.Pointer params, + ffi.Pointer params, ffi.Pointer _executor, ) { return _Cronet_UrlRequest_Init( @@ -149,11 +187,11 @@ class Wrapper { _Cronet_UrlRequest_Init_ptr.asFunction<_dart_Cronet_UrlRequest_Init>(); } -class Cronet_EnginePtr extends ffi.Opaque {} +class Cronet_Engine extends ffi.Opaque {} -class Cronet_UrlRequestPtr extends ffi.Opaque {} +class Cronet_UrlRequest extends ffi.Opaque {} -class Cronet_UrlRequestParamsPtr extends ffi.Opaque {} +class Cronet_UrlRequestParams extends ffi.Opaque {} typedef _c_dispatchCallback = ffi.Void Function( ffi.Pointer methodname, @@ -171,9 +209,41 @@ typedef _dart_InitDartApiDL = int Function( ffi.Pointer data, ); -typedef _c_unloadCronet = ffi.Void Function(); +typedef _c_InitCronetApi = ffi.Void Function( + ffi.Pointer shutdown, + ffi.Pointer destroy, + ffi.Pointer buffer_create, + ffi.Pointer buffer_InitWithAlloc, + ffi.Pointer UrlRequestCallback_CreateWith, + ffi.Pointer UrlRequest_InitWithParams, +); + +typedef _dart_InitCronetApi = void Function( + ffi.Pointer shutdown, + ffi.Pointer destroy, + ffi.Pointer buffer_create, + ffi.Pointer buffer_InitWithAlloc, + ffi.Pointer UrlRequestCallback_CreateWith, + ffi.Pointer UrlRequest_InitWithParams, +); -typedef _dart_unloadCronet = void Function(); +typedef _c_InitCronetExecutorApi = ffi.Void Function( + ffi.Pointer executor_createWith, + ffi.Pointer executor_setClientContext, + ffi.Pointer executor_getClientContext, + ffi.Pointer executor_destroy, + ffi.Pointer runnable_run, + ffi.Pointer runnable_destroy, +); + +typedef _dart_InitCronetExecutorApi = void Function( + ffi.Pointer executor_createWith, + ffi.Pointer executor_setClientContext, + ffi.Pointer executor_getClientContext, + ffi.Pointer executor_destroy, + ffi.Pointer runnable_run, + ffi.Pointer runnable_destroy, +); typedef _c_Create_Executor = ffi.Pointer Function(); @@ -189,44 +259,44 @@ typedef _dart_Destroy_Executor = void Function( typedef _c_registerHttpClient = ffi.Void Function( ffi.Handle h, - ffi.Pointer ce, + ffi.Pointer ce, ); typedef _dart_registerHttpClient = void Function( Object h, - ffi.Pointer ce, + ffi.Pointer ce, ); typedef _c_registerCallbackHandler = ffi.Void Function( ffi.Int64 nativePort, - ffi.Pointer rp, + ffi.Pointer rp, ); typedef _dart_registerCallbackHandler = void Function( int nativePort, - ffi.Pointer rp, + ffi.Pointer rp, ); typedef _c_removeRequest = ffi.Void Function( - ffi.Pointer rp, + ffi.Pointer rp, ); typedef _dart_removeRequest = void Function( - ffi.Pointer rp, + ffi.Pointer rp, ); typedef _c_Cronet_UrlRequest_Init = ffi.Int32 Function( - ffi.Pointer self, - ffi.Pointer engine, + ffi.Pointer self, + ffi.Pointer engine, ffi.Pointer url, - ffi.Pointer params, + ffi.Pointer params, ffi.Pointer _executor, ); typedef _dart_Cronet_UrlRequest_Init = int Function( - ffi.Pointer self, - ffi.Pointer engine, + ffi.Pointer self, + ffi.Pointer engine, ffi.Pointer url, - ffi.Pointer params, + ffi.Pointer params, ffi.Pointer _executor, ); diff --git a/src/wrapper.cc b/src/wrapper.cc index 5fd322d..ec4b3a4 100644 --- a/src/wrapper.cc +++ b/src/wrapper.cc @@ -12,21 +12,31 @@ #include #include -// Set CRONET_VERSION from build script - -#ifdef CRONET_VERSION - #define CRONET_LIB_NAME CRONET_LIB_PREFIX "." CRONET_VERSION CRONET_LIB_EXTENSION -#else - #define CRONET_LIB_NAME CRONET_LIB_PREFIX ".86.0.4240.198" CRONET_LIB_EXTENSION -#endif +//////////////////////////////////////////////////////////////////////////////// +// Globals -// cronet function loading and exposing macros -// use IMPORT for private use - accessable as func_name -// use P_IMPORT for those API who needs to be wrapped before exposing - accessable as _func_name +std::unordered_map requestNativePorts; -#define IMPORT(r_type, f_name, ...) r_type (* f_name) (__VA_ARGS__) = reinterpret_cast(dlsym(handle, #f_name)) +Cronet_RESULT (*_Cronet_Engine_Shutdown)(Cronet_EnginePtr self); +void (*_Cronet_Engine_Destroy)(Cronet_EnginePtr self); +Cronet_BufferPtr (*_Cronet_Buffer_Create)(void); +void (*_Cronet_Buffer_InitWithAlloc)(Cronet_BufferPtr self, uint64_t size); +Cronet_UrlRequestCallbackPtr (*_Cronet_UrlRequestCallback_CreateWith)( + Cronet_UrlRequestCallback_OnRedirectReceivedFunc OnRedirectReceivedFunc, + Cronet_UrlRequestCallback_OnResponseStartedFunc OnResponseStartedFunc, + Cronet_UrlRequestCallback_OnReadCompletedFunc OnReadCompletedFunc, + Cronet_UrlRequestCallback_OnSucceededFunc OnSucceededFunc, + Cronet_UrlRequestCallback_OnFailedFunc OnFailedFunc, + Cronet_UrlRequestCallback_OnCanceledFunc OnCanceledFunc); +Cronet_RESULT (*_Cronet_UrlRequest_InitWithParams)( + Cronet_UrlRequestPtr self, + Cronet_EnginePtr engine, + Cronet_String url, + Cronet_UrlRequestParamsPtr params, + Cronet_UrlRequestCallbackPtr callback, + Cronet_ExecutorPtr executor); +//////////////////////////////////////////////////////////////////////////////// -#define P_IMPORT(r_type, f_name, ...) r_type (* _ ## f_name) (__VA_ARGS__) = reinterpret_cast(dlsym(handle, #f_name)) //////////////////////////////////////////////////////////////////////////////// // Initialize `dart_api_dl.h` @@ -36,205 +46,31 @@ intptr_t InitDartApiDL(void* data) { //////////////////////////////////////////////////////////////////////////////// -// loading cronet -LIBTYPE handle = OPENLIB(CRONET_LIB_NAME); -std::unordered_map requestNativePorts; - -/* Getting Cronet's Functions */ -P_IMPORT(Cronet_EnginePtr,Cronet_Engine_Create , void); -P_IMPORT(void, Cronet_Engine_Destroy, Cronet_EnginePtr); -P_IMPORT(Cronet_RESULT, Cronet_Engine_Shutdown, Cronet_EnginePtr); -P_IMPORT(Cronet_String, Cronet_Engine_GetVersionString, Cronet_EnginePtr); - -P_IMPORT(Cronet_EngineParamsPtr, Cronet_EngineParams_Create, void); -P_IMPORT(void, Cronet_EngineParams_Destroy, Cronet_EngineParamsPtr); - -P_IMPORT(Cronet_QuicHintPtr,Cronet_QuicHint_Create, void); -P_IMPORT(void, Cronet_QuicHint_Destroy, Cronet_QuicHintPtr); -P_IMPORT(void, Cronet_QuicHint_host_set, Cronet_QuicHintPtr self, const Cronet_String host); -P_IMPORT(void, Cronet_QuicHint_port_set, Cronet_QuicHintPtr self, const int32_t port); -P_IMPORT(void, Cronet_QuicHint_alternate_port_set, Cronet_QuicHintPtr self, const int32_t alternate_port); - -P_IMPORT(void, Cronet_EngineParams_enable_check_result_set, Cronet_EngineParamsPtr, const bool); -P_IMPORT(void, Cronet_EngineParams_user_agent_set, Cronet_EngineParamsPtr, const Cronet_String); -P_IMPORT(void, Cronet_EngineParams_enable_quic_set, Cronet_EngineParamsPtr, const bool); -P_IMPORT(void, Cronet_EngineParams_quic_hints_add, Cronet_EngineParamsPtr self,const Cronet_QuicHintPtr element); -P_IMPORT(void, Cronet_EngineParams_enable_http2_set, Cronet_EngineParamsPtr, const bool); -P_IMPORT(void, Cronet_EngineParams_enable_brotli_set, Cronet_EngineParamsPtr, const bool); -P_IMPORT(void, Cronet_EngineParams_accept_language_set, Cronet_EngineParamsPtr, const Cronet_String); -P_IMPORT(void, Cronet_EngineParams_http_cache_mode_set, Cronet_EngineParamsPtr, const Cronet_EngineParams_HTTP_CACHE_MODE http_cache_mode); -P_IMPORT(void, Cronet_EngineParams_http_cache_max_size_set, Cronet_EngineParamsPtr, const int64_t http_cache_max_size); -P_IMPORT(void, Cronet_EngineParams_storage_path_set, Cronet_EngineParamsPtr, const Cronet_String storage_path); - -P_IMPORT(Cronet_RESULT, Cronet_Engine_StartWithParams, Cronet_EnginePtr, Cronet_EngineParamsPtr); -P_IMPORT(Cronet_UrlRequestPtr, Cronet_UrlRequest_Create, void); -P_IMPORT(void, Cronet_UrlRequest_Destroy, Cronet_UrlRequestPtr); -P_IMPORT(void, Cronet_UrlRequest_Cancel, Cronet_UrlRequestPtr); -P_IMPORT(void, Cronet_UrlRequest_SetClientContext, Cronet_UrlRequestPtr, Cronet_ClientContext); -P_IMPORT(Cronet_ClientContext, Cronet_UrlRequest_GetClientContext, Cronet_UrlRequestPtr); -P_IMPORT(Cronet_UrlRequestParamsPtr, Cronet_UrlRequestParams_Create, void); -P_IMPORT(void, Cronet_UrlRequestParams_http_method_set, Cronet_UrlRequestParamsPtr, const Cronet_String); - -P_IMPORT(void, Cronet_UrlRequestParams_request_headers_add, Cronet_UrlRequestParamsPtr, const Cronet_HttpHeaderPtr); - -void Cronet_UrlRequestParams_request_headers_add( - Cronet_UrlRequestParamsPtr self, - const Cronet_HttpHeaderPtr element) {return _Cronet_UrlRequestParams_request_headers_add(self, element);} - -P_IMPORT(Cronet_HttpHeaderPtr, Cronet_HttpHeader_Create, void); -Cronet_HttpHeaderPtr Cronet_HttpHeader_Create(void) {return _Cronet_HttpHeader_Create();} - -P_IMPORT(void,Cronet_HttpHeader_Destroy, Cronet_HttpHeaderPtr); -void Cronet_HttpHeader_Destroy(Cronet_HttpHeaderPtr self) {return _Cronet_HttpHeader_Destroy(self);} - -P_IMPORT(void,Cronet_HttpHeader_name_set, Cronet_HttpHeaderPtr, const Cronet_String); - -void Cronet_HttpHeader_name_set(Cronet_HttpHeaderPtr self, - const Cronet_String name) {return _Cronet_HttpHeader_name_set(self, name);} - -P_IMPORT(void,Cronet_HttpHeader_value_set, Cronet_HttpHeaderPtr, const Cronet_String); -void Cronet_HttpHeader_value_set(Cronet_HttpHeaderPtr self, - const Cronet_String value) {return _Cronet_HttpHeader_value_set(self, value);} - -// Unexposed - see Cronet_UrlRequest_Init -P_IMPORT(Cronet_RESULT, Cronet_UrlRequest_InitWithParams, Cronet_UrlRequestPtr, Cronet_EnginePtr, Cronet_String, Cronet_UrlRequestParamsPtr, Cronet_UrlRequestCallbackPtr, Cronet_ExecutorPtr); - -// Unexposed - see Cronet_UrlRequest_Init -P_IMPORT(Cronet_UrlRequestCallbackPtr, Cronet_UrlRequestCallback_CreateWith, - Cronet_UrlRequestCallback_OnRedirectReceivedFunc, - Cronet_UrlRequestCallback_OnResponseStartedFunc, - Cronet_UrlRequestCallback_OnReadCompletedFunc, - Cronet_UrlRequestCallback_OnSucceededFunc, - Cronet_UrlRequestCallback_OnFailedFunc, - Cronet_UrlRequestCallback_OnCanceledFunc); - -P_IMPORT(Cronet_RESULT, Cronet_UrlRequest_Start, Cronet_UrlRequestPtr); -P_IMPORT(Cronet_RESULT, Cronet_UrlRequest_FollowRedirect, Cronet_UrlRequestPtr); -P_IMPORT(Cronet_RESULT, Cronet_UrlRequest_Read, Cronet_UrlRequestPtr, Cronet_BufferPtr); -P_IMPORT(Cronet_BufferPtr, Cronet_Buffer_Create, void); -P_IMPORT(void, Cronet_Buffer_Destroy, Cronet_BufferPtr); -P_IMPORT(void, Cronet_Buffer_InitWithAlloc, Cronet_BufferPtr, uint64_t); -P_IMPORT(uint64_t, Cronet_Buffer_GetSize, Cronet_BufferPtr); -P_IMPORT(Cronet_RawDataPtr, Cronet_Buffer_GetData, Cronet_BufferPtr); -P_IMPORT(int64_t, Cronet_UrlResponseInfo_received_byte_count_get, Cronet_UrlResponseInfoPtr); -P_IMPORT(Cronet_String, Cronet_Error_message_get, const Cronet_ErrorPtr); - -P_IMPORT(bool, Cronet_Engine_StartNetLogToFile, Cronet_EnginePtr self,Cronet_String file_name,bool log_all); -P_IMPORT(void, Cronet_Engine_StopNetLog,Cronet_EnginePtr self); - -bool Cronet_Engine_StartNetLogToFile(Cronet_EnginePtr self, - Cronet_String file_name, - bool log_all) { - return _Cronet_Engine_StartNetLogToFile(self, file_name, true); -} - -void Cronet_Engine_StopNetLog(Cronet_EnginePtr self) {return _Cronet_Engine_StopNetLog(self);} - -P_IMPORT(int32_t, Cronet_UrlResponseInfo_http_status_code_get, const Cronet_UrlResponseInfoPtr); -int32_t Cronet_UrlResponseInfo_http_status_code_get(const Cronet_UrlResponseInfoPtr self) {return _Cronet_UrlResponseInfo_http_status_code_get(self);} - - -P_IMPORT(Cronet_String, Cronet_UrlResponseInfo_http_status_text_get, const Cronet_UrlResponseInfoPtr); -Cronet_String Cronet_UrlResponseInfo_http_status_text_get(const Cronet_UrlResponseInfoPtr self) {return _Cronet_UrlResponseInfo_http_status_text_get(self);} - -// Mapping Cronet Function -> Wrapper function. Most of them are unchanged, except some. -// -// Note: Can someone suggest a better way to map unchanged APIs? -Cronet_String Cronet_Engine_GetVersionString(Cronet_EnginePtr ce) {return _Cronet_Engine_GetVersionString(ce);} -Cronet_EngineParamsPtr Cronet_EngineParams_Create(void) {return _Cronet_EngineParams_Create();} -void Cronet_EngineParams_Destroy(Cronet_EngineParamsPtr self) {} -void Cronet_EngineParams_enable_check_result_set( - Cronet_EngineParamsPtr self, - const bool enable_check_result) {return _Cronet_EngineParams_enable_check_result_set(self,enable_check_result);} - -Cronet_QuicHintPtr Cronet_QuicHint_Create(void) { - return _Cronet_QuicHint_Create(); -} - -void Cronet_QuicHint_Destroy(Cronet_QuicHintPtr self) { - return _Cronet_QuicHint_Destroy(self); -} - -void Cronet_QuicHint_host_set(Cronet_QuicHintPtr self, - const Cronet_String host) { - return _Cronet_QuicHint_host_set(self, host); -} - -void Cronet_QuicHint_port_set(Cronet_QuicHintPtr self, const int32_t port) { - return _Cronet_QuicHint_port_set(self, port); -} - -void Cronet_QuicHint_alternate_port_set(Cronet_QuicHintPtr self, - const int32_t alternate_port) { - return _Cronet_QuicHint_alternate_port_set(self, alternate_port); -} - -void Cronet_EngineParams_user_agent_set(Cronet_EngineParamsPtr self, - const Cronet_String user_agent){_Cronet_EngineParams_user_agent_set(self, user_agent);} - -void Cronet_EngineParams_enable_quic_set(Cronet_EngineParamsPtr self, - const bool enable_quic){_Cronet_EngineParams_enable_quic_set(self,enable_quic);} - -void Cronet_EngineParams_accept_language_set( - Cronet_EngineParamsPtr self, - const Cronet_String accept_language) {return _Cronet_EngineParams_accept_language_set(self, accept_language);} - -void Cronet_EngineParams_storage_path_set(Cronet_EngineParamsPtr self, - const Cronet_String storage_path) { - return _Cronet_EngineParams_storage_path_set(self, storage_path); -} - -void Cronet_EngineParams_enable_http2_set(Cronet_EngineParamsPtr self, - const bool enable_http2) { - return _Cronet_EngineParams_enable_http2_set(self, enable_http2); -} - -void Cronet_EngineParams_quic_hints_add(Cronet_EngineParamsPtr self, - const Cronet_QuicHintPtr element) { - return _Cronet_EngineParams_quic_hints_add(self, element); - -} - -void Cronet_EngineParams_enable_brotli_set(Cronet_EngineParamsPtr self, - const bool enable_brotli) { - return _Cronet_EngineParams_enable_brotli_set(self, enable_brotli); -} - -void Cronet_EngineParams_http_cache_mode_set( - Cronet_EngineParamsPtr self, - const Cronet_EngineParams_HTTP_CACHE_MODE http_cache_mode) { - return _Cronet_EngineParams_http_cache_mode_set(self, http_cache_mode); - } - -void Cronet_EngineParams_http_cache_max_size_set( - Cronet_EngineParamsPtr self, - const int64_t http_cache_max_size) { - return _Cronet_EngineParams_http_cache_max_size_set(self, http_cache_max_size); +//////////////////////////////////////////////////////////////////////////////// +// Initialize required cronet functions +void InitCronetApi(void* shutdown, void *destroy, void *buffer_create, + void *buffer_InitWithAlloc, void *UrlRequestCallback_CreateWith, + void *UrlRequest_InitWithParams) { + _Cronet_Engine_Shutdown = reinterpret_cast(shutdown); + _Cronet_Engine_Destroy = reinterpret_cast(destroy); + _Cronet_Buffer_Create = reinterpret_cast(buffer_create); + _Cronet_Buffer_InitWithAlloc = reinterpret_cast(buffer_InitWithAlloc); + _Cronet_UrlRequestCallback_CreateWith = reinterpret_cast(UrlRequestCallback_CreateWith); + _Cronet_UrlRequest_InitWithParams = reinterpret_cast(UrlRequest_InitWithParams); } -Cronet_RESULT Cronet_Engine_StartWithParams(Cronet_EnginePtr self, - Cronet_EngineParamsPtr params) {return _Cronet_Engine_StartWithParams(self, params);} - -Cronet_UrlRequestPtr Cronet_UrlRequest_Create(void) {return _Cronet_UrlRequest_Create();} - -void Cronet_UrlRequest_Destroy(Cronet_UrlRequestPtr self) {return _Cronet_UrlRequest_Destroy(self);} -void Cronet_UrlRequest_Cancel(Cronet_UrlRequestPtr self) {return _Cronet_UrlRequest_Cancel(self);} - -void Cronet_UrlRequest_SetClientContext(Cronet_UrlRequestPtr self, Cronet_ClientContext client_context) {return _Cronet_UrlRequest_SetClientContext(self, client_context);} -Cronet_ClientContext Cronet_UrlRequest_GetClientContext(Cronet_UrlRequestPtr self) {return _Cronet_UrlRequest_GetClientContext(self);} - -Cronet_UrlRequestParamsPtr Cronet_UrlRequestParams_Create(void) {return _Cronet_UrlRequestParams_Create();} - -void Cronet_UrlRequestParams_http_method_set(Cronet_UrlRequestParamsPtr self, const Cronet_String http_method) {return _Cronet_UrlRequestParams_http_method_set(self, http_method);} - -Cronet_RESULT Cronet_UrlRequest_Start(Cronet_UrlRequestPtr self) {return _Cronet_UrlRequest_Start(self);} -Cronet_RESULT Cronet_UrlRequest_FollowRedirect(Cronet_UrlRequestPtr self) {return _Cronet_UrlRequest_FollowRedirect(self);} -Cronet_RESULT Cronet_UrlRequest_Read(Cronet_UrlRequestPtr self, Cronet_BufferPtr buffer) {return _Cronet_UrlRequest_Read(self, buffer);} - -Cronet_RawDataPtr Cronet_Buffer_GetData(Cronet_BufferPtr buffer) {return _Cronet_Buffer_GetData(buffer);} -uint64_t Cronet_Buffer_GetSize(Cronet_BufferPtr self) {return _Cronet_Buffer_GetSize(self);} - -/* Wrapper implemented APIs from here */ +//////////////////////////////////////////////////////////////////////////////// static void FreeFinalizer(void*, void* value) { free(value); @@ -310,16 +146,12 @@ static void HttpClientDestroy(void* isolate_callback_data, _Cronet_Engine_Destroy(ce); } -void unloadCronet() { - CLOSELIB(handle); -} - void removeRequest(Cronet_UrlRequestPtr rp) { requestNativePorts.erase(rp); } // Register our HttpClient object from dart side -void registerHttpClient(Dart_Handle h, Cronet_EnginePtr ce) { +void registerHttpClient(Dart_Handle h, Cronet_Engine* ce) { void* peer = ce; intptr_t size = 8; Dart_NewFinalizableHandle_DL(h, peer, size, HttpClientDestroy); @@ -344,10 +176,10 @@ void OnResponseStarted( Cronet_BufferPtr buffer = _Cronet_Buffer_Create(); _Cronet_Buffer_InitWithAlloc(buffer, 32 * 1024); - dispatchCallback("OnResponseStarted",request, callbackArgBuilder(1, info)); + dispatchCallback("OnResponseStarted",request, callbackArgBuilder(2, info, buffer)); - // Started reading the response. - _Cronet_UrlRequest_Read(request, buffer); + // // Started reading the response. + // _Cronet_UrlRequest_Read(request, buffer); } @@ -370,7 +202,7 @@ void OnFailed( Cronet_UrlRequestPtr request, Cronet_UrlResponseInfoPtr info, Cronet_ErrorPtr error) { - dispatchCallback("OnFailed",request, callbackArgBuilder(1, _Cronet_Error_message_get(error))); + dispatchCallback("OnFailed",request, callbackArgBuilder(1, error)); } void OnCanceled( @@ -380,22 +212,6 @@ void OnCanceled( dispatchCallback("OnCanceled",request, callbackArgBuilder(0)); } -Cronet_EnginePtr Cronet_Engine_Create() { - // Checks if cronet is loaded properly - // As this is the first function to call, - // if this succeeds, every subsequent use - // of cronet [handle] should. - if (!handle) { - std::cout << "Can't locate cronet library. Make sure that they are available." << std::endl; - std::cout << "Try Running this from the root of your project:\ndart run cronet " << std::endl; - std::clog << dlerror() << std::endl; - exit(EXIT_FAILURE); - } - return _Cronet_Engine_Create(); -} - -Cronet_RESULT Cronet_Engine_Shutdown(Cronet_EnginePtr self) { return _Cronet_Engine_Shutdown(self); } - ExecutorPtr Create_Executor() { return new SampleExecutor(); } @@ -412,5 +228,4 @@ Cronet_RESULT Cronet_UrlRequest_Init(Cronet_UrlRequestPtr self, Cronet_EnginePtr Cronet_UrlRequestCallbackPtr urCallback = _Cronet_UrlRequestCallback_CreateWith(OnRedirectReceived, OnResponseStarted, OnReadCompleted, OnSucceeded, OnFailed, OnCanceled); return _Cronet_UrlRequest_InitWithParams(self, engine, url, params, urCallback, executor->GetExecutor()); - } diff --git a/src/wrapper.h b/src/wrapper.h index 9598130..cc99d54 100644 --- a/src/wrapper.h +++ b/src/wrapper.h @@ -8,30 +8,10 @@ #include "../third_party/dart-sdk/dart_api_dl.h" #include "../third_party/cronet/cronet.idl_c.h" - #include"wrapper_export.h" #include -#ifdef __linux__ - #include - #define LIBTYPE void* - #define OPENLIB(libname) dlopen((libname), RTLD_NOW) - #define CLOSELIB(handle) dlclose((handle)) - #define CRONET_LIB_PREFIX "libcronet" - #define CRONET_LIB_EXTENSION ".so" -#elif defined(_WIN32) -#include - #define LIBTYPE HINSTANCE - #define OPENLIB(libname) LoadLibrary(TEXT(libname)) - #define dlsym(lib, fn) (void *)GetProcAddress((lib), (fn)) - #define dlerror() GetLastError() - #define CLOSELIB(handle) FreeLibrary((handle)) - #define CRONET_LIB_PREFIX "cronet" - #define CRONET_LIB_EXTENSION ".dll" -#endif - - #ifdef __cplusplus @@ -42,20 +22,27 @@ extern "C" { DART_EXPORT void dispatchCallback(char* methodname); DART_EXPORT intptr_t InitDartApiDL(void* data); -DART_EXPORT void unloadCronet(); +DART_EXPORT void InitCronetApi(void* shutdown, void *destroy, void *buffer_create, + void *buffer_InitWithAlloc, void *UrlRequestCallback_CreateWith, + void *UrlRequest_InitWithParams); +DART_EXPORT void InitCronetExecutorApi(void *executor_createWith, void *executor_setClientContext, + void *executor_getClientContext, + void *executor_destroy, + void *runnable_run, + void *runnable_destroy); typedef void* ExecutorPtr; DART_EXPORT ExecutorPtr Create_Executor(); DART_EXPORT void Destroy_Executor(ExecutorPtr executor); -DART_EXPORT void registerHttpClient(Dart_Handle h, Cronet_EnginePtr ce); -DART_EXPORT void registerCallbackHandler(Dart_Port nativePort, Cronet_UrlRequestPtr rp); -DART_EXPORT void removeRequest(Cronet_UrlRequestPtr rp); -DART_EXPORT Cronet_RESULT Cronet_UrlRequest_Init(Cronet_UrlRequestPtr self, Cronet_EnginePtr engine, Cronet_String url, Cronet_UrlRequestParamsPtr params, ExecutorPtr _executor); +DART_EXPORT void registerHttpClient(Dart_Handle h, Cronet_Engine* ce); +DART_EXPORT void registerCallbackHandler(Dart_Port nativePort, Cronet_UrlRequest* rp); +DART_EXPORT void removeRequest(Cronet_UrlRequest* rp); +DART_EXPORT Cronet_RESULT Cronet_UrlRequest_Init(Cronet_UrlRequest* self, Cronet_Engine* engine, Cronet_String url, Cronet_UrlRequestParams* params, ExecutorPtr _executor); /* executor only */ -typedef void (*Cronet_Executor_ExecuteFunc)(Cronet_ExecutorPtr self, Cronet_RunnablePtr command); +typedef void (*Cronet_Executor_ExecuteFunc)(Cronet_Executor* self, Cronet_Runnable* command); #ifdef __cplusplus diff --git a/third_party/cronet/cronet.idl_c.h b/third_party/cronet/cronet.idl_c.h index c8ec2c0..0c18400 100644 --- a/third_party/cronet/cronet.idl_c.h +++ b/third_party/cronet/cronet.idl_c.h @@ -173,7 +173,7 @@ typedef enum Cronet_UrlRequestStatusListener_Status { // // Concrete interface Cronet_Buffer. // // Create an instance of Cronet_Buffer. -// CRONET_EXPORT Cronet_BufferPtr Cronet_Buffer_Create(void); +CRONET_EXPORT Cronet_BufferPtr Cronet_Buffer_Create(void); // // Destroy an instance of Cronet_Buffer. // CRONET_EXPORT void Cronet_Buffer_Destroy(Cronet_BufferPtr self); // // Set and get app-specific Cronet_ClientContext. @@ -189,8 +189,8 @@ typedef enum Cronet_UrlRequestStatusListener_Status { // Cronet_RawDataPtr data, // uint64_t size, // Cronet_BufferCallbackPtr callback); -// CRONET_EXPORT -// void Cronet_Buffer_InitWithAlloc(Cronet_BufferPtr self, uint64_t size); +CRONET_EXPORT +void Cronet_Buffer_InitWithAlloc(Cronet_BufferPtr self, uint64_t size); CRONET_EXPORT uint64_t Cronet_Buffer_GetSize(Cronet_BufferPtr self); CRONET_EXPORT @@ -202,8 +202,8 @@ Cronet_RawDataPtr Cronet_Buffer_GetData(Cronet_BufferPtr self); // Cronet_RawDataPtr data, // uint64_t size, // Cronet_BufferCallbackPtr callback); -// typedef void (*Cronet_Buffer_InitWithAllocFunc)(Cronet_BufferPtr self, -// uint64_t size); +typedef void (*Cronet_Buffer_InitWithAllocFunc)(Cronet_BufferPtr self, + uint64_t size); // typedef uint64_t (*Cronet_Buffer_GetSizeFunc)(Cronet_BufferPtr self); // typedef Cronet_RawDataPtr (*Cronet_Buffer_GetDataFunc)(Cronet_BufferPtr self); // // Concrete interface Cronet_Buffer is implemented by Cronet. @@ -248,8 +248,8 @@ Cronet_RawDataPtr Cronet_Buffer_GetData(Cronet_BufferPtr self); // // There is no method to create a concrete implementation. -// // Destroy an instance of Cronet_Runnable. -// CRONET_EXPORT void Cronet_Runnable_Destroy(Cronet_RunnablePtr self); +// Destroy an instance of Cronet_Runnable. +CRONET_EXPORT void Cronet_Runnable_Destroy(Cronet_RunnablePtr self); // // Set and get app-specific Cronet_ClientContext. // CRONET_EXPORT void Cronet_Runnable_SetClientContext( // Cronet_RunnablePtr self, @@ -259,8 +259,8 @@ Cronet_RawDataPtr Cronet_Buffer_GetData(Cronet_BufferPtr self); // // Abstract interface Cronet_Runnable is implemented by the app. // // The following concrete methods forward call to app implementation. // // The app doesn't normally call them. -// CRONET_EXPORT -// void Cronet_Runnable_Run(Cronet_RunnablePtr self); +CRONET_EXPORT +void Cronet_Runnable_Run(Cronet_RunnablePtr self); // // The app implements abstract interface Cronet_Runnable by defining custom // // functions for each method. // typedef void (*Cronet_Runnable_RunFunc)(Cronet_RunnablePtr self); @@ -275,27 +275,27 @@ Cronet_RawDataPtr Cronet_Buffer_GetData(Cronet_BufferPtr self); // // There is no method to create a concrete implementation. // // Destroy an instance of Cronet_Executor. -// CRONET_EXPORT void Cronet_Executor_Destroy(Cronet_ExecutorPtr self); -// // Set and get app-specific Cronet_ClientContext. -// CRONET_EXPORT void Cronet_Executor_SetClientContext( -// Cronet_ExecutorPtr self, -// Cronet_ClientContext client_context); -// CRONET_EXPORT Cronet_ClientContext -// Cronet_Executor_GetClientContext(Cronet_ExecutorPtr self); -// // Abstract interface Cronet_Executor is implemented by the app. -// // The following concrete methods forward call to app implementation. -// // The app doesn't normally call them. -// CRONET_EXPORT -// void Cronet_Executor_Execute(Cronet_ExecutorPtr self, -// Cronet_RunnablePtr command); +CRONET_EXPORT void Cronet_Executor_Destroy(Cronet_ExecutorPtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_Executor_SetClientContext( + Cronet_ExecutorPtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_Executor_GetClientContext(Cronet_ExecutorPtr self); +// Abstract interface Cronet_Executor is implemented by the app. +// The following concrete methods forward call to app implementation. +// The app doesn't normally call them. +CRONET_EXPORT +void Cronet_Executor_Execute(Cronet_ExecutorPtr self, + Cronet_RunnablePtr command); // // The app implements abstract interface Cronet_Executor by defining custom // // functions for each method. -// typedef void (*Cronet_Executor_ExecuteFunc)(Cronet_ExecutorPtr self, -// Cronet_RunnablePtr command); +typedef void (*Cronet_Executor_ExecuteFunc)(Cronet_ExecutorPtr self, + Cronet_RunnablePtr command); // // The app creates an instance of Cronet_Executor by providing custom functions // // for each method. -// CRONET_EXPORT Cronet_ExecutorPtr -// Cronet_Executor_CreateWith(Cronet_Executor_ExecuteFunc ExecuteFunc); +CRONET_EXPORT Cronet_ExecutorPtr +Cronet_Executor_CreateWith(Cronet_Executor_ExecuteFunc ExecuteFunc); // /////////////////////// // // Concrete interface Cronet_Engine. @@ -303,7 +303,7 @@ Cronet_RawDataPtr Cronet_Buffer_GetData(Cronet_BufferPtr self); // // Create an instance of Cronet_Engine. CRONET_EXPORT Cronet_EnginePtr Cronet_Engine_Create(void); // // Destroy an instance of Cronet_Engine. -// CRONET_EXPORT void Cronet_Engine_Destroy(Cronet_EnginePtr self); +CRONET_EXPORT void Cronet_Engine_Destroy(Cronet_EnginePtr self); // // Set and get app-specific Cronet_ClientContext. // CRONET_EXPORT void Cronet_Engine_SetClientContext( // Cronet_EnginePtr self, @@ -483,13 +483,13 @@ typedef void (*Cronet_UrlRequestCallback_OnCanceledFunc)( Cronet_UrlResponseInfoPtr info); // // The app creates an instance of Cronet_UrlRequestCallback by providing custom // // functions for each method. -// CRONET_EXPORT Cronet_UrlRequestCallbackPtr Cronet_UrlRequestCallback_CreateWith( -// Cronet_UrlRequestCallback_OnRedirectReceivedFunc OnRedirectReceivedFunc, -// Cronet_UrlRequestCallback_OnResponseStartedFunc OnResponseStartedFunc, -// Cronet_UrlRequestCallback_OnReadCompletedFunc OnReadCompletedFunc, -// Cronet_UrlRequestCallback_OnSucceededFunc OnSucceededFunc, -// Cronet_UrlRequestCallback_OnFailedFunc OnFailedFunc, -// Cronet_UrlRequestCallback_OnCanceledFunc OnCanceledFunc); +CRONET_EXPORT Cronet_UrlRequestCallbackPtr Cronet_UrlRequestCallback_CreateWith( + Cronet_UrlRequestCallback_OnRedirectReceivedFunc OnRedirectReceivedFunc, + Cronet_UrlRequestCallback_OnResponseStartedFunc OnResponseStartedFunc, + Cronet_UrlRequestCallback_OnReadCompletedFunc OnReadCompletedFunc, + Cronet_UrlRequestCallback_OnSucceededFunc OnSucceededFunc, + Cronet_UrlRequestCallback_OnFailedFunc OnFailedFunc, + Cronet_UrlRequestCallback_OnCanceledFunc OnCanceledFunc); // /////////////////////// // // Concrete interface Cronet_UploadDataSink. @@ -605,14 +605,14 @@ CRONET_EXPORT Cronet_ClientContext Cronet_UrlRequest_GetClientContext(Cronet_UrlRequestPtr self); // // Concrete methods of Cronet_UrlRequest implemented by Cronet. // // The app calls them to manipulate Cronet_UrlRequest. -// CRONET_EXPORT -// Cronet_RESULT Cronet_UrlRequest_InitWithParams( -// Cronet_UrlRequestPtr self, -// Cronet_EnginePtr engine, -// Cronet_String url, -// Cronet_UrlRequestParamsPtr params, -// Cronet_UrlRequestCallbackPtr callback, -// Cronet_ExecutorPtr executor); +CRONET_EXPORT +Cronet_RESULT Cronet_UrlRequest_InitWithParams( + Cronet_UrlRequestPtr self, + Cronet_EnginePtr engine, + Cronet_String url, + Cronet_UrlRequestParamsPtr params, + Cronet_UrlRequestCallbackPtr callback, + Cronet_ExecutorPtr executor); CRONET_EXPORT Cronet_RESULT Cronet_UrlRequest_Start(Cronet_UrlRequestPtr self); CRONET_EXPORT @@ -629,33 +629,33 @@ void Cronet_UrlRequest_Cancel(Cronet_UrlRequestPtr self); // Cronet_UrlRequestStatusListenerPtr listener); // // Concrete interface Cronet_UrlRequest is implemented by Cronet. // // The app can implement these for testing / mocking. -// typedef Cronet_RESULT (*Cronet_UrlRequest_InitWithParamsFunc)( -// Cronet_UrlRequestPtr self, -// Cronet_EnginePtr engine, -// Cronet_String url, -// Cronet_UrlRequestParamsPtr params, -// Cronet_UrlRequestCallbackPtr callback, -// Cronet_ExecutorPtr executor); -// typedef Cronet_RESULT (*Cronet_UrlRequest_StartFunc)(Cronet_UrlRequestPtr self); -// typedef Cronet_RESULT (*Cronet_UrlRequest_FollowRedirectFunc)( -// Cronet_UrlRequestPtr self); -// typedef Cronet_RESULT (*Cronet_UrlRequest_ReadFunc)(Cronet_UrlRequestPtr self, -// Cronet_BufferPtr buffer); -// typedef void (*Cronet_UrlRequest_CancelFunc)(Cronet_UrlRequestPtr self); -// typedef bool (*Cronet_UrlRequest_IsDoneFunc)(Cronet_UrlRequestPtr self); -// typedef void (*Cronet_UrlRequest_GetStatusFunc)( -// Cronet_UrlRequestPtr self, -// Cronet_UrlRequestStatusListenerPtr listener); +typedef Cronet_RESULT (*Cronet_UrlRequest_InitWithParamsFunc)( + Cronet_UrlRequestPtr self, + Cronet_EnginePtr engine, + Cronet_String url, + Cronet_UrlRequestParamsPtr params, + Cronet_UrlRequestCallbackPtr callback, + Cronet_ExecutorPtr executor); +typedef Cronet_RESULT (*Cronet_UrlRequest_StartFunc)(Cronet_UrlRequestPtr self); +typedef Cronet_RESULT (*Cronet_UrlRequest_FollowRedirectFunc)( + Cronet_UrlRequestPtr self); +typedef Cronet_RESULT (*Cronet_UrlRequest_ReadFunc)(Cronet_UrlRequestPtr self, + Cronet_BufferPtr buffer); +typedef void (*Cronet_UrlRequest_CancelFunc)(Cronet_UrlRequestPtr self); +typedef bool (*Cronet_UrlRequest_IsDoneFunc)(Cronet_UrlRequestPtr self); +typedef void (*Cronet_UrlRequest_GetStatusFunc)( + Cronet_UrlRequestPtr self, + Cronet_UrlRequestStatusListenerPtr listener); // // Concrete interface Cronet_UrlRequest is implemented by Cronet. // // The app can use this for testing / mocking. -// CRONET_EXPORT Cronet_UrlRequestPtr Cronet_UrlRequest_CreateWith( -// Cronet_UrlRequest_InitWithParamsFunc InitWithParamsFunc, -// Cronet_UrlRequest_StartFunc StartFunc, -// Cronet_UrlRequest_FollowRedirectFunc FollowRedirectFunc, -// Cronet_UrlRequest_ReadFunc ReadFunc, -// Cronet_UrlRequest_CancelFunc CancelFunc, -// Cronet_UrlRequest_IsDoneFunc IsDoneFunc, -// Cronet_UrlRequest_GetStatusFunc GetStatusFunc); +CRONET_EXPORT Cronet_UrlRequestPtr Cronet_UrlRequest_CreateWith( + Cronet_UrlRequest_InitWithParamsFunc InitWithParamsFunc, + Cronet_UrlRequest_StartFunc StartFunc, + Cronet_UrlRequest_FollowRedirectFunc FollowRedirectFunc, + Cronet_UrlRequest_ReadFunc ReadFunc, + Cronet_UrlRequest_CancelFunc CancelFunc, + Cronet_UrlRequest_IsDoneFunc IsDoneFunc, + Cronet_UrlRequest_GetStatusFunc GetStatusFunc); // /////////////////////// // // Abstract interface Cronet_RequestFinishedInfoListener is implemented by the @@ -720,10 +720,10 @@ void Cronet_UrlRequest_Cancel(Cronet_UrlRequestPtr self); // // Cronet_Error getters. // CRONET_EXPORT // Cronet_Error_ERROR_CODE Cronet_Error_error_code_get(const Cronet_ErrorPtr self); -// CRONET_EXPORT -// Cronet_String Cronet_Error_message_get(const Cronet_ErrorPtr self); -// CRONET_EXPORT -// int32_t Cronet_Error_internal_error_code_get(const Cronet_ErrorPtr self); +CRONET_EXPORT +Cronet_String Cronet_Error_message_get(const Cronet_ErrorPtr self); +CRONET_EXPORT +int32_t Cronet_Error_internal_error_code_get(const Cronet_ErrorPtr self); // CRONET_EXPORT // bool Cronet_Error_immediately_retryable_get(const Cronet_ErrorPtr self); // CRONET_EXPORT diff --git a/third_party/cronet_impl/sample_executor.cc b/third_party/cronet_impl/sample_executor.cc index 0581835..a0544b4 100644 --- a/third_party/cronet_impl/sample_executor.cc +++ b/third_party/cronet_impl/sample_executor.cc @@ -4,36 +4,51 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "sample_executor.h" +#include "../../src/wrapper.h" #include -extern LIBTYPE handle; - -// cronet function loading and exposing macros -// use IMPORT to expose a API unchanged or just for private use - accessable as func_name -// use P_IMPORT for those API who needs to be wrapped before exposing - accessable as _func_name - -#define IMPORT(r_type, f_name, ...) r_type (* f_name) (__VA_ARGS__) = reinterpret_cast(dlsym(handle, #f_name)) - -#define P_IMPORT(r_type, f_name, ...) r_type (* _ ## f_name) (__VA_ARGS__) = reinterpret_cast(dlsym(handle, #f_name)) /* Executor Only */ -IMPORT(Cronet_ExecutorPtr, Cronet_Executor_CreateWith, Cronet_Executor_ExecuteFunc); -IMPORT(void, Cronet_Executor_SetClientContext, Cronet_ExecutorPtr, Cronet_ClientContext); -IMPORT(void, Cronet_Executor_Destroy, Cronet_ExecutorPtr); -IMPORT(void, Cronet_Runnable_Run, Cronet_RunnablePtr); -IMPORT(void, Cronet_Runnable_Destroy, Cronet_RunnablePtr); -IMPORT(Cronet_ClientContext, Cronet_Executor_GetClientContext, Cronet_ExecutorPtr); +Cronet_ExecutorPtr (*_Cronet_Executor_CreateWith)(Cronet_Executor_ExecuteFunc); +void (*_Cronet_Executor_SetClientContext)( + Cronet_ExecutorPtr self, + Cronet_ClientContext client_context); +Cronet_ClientContext (*_Cronet_Executor_GetClientContext)(Cronet_ExecutorPtr self); +void (*_Cronet_Executor_Destroy)(Cronet_ExecutorPtr self); +void (*_Cronet_Runnable_Run)(Cronet_RunnablePtr self); +void (*_Cronet_Runnable_Destroy)(Cronet_RunnablePtr self); + +void InitCronetExecutorApi(void *executor_createWith, void *executor_setClientContext, + void *executor_getClientContext, + void *executor_destroy, + void *runnable_run, + void *runnable_destroy) { + _Cronet_Executor_CreateWith = reinterpret_cast(executor_createWith); + _Cronet_Executor_SetClientContext = reinterpret_cast + (executor_setClientContext); + _Cronet_Executor_GetClientContext = reinterpret_cast + (executor_getClientContext); + _Cronet_Executor_Destroy = reinterpret_cast(executor_destroy); + _Cronet_Runnable_Run = reinterpret_cast(runnable_run); + _Cronet_Runnable_Destroy = reinterpret_cast(runnable_destroy); +} +// IMPORT(Cronet_ExecutorPtr, Cronet_Executor_CreateWith, Cronet_Executor_ExecuteFunc); +// IMPORT(void, Cronet_Executor_SetClientContext, Cronet_ExecutorPtr, Cronet_ClientContext); +// IMPORT(void, Cronet_Executor_Destroy, Cronet_ExecutorPtr); +// IMPORT(void, Cronet_Runnable_Run, Cronet_RunnablePtr); +// IMPORT(void, Cronet_Runnable_Destroy, Cronet_RunnablePtr); +// IMPORT(Cronet_ClientContext, Cronet_Executor_GetClientContext, Cronet_ExecutorPtr); SampleExecutor::SampleExecutor() : executor_thread_(SampleExecutor::ThreadLoop, this) {} SampleExecutor::~SampleExecutor() { ShutdownExecutor(); - Cronet_Executor_Destroy(executor_); + _Cronet_Executor_Destroy(executor_); } void SampleExecutor::Init() { - executor_ = Cronet_Executor_CreateWith(SampleExecutor::Execute); - Cronet_Executor_SetClientContext(executor_, this); + executor_ = _Cronet_Executor_CreateWith(SampleExecutor::Execute); + _Cronet_Executor_SetClientContext(executor_, this); } Cronet_ExecutorPtr SampleExecutor::GetExecutor() { @@ -70,8 +85,8 @@ void SampleExecutor::RunTasksInQueue() { task_queue_.pop(); } - Cronet_Runnable_Run(runnable); - Cronet_Runnable_Destroy(runnable); + _Cronet_Runnable_Run(runnable); + _Cronet_Runnable_Destroy(runnable); } // Delete remaining tasks. std::queue tasks_to_destroy; @@ -80,7 +95,7 @@ void SampleExecutor::RunTasksInQueue() { tasks_to_destroy.swap(task_queue_); } while (!tasks_to_destroy.empty()) { - Cronet_Runnable_Destroy(tasks_to_destroy.front()); + _Cronet_Runnable_Destroy(tasks_to_destroy.front()); tasks_to_destroy.pop(); } } @@ -97,7 +112,7 @@ void SampleExecutor::Execute(Cronet_RunnablePtr runnable) { } } if (runnable) { - Cronet_Runnable_Destroy(runnable); + _Cronet_Runnable_Destroy(runnable); } else { task_available_.notify_one(); } @@ -106,6 +121,6 @@ void SampleExecutor::Execute(Cronet_RunnablePtr runnable) { void SampleExecutor::Execute(Cronet_ExecutorPtr self, Cronet_RunnablePtr runnable) { auto* executor = - static_cast(Cronet_Executor_GetClientContext(self)); + static_cast(_Cronet_Executor_GetClientContext(self)); executor->Execute(runnable); } From 96636e8d8006d0ec87ac99cfe8123b33ed629286 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Sun, 27 Jun 2021 15:44:24 +0530 Subject: [PATCH 27/42] locate binaries to .dart_tool --- README.md | 2 +- bin/build.dart | 9 ++-- bin/prepare_cronet.dart | 26 +++++----- lib/src/dylib_handler.dart | 51 +++++++++++++++++-- lib/src/third_party/ffigen/find_resource.dart | 4 +- 5 files changed, 67 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 5e8efba..9bf4468 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ You can also test your cronet build independently by following [BUILD.md](third_ ## Building Your Own -1. Make sure you've downloaded your custom version of cronet shared library and filename follows the pattern `cronet..`. Default is: `cronet.86.0.4240.198.so` for linux. Else, you can build cronet from [source](https://www.chromium.org/developers/how-tos/get-the-code) using the [provided instuctions](https://chromium.googlesource.com/chromium/src/+/master/components/cronet/build_instructions.md). Then copy the library to the root of your project. For linux, you can also place the files under `cronet_binaries/linux64` for 64bit linux systems. +1. Make sure you've downloaded your custom version of cronet shared library and filename follows the pattern `cronet.86.0.4240.198.` with a prefix `lib` if on `linux`. Else, you can build cronet from [source](https://www.chromium.org/developers/how-tos/get-the-code) using the [provided instuctions](https://chromium.googlesource.com/chromium/src/+/master/components/cronet/build_instructions.md). Then copy the library to the root of your project. For linux, you can also place the files under `.dart_tool/cronet/linux64` for 64bit linux systems. 2. Run `dart run cronet:build` from the root of your project. diff --git a/bin/build.dart b/bin/build.dart index b1b91b6..79dcb12 100644 --- a/bin/build.dart +++ b/bin/build.dart @@ -16,18 +16,17 @@ void main(List args) { final ansi = Ansi(Ansi.terminalSupportsAnsi); if (args.contains('-h')) { - print('dart run cronet:build [cronet_version]'); + print('dart run cronet:build'); } - final version = args.isEmpty ? cronetVersion : args[0]; if (Platform.isLinux) { - buildWrapperLinux(version); + buildWrapperLinux(); } else if (Platform.isWindows) { - buildWrapperWindows(version); + buildWrapperWindows(); } else { logger.stderr('${ansi.red}Unsupported platform.${ansi.none}'); return; } - final cronetName = getDylibName('cronet.$version'); + final cronetName = getDylibName('cronet.$cronetVersion'); if (!isCronetAvailable(Platform.isLinux ? 'linux64' : 'windows64')) { logger.stderr('${ansi.yellow}Make sure that your cronet shared library' ' is named as $cronetName and either placed in ${Directory.current.path}' diff --git a/bin/prepare_cronet.dart b/bin/prepare_cronet.dart index 53bd5fe..04156e0 100644 --- a/bin/prepare_cronet.dart +++ b/bin/prepare_cronet.dart @@ -14,7 +14,7 @@ import 'package:cronet/src/constants.dart'; import 'package:cli_util/cli_logging.dart' show Ansi, Logger; /// Builds the `wrapper` shared library for linux. -bool buildWrapperLinux([String? version]) { +bool buildWrapperLinux() { final wrapperPath = wrapperSourcePath(); final pwd = Directory.current; const compiler = 'g++'; @@ -45,14 +45,16 @@ bool buildWrapperLinux([String? version]) { print(result.stdout); print(result.stderr); if (result.exitCode != 0) return false; - print('Copying wrapper to project root...'); - File('$wrapperPath/$outputName').copySync(outputName); + print("Copying wrapper to project's .dart_tool..."); + Directory('.dart_tool/cronet/linux64').createSync(recursive: true); + File('$wrapperPath/$outputName') + .copySync('.dart_tool/cronet/linux64/$outputName'); if (result.exitCode != 0) return false; return true; } /// Builds the `wrapper` shared library for windows. -bool buildWrapperWindows([String? version]) { +bool buildWrapperWindows() { final logger = Logger.standard(); final ansi = Ansi(Ansi.terminalSupportsAnsi); final wrapperPath = wrapperSourcePath(); @@ -68,8 +70,7 @@ bool buildWrapperWindows([String? version]) { logger.stdout("${ansi.red}Build failed.${ansi.none}"); logger.stdout( 'Open ${ansi.yellow}x64 Native Tools Command Prompt for VS 2019.${ansi.none} Then run:\n'); - logger.stdout( - 'cd ${pwd.path}\ndart run cronet:build ${version ?? cronetVersion}'); + logger.stdout('cd ${pwd.path}\ndart run cronet:build'); return false; } var result = Process.runSync('cmake', ['--build', 'out']); @@ -77,7 +78,9 @@ bool buildWrapperWindows([String? version]) { print(result.stderr); if (result.exitCode != 0) return false; Directory.current = pwd; - File('$wrapperPath\\out\\Debug\\wrapper.dll').copySync('wrapper.dll'); + Directory('.dart_tool\\cronet\\windows64').createSync(recursive: true); + File('$wrapperPath\\out\\Debug\\wrapper.dll') + .copySync('.dart_tool\\cronet\\windows64\\wrapper.dll'); return true; } @@ -102,13 +105,8 @@ void extract(String fileName, [String dir = '']) { /// Places downloaded binaries to proper location. void placeBinaries(String platform, String fileName) { print('Extracting Cronet for $platform'); - - if (platform.startsWith('windows')) { - extract(fileName); - } else { - Directory('cronet_binaries').createSync(); - extract(fileName, 'cronet_binaries/'); - } + Directory('.dart_tool/cronet').createSync(recursive: true); + extract(fileName, '.dart_tool/cronet/'); print('Done! Cleaning up...'); File(fileName).deleteSync(); diff --git a/lib/src/dylib_handler.dart b/lib/src/dylib_handler.dart index 63bc25c..93fd0f0 100644 --- a/lib/src/dylib_handler.dart +++ b/lib/src/dylib_handler.dart @@ -18,18 +18,31 @@ bool _doesFileExist(Uri uri) { /// Resolves the absolute path of a resource (usually a dylib). /// /// Checks if a dynamic library is located in - -/// 1. Present Working Directory -/// 2. Current script's/executable's directory -/// 3. Current script's/executable's directory's parent +/// 1. Present Working Directory and it's .dart_tool. +/// 2. Current script's/executable's directory and it's .dart_tool. +/// 3. Current script's/executable's directory's parent and it's .dart_tool. /// and returns the absolute path or [null] if can't be resolved. String? _resolveLibUri(String name) { var libUri = Directory.current.uri.resolve(name); + var dartTool = '.dart_tool/cronet/'; // If lib is in Present Working Directory. if (_doesFileExist(libUri)) { return libUri.toFilePath(windows: Platform.isWindows); } + // If lib is in Present Working Directory's .dart_tool folder. + if (Platform.isWindows) { + dartTool += 'windows64'; + } else { + dartTool += 'linux64'; + } + + libUri = Directory.current.uri.resolve('$dartTool/$name'); + if (_doesFileExist(libUri)) { + return libUri.toFilePath(windows: Platform.isWindows); + } + // If lib is in script's directory. libUri = Uri.directory(dirname(Platform.script.path)).resolve(name); @@ -37,6 +50,13 @@ String? _resolveLibUri(String name) { return libUri.toFilePath(windows: Platform.isWindows); } + // If lib is in script's .dart_tool directory. + libUri = + Uri.directory(dirname(Platform.script.path)).resolve('$dartTool/$name'); + if (_doesFileExist(libUri)) { + return libUri.toFilePath(windows: Platform.isWindows); + } + // If lib is in executable's directory. libUri = Uri.directory(dirname(Platform.resolvedExecutable)).resolve(name); @@ -44,6 +64,14 @@ String? _resolveLibUri(String name) { return libUri.toFilePath(windows: Platform.isWindows); } + // If lib is in executable's .dart_tool directory. + libUri = Uri.directory(dirname(Platform.resolvedExecutable)) + .resolve('$dartTool/$name'); + + if (_doesFileExist(libUri)) { + return libUri.toFilePath(windows: Platform.isWindows); + } + // If lib is in script's directory's parent. libUri = Uri.directory(dirname(Platform.script.path)).resolve('../$name'); @@ -52,6 +80,15 @@ String? _resolveLibUri(String name) { return libUri.toFilePath(windows: Platform.isWindows); } + // If lib is in script's directory's parent's .dart_tool. + + libUri = Uri.directory(dirname(Platform.script.path)) + .resolve('../$dartTool/$name'); + + if (_doesFileExist(libUri)) { + return libUri.toFilePath(windows: Platform.isWindows); + } + // If lib is in executable's directory's parent. libUri = @@ -61,6 +98,14 @@ String? _resolveLibUri(String name) { return libUri.toFilePath(windows: Platform.isWindows); } + // If lib is in executable's directory's parent's .dart_tool. + libUri = Uri.directory(dirname(Platform.resolvedExecutable)) + .resolve('..../$dartTool/$name'); + + if (_doesFileExist(libUri)) { + return libUri.toFilePath(windows: Platform.isWindows); + } + return null; } diff --git a/lib/src/third_party/ffigen/find_resource.dart b/lib/src/third_party/ffigen/find_resource.dart index 4ef1ca2..698c14f 100644 --- a/lib/src/third_party/ffigen/find_resource.dart +++ b/lib/src/third_party/ffigen/find_resource.dart @@ -53,8 +53,8 @@ String wrapperSourcePath() { /// Checks if cronet binaries are already available in the project. bool isCronetAvailable(String platform) { - final cronetBinaries = Directory.fromUri( - Directory.current.uri.resolve('cronet_binaries/$platform/')) + final cronetBinaries = File.fromUri(Directory.current.uri + .resolve('.dart_tool/cronet/$platform/${getCronetName(platform)}')) .existsSync(); final inRoot = File.fromUri(Directory.current.uri.resolve(getWrapperName(platform))) From d3e4d848fd23aa20c71322f91e81c1f5bf895947 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Mon, 28 Jun 2021 19:25:19 +0530 Subject: [PATCH 28/42] formatting and sanity checks --- lib/src/http_callback_handler.dart | 5 +- lib/src/http_client.dart | 3 + lib/src/http_client_request.dart | 1 + src/wrapper.cc | 219 +++++++++++---------- src/wrapper.h | 49 ++--- third_party/cronet_impl/sample_executor.cc | 66 ++++--- 6 files changed, 184 insertions(+), 159 deletions(-) diff --git a/lib/src/http_callback_handler.dart b/lib/src/http_callback_handler.dart index 23796fb..a83ee61 100644 --- a/lib/src/http_callback_handler.dart +++ b/lib/src/http_callback_handler.dart @@ -130,8 +130,11 @@ class CallbackHandler { 299, () => cleanUpRequest(reqPtr, cleanUpClient)); log('Response started'); - cronet.Cronet_UrlRequest_Read( + final res = cronet.Cronet_UrlRequest_Read( reqPtr, Pointer.fromAddress(args[1]).cast()); + if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { + throw UrlRequestException(res); + } } break; // Read a chunk of data. diff --git a/lib/src/http_client.dart b/lib/src/http_client.dart index 8026c74..84e2694 100644 --- a/lib/src/http_client.dart +++ b/lib/src/http_client.dart @@ -68,6 +68,7 @@ class HttpClient { this.brotli = true, this.acceptLanguage = 'en_US', }) : _cronetEngine = _cronet.Cronet_Engine_Create() { + if (_cronetEngine == nullptr) throw Error(); // Initialize Dart Native API dynamically. _wrapper.InitDartApiDL(NativeApi.initializeApiDLData); _wrapper.registerHttpClient( @@ -91,6 +92,7 @@ class HttpClient { _cronet.addresses.Cronet_Runnable_Destroy.cast()); // Starting the engine with parameters. final engineParams = _cronet.Cronet_EngineParams_Create(); + if (engineParams == nullptr) throw Error(); _cronet.Cronet_EngineParams_user_agent_set( engineParams, userAgent.toNativeUtf8().cast()); @@ -114,6 +116,7 @@ class HttpClient { } for (final quicHint in quicHints) { final hint = _cronet.Cronet_QuicHint_Create(); + if (hint == nullptr) throw Error(); _cronet.Cronet_QuicHint_host_set( hint, quicHint.host.toNativeUtf8().cast()); _cronet.Cronet_QuicHint_port_set(hint, quicHint.port); diff --git a/lib/src/http_client_request.dart b/lib/src/http_client_request.dart index 6ab7dc5..b9ddf9e 100644 --- a/lib/src/http_client_request.dart +++ b/lib/src/http_client_request.dart @@ -93,6 +93,7 @@ class HttpClientRequestImpl implements HttpClientRequest { // Starts the request. void _startRequest() { final requestParams = _cronet.Cronet_UrlRequestParams_Create(); + if (requestParams == nullptr) throw Error(); _cronet.Cronet_UrlRequestParams_http_method_set( requestParams, _method.toNativeUtf8().cast()); diff --git a/src/wrapper.cc b/src/wrapper.cc index ec4b3a4..9904d38 100644 --- a/src/wrapper.cc +++ b/src/wrapper.cc @@ -1,13 +1,12 @@ -// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +#include "wrapper.h" +#include "../third_party/cronet_impl/sample_executor.h" #include "../third_party/dart-sdk/dart_api.h" #include "../third_party/dart-sdk/dart_native_api.h" #include "../third_party/dart-sdk/dart_tools_api.h" -// #include"dart_api_dl.c" -#include "wrapper.h" -#include "../third_party/cronet_impl/sample_executor.h" #include #include #include @@ -29,52 +28,55 @@ Cronet_UrlRequestCallbackPtr (*_Cronet_UrlRequestCallback_CreateWith)( Cronet_UrlRequestCallback_OnFailedFunc OnFailedFunc, Cronet_UrlRequestCallback_OnCanceledFunc OnCanceledFunc); Cronet_RESULT (*_Cronet_UrlRequest_InitWithParams)( - Cronet_UrlRequestPtr self, - Cronet_EnginePtr engine, - Cronet_String url, - Cronet_UrlRequestParamsPtr params, - Cronet_UrlRequestCallbackPtr callback, + Cronet_UrlRequestPtr self, Cronet_EnginePtr engine, Cronet_String url, + Cronet_UrlRequestParamsPtr params, Cronet_UrlRequestCallbackPtr callback, Cronet_ExecutorPtr executor); //////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////// // Initialize `dart_api_dl.h` -intptr_t InitDartApiDL(void* data) { - return Dart_InitializeApiDL(data); -} +intptr_t InitDartApiDL(void *data) { return Dart_InitializeApiDL(data); } //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // Initialize required cronet functions -void InitCronetApi(void* shutdown, void *destroy, void *buffer_create, - void *buffer_InitWithAlloc, void *UrlRequestCallback_CreateWith, - void *UrlRequest_InitWithParams) { - _Cronet_Engine_Shutdown = reinterpret_cast(shutdown); - _Cronet_Engine_Destroy = reinterpret_cast(destroy); - _Cronet_Buffer_Create = reinterpret_cast(buffer_create); - _Cronet_Buffer_InitWithAlloc = reinterpret_cast(buffer_InitWithAlloc); - _Cronet_UrlRequestCallback_CreateWith = reinterpret_cast(UrlRequestCallback_CreateWith); - _Cronet_UrlRequest_InitWithParams = reinterpret_cast(UrlRequest_InitWithParams); +void InitCronetApi(void *shutdown, void *destroy, void *buffer_create, + void *buffer_InitWithAlloc, + void *UrlRequestCallback_CreateWith, + void *UrlRequest_InitWithParams) { + if (!(shutdown && destroy && buffer_create && buffer_InitWithAlloc && + UrlRequestCallback_CreateWith && UrlRequest_InitWithParams)) { + std::cerr << "Invalid pointer(s): null" << std::endl; + return; + } + _Cronet_Engine_Shutdown = + reinterpret_cast(shutdown); + _Cronet_Engine_Destroy = + reinterpret_cast(destroy); + _Cronet_Buffer_Create = + reinterpret_cast(buffer_create); + _Cronet_Buffer_InitWithAlloc = + reinterpret_cast( + buffer_InitWithAlloc); + _Cronet_UrlRequestCallback_CreateWith = + reinterpret_cast( + UrlRequestCallback_CreateWith); + _Cronet_UrlRequest_InitWithParams = reinterpret_cast(UrlRequest_InitWithParams); } //////////////////////////////////////////////////////////////////////////////// -static void FreeFinalizer(void*, void* value) { - free(value); -} +static void FreeFinalizer(void *, void *value) { free(value); } /* Callback Helpers */ @@ -95,39 +97,43 @@ void registerCallbackHandler(Dart_Port send_port, Cronet_UrlRequestPtr rp) { // // Using this due to the lack of support for asynchronous callbacks in dart:ffi. // See Issue: dart-lang/sdk#37022. -void dispatchCallback(const char* methodname, Cronet_UrlRequestPtr request, Dart_CObject args) { +void dispatchCallback(const char *methodname, Cronet_UrlRequestPtr request, + Dart_CObject args) { Dart_CObject c_method_name; c_method_name.type = Dart_CObject_kString; c_method_name.value.as_string = const_cast(methodname); - Dart_CObject* c_request_arr[] = {&c_method_name, &args}; + Dart_CObject *c_request_arr[] = {&c_method_name, &args}; Dart_CObject c_request; c_request.type = Dart_CObject_kArray; c_request.value.as_array.values = c_request_arr; c_request.value.as_array.length = sizeof(c_request_arr) / sizeof(c_request_arr[0]); - + Dart_PostCObject_DL(requestNativePorts[request], &c_request); } -// Builds the arguments to pass to the Dart side as a parameter to the callbacks. -// [num] is the number of arguments to be passed and rest are the arguments. +// Builds the arguments to pass to the Dart side as a parameter to the +// callbacks. [num] is the number of arguments to be passed and rest are the +// arguments. Dart_CObject callbackArgBuilder(int num, ...) { Dart_CObject c_request_data; va_list valist; va_start(valist, num); - void* request_buffer = malloc(sizeof(uint64_t) * num); - uint64_t* buf = reinterpret_cast(request_buffer); + void *request_buffer = malloc(sizeof(uint64_t) * num); + uint64_t *buf = reinterpret_cast(request_buffer); - for(int i = 0; i < num; i++) { - buf[i] = va_arg(valist,uint64_t); + for (int i = 0; i < num; i++) { + buf[i] = va_arg(valist, uint64_t); } c_request_data.type = Dart_CObject_kExternalTypedData; c_request_data.value.as_external_typed_data.type = Dart_TypedData_kUint64; - c_request_data.value.as_external_typed_data.length = sizeof(uint64_t) * num; // 4 args to pass - c_request_data.value.as_external_typed_data.data = static_cast(request_buffer); + c_request_data.value.as_external_typed_data.length = + sizeof(uint64_t) * num; // 4 args to pass + c_request_data.value.as_external_typed_data.data = + static_cast(request_buffer); c_request_data.value.as_external_typed_data.peer = request_buffer; c_request_data.value.as_external_typed_data.callback = FreeFinalizer; @@ -136,96 +142,99 @@ Dart_CObject callbackArgBuilder(int num, ...) { return c_request_data; } - - /* Engine Cleanup Tasks */ -static void HttpClientDestroy(void* isolate_callback_data, - void* peer) { +static void HttpClientDestroy(void *isolate_callback_data, void *peer) { Cronet_EnginePtr ce = reinterpret_cast(peer); - _Cronet_Engine_Shutdown(ce); + if (_Cronet_Engine_Shutdown(ce) != Cronet_RESULT_SUCCESS) { + std::cerr << "Failed to shut down the cronet engine." << std::endl; + return; + } _Cronet_Engine_Destroy(ce); } -void removeRequest(Cronet_UrlRequestPtr rp) { - requestNativePorts.erase(rp); -} +void removeRequest(Cronet_UrlRequestPtr rp) { requestNativePorts.erase(rp); } // Register our HttpClient object from dart side -void registerHttpClient(Dart_Handle h, Cronet_Engine* ce) { - void* peer = ce; +void registerHttpClient(Dart_Handle h, Cronet_Engine *ce) { + void *peer = ce; intptr_t size = 8; Dart_NewFinalizableHandle_DL(h, peer, size, HttpClientDestroy); } /* URL Callbacks Implementations */ -void OnRedirectReceived( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info, - Cronet_String newLocationUrl) { - dispatchCallback("OnRedirectReceived",request, callbackArgBuilder(2, newLocationUrl, info)); +void OnRedirectReceived(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_String newLocationUrl) { + dispatchCallback("OnRedirectReceived", request, + callbackArgBuilder(2, newLocationUrl, info)); } -void OnResponseStarted( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info) { - +void OnResponseStarted(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info) { + // Create and allocate 32kb buffer. Cronet_BufferPtr buffer = _Cronet_Buffer_Create(); _Cronet_Buffer_InitWithAlloc(buffer, 32 * 1024); - dispatchCallback("OnResponseStarted",request, callbackArgBuilder(2, info, buffer)); + dispatchCallback("OnResponseStarted", request, + callbackArgBuilder(2, info, buffer)); // // Started reading the response. // _Cronet_UrlRequest_Read(request, buffer); - } -void OnReadCompleted( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info, - Cronet_BufferPtr buffer, - uint64_t bytes_read) { - dispatchCallback("OnReadCompleted",request, callbackArgBuilder(4, request, info, buffer, bytes_read)); +void OnReadCompleted(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, Cronet_BufferPtr buffer, + uint64_t bytes_read) { + dispatchCallback("OnReadCompleted", request, + callbackArgBuilder(4, request, info, buffer, bytes_read)); } - -void OnSucceeded(Cronet_UrlRequestCallbackPtr self, Cronet_UrlRequestPtr request, Cronet_UrlResponseInfoPtr info) { - dispatchCallback("OnSucceeded",request, callbackArgBuilder(1, info)); +void OnSucceeded(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, Cronet_UrlResponseInfoPtr info) { + dispatchCallback("OnSucceeded", request, callbackArgBuilder(1, info)); } -void OnFailed( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info, - Cronet_ErrorPtr error) { - dispatchCallback("OnFailed",request, callbackArgBuilder(1, error)); +void OnFailed(Cronet_UrlRequestCallbackPtr self, Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, Cronet_ErrorPtr error) { + dispatchCallback("OnFailed", request, callbackArgBuilder(1, error)); } -void OnCanceled( - Cronet_UrlRequestCallbackPtr self, - Cronet_UrlRequestPtr request, - Cronet_UrlResponseInfoPtr info) { - dispatchCallback("OnCanceled",request, callbackArgBuilder(0)); +void OnCanceled(Cronet_UrlRequestCallbackPtr self, Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info) { + dispatchCallback("OnCanceled", request, callbackArgBuilder(0)); } -ExecutorPtr Create_Executor() { - return new SampleExecutor(); -} +ExecutorPtr Create_Executor() { return new SampleExecutor(); } void Destroy_Executor(ExecutorPtr executor) { - delete reinterpret_cast(executor); + if (executor == nullptr) { + std::cerr << "Invalid executor pointer: null." << std::endl; + return; + } + delete reinterpret_cast(executor); +} + +// NOTE: Changed from original cronet's api. executor & callback params aren't +// needed +Cronet_RESULT Cronet_UrlRequest_Init(Cronet_UrlRequestPtr self, + Cronet_EnginePtr engine, Cronet_String url, + Cronet_UrlRequestParamsPtr params, + ExecutorPtr _executor) { + SampleExecutor *executor = reinterpret_cast(_executor); + if (executor == nullptr) { + std::cerr << "Invalid executor pointer: null." << std::endl; + return Cronet_RESULT_NULL_POINTER_EXECUTOR; + } + executor->Init(); + Cronet_UrlRequestCallbackPtr urCallback = + _Cronet_UrlRequestCallback_CreateWith(OnRedirectReceived, + OnResponseStarted, OnReadCompleted, + OnSucceeded, OnFailed, OnCanceled); + return _Cronet_UrlRequest_InitWithParams(self, engine, url, params, + urCallback, executor->GetExecutor()); } - - -// NOTE: Changed from original cronet's api. executor & callback params aren't needed -Cronet_RESULT Cronet_UrlRequest_Init(Cronet_UrlRequestPtr self, Cronet_EnginePtr engine, Cronet_String url, Cronet_UrlRequestParamsPtr params, ExecutorPtr _executor) { - SampleExecutor* executor = reinterpret_cast(_executor); - executor->Init(); - Cronet_UrlRequestCallbackPtr urCallback = _Cronet_UrlRequestCallback_CreateWith(OnRedirectReceived, OnResponseStarted, OnReadCompleted, - OnSucceeded, OnFailed, OnCanceled); - return _Cronet_UrlRequest_InitWithParams(self, engine, url, params, urCallback, executor->GetExecutor()); -} diff --git a/src/wrapper.h b/src/wrapper.h index cc99d54..06e7853 100644 --- a/src/wrapper.h +++ b/src/wrapper.h @@ -5,48 +5,53 @@ #ifndef WRAPPER_H_ #define WRAPPER_H_ -#include "../third_party/dart-sdk/dart_api_dl.h" #include "../third_party/cronet/cronet.idl_c.h" +#include "../third_party/dart-sdk/dart_api_dl.h" -#include"wrapper_export.h" -#include +#include "wrapper_export.h" -#ifdef __cplusplus +#include +#ifdef __cplusplus extern "C" { #endif #include -DART_EXPORT void dispatchCallback(char* methodname); -DART_EXPORT intptr_t InitDartApiDL(void* data); -DART_EXPORT void InitCronetApi(void* shutdown, void *destroy, void *buffer_create, - void *buffer_InitWithAlloc, void *UrlRequestCallback_CreateWith, - void *UrlRequest_InitWithParams); -DART_EXPORT void InitCronetExecutorApi(void *executor_createWith, void *executor_setClientContext, - void *executor_getClientContext, - void *executor_destroy, - void *runnable_run, - void *runnable_destroy); -typedef void* ExecutorPtr; +DART_EXPORT void dispatchCallback(char *methodname); +DART_EXPORT intptr_t InitDartApiDL(void *data); +DART_EXPORT void InitCronetApi(void *shutdown, void *destroy, + void *buffer_create, void *buffer_InitWithAlloc, + void *UrlRequestCallback_CreateWith, + void *UrlRequest_InitWithParams); +DART_EXPORT void InitCronetExecutorApi(void *executor_createWith, + void *executor_setClientContext, + void *executor_getClientContext, + void *executor_destroy, + void *runnable_run, + void *runnable_destroy); +typedef void *ExecutorPtr; DART_EXPORT ExecutorPtr Create_Executor(); DART_EXPORT void Destroy_Executor(ExecutorPtr executor); -DART_EXPORT void registerHttpClient(Dart_Handle h, Cronet_Engine* ce); -DART_EXPORT void registerCallbackHandler(Dart_Port nativePort, Cronet_UrlRequest* rp); -DART_EXPORT void removeRequest(Cronet_UrlRequest* rp); -DART_EXPORT Cronet_RESULT Cronet_UrlRequest_Init(Cronet_UrlRequest* self, Cronet_Engine* engine, Cronet_String url, Cronet_UrlRequestParams* params, ExecutorPtr _executor); +DART_EXPORT void registerHttpClient(Dart_Handle h, Cronet_Engine *ce); +DART_EXPORT void registerCallbackHandler(Dart_Port nativePort, + Cronet_UrlRequest *rp); +DART_EXPORT void removeRequest(Cronet_UrlRequest *rp); +DART_EXPORT Cronet_RESULT Cronet_UrlRequest_Init( + Cronet_UrlRequest *self, Cronet_Engine *engine, Cronet_String url, + Cronet_UrlRequestParams *params, ExecutorPtr _executor); /* executor only */ -typedef void (*Cronet_Executor_ExecuteFunc)(Cronet_Executor* self, Cronet_Runnable* command); - +typedef void (*Cronet_Executor_ExecuteFunc)(Cronet_Executor *self, + Cronet_Runnable *command); #ifdef __cplusplus } #endif -#endif // WRAPPER_H_ +#endif // WRAPPER_H_ diff --git a/third_party/cronet_impl/sample_executor.cc b/third_party/cronet_impl/sample_executor.cc index a0544b4..561e2ab 100644 --- a/third_party/cronet_impl/sample_executor.cc +++ b/third_party/cronet_impl/sample_executor.cc @@ -10,34 +10,41 @@ /* Executor Only */ Cronet_ExecutorPtr (*_Cronet_Executor_CreateWith)(Cronet_Executor_ExecuteFunc); -void (*_Cronet_Executor_SetClientContext)( - Cronet_ExecutorPtr self, - Cronet_ClientContext client_context); -Cronet_ClientContext (*_Cronet_Executor_GetClientContext)(Cronet_ExecutorPtr self); +void (*_Cronet_Executor_SetClientContext)(Cronet_ExecutorPtr self, + Cronet_ClientContext client_context); +Cronet_ClientContext (*_Cronet_Executor_GetClientContext)( + Cronet_ExecutorPtr self); void (*_Cronet_Executor_Destroy)(Cronet_ExecutorPtr self); void (*_Cronet_Runnable_Run)(Cronet_RunnablePtr self); void (*_Cronet_Runnable_Destroy)(Cronet_RunnablePtr self); -void InitCronetExecutorApi(void *executor_createWith, void *executor_setClientContext, - void *executor_getClientContext, - void *executor_destroy, - void *runnable_run, - void *runnable_destroy) { - _Cronet_Executor_CreateWith = reinterpret_cast(executor_createWith); - _Cronet_Executor_SetClientContext = reinterpret_cast - (executor_setClientContext); - _Cronet_Executor_GetClientContext = reinterpret_cast - (executor_getClientContext); - _Cronet_Executor_Destroy = reinterpret_cast(executor_destroy); - _Cronet_Runnable_Run = reinterpret_cast(runnable_run); - _Cronet_Runnable_Destroy = reinterpret_cast(runnable_destroy); +void InitCronetExecutorApi(void *executor_createWith, + void *executor_setClientContext, + void *executor_getClientContext, + void *executor_destroy, void *runnable_run, + void *runnable_destroy) { + if (!(executor_createWith && executor_setClientContext && + executor_getClientContext && executor_destroy && runnable_run && + runnable_destroy)) { + std::cerr << "Invalid pointer(s): null" << std::endl; + return; + } + _Cronet_Executor_CreateWith = + reinterpret_cast( + executor_createWith); + _Cronet_Executor_SetClientContext = + reinterpret_cast( + executor_setClientContext); + _Cronet_Executor_GetClientContext = + reinterpret_cast( + executor_getClientContext); + _Cronet_Executor_Destroy = + reinterpret_cast(executor_destroy); + _Cronet_Runnable_Run = + reinterpret_cast(runnable_run); + _Cronet_Runnable_Destroy = + reinterpret_cast(runnable_destroy); } -// IMPORT(Cronet_ExecutorPtr, Cronet_Executor_CreateWith, Cronet_Executor_ExecuteFunc); -// IMPORT(void, Cronet_Executor_SetClientContext, Cronet_ExecutorPtr, Cronet_ClientContext); -// IMPORT(void, Cronet_Executor_Destroy, Cronet_ExecutorPtr); -// IMPORT(void, Cronet_Runnable_Run, Cronet_RunnablePtr); -// IMPORT(void, Cronet_Runnable_Destroy, Cronet_RunnablePtr); -// IMPORT(Cronet_ClientContext, Cronet_Executor_GetClientContext, Cronet_ExecutorPtr); SampleExecutor::SampleExecutor() : executor_thread_(SampleExecutor::ThreadLoop, this) {} @@ -51,9 +58,7 @@ void SampleExecutor::Init() { _Cronet_Executor_SetClientContext(executor_, this); } -Cronet_ExecutorPtr SampleExecutor::GetExecutor() { - return executor_; -} +Cronet_ExecutorPtr SampleExecutor::GetExecutor() { return executor_; } void SampleExecutor::ShutdownExecutor() { // Break tasks loop. { @@ -69,7 +74,7 @@ void SampleExecutor::RunTasksInQueue() { while (true) { Cronet_RunnablePtr runnable = nullptr; { - + // Wait for a task to run or stop signal. std::unique_lock lock(lock_); while (task_queue_.empty() && !stop_thread_loop_) { @@ -83,7 +88,6 @@ void SampleExecutor::RunTasksInQueue() { } runnable = task_queue_.front(); task_queue_.pop(); - } _Cronet_Runnable_Run(runnable); _Cronet_Runnable_Destroy(runnable); @@ -100,7 +104,7 @@ void SampleExecutor::RunTasksInQueue() { } } /* static */ -void SampleExecutor::ThreadLoop(SampleExecutor* executor) { +void SampleExecutor::ThreadLoop(SampleExecutor *executor) { executor->RunTasksInQueue(); } void SampleExecutor::Execute(Cronet_RunnablePtr runnable) { @@ -120,7 +124,7 @@ void SampleExecutor::Execute(Cronet_RunnablePtr runnable) { /* static */ void SampleExecutor::Execute(Cronet_ExecutorPtr self, Cronet_RunnablePtr runnable) { - auto* executor = - static_cast(_Cronet_Executor_GetClientContext(self)); + auto *executor = + static_cast(_Cronet_Executor_GetClientContext(self)); executor->Execute(runnable); } From 5958aad69455a25ff744302992d632f32f34a8b6 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Tue, 29 Jun 2021 12:22:31 +0530 Subject: [PATCH 29/42] add licence & minor refactors --- lib/cronet.dart | 4 +- lib/src/enums.dart | 13 +- lib/src/http_callback_handler.dart | 9 +- lib/src/http_client.dart | 6 +- lib/src/http_client_request.dart | 27 +- lib/src/quic_hint.dart | 1 + lib/src/third_party/cronet/LICENSE | 2327 +++++++++++++++++ lib/src/third_party/cronet/ffigen.yaml | 10 +- .../cronet/generated_bindings.dart | 3 +- lib/src/wrapper/ffigen.yaml | 4 +- lib/src/wrapper/generated_bindings.dart | 74 +- pubspec.yaml | 1 - src/wrapper.cc | 34 +- src/wrapper.h | 7 +- third_party/cronet/LICENSE | 2327 +++++++++++++++++ third_party/cronet_impl/LICENSE | 2327 +++++++++++++++++ third_party/cronet_sample/LICENSE | 2327 +++++++++++++++++ 17 files changed, 9401 insertions(+), 100 deletions(-) create mode 100644 lib/src/third_party/cronet/LICENSE create mode 100644 third_party/cronet/LICENSE create mode 100644 third_party/cronet_impl/LICENSE create mode 100644 third_party/cronet_sample/LICENSE diff --git a/lib/cronet.dart b/lib/cronet.dart index 3e3b219..b96e21a 100644 --- a/lib/cronet.dart +++ b/lib/cronet.dart @@ -2,9 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +export 'src/enums.dart'; +export 'src/exceptions.dart'; export 'src/http_client.dart'; export 'src/http_client_request.dart' hide HttpClientRequestImpl; export 'src/http_client_response.dart' hide HttpClientResponseImpl; export 'src/quic_hint.dart'; -export 'src/enums.dart'; -export 'src/exceptions.dart'; diff --git a/lib/src/enums.dart b/lib/src/enums.dart index 5fd6d55..0ea9a26 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -2,5 +2,14 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -/// Defines the available http protocols supported by cronet. -enum HttpProtocol { quic, http2, http } +/// Defines the available http protocols supported by Cronet. +enum HttpProtocol { + /// HTTP/2 with QUIC. + quic, + + /// HTTP/2 without QUIC. + http2, + + /// HTTP/1.1. + http +} diff --git a/lib/src/http_callback_handler.dart b/lib/src/http_callback_handler.dart index a83ee61..ef16c01 100644 --- a/lib/src/http_callback_handler.dart +++ b/lib/src/http_callback_handler.dart @@ -58,15 +58,15 @@ class CallbackHandler { // // We need to call this then whenever we are done with the request. void cleanUpRequest( - Pointer reqPtr, Function cleanUpClient) { + Pointer reqPtr, void Function() cleanUpClient) { receivePort.close(); - wrapper.removeRequest(reqPtr.cast()); + wrapper.RemoveRequest(reqPtr.cast()); cleanUpClient(); } /// Checks status of an URL response. int statusChecker(Pointer respInfoPtr, int lBound, - int uBound, Function callback) { + int uBound, void Function() callback) { final respCode = cronet.Cronet_UrlResponseInfo_http_status_code_get(respInfoPtr); if (!(respCode >= lBound && respCode <= uBound)) { @@ -86,7 +86,8 @@ class CallbackHandler { /// /// This also invokes the appropriate callbacks that are registered, /// according to the network events sent from cronet side. - void listen(Pointer reqPtr, Function cleanUpClient) { + void listen( + Pointer reqPtr, void Function() cleanUpClient) { // Registers the listener on the receivePort. // // The message parameter contains both the name of the event and diff --git a/lib/src/http_client.dart b/lib/src/http_client.dart index 84e2694..81bebd1 100644 --- a/lib/src/http_client.dart +++ b/lib/src/http_client.dart @@ -10,10 +10,10 @@ import 'package:ffi/ffi.dart'; import 'dylib_handler.dart'; import 'enums.dart'; import 'exceptions.dart'; -import 'third_party/cronet/generated_bindings.dart'; -import 'wrapper/generated_bindings.dart' as wrapper; import 'http_client_request.dart'; import 'quic_hint.dart'; +import 'third_party/cronet/generated_bindings.dart'; +import 'wrapper/generated_bindings.dart' as wrapper; // Cronet library is loaded in global scope. final _cronet = Cronet(loadCronet()); @@ -71,7 +71,7 @@ class HttpClient { if (_cronetEngine == nullptr) throw Error(); // Initialize Dart Native API dynamically. _wrapper.InitDartApiDL(NativeApi.initializeApiDLData); - _wrapper.registerHttpClient( + _wrapper.RegisterHttpClient( this, _cronetEngine.cast()); // Registers few cronet functions that are required by the wrapper. _wrapper.InitCronetApi( diff --git a/lib/src/http_client_request.dart b/lib/src/http_client_request.dart index b9ddf9e..0c1f469 100644 --- a/lib/src/http_client_request.dart +++ b/lib/src/http_client_request.dart @@ -11,10 +11,10 @@ import 'dart:isolate'; import 'package:ffi/ffi.dart'; import 'exceptions.dart'; +import 'http_callback_handler.dart'; +import 'http_client_response.dart'; import 'third_party/cronet/generated_bindings.dart'; import 'wrapper/generated_bindings.dart' as wrapper; -import 'http_client_response.dart'; -import 'http_callback_handler.dart'; /// HTTP request for a client connection. /// @@ -67,13 +67,13 @@ class HttpClientRequestImpl implements HttpClientRequest { final Cronet _cronet; final wrapper.Wrapper _wrapper; final Pointer _cronetEngine; - final CallbackHandler _cbh; + final CallbackHandler _callbackHandler; final Pointer _request; /// Holds the function to clean up after the request is done (if nessesary). /// /// Implemented by: http_client.dart. - final Function _clientCleanup; + final void Function(HttpClientRequest) _clientCleanup; @override Encoding encoding; @@ -82,11 +82,12 @@ class HttpClientRequestImpl implements HttpClientRequest { HttpClientRequestImpl(this._uri, this._method, this._cronet, this._wrapper, this._cronetEngine, this._clientCleanup, {this.encoding = utf8}) - : _cbh = CallbackHandler( + : _callbackHandler = CallbackHandler( _cronet, _wrapper, _wrapper.Create_Executor(), ReceivePort()), _request = _cronet.Cronet_UrlRequest_Create() { // Register the native port to C side. - _wrapper.registerCallbackHandler(_cbh.receivePort.sendPort.nativePort, + _wrapper.RegisterCallbackHandler( + _callbackHandler.receivePort.sendPort.nativePort, _request.cast()); } @@ -102,7 +103,7 @@ class HttpClientRequestImpl implements HttpClientRequest { _cronetEngine.cast(), _uri.toString().toNativeUtf8().cast(), requestParams.cast(), - _cbh.executor); + _callbackHandler.executor); if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { throw UrlRequestException(res); @@ -112,7 +113,7 @@ class HttpClientRequestImpl implements HttpClientRequest { if (res2 != Cronet_RESULT.Cronet_RESULT_SUCCESS) { throw UrlRequestException(res2); } - _cbh.listen(_request, () => _clientCleanup(this)); + _callbackHandler.listen(_request, () => _clientCleanup(this)); } /// Returns [Future] of [HttpClientResponse] which can be listened for server response. @@ -122,7 +123,7 @@ class HttpClientRequestImpl implements HttpClientRequest { Future close() { return Future(() { _startRequest(); - return HttpClientResponseImpl(_cbh.stream); + return HttpClientResponseImpl(_callbackHandler.stream); }); } @@ -136,17 +137,17 @@ class HttpClientRequestImpl implements HttpClientRequest { /// Follow the redirects. @override - bool get followRedirects => _cbh.followRedirects; + bool get followRedirects => _callbackHandler.followRedirects; set followRedirects(bool follow) { - _cbh.followRedirects = follow; + _callbackHandler.followRedirects = follow; } /// Maximum numbers of redirects to follow. /// Have no effect if [followRedirects] is set to false. @override - int get maxRedirects => _cbh.maxRedirects; + int get maxRedirects => _callbackHandler.maxRedirects; set maxRedirects(int redirects) { - _cbh.maxRedirects = redirects; + _callbackHandler.maxRedirects = redirects; } /// The uri of the request. diff --git a/lib/src/quic_hint.dart b/lib/src/quic_hint.dart index 59cd3b0..44a9f20 100644 --- a/lib/src/quic_hint.dart +++ b/lib/src/quic_hint.dart @@ -2,6 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +/// Hints to use with Quic protocol. class QuicHint { final String host; final int port; diff --git a/lib/src/third_party/cronet/LICENSE b/lib/src/third_party/cronet/LICENSE new file mode 100644 index 0000000..03c4569 --- /dev/null +++ b/lib/src/third_party/cronet/LICENSE @@ -0,0 +1,2327 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +double_conversion +-------------------- +Copyright 2006-2011, the V8 project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +dynamic_annotations +-------------------- +/* Copyright (c) 2008-2009, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * --- + * Author: Kostya Serebryany + */ + +-------------------- +libevent +-------------------- +Libevent is available for use under the following license, commonly known +as the 3-clause (or "modified") BSD license: + +============================== +Copyright (c) 2000-2007 Niels Provos +Copyright (c) 2007-2010 Niels Provos and Nick Mathewson + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +============================== + +Portions of Libevent are based on works by others, also made available by +them under the three-clause BSD license above. The copyright notices are +available in the corresponding source files; the license is as above. Here's +a list: + +log.c: + Copyright (c) 2000 Dug Song + Copyright (c) 1993 The Regents of the University of California. + +strlcpy.c: + Copyright (c) 1998 Todd C. Miller + +win32.c: + Copyright (c) 2003 Michael A. Davis + +evport.c: + Copyright (c) 2007 Sun Microsystems + +min_heap.h: + Copyright (c) 2006 Maxim Yegorushkin + +tree.h: + Copyright 2002 Niels Provos + +-------------------- +symbolize +-------------------- +// Copyright (c) 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +xdg_mime +-------------------- +Licensed under the Academic Free License version 2.0 (below) +Or under the following terms: + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the +Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. + + +-------------------------------------------------------------------------------- +Academic Free License v. 2.0 +-------------------------------------------------------------------------------- + +This Academic Free License (the "License") applies to any original work of +authorship (the "Original Work") whose owner (the "Licensor") has placed the +following notice immediately following the copyright notice for the Original +Work: + +Licensed under the Academic Free License version 2.0 +1) Grant of Copyright License. Licensor hereby grants You a world-wide, +royalty-free, non-exclusive, perpetual, sublicenseable license to do the +following: + +a) to reproduce the Original Work in copies; +b) to prepare derivative works ("Derivative Works") based upon the Original + Work; +c) to distribute copies of the Original Work and Derivative Works to the + public; +d) to perform the Original Work publicly; and +e) to display the Original Work publicly. + +2) Grant of Patent License. Licensor hereby grants You a world-wide, +royalty-free, non-exclusive, perpetual, sublicenseable license, under patent +claims owned or controlled by the Licensor that are embodied in the Original +Work as furnished by the Licensor, to make, use, sell and offer for sale the +Original Work and Derivative Works. + +3) Grant of Source Code License. The term "Source Code" means the preferred +form of the Original Work for making modifications to it and all available +documentation describing how to modify the Original Work. Licensor hereby +agrees to provide a machine-readable copy of the Source Code of the Original +Work along with each copy of the Original Work that Licensor distributes. +Licensor reserves the right to satisfy this obligation by placing a +machine-readable copy of the Source Code in an information repository +reasonably calculated to permit inexpensive and convenient access by You for as +long as Licensor continues to distribute the Original Work, and by publishing +the address of that information repository in a notice immediately following +the copyright notice that applies to the Original Work. + +4) Exclusions From License Grant. Neither the names of Licensor, nor the names +of any contributors to the Original Work, nor any of their trademarks or +service marks, may be used to endorse or promote products derived from this +Original Work without express prior written permission of the Licensor. Nothing +in this License shall be deemed to grant any rights to trademarks, copyrights, +patents, trade secrets or any other intellectual property of Licensor except as +expressly stated herein. No patent license is granted to make, use, sell or +offer to sell embodiments of any patent claims other than the licensed claims +defined in Section 2. No right is granted to the trademarks of Licensor even if +such marks are included in the Original Work. Nothing in this License shall be +interpreted to prohibit Licensor from licensing under different terms from this +License any Original Work that Licensor otherwise would have a right to +license. + +5) This section intentionally omitted. + +6) Attribution Rights. You must retain, in the Source Code of any Derivative +Works that You create, all copyright, patent or trademark notices from the +Source Code of the Original Work, as well as any notices of licensing and any +descriptive text identified therein as an "Attribution Notice." You must cause +the Source Code for any Derivative Works that You create to carry a prominent +Attribution Notice reasonably calculated to inform recipients that You have +modified the Original Work. + +7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that +the copyright in and to the Original Work and the patent rights granted herein +by Licensor are owned by the Licensor or are sublicensed to You under the terms +of this License with the permission of the contributor(s) of those copyrights +and patent rights. Except as expressly stated in the immediately proceeding +sentence, the Original Work is provided under this License on an "AS IS" BASIS +and WITHOUT WARRANTY, either express or implied, including, without limitation, +the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. +This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No +license to Original Work is granted hereunder except under this disclaimer. + +8) Limitation of Liability. Under no circumstances and under no legal theory, +whether in tort (including negligence), contract, or otherwise, shall the +Licensor be liable to any person for any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License +or the use of the Original Work including, without limitation, damages for loss +of goodwill, work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses. This limitation of liability shall not +apply to liability for death or personal injury resulting from Licensor's +negligence to the extent applicable law prohibits such limitation. Some +jurisdictions do not allow the exclusion or limitation of incidental or +consequential damages, so this exclusion and limitation may not apply to You. + +9) Acceptance and Termination. If You distribute copies of the Original Work or +a Derivative Work, You must make a reasonable effort under the circumstances to +obtain the express assent of recipients to the terms of this License. Nothing +else but this License (or another written agreement between Licensor and You) +grants You permission to create Derivative Works based upon the Original Work +or to exercise any of the rights granted in Section 1 herein, and any attempt +to do so except under the terms of this License (or another written agreement +between Licensor and You) is expressly prohibited by U.S. copyright law, the +equivalent laws of other countries, and by international treaty. Therefore, by +exercising any of the rights granted to You in Section 1 herein, You indicate +Your acceptance of this License and all of its terms and conditions. + +10) Termination for Patent Action. This License shall terminate automatically +and You may no longer exercise any of the rights granted to You by this License +as of the date You commence an action, including a cross-claim or counterclaim, +for patent infringement (i) against Licensor with respect to a patent +applicable to software or (ii) against any entity with respect to a patent +applicable to the Original Work (but excluding combinations of the Original +Work with other software or hardware). + +11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this +License may be brought only in the courts of a jurisdiction wherein the +Licensor resides or in which Licensor conducts its primary business, and under +the laws of that jurisdiction excluding its conflict-of-law provisions. The +application of the United Nations Convention on Contracts for the International +Sale of Goods is expressly excluded. Any use of the Original Work outside the +scope of this License or after its termination shall be subject to the +requirements and penalties of the U.S. Copyright Act, 17 U.S.C. 101 et seq., +the equivalent laws of other countries, and international treaty. This section +shall survive the termination of this License. + +12) Attorneys Fees. In any action to enforce the terms of this License or +seeking damages relating thereto, the prevailing party shall be entitled to +recover its costs and expenses, including, without limitation, reasonable +attorneys' fees and costs incurred in connection with such action, including +any appeal of such action. This section shall survive the termination of this +License. + +13) Miscellaneous. This License represents the complete agreement concerning +the subject matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent necessary to +make it enforceable. + +14) Definition of "You" in This License. "You" throughout this License, whether +in upper or lower case, means an individual or a legal entity exercising rights +under, and complying with all of the terms of, this License. For legal +entities, "You" includes any entity that controls, is controlled by, or is +under common control with you. For purposes of this definition, "control" means +(i) the power, direct or indirect, to cause the direction or management of such +entity, whether by contract or otherwise, or (ii) ownership of fifty percent +(50%) or more of the outstanding shares, or (iii) beneficial ownership of such +entity. + +15) Right to Use. You may use the Original Work in all ways not otherwise +restricted or conditioned by this License or by law, and Licensor promises not +to interfere with or be responsible for such uses by You. + +This license is Copyright (C) 2003 Lawrence E. Rosen. All rights reserved. +Permission is hereby granted to copy and distribute this license without +modification. This license may not be modified without the express written +permission of its copyright owner. + +-------------------- +xdg_user_dirs +-------------------- + Copyright (c) 2007 Red Hat, inc + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + +-------------------- +libc++abi +-------------------- +============================================================================== +The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: +============================================================================== + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +---- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + +============================================================================== +Software from third parties included in the LLVM Project: +============================================================================== +The LLVM Project contains third party software which is under different license +terms. All such code will be identified clearly using at least one of two +mechanisms: +1) It will be in a separate directory tree with its own `LICENSE.txt` or + `LICENSE` file at the top containing the specific license and restrictions + which apply to that software, or +2) It will contain specific license and restriction terms at the top of every + file. + +============================================================================== +Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): +============================================================================== + +The libc++abi library is dual licensed under both the University of Illinois +"BSD-Like" license and the MIT license. As a user of this code you may choose +to use it under either license. As a contributor, you agree to allow your code +to be used under both. + +Full text of the relevant licenses is included below. + +============================================================================== + +University of Illinois/NCSA +Open Source License + +Copyright (c) 2009-2019 by the contributors listed in CREDITS.TXT + +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + +============================================================================== + +Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-------------------- +quiche +-------------------- +// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +abseil-cpp +-------------------- + + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +-------------------- +boringssl +-------------------- +BoringSSL is a fork of OpenSSL. As such, large parts of it fall under OpenSSL +licensing. Files that are completely new have a Google copyright and an ISC +license. This license is reproduced at the bottom of this file. + +Contributors to BoringSSL are required to follow the CLA rules for Chromium: +https://cla.developers.google.com/clas + +Files in third_party/ have their own licenses, as described therein. The MIT +license, for third_party/fiat, which, unlike other third_party directories, is +compiled into non-test libraries, is included below. + +The OpenSSL toolkit stays under a dual license, i.e. both the conditions of the +OpenSSL License and the original SSLeay license apply to the toolkit. See below +for the actual license texts. Actually both licenses are BSD-style Open Source +licenses. In case of any license issues related to OpenSSL please contact +openssl-core@openssl.org. + +The following are Google-internal bug numbers where explicit permission from +some authors is recorded for use of their work. (This is purely for our own +record keeping.) + 27287199 + 27287880 + 27287883 + + OpenSSL License + --------------- + +/* ==================================================================== + * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + + Original SSLeay License + ----------------------- + +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + + +ISC license used for completely new code in BoringSSL: + +/* Copyright (c) 2015, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + + +The code in third_party/fiat carries the MIT license: + +Copyright (c) 2015-2016 the fiat-crypto authors (see +https://github.com/mit-plv/fiat-crypto/blob/master/AUTHORS). + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +Licenses for support code +------------------------- + +Parts of the TLS test suite are under the Go license. This code is not included +in BoringSSL (i.e. libcrypto and libssl) when compiled, however, so +distributing code linked against BoringSSL does not trigger this license: + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +BoringSSL uses the Chromium test infrastructure to run a continuous build, +trybots etc. The scripts which manage this, and the script for generating build +metadata, are under the Chromium license. Distributing code linked against +BoringSSL does not trigger this license. + +Copyright 2015 The Chromium Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +fiat +-------------------- +The MIT License (MIT) + +Copyright (c) 2015-2016 the fiat-crypto authors (see +https://github.com/mit-plv/fiat-crypto/blob/master/AUTHORS). + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +-------------------- +breakpad +-------------------- +Copyright (c) 2006, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1996 - 2011, Daniel Stenberg, . + +All rights reserved. + +Permission to use, copy, modify, and distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright +notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN +NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of a copyright holder shall not +be used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization of the copyright holder. + + +Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + +@APPLE_LICENSE_HEADER_START@ + +This file contains Original Code and/or Modifications of Original Code +as defined in and that are subject to the Apple Public Source License +Version 2.0 (the 'License'). You may not use this file except in +compliance with the License. Please obtain a copy of the License at +http://www.opensource.apple.com/apsl/ and read it before using this +file. + +The Original Code and all software distributed under the License are +distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +Please see the License for the specific language governing rights and +limitations under the License. + +@APPLE_LICENSE_HEADER_END@ + + +Copyright 2007-2008 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy +of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations under +the License. + +-------------------- +brotli +-------------------- +Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-------------------- +ced +-------------------- +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +crashpad +-------------------- + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +-------------------- +icu +-------------------- +COPYRIGHT AND PERMISSION NOTICE (ICU 58 and later) + +Copyright © 1991-2020 Unicode, Inc. All rights reserved. +Distributed under the Terms of Use in https://www.unicode.org/copyright.html. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Unicode data files and any associated documentation +(the "Data Files") or Unicode software and any associated documentation +(the "Software") to deal in the Data Files or Software +without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, and/or sell copies of +the Data Files or Software, and to permit persons to whom the Data Files +or Software are furnished to do so, provided that either +(a) this copyright and permission notice appear with all copies +of the Data Files or Software, or +(b) this copyright and permission notice appear in associated +Documentation. + +THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT OF THIRD PARTY RIGHTS. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS +NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL +DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THE DATA FILES OR SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, +use or other dealings in these Data Files or Software without prior +written authorization of the copyright holder. + +--------------------- + +Third-Party Software Licenses + +This section contains third-party software notices and/or additional +terms for licensed third-party software components included within ICU +libraries. + +1. ICU License - ICU 1.8.1 to ICU 57.1 + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1995-2016 International Business Machines Corporation and others +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, and/or sell copies of the Software, and to permit persons +to whom the Software is furnished to do so, provided that the above +copyright notice(s) and this permission notice appear in all copies of +the Software and that both the above copyright notice(s) and this +permission notice appear in supporting documentation. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY +SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF +CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, use +or other dealings in this Software without prior written authorization +of the copyright holder. + +All trademarks and registered trademarks mentioned herein are the +property of their respective owners. + +2. Chinese/Japanese Word Break Dictionary Data (cjdict.txt) + + # The Google Chrome software developed by Google is licensed under + # the BSD license. Other software included in this distribution is + # provided under other licenses, as set forth below. + # + # The BSD License + # http://opensource.org/licenses/bsd-license.php + # Copyright (C) 2006-2008, Google Inc. + # + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided that the following conditions are met: + # + # Redistributions of source code must retain the above copyright notice, + # this list of conditions and the following disclaimer. + # Redistributions in binary form must reproduce the above + # copyright notice, this list of conditions and the following + # disclaimer in the documentation and/or other materials provided with + # the distribution. + # Neither the name of Google Inc. nor the names of its + # contributors may be used to endorse or promote products derived from + # this software without specific prior written permission. + # + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + # + # + # The word list in cjdict.txt are generated by combining three word lists + # listed below with further processing for compound word breaking. The + # frequency is generated with an iterative training against Google web + # corpora. + # + # * Libtabe (Chinese) + # - https://sourceforge.net/project/?group_id=1519 + # - Its license terms and conditions are shown below. + # + # * IPADIC (Japanese) + # - http://chasen.aist-nara.ac.jp/chasen/distribution.html + # - Its license terms and conditions are shown below. + # + # ---------COPYING.libtabe ---- BEGIN-------------------- + # + # /* + # * Copyright (c) 1999 TaBE Project. + # * Copyright (c) 1999 Pai-Hsiang Hsiao. + # * All rights reserved. + # * + # * Redistribution and use in source and binary forms, with or without + # * modification, are permitted provided that the following conditions + # * are met: + # * + # * . Redistributions of source code must retain the above copyright + # * notice, this list of conditions and the following disclaimer. + # * . Redistributions in binary form must reproduce the above copyright + # * notice, this list of conditions and the following disclaimer in + # * the documentation and/or other materials provided with the + # * distribution. + # * . Neither the name of the TaBE Project nor the names of its + # * contributors may be used to endorse or promote products derived + # * from this software without specific prior written permission. + # * + # * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + # * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + # * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + # * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + # * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + # * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + # * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + # * OF THE POSSIBILITY OF SUCH DAMAGE. + # */ + # + # /* + # * Copyright (c) 1999 Computer Systems and Communication Lab, + # * Institute of Information Science, Academia + # * Sinica. All rights reserved. + # * + # * Redistribution and use in source and binary forms, with or without + # * modification, are permitted provided that the following conditions + # * are met: + # * + # * . Redistributions of source code must retain the above copyright + # * notice, this list of conditions and the following disclaimer. + # * . Redistributions in binary form must reproduce the above copyright + # * notice, this list of conditions and the following disclaimer in + # * the documentation and/or other materials provided with the + # * distribution. + # * . Neither the name of the Computer Systems and Communication Lab + # * nor the names of its contributors may be used to endorse or + # * promote products derived from this software without specific + # * prior written permission. + # * + # * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + # * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + # * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + # * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + # * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + # * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + # * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + # * OF THE POSSIBILITY OF SUCH DAMAGE. + # */ + # + # Copyright 1996 Chih-Hao Tsai @ Beckman Institute, + # University of Illinois + # c-tsai4@uiuc.edu http://casper.beckman.uiuc.edu/~c-tsai4 + # + # ---------------COPYING.libtabe-----END-------------------------------- + # + # + # ---------------COPYING.ipadic-----BEGIN------------------------------- + # + # Copyright 2000, 2001, 2002, 2003 Nara Institute of Science + # and Technology. All Rights Reserved. + # + # Use, reproduction, and distribution of this software is permitted. + # Any copy of this software, whether in its original form or modified, + # must include both the above copyright notice and the following + # paragraphs. + # + # Nara Institute of Science and Technology (NAIST), + # the copyright holders, disclaims all warranties with regard to this + # software, including all implied warranties of merchantability and + # fitness, in no event shall NAIST be liable for + # any special, indirect or consequential damages or any damages + # whatsoever resulting from loss of use, data or profits, whether in an + # action of contract, negligence or other tortuous action, arising out + # of or in connection with the use or performance of this software. + # + # A large portion of the dictionary entries + # originate from ICOT Free Software. The following conditions for ICOT + # Free Software applies to the current dictionary as well. + # + # Each User may also freely distribute the Program, whether in its + # original form or modified, to any third party or parties, PROVIDED + # that the provisions of Section 3 ("NO WARRANTY") will ALWAYS appear + # on, or be attached to, the Program, which is distributed substantially + # in the same form as set out herein and that such intended + # distribution, if actually made, will neither violate or otherwise + # contravene any of the laws and regulations of the countries having + # jurisdiction over the User or the intended distribution itself. + # + # NO WARRANTY + # + # The program was produced on an experimental basis in the course of the + # research and development conducted during the project and is provided + # to users as so produced on an experimental basis. Accordingly, the + # program is provided without any warranty whatsoever, whether express, + # implied, statutory or otherwise. The term "warranty" used herein + # includes, but is not limited to, any warranty of the quality, + # performance, merchantability and fitness for a particular purpose of + # the program and the nonexistence of any infringement or violation of + # any right of any third party. + # + # Each user of the program will agree and understand, and be deemed to + # have agreed and understood, that there is no warranty whatsoever for + # the program and, accordingly, the entire risk arising from or + # otherwise connected with the program is assumed by the user. + # + # Therefore, neither ICOT, the copyright holder, or any other + # organization that participated in or was otherwise related to the + # development of the program and their respective officials, directors, + # officers and other employees shall be held liable for any and all + # damages, including, without limitation, general, special, incidental + # and consequential damages, arising out of or otherwise in connection + # with the use or inability to use the program or any product, material + # or result produced or otherwise obtained by using the program, + # regardless of whether they have been advised of, or otherwise had + # knowledge of, the possibility of such damages at any time during the + # project or thereafter. Each user will be deemed to have agreed to the + # foregoing by his or her commencement of use of the program. The term + # "use" as used herein includes, but is not limited to, the use, + # modification, copying and distribution of the program and the + # production of secondary products from the program. + # + # In the case where the program, whether in its original form or + # modified, was distributed or delivered to or received by a user from + # any person, organization or entity other than ICOT, unless it makes or + # grants independently of ICOT any specific warranty to the user in + # writing, such person, organization or entity, will also be exempted + # from and not be held liable to the user for any such damages as noted + # above as far as the program is concerned. + # + # ---------------COPYING.ipadic-----END---------------------------------- + +3. Lao Word Break Dictionary Data (laodict.txt) + + # Copyright (c) 2013 International Business Machines Corporation + # and others. All Rights Reserved. + # + # Project: https://github.com/veer66/lao-dictionary + # Dictionary: https://github.com/veer66/lao-dictionary/blob/master/Lao-Dictionary.txt + # License: https://github.com/veer66/lao-dictionary/blob/master/Lao-Dictionary-LICENSE.txt + # (copied below) + # + # This file is derived from the above dictionary, with slight + # modifications. + # ---------------------------------------------------------------------- + # Copyright (C) 2013 Brian Eugene Wilson, Robert Martin Campbell. + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, + # are permitted provided that the following conditions are met: + # + # + # Redistributions of source code must retain the above copyright notice, this + # list of conditions and the following disclaimer. Redistributions in + # binary form must reproduce the above copyright notice, this list of + # conditions and the following disclaimer in the documentation and/or + # other materials provided with the distribution. + # + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + # OF THE POSSIBILITY OF SUCH DAMAGE. + # -------------------------------------------------------------------------- + +4. Burmese Word Break Dictionary Data (burmesedict.txt) + + # Copyright (c) 2014 International Business Machines Corporation + # and others. All Rights Reserved. + # + # This list is part of a project hosted at: + # github.com/kanyawtech/myanmar-karen-word-lists + # + # -------------------------------------------------------------------------- + # Copyright (c) 2013, LeRoy Benjamin Sharon + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided that the following conditions + # are met: Redistributions of source code must retain the above + # copyright notice, this list of conditions and the following + # disclaimer. Redistributions in binary form must reproduce the + # above copyright notice, this list of conditions and the following + # disclaimer in the documentation and/or other materials provided + # with the distribution. + # + # Neither the name Myanmar Karen Word Lists, nor the names of its + # contributors may be used to endorse or promote products derived + # from this software without specific prior written permission. + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS + # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + # SUCH DAMAGE. + # -------------------------------------------------------------------------- + +5. Time Zone Database + + ICU uses the public domain data and code derived from Time Zone +Database for its time zone support. The ownership of the TZ database +is explained in BCP 175: Procedure for Maintaining the Time Zone +Database section 7. + + # 7. Database Ownership + # + # The TZ database itself is not an IETF Contribution or an IETF + # document. Rather it is a pre-existing and regularly updated work + # that is in the public domain, and is intended to remain in the + # public domain. Therefore, BCPs 78 [RFC5378] and 79 [RFC3979] do + # not apply to the TZ Database or contributions that individuals make + # to it. Should any claims be made and substantiated against the TZ + # Database, the organization that is providing the IANA + # Considerations defined in this RFC, under the memorandum of + # understanding with the IETF, currently ICANN, may act in accordance + # with all competent court orders. No ownership claims will be made + # by ICANN or the IETF Trust on the database or the code. Any person + # making a contribution to the database or code waives all rights to + # future claims in that contribution or in the TZ Database. + +6. Google double-conversion + +Copyright 2006-2011, the V8 project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +jsoncpp +-------------------- +The JsonCpp library's source code, including accompanying documentation, +tests and demonstration applications, are licensed under the following +conditions... + +The author (Baptiste Lepilleur) explicitly disclaims copyright in all +jurisdictions which recognize such a disclaimer. In such jurisdictions, +this software is released into the Public Domain. + +In jurisdictions which do not recognize Public Domain property (e.g. Germany as of +2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is +released under the terms of the MIT License (see below). + +In jurisdictions which recognize Public Domain property, the user of this +software may choose to accept it either as 1) Public Domain, 2) under the +conditions of the MIT License (see below), or 3) under the terms of dual +Public Domain/MIT License conditions described here, as they choose. + +The MIT License is about as close to Public Domain as a license can get, and is +described in clear, concise terms at: + + http://en.wikipedia.org/wiki/MIT_License + +The full text of the MIT License follows: + +======================================================================== +Copyright (c) 2007-2010 Baptiste Lepilleur + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +======================================================================== +(END LICENSE TEXT) + +The MIT license is compatible with both the GPL and commercial +software, affording one all of the rights of Public Domain with the +minor nuisance of being required to keep the above copyright notice +and license text in the source code. Note also that by accepting the +Public Domain "license" you can re-license your copy using whatever +license you like. + +-------------------- +modp_b64 +-------------------- + * MODP_B64 - High performance base64 encoder/decoder + * Version 1.3 -- 17-Mar-2006 + * http://modp.com/release/base64 + * + * Copyright (c) 2005, 2006 Nick Galbreath -- nickg [at] modp [dot] com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the modp.com nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +perfetto +-------------------- + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright (c) 2017, The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +-------------------- +protobuf +-------------------- +Copyright 2008 Google Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Code generated by the Protocol Buffer compiler is owned by the owner +of the input file used when generating it. This code is not +standalone and requires a support library to be linked with it. This +support library is itself covered by the above license. + +-------------------- +zlib +-------------------- +version 1.2.11, January 15th, 2017 + +Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. diff --git a/lib/src/third_party/cronet/ffigen.yaml b/lib/src/third_party/cronet/ffigen.yaml index 62d0588..525efb5 100644 --- a/lib/src/third_party/cronet/ffigen.yaml +++ b/lib/src/third_party/cronet/ffigen.yaml @@ -1,7 +1,6 @@ name: 'Cronet' description: 'Bindings to Cronet' output: 'lib/src/third_party/cronet/generated_bindings.dart' -array-workaround: true headers: entry-points: - 'third_party/cronet/cronet.idl_c.h' @@ -13,13 +12,15 @@ compiler-opts: functions: symbol-address: include: - - 'Cronet_Engine_Shutdown' # For wrapper. + # For wrapper. + - 'Cronet_Engine_Shutdown' - 'Cronet_Engine_Destroy' - 'Cronet_Buffer_Create' - 'Cronet_Buffer_InitWithAlloc' - 'Cronet_UrlRequestCallback_CreateWith' - 'Cronet_UrlRequest_InitWithParams' - - 'Cronet_Executor_CreateWith' # For executor. + # For executor. + - 'Cronet_Executor_CreateWith' - 'Cronet_Executor_SetClientContext' - 'Cronet_Executor_GetClientContext' - 'Cronet_Executor_Destroy' @@ -30,5 +31,6 @@ preamble: | // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - // ignore_for_file: non_constant_identifier_names, camel_case_types + // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names + // ignore_for_file: non_constant_identifier_names diff --git a/lib/src/third_party/cronet/generated_bindings.dart b/lib/src/third_party/cronet/generated_bindings.dart index ad90121..8abfba1 100644 --- a/lib/src/third_party/cronet/generated_bindings.dart +++ b/lib/src/third_party/cronet/generated_bindings.dart @@ -2,8 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// ignore_for_file: non_constant_identifier_names, camel_case_types +// ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names +// ignore_for_file: non_constant_identifier_names // AUTO GENERATED FILE, DO NOT EDIT. // diff --git a/lib/src/wrapper/ffigen.yaml b/lib/src/wrapper/ffigen.yaml index bfe7300..528f26d 100644 --- a/lib/src/wrapper/ffigen.yaml +++ b/lib/src/wrapper/ffigen.yaml @@ -1,7 +1,6 @@ name: 'Wrapper' description: 'Bindings to Wrapper for Cronet' output: 'lib/src/wrapper/generated_bindings.dart' -array-workaround: true headers: entry-points: - 'src/wrapper.h' @@ -20,5 +19,6 @@ preamble: | // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. - // ignore_for_file: non_constant_identifier_names, camel_case_types + // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names + // ignore_for_file: non_constant_identifier_names diff --git a/lib/src/wrapper/generated_bindings.dart b/lib/src/wrapper/generated_bindings.dart index a0192b9..9665421 100644 --- a/lib/src/wrapper/generated_bindings.dart +++ b/lib/src/wrapper/generated_bindings.dart @@ -2,8 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// ignore_for_file: non_constant_identifier_names, camel_case_types +// ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names +// ignore_for_file: non_constant_identifier_names // AUTO GENERATED FILE, DO NOT EDIT. // @@ -25,19 +26,6 @@ class Wrapper { lookup) : _lookup = lookup; - void dispatchCallback( - ffi.Pointer methodname, - ) { - return _dispatchCallback( - methodname, - ); - } - - late final _dispatchCallback_ptr = - _lookup>('dispatchCallback'); - late final _dart_dispatchCallback _dispatchCallback = - _dispatchCallback_ptr.asFunction<_dart_dispatchCallback>(); - int InitDartApiDL( ffi.Pointer data, ) { @@ -120,49 +108,49 @@ class Wrapper { late final _dart_Destroy_Executor _Destroy_Executor = _Destroy_Executor_ptr.asFunction<_dart_Destroy_Executor>(); - void registerHttpClient( + void RegisterHttpClient( Object h, ffi.Pointer ce, ) { - return _registerHttpClient( + return _RegisterHttpClient( h, ce, ); } - late final _registerHttpClient_ptr = - _lookup>('registerHttpClient'); - late final _dart_registerHttpClient _registerHttpClient = - _registerHttpClient_ptr.asFunction<_dart_registerHttpClient>(); + late final _RegisterHttpClient_ptr = + _lookup>('RegisterHttpClient'); + late final _dart_RegisterHttpClient _RegisterHttpClient = + _RegisterHttpClient_ptr.asFunction<_dart_RegisterHttpClient>(); - void registerCallbackHandler( + void RegisterCallbackHandler( int nativePort, ffi.Pointer rp, ) { - return _registerCallbackHandler( + return _RegisterCallbackHandler( nativePort, rp, ); } - late final _registerCallbackHandler_ptr = - _lookup>( - 'registerCallbackHandler'); - late final _dart_registerCallbackHandler _registerCallbackHandler = - _registerCallbackHandler_ptr.asFunction<_dart_registerCallbackHandler>(); + late final _RegisterCallbackHandler_ptr = + _lookup>( + 'RegisterCallbackHandler'); + late final _dart_RegisterCallbackHandler _RegisterCallbackHandler = + _RegisterCallbackHandler_ptr.asFunction<_dart_RegisterCallbackHandler>(); - void removeRequest( + void RemoveRequest( ffi.Pointer rp, ) { - return _removeRequest( + return _RemoveRequest( rp, ); } - late final _removeRequest_ptr = - _lookup>('removeRequest'); - late final _dart_removeRequest _removeRequest = - _removeRequest_ptr.asFunction<_dart_removeRequest>(); + late final _RemoveRequest_ptr = + _lookup>('RemoveRequest'); + late final _dart_RemoveRequest _RemoveRequest = + _RemoveRequest_ptr.asFunction<_dart_RemoveRequest>(); int Cronet_UrlRequest_Init( ffi.Pointer self, @@ -193,14 +181,6 @@ class Cronet_UrlRequest extends ffi.Opaque {} class Cronet_UrlRequestParams extends ffi.Opaque {} -typedef _c_dispatchCallback = ffi.Void Function( - ffi.Pointer methodname, -); - -typedef _dart_dispatchCallback = void Function( - ffi.Pointer methodname, -); - typedef _c_InitDartApiDL = ffi.IntPtr Function( ffi.Pointer data, ); @@ -257,31 +237,31 @@ typedef _dart_Destroy_Executor = void Function( ffi.Pointer executor, ); -typedef _c_registerHttpClient = ffi.Void Function( +typedef _c_RegisterHttpClient = ffi.Void Function( ffi.Handle h, ffi.Pointer ce, ); -typedef _dart_registerHttpClient = void Function( +typedef _dart_RegisterHttpClient = void Function( Object h, ffi.Pointer ce, ); -typedef _c_registerCallbackHandler = ffi.Void Function( +typedef _c_RegisterCallbackHandler = ffi.Void Function( ffi.Int64 nativePort, ffi.Pointer rp, ); -typedef _dart_registerCallbackHandler = void Function( +typedef _dart_RegisterCallbackHandler = void Function( int nativePort, ffi.Pointer rp, ); -typedef _c_removeRequest = ffi.Void Function( +typedef _c_RemoveRequest = ffi.Void Function( ffi.Pointer rp, ); -typedef _dart_removeRequest = void Function( +typedef _dart_RemoveRequest = void Function( ffi.Pointer rp, ); diff --git a/pubspec.yaml b/pubspec.yaml index 39b16c6..47f8f80 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,6 @@ name: cronet version: 0.0.1 -author: Dart Team homepage: https://github.com/google/cronet.dart description: Experimental Cronet dart bindings. diff --git a/src/wrapper.cc b/src/wrapper.cc index 9904d38..59a28fe 100644 --- a/src/wrapper.cc +++ b/src/wrapper.cc @@ -84,7 +84,7 @@ static void FreeFinalizer(void *, void *value) { free(value); } // ReceievePort's NativePort component // // This is required to send the data -void registerCallbackHandler(Dart_Port send_port, Cronet_UrlRequestPtr rp) { +void RegisterCallbackHandler(Dart_Port send_port, Cronet_UrlRequestPtr rp) { requestNativePorts[rp] = send_port; } @@ -96,8 +96,8 @@ void registerCallbackHandler(Dart_Port send_port, Cronet_UrlRequestPtr rp) { // message[1] contains all the data to pass to that method. // // Using this due to the lack of support for asynchronous callbacks in dart:ffi. -// See Issue: dart-lang/sdk#37022. -void dispatchCallback(const char *methodname, Cronet_UrlRequestPtr request, +// See Issue: https://github.com/dart-lang/sdk/issues/37022. +void DispatchCallback(const char *methodname, Cronet_UrlRequestPtr request, Dart_CObject args) { Dart_CObject c_method_name; c_method_name.type = Dart_CObject_kString; @@ -117,7 +117,7 @@ void dispatchCallback(const char *methodname, Cronet_UrlRequestPtr request, // Builds the arguments to pass to the Dart side as a parameter to the // callbacks. [num] is the number of arguments to be passed and rest are the // arguments. -Dart_CObject callbackArgBuilder(int num, ...) { +Dart_CObject CallbackArgBuilder(int num, ...) { Dart_CObject c_request_data; va_list valist; va_start(valist, num); @@ -131,7 +131,7 @@ Dart_CObject callbackArgBuilder(int num, ...) { c_request_data.type = Dart_CObject_kExternalTypedData; c_request_data.value.as_external_typed_data.type = Dart_TypedData_kUint64; c_request_data.value.as_external_typed_data.length = - sizeof(uint64_t) * num; // 4 args to pass + sizeof(uint64_t) * num; c_request_data.value.as_external_typed_data.data = static_cast(request_buffer); c_request_data.value.as_external_typed_data.peer = request_buffer; @@ -152,10 +152,10 @@ static void HttpClientDestroy(void *isolate_callback_data, void *peer) { _Cronet_Engine_Destroy(ce); } -void removeRequest(Cronet_UrlRequestPtr rp) { requestNativePorts.erase(rp); } +void RemoveRequest(Cronet_UrlRequestPtr rp) { requestNativePorts.erase(rp); } // Register our HttpClient object from dart side -void registerHttpClient(Dart_Handle h, Cronet_Engine *ce) { +void RegisterHttpClient(Dart_Handle h, Cronet_Engine *ce) { void *peer = ce; intptr_t size = 8; Dart_NewFinalizableHandle_DL(h, peer, size, HttpClientDestroy); @@ -167,8 +167,8 @@ void OnRedirectReceived(Cronet_UrlRequestCallbackPtr self, Cronet_UrlRequestPtr request, Cronet_UrlResponseInfoPtr info, Cronet_String newLocationUrl) { - dispatchCallback("OnRedirectReceived", request, - callbackArgBuilder(2, newLocationUrl, info)); + DispatchCallback("OnRedirectReceived", request, + CallbackArgBuilder(2, newLocationUrl, info)); } void OnResponseStarted(Cronet_UrlRequestCallbackPtr self, @@ -179,8 +179,8 @@ void OnResponseStarted(Cronet_UrlRequestCallbackPtr self, Cronet_BufferPtr buffer = _Cronet_Buffer_Create(); _Cronet_Buffer_InitWithAlloc(buffer, 32 * 1024); - dispatchCallback("OnResponseStarted", request, - callbackArgBuilder(2, info, buffer)); + DispatchCallback("OnResponseStarted", request, + CallbackArgBuilder(2, info, buffer)); // // Started reading the response. // _Cronet_UrlRequest_Read(request, buffer); @@ -190,23 +190,23 @@ void OnReadCompleted(Cronet_UrlRequestCallbackPtr self, Cronet_UrlRequestPtr request, Cronet_UrlResponseInfoPtr info, Cronet_BufferPtr buffer, uint64_t bytes_read) { - dispatchCallback("OnReadCompleted", request, - callbackArgBuilder(4, request, info, buffer, bytes_read)); + DispatchCallback("OnReadCompleted", request, + CallbackArgBuilder(4, request, info, buffer, bytes_read)); } void OnSucceeded(Cronet_UrlRequestCallbackPtr self, Cronet_UrlRequestPtr request, Cronet_UrlResponseInfoPtr info) { - dispatchCallback("OnSucceeded", request, callbackArgBuilder(1, info)); + DispatchCallback("OnSucceeded", request, CallbackArgBuilder(1, info)); } void OnFailed(Cronet_UrlRequestCallbackPtr self, Cronet_UrlRequestPtr request, Cronet_UrlResponseInfoPtr info, Cronet_ErrorPtr error) { - dispatchCallback("OnFailed", request, callbackArgBuilder(1, error)); + DispatchCallback("OnFailed", request, CallbackArgBuilder(1, error)); } void OnCanceled(Cronet_UrlRequestCallbackPtr self, Cronet_UrlRequestPtr request, Cronet_UrlResponseInfoPtr info) { - dispatchCallback("OnCanceled", request, callbackArgBuilder(0)); + DispatchCallback("OnCanceled", request, CallbackArgBuilder(0)); } ExecutorPtr Create_Executor() { return new SampleExecutor(); } @@ -220,7 +220,7 @@ void Destroy_Executor(ExecutorPtr executor) { } // NOTE: Changed from original cronet's api. executor & callback params aren't -// needed +// needed. Cronet_RESULT Cronet_UrlRequest_Init(Cronet_UrlRequestPtr self, Cronet_EnginePtr engine, Cronet_String url, Cronet_UrlRequestParamsPtr params, diff --git a/src/wrapper.h b/src/wrapper.h index 06e7853..69628cd 100644 --- a/src/wrapper.h +++ b/src/wrapper.h @@ -20,7 +20,6 @@ extern "C" { #include -DART_EXPORT void dispatchCallback(char *methodname); DART_EXPORT intptr_t InitDartApiDL(void *data); DART_EXPORT void InitCronetApi(void *shutdown, void *destroy, void *buffer_create, void *buffer_InitWithAlloc, @@ -37,10 +36,10 @@ typedef void *ExecutorPtr; DART_EXPORT ExecutorPtr Create_Executor(); DART_EXPORT void Destroy_Executor(ExecutorPtr executor); -DART_EXPORT void registerHttpClient(Dart_Handle h, Cronet_Engine *ce); -DART_EXPORT void registerCallbackHandler(Dart_Port nativePort, +DART_EXPORT void RegisterHttpClient(Dart_Handle h, Cronet_Engine *ce); +DART_EXPORT void RegisterCallbackHandler(Dart_Port nativePort, Cronet_UrlRequest *rp); -DART_EXPORT void removeRequest(Cronet_UrlRequest *rp); +DART_EXPORT void RemoveRequest(Cronet_UrlRequest *rp); DART_EXPORT Cronet_RESULT Cronet_UrlRequest_Init( Cronet_UrlRequest *self, Cronet_Engine *engine, Cronet_String url, Cronet_UrlRequestParams *params, ExecutorPtr _executor); diff --git a/third_party/cronet/LICENSE b/third_party/cronet/LICENSE new file mode 100644 index 0000000..03c4569 --- /dev/null +++ b/third_party/cronet/LICENSE @@ -0,0 +1,2327 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +double_conversion +-------------------- +Copyright 2006-2011, the V8 project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +dynamic_annotations +-------------------- +/* Copyright (c) 2008-2009, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * --- + * Author: Kostya Serebryany + */ + +-------------------- +libevent +-------------------- +Libevent is available for use under the following license, commonly known +as the 3-clause (or "modified") BSD license: + +============================== +Copyright (c) 2000-2007 Niels Provos +Copyright (c) 2007-2010 Niels Provos and Nick Mathewson + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +============================== + +Portions of Libevent are based on works by others, also made available by +them under the three-clause BSD license above. The copyright notices are +available in the corresponding source files; the license is as above. Here's +a list: + +log.c: + Copyright (c) 2000 Dug Song + Copyright (c) 1993 The Regents of the University of California. + +strlcpy.c: + Copyright (c) 1998 Todd C. Miller + +win32.c: + Copyright (c) 2003 Michael A. Davis + +evport.c: + Copyright (c) 2007 Sun Microsystems + +min_heap.h: + Copyright (c) 2006 Maxim Yegorushkin + +tree.h: + Copyright 2002 Niels Provos + +-------------------- +symbolize +-------------------- +// Copyright (c) 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +xdg_mime +-------------------- +Licensed under the Academic Free License version 2.0 (below) +Or under the following terms: + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the +Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. + + +-------------------------------------------------------------------------------- +Academic Free License v. 2.0 +-------------------------------------------------------------------------------- + +This Academic Free License (the "License") applies to any original work of +authorship (the "Original Work") whose owner (the "Licensor") has placed the +following notice immediately following the copyright notice for the Original +Work: + +Licensed under the Academic Free License version 2.0 +1) Grant of Copyright License. Licensor hereby grants You a world-wide, +royalty-free, non-exclusive, perpetual, sublicenseable license to do the +following: + +a) to reproduce the Original Work in copies; +b) to prepare derivative works ("Derivative Works") based upon the Original + Work; +c) to distribute copies of the Original Work and Derivative Works to the + public; +d) to perform the Original Work publicly; and +e) to display the Original Work publicly. + +2) Grant of Patent License. Licensor hereby grants You a world-wide, +royalty-free, non-exclusive, perpetual, sublicenseable license, under patent +claims owned or controlled by the Licensor that are embodied in the Original +Work as furnished by the Licensor, to make, use, sell and offer for sale the +Original Work and Derivative Works. + +3) Grant of Source Code License. The term "Source Code" means the preferred +form of the Original Work for making modifications to it and all available +documentation describing how to modify the Original Work. Licensor hereby +agrees to provide a machine-readable copy of the Source Code of the Original +Work along with each copy of the Original Work that Licensor distributes. +Licensor reserves the right to satisfy this obligation by placing a +machine-readable copy of the Source Code in an information repository +reasonably calculated to permit inexpensive and convenient access by You for as +long as Licensor continues to distribute the Original Work, and by publishing +the address of that information repository in a notice immediately following +the copyright notice that applies to the Original Work. + +4) Exclusions From License Grant. Neither the names of Licensor, nor the names +of any contributors to the Original Work, nor any of their trademarks or +service marks, may be used to endorse or promote products derived from this +Original Work without express prior written permission of the Licensor. Nothing +in this License shall be deemed to grant any rights to trademarks, copyrights, +patents, trade secrets or any other intellectual property of Licensor except as +expressly stated herein. No patent license is granted to make, use, sell or +offer to sell embodiments of any patent claims other than the licensed claims +defined in Section 2. No right is granted to the trademarks of Licensor even if +such marks are included in the Original Work. Nothing in this License shall be +interpreted to prohibit Licensor from licensing under different terms from this +License any Original Work that Licensor otherwise would have a right to +license. + +5) This section intentionally omitted. + +6) Attribution Rights. You must retain, in the Source Code of any Derivative +Works that You create, all copyright, patent or trademark notices from the +Source Code of the Original Work, as well as any notices of licensing and any +descriptive text identified therein as an "Attribution Notice." You must cause +the Source Code for any Derivative Works that You create to carry a prominent +Attribution Notice reasonably calculated to inform recipients that You have +modified the Original Work. + +7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that +the copyright in and to the Original Work and the patent rights granted herein +by Licensor are owned by the Licensor or are sublicensed to You under the terms +of this License with the permission of the contributor(s) of those copyrights +and patent rights. Except as expressly stated in the immediately proceeding +sentence, the Original Work is provided under this License on an "AS IS" BASIS +and WITHOUT WARRANTY, either express or implied, including, without limitation, +the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. +This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No +license to Original Work is granted hereunder except under this disclaimer. + +8) Limitation of Liability. Under no circumstances and under no legal theory, +whether in tort (including negligence), contract, or otherwise, shall the +Licensor be liable to any person for any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License +or the use of the Original Work including, without limitation, damages for loss +of goodwill, work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses. This limitation of liability shall not +apply to liability for death or personal injury resulting from Licensor's +negligence to the extent applicable law prohibits such limitation. Some +jurisdictions do not allow the exclusion or limitation of incidental or +consequential damages, so this exclusion and limitation may not apply to You. + +9) Acceptance and Termination. If You distribute copies of the Original Work or +a Derivative Work, You must make a reasonable effort under the circumstances to +obtain the express assent of recipients to the terms of this License. Nothing +else but this License (or another written agreement between Licensor and You) +grants You permission to create Derivative Works based upon the Original Work +or to exercise any of the rights granted in Section 1 herein, and any attempt +to do so except under the terms of this License (or another written agreement +between Licensor and You) is expressly prohibited by U.S. copyright law, the +equivalent laws of other countries, and by international treaty. Therefore, by +exercising any of the rights granted to You in Section 1 herein, You indicate +Your acceptance of this License and all of its terms and conditions. + +10) Termination for Patent Action. This License shall terminate automatically +and You may no longer exercise any of the rights granted to You by this License +as of the date You commence an action, including a cross-claim or counterclaim, +for patent infringement (i) against Licensor with respect to a patent +applicable to software or (ii) against any entity with respect to a patent +applicable to the Original Work (but excluding combinations of the Original +Work with other software or hardware). + +11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this +License may be brought only in the courts of a jurisdiction wherein the +Licensor resides or in which Licensor conducts its primary business, and under +the laws of that jurisdiction excluding its conflict-of-law provisions. The +application of the United Nations Convention on Contracts for the International +Sale of Goods is expressly excluded. Any use of the Original Work outside the +scope of this License or after its termination shall be subject to the +requirements and penalties of the U.S. Copyright Act, 17 U.S.C. 101 et seq., +the equivalent laws of other countries, and international treaty. This section +shall survive the termination of this License. + +12) Attorneys Fees. In any action to enforce the terms of this License or +seeking damages relating thereto, the prevailing party shall be entitled to +recover its costs and expenses, including, without limitation, reasonable +attorneys' fees and costs incurred in connection with such action, including +any appeal of such action. This section shall survive the termination of this +License. + +13) Miscellaneous. This License represents the complete agreement concerning +the subject matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent necessary to +make it enforceable. + +14) Definition of "You" in This License. "You" throughout this License, whether +in upper or lower case, means an individual or a legal entity exercising rights +under, and complying with all of the terms of, this License. For legal +entities, "You" includes any entity that controls, is controlled by, or is +under common control with you. For purposes of this definition, "control" means +(i) the power, direct or indirect, to cause the direction or management of such +entity, whether by contract or otherwise, or (ii) ownership of fifty percent +(50%) or more of the outstanding shares, or (iii) beneficial ownership of such +entity. + +15) Right to Use. You may use the Original Work in all ways not otherwise +restricted or conditioned by this License or by law, and Licensor promises not +to interfere with or be responsible for such uses by You. + +This license is Copyright (C) 2003 Lawrence E. Rosen. All rights reserved. +Permission is hereby granted to copy and distribute this license without +modification. This license may not be modified without the express written +permission of its copyright owner. + +-------------------- +xdg_user_dirs +-------------------- + Copyright (c) 2007 Red Hat, inc + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + +-------------------- +libc++abi +-------------------- +============================================================================== +The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: +============================================================================== + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +---- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + +============================================================================== +Software from third parties included in the LLVM Project: +============================================================================== +The LLVM Project contains third party software which is under different license +terms. All such code will be identified clearly using at least one of two +mechanisms: +1) It will be in a separate directory tree with its own `LICENSE.txt` or + `LICENSE` file at the top containing the specific license and restrictions + which apply to that software, or +2) It will contain specific license and restriction terms at the top of every + file. + +============================================================================== +Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): +============================================================================== + +The libc++abi library is dual licensed under both the University of Illinois +"BSD-Like" license and the MIT license. As a user of this code you may choose +to use it under either license. As a contributor, you agree to allow your code +to be used under both. + +Full text of the relevant licenses is included below. + +============================================================================== + +University of Illinois/NCSA +Open Source License + +Copyright (c) 2009-2019 by the contributors listed in CREDITS.TXT + +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + +============================================================================== + +Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-------------------- +quiche +-------------------- +// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +abseil-cpp +-------------------- + + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +-------------------- +boringssl +-------------------- +BoringSSL is a fork of OpenSSL. As such, large parts of it fall under OpenSSL +licensing. Files that are completely new have a Google copyright and an ISC +license. This license is reproduced at the bottom of this file. + +Contributors to BoringSSL are required to follow the CLA rules for Chromium: +https://cla.developers.google.com/clas + +Files in third_party/ have their own licenses, as described therein. The MIT +license, for third_party/fiat, which, unlike other third_party directories, is +compiled into non-test libraries, is included below. + +The OpenSSL toolkit stays under a dual license, i.e. both the conditions of the +OpenSSL License and the original SSLeay license apply to the toolkit. See below +for the actual license texts. Actually both licenses are BSD-style Open Source +licenses. In case of any license issues related to OpenSSL please contact +openssl-core@openssl.org. + +The following are Google-internal bug numbers where explicit permission from +some authors is recorded for use of their work. (This is purely for our own +record keeping.) + 27287199 + 27287880 + 27287883 + + OpenSSL License + --------------- + +/* ==================================================================== + * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + + Original SSLeay License + ----------------------- + +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + + +ISC license used for completely new code in BoringSSL: + +/* Copyright (c) 2015, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + + +The code in third_party/fiat carries the MIT license: + +Copyright (c) 2015-2016 the fiat-crypto authors (see +https://github.com/mit-plv/fiat-crypto/blob/master/AUTHORS). + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +Licenses for support code +------------------------- + +Parts of the TLS test suite are under the Go license. This code is not included +in BoringSSL (i.e. libcrypto and libssl) when compiled, however, so +distributing code linked against BoringSSL does not trigger this license: + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +BoringSSL uses the Chromium test infrastructure to run a continuous build, +trybots etc. The scripts which manage this, and the script for generating build +metadata, are under the Chromium license. Distributing code linked against +BoringSSL does not trigger this license. + +Copyright 2015 The Chromium Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +fiat +-------------------- +The MIT License (MIT) + +Copyright (c) 2015-2016 the fiat-crypto authors (see +https://github.com/mit-plv/fiat-crypto/blob/master/AUTHORS). + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +-------------------- +breakpad +-------------------- +Copyright (c) 2006, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1996 - 2011, Daniel Stenberg, . + +All rights reserved. + +Permission to use, copy, modify, and distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright +notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN +NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of a copyright holder shall not +be used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization of the copyright holder. + + +Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + +@APPLE_LICENSE_HEADER_START@ + +This file contains Original Code and/or Modifications of Original Code +as defined in and that are subject to the Apple Public Source License +Version 2.0 (the 'License'). You may not use this file except in +compliance with the License. Please obtain a copy of the License at +http://www.opensource.apple.com/apsl/ and read it before using this +file. + +The Original Code and all software distributed under the License are +distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +Please see the License for the specific language governing rights and +limitations under the License. + +@APPLE_LICENSE_HEADER_END@ + + +Copyright 2007-2008 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy +of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations under +the License. + +-------------------- +brotli +-------------------- +Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-------------------- +ced +-------------------- +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +crashpad +-------------------- + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +-------------------- +icu +-------------------- +COPYRIGHT AND PERMISSION NOTICE (ICU 58 and later) + +Copyright © 1991-2020 Unicode, Inc. All rights reserved. +Distributed under the Terms of Use in https://www.unicode.org/copyright.html. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Unicode data files and any associated documentation +(the "Data Files") or Unicode software and any associated documentation +(the "Software") to deal in the Data Files or Software +without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, and/or sell copies of +the Data Files or Software, and to permit persons to whom the Data Files +or Software are furnished to do so, provided that either +(a) this copyright and permission notice appear with all copies +of the Data Files or Software, or +(b) this copyright and permission notice appear in associated +Documentation. + +THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT OF THIRD PARTY RIGHTS. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS +NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL +DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THE DATA FILES OR SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, +use or other dealings in these Data Files or Software without prior +written authorization of the copyright holder. + +--------------------- + +Third-Party Software Licenses + +This section contains third-party software notices and/or additional +terms for licensed third-party software components included within ICU +libraries. + +1. ICU License - ICU 1.8.1 to ICU 57.1 + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1995-2016 International Business Machines Corporation and others +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, and/or sell copies of the Software, and to permit persons +to whom the Software is furnished to do so, provided that the above +copyright notice(s) and this permission notice appear in all copies of +the Software and that both the above copyright notice(s) and this +permission notice appear in supporting documentation. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY +SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF +CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, use +or other dealings in this Software without prior written authorization +of the copyright holder. + +All trademarks and registered trademarks mentioned herein are the +property of their respective owners. + +2. Chinese/Japanese Word Break Dictionary Data (cjdict.txt) + + # The Google Chrome software developed by Google is licensed under + # the BSD license. Other software included in this distribution is + # provided under other licenses, as set forth below. + # + # The BSD License + # http://opensource.org/licenses/bsd-license.php + # Copyright (C) 2006-2008, Google Inc. + # + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided that the following conditions are met: + # + # Redistributions of source code must retain the above copyright notice, + # this list of conditions and the following disclaimer. + # Redistributions in binary form must reproduce the above + # copyright notice, this list of conditions and the following + # disclaimer in the documentation and/or other materials provided with + # the distribution. + # Neither the name of Google Inc. nor the names of its + # contributors may be used to endorse or promote products derived from + # this software without specific prior written permission. + # + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + # + # + # The word list in cjdict.txt are generated by combining three word lists + # listed below with further processing for compound word breaking. The + # frequency is generated with an iterative training against Google web + # corpora. + # + # * Libtabe (Chinese) + # - https://sourceforge.net/project/?group_id=1519 + # - Its license terms and conditions are shown below. + # + # * IPADIC (Japanese) + # - http://chasen.aist-nara.ac.jp/chasen/distribution.html + # - Its license terms and conditions are shown below. + # + # ---------COPYING.libtabe ---- BEGIN-------------------- + # + # /* + # * Copyright (c) 1999 TaBE Project. + # * Copyright (c) 1999 Pai-Hsiang Hsiao. + # * All rights reserved. + # * + # * Redistribution and use in source and binary forms, with or without + # * modification, are permitted provided that the following conditions + # * are met: + # * + # * . Redistributions of source code must retain the above copyright + # * notice, this list of conditions and the following disclaimer. + # * . Redistributions in binary form must reproduce the above copyright + # * notice, this list of conditions and the following disclaimer in + # * the documentation and/or other materials provided with the + # * distribution. + # * . Neither the name of the TaBE Project nor the names of its + # * contributors may be used to endorse or promote products derived + # * from this software without specific prior written permission. + # * + # * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + # * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + # * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + # * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + # * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + # * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + # * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + # * OF THE POSSIBILITY OF SUCH DAMAGE. + # */ + # + # /* + # * Copyright (c) 1999 Computer Systems and Communication Lab, + # * Institute of Information Science, Academia + # * Sinica. All rights reserved. + # * + # * Redistribution and use in source and binary forms, with or without + # * modification, are permitted provided that the following conditions + # * are met: + # * + # * . Redistributions of source code must retain the above copyright + # * notice, this list of conditions and the following disclaimer. + # * . Redistributions in binary form must reproduce the above copyright + # * notice, this list of conditions and the following disclaimer in + # * the documentation and/or other materials provided with the + # * distribution. + # * . Neither the name of the Computer Systems and Communication Lab + # * nor the names of its contributors may be used to endorse or + # * promote products derived from this software without specific + # * prior written permission. + # * + # * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + # * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + # * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + # * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + # * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + # * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + # * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + # * OF THE POSSIBILITY OF SUCH DAMAGE. + # */ + # + # Copyright 1996 Chih-Hao Tsai @ Beckman Institute, + # University of Illinois + # c-tsai4@uiuc.edu http://casper.beckman.uiuc.edu/~c-tsai4 + # + # ---------------COPYING.libtabe-----END-------------------------------- + # + # + # ---------------COPYING.ipadic-----BEGIN------------------------------- + # + # Copyright 2000, 2001, 2002, 2003 Nara Institute of Science + # and Technology. All Rights Reserved. + # + # Use, reproduction, and distribution of this software is permitted. + # Any copy of this software, whether in its original form or modified, + # must include both the above copyright notice and the following + # paragraphs. + # + # Nara Institute of Science and Technology (NAIST), + # the copyright holders, disclaims all warranties with regard to this + # software, including all implied warranties of merchantability and + # fitness, in no event shall NAIST be liable for + # any special, indirect or consequential damages or any damages + # whatsoever resulting from loss of use, data or profits, whether in an + # action of contract, negligence or other tortuous action, arising out + # of or in connection with the use or performance of this software. + # + # A large portion of the dictionary entries + # originate from ICOT Free Software. The following conditions for ICOT + # Free Software applies to the current dictionary as well. + # + # Each User may also freely distribute the Program, whether in its + # original form or modified, to any third party or parties, PROVIDED + # that the provisions of Section 3 ("NO WARRANTY") will ALWAYS appear + # on, or be attached to, the Program, which is distributed substantially + # in the same form as set out herein and that such intended + # distribution, if actually made, will neither violate or otherwise + # contravene any of the laws and regulations of the countries having + # jurisdiction over the User or the intended distribution itself. + # + # NO WARRANTY + # + # The program was produced on an experimental basis in the course of the + # research and development conducted during the project and is provided + # to users as so produced on an experimental basis. Accordingly, the + # program is provided without any warranty whatsoever, whether express, + # implied, statutory or otherwise. The term "warranty" used herein + # includes, but is not limited to, any warranty of the quality, + # performance, merchantability and fitness for a particular purpose of + # the program and the nonexistence of any infringement or violation of + # any right of any third party. + # + # Each user of the program will agree and understand, and be deemed to + # have agreed and understood, that there is no warranty whatsoever for + # the program and, accordingly, the entire risk arising from or + # otherwise connected with the program is assumed by the user. + # + # Therefore, neither ICOT, the copyright holder, or any other + # organization that participated in or was otherwise related to the + # development of the program and their respective officials, directors, + # officers and other employees shall be held liable for any and all + # damages, including, without limitation, general, special, incidental + # and consequential damages, arising out of or otherwise in connection + # with the use or inability to use the program or any product, material + # or result produced or otherwise obtained by using the program, + # regardless of whether they have been advised of, or otherwise had + # knowledge of, the possibility of such damages at any time during the + # project or thereafter. Each user will be deemed to have agreed to the + # foregoing by his or her commencement of use of the program. The term + # "use" as used herein includes, but is not limited to, the use, + # modification, copying and distribution of the program and the + # production of secondary products from the program. + # + # In the case where the program, whether in its original form or + # modified, was distributed or delivered to or received by a user from + # any person, organization or entity other than ICOT, unless it makes or + # grants independently of ICOT any specific warranty to the user in + # writing, such person, organization or entity, will also be exempted + # from and not be held liable to the user for any such damages as noted + # above as far as the program is concerned. + # + # ---------------COPYING.ipadic-----END---------------------------------- + +3. Lao Word Break Dictionary Data (laodict.txt) + + # Copyright (c) 2013 International Business Machines Corporation + # and others. All Rights Reserved. + # + # Project: https://github.com/veer66/lao-dictionary + # Dictionary: https://github.com/veer66/lao-dictionary/blob/master/Lao-Dictionary.txt + # License: https://github.com/veer66/lao-dictionary/blob/master/Lao-Dictionary-LICENSE.txt + # (copied below) + # + # This file is derived from the above dictionary, with slight + # modifications. + # ---------------------------------------------------------------------- + # Copyright (C) 2013 Brian Eugene Wilson, Robert Martin Campbell. + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, + # are permitted provided that the following conditions are met: + # + # + # Redistributions of source code must retain the above copyright notice, this + # list of conditions and the following disclaimer. Redistributions in + # binary form must reproduce the above copyright notice, this list of + # conditions and the following disclaimer in the documentation and/or + # other materials provided with the distribution. + # + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + # OF THE POSSIBILITY OF SUCH DAMAGE. + # -------------------------------------------------------------------------- + +4. Burmese Word Break Dictionary Data (burmesedict.txt) + + # Copyright (c) 2014 International Business Machines Corporation + # and others. All Rights Reserved. + # + # This list is part of a project hosted at: + # github.com/kanyawtech/myanmar-karen-word-lists + # + # -------------------------------------------------------------------------- + # Copyright (c) 2013, LeRoy Benjamin Sharon + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided that the following conditions + # are met: Redistributions of source code must retain the above + # copyright notice, this list of conditions and the following + # disclaimer. Redistributions in binary form must reproduce the + # above copyright notice, this list of conditions and the following + # disclaimer in the documentation and/or other materials provided + # with the distribution. + # + # Neither the name Myanmar Karen Word Lists, nor the names of its + # contributors may be used to endorse or promote products derived + # from this software without specific prior written permission. + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS + # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + # SUCH DAMAGE. + # -------------------------------------------------------------------------- + +5. Time Zone Database + + ICU uses the public domain data and code derived from Time Zone +Database for its time zone support. The ownership of the TZ database +is explained in BCP 175: Procedure for Maintaining the Time Zone +Database section 7. + + # 7. Database Ownership + # + # The TZ database itself is not an IETF Contribution or an IETF + # document. Rather it is a pre-existing and regularly updated work + # that is in the public domain, and is intended to remain in the + # public domain. Therefore, BCPs 78 [RFC5378] and 79 [RFC3979] do + # not apply to the TZ Database or contributions that individuals make + # to it. Should any claims be made and substantiated against the TZ + # Database, the organization that is providing the IANA + # Considerations defined in this RFC, under the memorandum of + # understanding with the IETF, currently ICANN, may act in accordance + # with all competent court orders. No ownership claims will be made + # by ICANN or the IETF Trust on the database or the code. Any person + # making a contribution to the database or code waives all rights to + # future claims in that contribution or in the TZ Database. + +6. Google double-conversion + +Copyright 2006-2011, the V8 project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +jsoncpp +-------------------- +The JsonCpp library's source code, including accompanying documentation, +tests and demonstration applications, are licensed under the following +conditions... + +The author (Baptiste Lepilleur) explicitly disclaims copyright in all +jurisdictions which recognize such a disclaimer. In such jurisdictions, +this software is released into the Public Domain. + +In jurisdictions which do not recognize Public Domain property (e.g. Germany as of +2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is +released under the terms of the MIT License (see below). + +In jurisdictions which recognize Public Domain property, the user of this +software may choose to accept it either as 1) Public Domain, 2) under the +conditions of the MIT License (see below), or 3) under the terms of dual +Public Domain/MIT License conditions described here, as they choose. + +The MIT License is about as close to Public Domain as a license can get, and is +described in clear, concise terms at: + + http://en.wikipedia.org/wiki/MIT_License + +The full text of the MIT License follows: + +======================================================================== +Copyright (c) 2007-2010 Baptiste Lepilleur + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +======================================================================== +(END LICENSE TEXT) + +The MIT license is compatible with both the GPL and commercial +software, affording one all of the rights of Public Domain with the +minor nuisance of being required to keep the above copyright notice +and license text in the source code. Note also that by accepting the +Public Domain "license" you can re-license your copy using whatever +license you like. + +-------------------- +modp_b64 +-------------------- + * MODP_B64 - High performance base64 encoder/decoder + * Version 1.3 -- 17-Mar-2006 + * http://modp.com/release/base64 + * + * Copyright (c) 2005, 2006 Nick Galbreath -- nickg [at] modp [dot] com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the modp.com nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +perfetto +-------------------- + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright (c) 2017, The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +-------------------- +protobuf +-------------------- +Copyright 2008 Google Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Code generated by the Protocol Buffer compiler is owned by the owner +of the input file used when generating it. This code is not +standalone and requires a support library to be linked with it. This +support library is itself covered by the above license. + +-------------------- +zlib +-------------------- +version 1.2.11, January 15th, 2017 + +Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. diff --git a/third_party/cronet_impl/LICENSE b/third_party/cronet_impl/LICENSE new file mode 100644 index 0000000..03c4569 --- /dev/null +++ b/third_party/cronet_impl/LICENSE @@ -0,0 +1,2327 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +double_conversion +-------------------- +Copyright 2006-2011, the V8 project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +dynamic_annotations +-------------------- +/* Copyright (c) 2008-2009, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * --- + * Author: Kostya Serebryany + */ + +-------------------- +libevent +-------------------- +Libevent is available for use under the following license, commonly known +as the 3-clause (or "modified") BSD license: + +============================== +Copyright (c) 2000-2007 Niels Provos +Copyright (c) 2007-2010 Niels Provos and Nick Mathewson + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +============================== + +Portions of Libevent are based on works by others, also made available by +them under the three-clause BSD license above. The copyright notices are +available in the corresponding source files; the license is as above. Here's +a list: + +log.c: + Copyright (c) 2000 Dug Song + Copyright (c) 1993 The Regents of the University of California. + +strlcpy.c: + Copyright (c) 1998 Todd C. Miller + +win32.c: + Copyright (c) 2003 Michael A. Davis + +evport.c: + Copyright (c) 2007 Sun Microsystems + +min_heap.h: + Copyright (c) 2006 Maxim Yegorushkin + +tree.h: + Copyright 2002 Niels Provos + +-------------------- +symbolize +-------------------- +// Copyright (c) 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +xdg_mime +-------------------- +Licensed under the Academic Free License version 2.0 (below) +Or under the following terms: + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the +Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. + + +-------------------------------------------------------------------------------- +Academic Free License v. 2.0 +-------------------------------------------------------------------------------- + +This Academic Free License (the "License") applies to any original work of +authorship (the "Original Work") whose owner (the "Licensor") has placed the +following notice immediately following the copyright notice for the Original +Work: + +Licensed under the Academic Free License version 2.0 +1) Grant of Copyright License. Licensor hereby grants You a world-wide, +royalty-free, non-exclusive, perpetual, sublicenseable license to do the +following: + +a) to reproduce the Original Work in copies; +b) to prepare derivative works ("Derivative Works") based upon the Original + Work; +c) to distribute copies of the Original Work and Derivative Works to the + public; +d) to perform the Original Work publicly; and +e) to display the Original Work publicly. + +2) Grant of Patent License. Licensor hereby grants You a world-wide, +royalty-free, non-exclusive, perpetual, sublicenseable license, under patent +claims owned or controlled by the Licensor that are embodied in the Original +Work as furnished by the Licensor, to make, use, sell and offer for sale the +Original Work and Derivative Works. + +3) Grant of Source Code License. The term "Source Code" means the preferred +form of the Original Work for making modifications to it and all available +documentation describing how to modify the Original Work. Licensor hereby +agrees to provide a machine-readable copy of the Source Code of the Original +Work along with each copy of the Original Work that Licensor distributes. +Licensor reserves the right to satisfy this obligation by placing a +machine-readable copy of the Source Code in an information repository +reasonably calculated to permit inexpensive and convenient access by You for as +long as Licensor continues to distribute the Original Work, and by publishing +the address of that information repository in a notice immediately following +the copyright notice that applies to the Original Work. + +4) Exclusions From License Grant. Neither the names of Licensor, nor the names +of any contributors to the Original Work, nor any of their trademarks or +service marks, may be used to endorse or promote products derived from this +Original Work without express prior written permission of the Licensor. Nothing +in this License shall be deemed to grant any rights to trademarks, copyrights, +patents, trade secrets or any other intellectual property of Licensor except as +expressly stated herein. No patent license is granted to make, use, sell or +offer to sell embodiments of any patent claims other than the licensed claims +defined in Section 2. No right is granted to the trademarks of Licensor even if +such marks are included in the Original Work. Nothing in this License shall be +interpreted to prohibit Licensor from licensing under different terms from this +License any Original Work that Licensor otherwise would have a right to +license. + +5) This section intentionally omitted. + +6) Attribution Rights. You must retain, in the Source Code of any Derivative +Works that You create, all copyright, patent or trademark notices from the +Source Code of the Original Work, as well as any notices of licensing and any +descriptive text identified therein as an "Attribution Notice." You must cause +the Source Code for any Derivative Works that You create to carry a prominent +Attribution Notice reasonably calculated to inform recipients that You have +modified the Original Work. + +7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that +the copyright in and to the Original Work and the patent rights granted herein +by Licensor are owned by the Licensor or are sublicensed to You under the terms +of this License with the permission of the contributor(s) of those copyrights +and patent rights. Except as expressly stated in the immediately proceeding +sentence, the Original Work is provided under this License on an "AS IS" BASIS +and WITHOUT WARRANTY, either express or implied, including, without limitation, +the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. +This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No +license to Original Work is granted hereunder except under this disclaimer. + +8) Limitation of Liability. Under no circumstances and under no legal theory, +whether in tort (including negligence), contract, or otherwise, shall the +Licensor be liable to any person for any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License +or the use of the Original Work including, without limitation, damages for loss +of goodwill, work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses. This limitation of liability shall not +apply to liability for death or personal injury resulting from Licensor's +negligence to the extent applicable law prohibits such limitation. Some +jurisdictions do not allow the exclusion or limitation of incidental or +consequential damages, so this exclusion and limitation may not apply to You. + +9) Acceptance and Termination. If You distribute copies of the Original Work or +a Derivative Work, You must make a reasonable effort under the circumstances to +obtain the express assent of recipients to the terms of this License. Nothing +else but this License (or another written agreement between Licensor and You) +grants You permission to create Derivative Works based upon the Original Work +or to exercise any of the rights granted in Section 1 herein, and any attempt +to do so except under the terms of this License (or another written agreement +between Licensor and You) is expressly prohibited by U.S. copyright law, the +equivalent laws of other countries, and by international treaty. Therefore, by +exercising any of the rights granted to You in Section 1 herein, You indicate +Your acceptance of this License and all of its terms and conditions. + +10) Termination for Patent Action. This License shall terminate automatically +and You may no longer exercise any of the rights granted to You by this License +as of the date You commence an action, including a cross-claim or counterclaim, +for patent infringement (i) against Licensor with respect to a patent +applicable to software or (ii) against any entity with respect to a patent +applicable to the Original Work (but excluding combinations of the Original +Work with other software or hardware). + +11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this +License may be brought only in the courts of a jurisdiction wherein the +Licensor resides or in which Licensor conducts its primary business, and under +the laws of that jurisdiction excluding its conflict-of-law provisions. The +application of the United Nations Convention on Contracts for the International +Sale of Goods is expressly excluded. Any use of the Original Work outside the +scope of this License or after its termination shall be subject to the +requirements and penalties of the U.S. Copyright Act, 17 U.S.C. 101 et seq., +the equivalent laws of other countries, and international treaty. This section +shall survive the termination of this License. + +12) Attorneys Fees. In any action to enforce the terms of this License or +seeking damages relating thereto, the prevailing party shall be entitled to +recover its costs and expenses, including, without limitation, reasonable +attorneys' fees and costs incurred in connection with such action, including +any appeal of such action. This section shall survive the termination of this +License. + +13) Miscellaneous. This License represents the complete agreement concerning +the subject matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent necessary to +make it enforceable. + +14) Definition of "You" in This License. "You" throughout this License, whether +in upper or lower case, means an individual or a legal entity exercising rights +under, and complying with all of the terms of, this License. For legal +entities, "You" includes any entity that controls, is controlled by, or is +under common control with you. For purposes of this definition, "control" means +(i) the power, direct or indirect, to cause the direction or management of such +entity, whether by contract or otherwise, or (ii) ownership of fifty percent +(50%) or more of the outstanding shares, or (iii) beneficial ownership of such +entity. + +15) Right to Use. You may use the Original Work in all ways not otherwise +restricted or conditioned by this License or by law, and Licensor promises not +to interfere with or be responsible for such uses by You. + +This license is Copyright (C) 2003 Lawrence E. Rosen. All rights reserved. +Permission is hereby granted to copy and distribute this license without +modification. This license may not be modified without the express written +permission of its copyright owner. + +-------------------- +xdg_user_dirs +-------------------- + Copyright (c) 2007 Red Hat, inc + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + +-------------------- +libc++abi +-------------------- +============================================================================== +The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: +============================================================================== + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +---- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + +============================================================================== +Software from third parties included in the LLVM Project: +============================================================================== +The LLVM Project contains third party software which is under different license +terms. All such code will be identified clearly using at least one of two +mechanisms: +1) It will be in a separate directory tree with its own `LICENSE.txt` or + `LICENSE` file at the top containing the specific license and restrictions + which apply to that software, or +2) It will contain specific license and restriction terms at the top of every + file. + +============================================================================== +Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): +============================================================================== + +The libc++abi library is dual licensed under both the University of Illinois +"BSD-Like" license and the MIT license. As a user of this code you may choose +to use it under either license. As a contributor, you agree to allow your code +to be used under both. + +Full text of the relevant licenses is included below. + +============================================================================== + +University of Illinois/NCSA +Open Source License + +Copyright (c) 2009-2019 by the contributors listed in CREDITS.TXT + +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + +============================================================================== + +Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-------------------- +quiche +-------------------- +// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +abseil-cpp +-------------------- + + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +-------------------- +boringssl +-------------------- +BoringSSL is a fork of OpenSSL. As such, large parts of it fall under OpenSSL +licensing. Files that are completely new have a Google copyright and an ISC +license. This license is reproduced at the bottom of this file. + +Contributors to BoringSSL are required to follow the CLA rules for Chromium: +https://cla.developers.google.com/clas + +Files in third_party/ have their own licenses, as described therein. The MIT +license, for third_party/fiat, which, unlike other third_party directories, is +compiled into non-test libraries, is included below. + +The OpenSSL toolkit stays under a dual license, i.e. both the conditions of the +OpenSSL License and the original SSLeay license apply to the toolkit. See below +for the actual license texts. Actually both licenses are BSD-style Open Source +licenses. In case of any license issues related to OpenSSL please contact +openssl-core@openssl.org. + +The following are Google-internal bug numbers where explicit permission from +some authors is recorded for use of their work. (This is purely for our own +record keeping.) + 27287199 + 27287880 + 27287883 + + OpenSSL License + --------------- + +/* ==================================================================== + * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + + Original SSLeay License + ----------------------- + +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + + +ISC license used for completely new code in BoringSSL: + +/* Copyright (c) 2015, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + + +The code in third_party/fiat carries the MIT license: + +Copyright (c) 2015-2016 the fiat-crypto authors (see +https://github.com/mit-plv/fiat-crypto/blob/master/AUTHORS). + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +Licenses for support code +------------------------- + +Parts of the TLS test suite are under the Go license. This code is not included +in BoringSSL (i.e. libcrypto and libssl) when compiled, however, so +distributing code linked against BoringSSL does not trigger this license: + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +BoringSSL uses the Chromium test infrastructure to run a continuous build, +trybots etc. The scripts which manage this, and the script for generating build +metadata, are under the Chromium license. Distributing code linked against +BoringSSL does not trigger this license. + +Copyright 2015 The Chromium Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +fiat +-------------------- +The MIT License (MIT) + +Copyright (c) 2015-2016 the fiat-crypto authors (see +https://github.com/mit-plv/fiat-crypto/blob/master/AUTHORS). + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +-------------------- +breakpad +-------------------- +Copyright (c) 2006, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1996 - 2011, Daniel Stenberg, . + +All rights reserved. + +Permission to use, copy, modify, and distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright +notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN +NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of a copyright holder shall not +be used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization of the copyright holder. + + +Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + +@APPLE_LICENSE_HEADER_START@ + +This file contains Original Code and/or Modifications of Original Code +as defined in and that are subject to the Apple Public Source License +Version 2.0 (the 'License'). You may not use this file except in +compliance with the License. Please obtain a copy of the License at +http://www.opensource.apple.com/apsl/ and read it before using this +file. + +The Original Code and all software distributed under the License are +distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +Please see the License for the specific language governing rights and +limitations under the License. + +@APPLE_LICENSE_HEADER_END@ + + +Copyright 2007-2008 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy +of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations under +the License. + +-------------------- +brotli +-------------------- +Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-------------------- +ced +-------------------- +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +crashpad +-------------------- + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +-------------------- +icu +-------------------- +COPYRIGHT AND PERMISSION NOTICE (ICU 58 and later) + +Copyright © 1991-2020 Unicode, Inc. All rights reserved. +Distributed under the Terms of Use in https://www.unicode.org/copyright.html. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Unicode data files and any associated documentation +(the "Data Files") or Unicode software and any associated documentation +(the "Software") to deal in the Data Files or Software +without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, and/or sell copies of +the Data Files or Software, and to permit persons to whom the Data Files +or Software are furnished to do so, provided that either +(a) this copyright and permission notice appear with all copies +of the Data Files or Software, or +(b) this copyright and permission notice appear in associated +Documentation. + +THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT OF THIRD PARTY RIGHTS. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS +NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL +DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THE DATA FILES OR SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, +use or other dealings in these Data Files or Software without prior +written authorization of the copyright holder. + +--------------------- + +Third-Party Software Licenses + +This section contains third-party software notices and/or additional +terms for licensed third-party software components included within ICU +libraries. + +1. ICU License - ICU 1.8.1 to ICU 57.1 + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1995-2016 International Business Machines Corporation and others +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, and/or sell copies of the Software, and to permit persons +to whom the Software is furnished to do so, provided that the above +copyright notice(s) and this permission notice appear in all copies of +the Software and that both the above copyright notice(s) and this +permission notice appear in supporting documentation. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY +SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF +CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, use +or other dealings in this Software without prior written authorization +of the copyright holder. + +All trademarks and registered trademarks mentioned herein are the +property of their respective owners. + +2. Chinese/Japanese Word Break Dictionary Data (cjdict.txt) + + # The Google Chrome software developed by Google is licensed under + # the BSD license. Other software included in this distribution is + # provided under other licenses, as set forth below. + # + # The BSD License + # http://opensource.org/licenses/bsd-license.php + # Copyright (C) 2006-2008, Google Inc. + # + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided that the following conditions are met: + # + # Redistributions of source code must retain the above copyright notice, + # this list of conditions and the following disclaimer. + # Redistributions in binary form must reproduce the above + # copyright notice, this list of conditions and the following + # disclaimer in the documentation and/or other materials provided with + # the distribution. + # Neither the name of Google Inc. nor the names of its + # contributors may be used to endorse or promote products derived from + # this software without specific prior written permission. + # + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + # + # + # The word list in cjdict.txt are generated by combining three word lists + # listed below with further processing for compound word breaking. The + # frequency is generated with an iterative training against Google web + # corpora. + # + # * Libtabe (Chinese) + # - https://sourceforge.net/project/?group_id=1519 + # - Its license terms and conditions are shown below. + # + # * IPADIC (Japanese) + # - http://chasen.aist-nara.ac.jp/chasen/distribution.html + # - Its license terms and conditions are shown below. + # + # ---------COPYING.libtabe ---- BEGIN-------------------- + # + # /* + # * Copyright (c) 1999 TaBE Project. + # * Copyright (c) 1999 Pai-Hsiang Hsiao. + # * All rights reserved. + # * + # * Redistribution and use in source and binary forms, with or without + # * modification, are permitted provided that the following conditions + # * are met: + # * + # * . Redistributions of source code must retain the above copyright + # * notice, this list of conditions and the following disclaimer. + # * . Redistributions in binary form must reproduce the above copyright + # * notice, this list of conditions and the following disclaimer in + # * the documentation and/or other materials provided with the + # * distribution. + # * . Neither the name of the TaBE Project nor the names of its + # * contributors may be used to endorse or promote products derived + # * from this software without specific prior written permission. + # * + # * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + # * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + # * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + # * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + # * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + # * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + # * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + # * OF THE POSSIBILITY OF SUCH DAMAGE. + # */ + # + # /* + # * Copyright (c) 1999 Computer Systems and Communication Lab, + # * Institute of Information Science, Academia + # * Sinica. All rights reserved. + # * + # * Redistribution and use in source and binary forms, with or without + # * modification, are permitted provided that the following conditions + # * are met: + # * + # * . Redistributions of source code must retain the above copyright + # * notice, this list of conditions and the following disclaimer. + # * . Redistributions in binary form must reproduce the above copyright + # * notice, this list of conditions and the following disclaimer in + # * the documentation and/or other materials provided with the + # * distribution. + # * . Neither the name of the Computer Systems and Communication Lab + # * nor the names of its contributors may be used to endorse or + # * promote products derived from this software without specific + # * prior written permission. + # * + # * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + # * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + # * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + # * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + # * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + # * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + # * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + # * OF THE POSSIBILITY OF SUCH DAMAGE. + # */ + # + # Copyright 1996 Chih-Hao Tsai @ Beckman Institute, + # University of Illinois + # c-tsai4@uiuc.edu http://casper.beckman.uiuc.edu/~c-tsai4 + # + # ---------------COPYING.libtabe-----END-------------------------------- + # + # + # ---------------COPYING.ipadic-----BEGIN------------------------------- + # + # Copyright 2000, 2001, 2002, 2003 Nara Institute of Science + # and Technology. All Rights Reserved. + # + # Use, reproduction, and distribution of this software is permitted. + # Any copy of this software, whether in its original form or modified, + # must include both the above copyright notice and the following + # paragraphs. + # + # Nara Institute of Science and Technology (NAIST), + # the copyright holders, disclaims all warranties with regard to this + # software, including all implied warranties of merchantability and + # fitness, in no event shall NAIST be liable for + # any special, indirect or consequential damages or any damages + # whatsoever resulting from loss of use, data or profits, whether in an + # action of contract, negligence or other tortuous action, arising out + # of or in connection with the use or performance of this software. + # + # A large portion of the dictionary entries + # originate from ICOT Free Software. The following conditions for ICOT + # Free Software applies to the current dictionary as well. + # + # Each User may also freely distribute the Program, whether in its + # original form or modified, to any third party or parties, PROVIDED + # that the provisions of Section 3 ("NO WARRANTY") will ALWAYS appear + # on, or be attached to, the Program, which is distributed substantially + # in the same form as set out herein and that such intended + # distribution, if actually made, will neither violate or otherwise + # contravene any of the laws and regulations of the countries having + # jurisdiction over the User or the intended distribution itself. + # + # NO WARRANTY + # + # The program was produced on an experimental basis in the course of the + # research and development conducted during the project and is provided + # to users as so produced on an experimental basis. Accordingly, the + # program is provided without any warranty whatsoever, whether express, + # implied, statutory or otherwise. The term "warranty" used herein + # includes, but is not limited to, any warranty of the quality, + # performance, merchantability and fitness for a particular purpose of + # the program and the nonexistence of any infringement or violation of + # any right of any third party. + # + # Each user of the program will agree and understand, and be deemed to + # have agreed and understood, that there is no warranty whatsoever for + # the program and, accordingly, the entire risk arising from or + # otherwise connected with the program is assumed by the user. + # + # Therefore, neither ICOT, the copyright holder, or any other + # organization that participated in or was otherwise related to the + # development of the program and their respective officials, directors, + # officers and other employees shall be held liable for any and all + # damages, including, without limitation, general, special, incidental + # and consequential damages, arising out of or otherwise in connection + # with the use or inability to use the program or any product, material + # or result produced or otherwise obtained by using the program, + # regardless of whether they have been advised of, or otherwise had + # knowledge of, the possibility of such damages at any time during the + # project or thereafter. Each user will be deemed to have agreed to the + # foregoing by his or her commencement of use of the program. The term + # "use" as used herein includes, but is not limited to, the use, + # modification, copying and distribution of the program and the + # production of secondary products from the program. + # + # In the case where the program, whether in its original form or + # modified, was distributed or delivered to or received by a user from + # any person, organization or entity other than ICOT, unless it makes or + # grants independently of ICOT any specific warranty to the user in + # writing, such person, organization or entity, will also be exempted + # from and not be held liable to the user for any such damages as noted + # above as far as the program is concerned. + # + # ---------------COPYING.ipadic-----END---------------------------------- + +3. Lao Word Break Dictionary Data (laodict.txt) + + # Copyright (c) 2013 International Business Machines Corporation + # and others. All Rights Reserved. + # + # Project: https://github.com/veer66/lao-dictionary + # Dictionary: https://github.com/veer66/lao-dictionary/blob/master/Lao-Dictionary.txt + # License: https://github.com/veer66/lao-dictionary/blob/master/Lao-Dictionary-LICENSE.txt + # (copied below) + # + # This file is derived from the above dictionary, with slight + # modifications. + # ---------------------------------------------------------------------- + # Copyright (C) 2013 Brian Eugene Wilson, Robert Martin Campbell. + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, + # are permitted provided that the following conditions are met: + # + # + # Redistributions of source code must retain the above copyright notice, this + # list of conditions and the following disclaimer. Redistributions in + # binary form must reproduce the above copyright notice, this list of + # conditions and the following disclaimer in the documentation and/or + # other materials provided with the distribution. + # + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + # OF THE POSSIBILITY OF SUCH DAMAGE. + # -------------------------------------------------------------------------- + +4. Burmese Word Break Dictionary Data (burmesedict.txt) + + # Copyright (c) 2014 International Business Machines Corporation + # and others. All Rights Reserved. + # + # This list is part of a project hosted at: + # github.com/kanyawtech/myanmar-karen-word-lists + # + # -------------------------------------------------------------------------- + # Copyright (c) 2013, LeRoy Benjamin Sharon + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided that the following conditions + # are met: Redistributions of source code must retain the above + # copyright notice, this list of conditions and the following + # disclaimer. Redistributions in binary form must reproduce the + # above copyright notice, this list of conditions and the following + # disclaimer in the documentation and/or other materials provided + # with the distribution. + # + # Neither the name Myanmar Karen Word Lists, nor the names of its + # contributors may be used to endorse or promote products derived + # from this software without specific prior written permission. + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS + # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + # SUCH DAMAGE. + # -------------------------------------------------------------------------- + +5. Time Zone Database + + ICU uses the public domain data and code derived from Time Zone +Database for its time zone support. The ownership of the TZ database +is explained in BCP 175: Procedure for Maintaining the Time Zone +Database section 7. + + # 7. Database Ownership + # + # The TZ database itself is not an IETF Contribution or an IETF + # document. Rather it is a pre-existing and regularly updated work + # that is in the public domain, and is intended to remain in the + # public domain. Therefore, BCPs 78 [RFC5378] and 79 [RFC3979] do + # not apply to the TZ Database or contributions that individuals make + # to it. Should any claims be made and substantiated against the TZ + # Database, the organization that is providing the IANA + # Considerations defined in this RFC, under the memorandum of + # understanding with the IETF, currently ICANN, may act in accordance + # with all competent court orders. No ownership claims will be made + # by ICANN or the IETF Trust on the database or the code. Any person + # making a contribution to the database or code waives all rights to + # future claims in that contribution or in the TZ Database. + +6. Google double-conversion + +Copyright 2006-2011, the V8 project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +jsoncpp +-------------------- +The JsonCpp library's source code, including accompanying documentation, +tests and demonstration applications, are licensed under the following +conditions... + +The author (Baptiste Lepilleur) explicitly disclaims copyright in all +jurisdictions which recognize such a disclaimer. In such jurisdictions, +this software is released into the Public Domain. + +In jurisdictions which do not recognize Public Domain property (e.g. Germany as of +2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is +released under the terms of the MIT License (see below). + +In jurisdictions which recognize Public Domain property, the user of this +software may choose to accept it either as 1) Public Domain, 2) under the +conditions of the MIT License (see below), or 3) under the terms of dual +Public Domain/MIT License conditions described here, as they choose. + +The MIT License is about as close to Public Domain as a license can get, and is +described in clear, concise terms at: + + http://en.wikipedia.org/wiki/MIT_License + +The full text of the MIT License follows: + +======================================================================== +Copyright (c) 2007-2010 Baptiste Lepilleur + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +======================================================================== +(END LICENSE TEXT) + +The MIT license is compatible with both the GPL and commercial +software, affording one all of the rights of Public Domain with the +minor nuisance of being required to keep the above copyright notice +and license text in the source code. Note also that by accepting the +Public Domain "license" you can re-license your copy using whatever +license you like. + +-------------------- +modp_b64 +-------------------- + * MODP_B64 - High performance base64 encoder/decoder + * Version 1.3 -- 17-Mar-2006 + * http://modp.com/release/base64 + * + * Copyright (c) 2005, 2006 Nick Galbreath -- nickg [at] modp [dot] com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the modp.com nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +perfetto +-------------------- + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright (c) 2017, The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +-------------------- +protobuf +-------------------- +Copyright 2008 Google Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Code generated by the Protocol Buffer compiler is owned by the owner +of the input file used when generating it. This code is not +standalone and requires a support library to be linked with it. This +support library is itself covered by the above license. + +-------------------- +zlib +-------------------- +version 1.2.11, January 15th, 2017 + +Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. diff --git a/third_party/cronet_sample/LICENSE b/third_party/cronet_sample/LICENSE new file mode 100644 index 0000000..03c4569 --- /dev/null +++ b/third_party/cronet_sample/LICENSE @@ -0,0 +1,2327 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +double_conversion +-------------------- +Copyright 2006-2011, the V8 project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +dynamic_annotations +-------------------- +/* Copyright (c) 2008-2009, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * --- + * Author: Kostya Serebryany + */ + +-------------------- +libevent +-------------------- +Libevent is available for use under the following license, commonly known +as the 3-clause (or "modified") BSD license: + +============================== +Copyright (c) 2000-2007 Niels Provos +Copyright (c) 2007-2010 Niels Provos and Nick Mathewson + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +============================== + +Portions of Libevent are based on works by others, also made available by +them under the three-clause BSD license above. The copyright notices are +available in the corresponding source files; the license is as above. Here's +a list: + +log.c: + Copyright (c) 2000 Dug Song + Copyright (c) 1993 The Regents of the University of California. + +strlcpy.c: + Copyright (c) 1998 Todd C. Miller + +win32.c: + Copyright (c) 2003 Michael A. Davis + +evport.c: + Copyright (c) 2007 Sun Microsystems + +min_heap.h: + Copyright (c) 2006 Maxim Yegorushkin + +tree.h: + Copyright 2002 Niels Provos + +-------------------- +symbolize +-------------------- +// Copyright (c) 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +xdg_mime +-------------------- +Licensed under the Academic Free License version 2.0 (below) +Or under the following terms: + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the +Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. + + +-------------------------------------------------------------------------------- +Academic Free License v. 2.0 +-------------------------------------------------------------------------------- + +This Academic Free License (the "License") applies to any original work of +authorship (the "Original Work") whose owner (the "Licensor") has placed the +following notice immediately following the copyright notice for the Original +Work: + +Licensed under the Academic Free License version 2.0 +1) Grant of Copyright License. Licensor hereby grants You a world-wide, +royalty-free, non-exclusive, perpetual, sublicenseable license to do the +following: + +a) to reproduce the Original Work in copies; +b) to prepare derivative works ("Derivative Works") based upon the Original + Work; +c) to distribute copies of the Original Work and Derivative Works to the + public; +d) to perform the Original Work publicly; and +e) to display the Original Work publicly. + +2) Grant of Patent License. Licensor hereby grants You a world-wide, +royalty-free, non-exclusive, perpetual, sublicenseable license, under patent +claims owned or controlled by the Licensor that are embodied in the Original +Work as furnished by the Licensor, to make, use, sell and offer for sale the +Original Work and Derivative Works. + +3) Grant of Source Code License. The term "Source Code" means the preferred +form of the Original Work for making modifications to it and all available +documentation describing how to modify the Original Work. Licensor hereby +agrees to provide a machine-readable copy of the Source Code of the Original +Work along with each copy of the Original Work that Licensor distributes. +Licensor reserves the right to satisfy this obligation by placing a +machine-readable copy of the Source Code in an information repository +reasonably calculated to permit inexpensive and convenient access by You for as +long as Licensor continues to distribute the Original Work, and by publishing +the address of that information repository in a notice immediately following +the copyright notice that applies to the Original Work. + +4) Exclusions From License Grant. Neither the names of Licensor, nor the names +of any contributors to the Original Work, nor any of their trademarks or +service marks, may be used to endorse or promote products derived from this +Original Work without express prior written permission of the Licensor. Nothing +in this License shall be deemed to grant any rights to trademarks, copyrights, +patents, trade secrets or any other intellectual property of Licensor except as +expressly stated herein. No patent license is granted to make, use, sell or +offer to sell embodiments of any patent claims other than the licensed claims +defined in Section 2. No right is granted to the trademarks of Licensor even if +such marks are included in the Original Work. Nothing in this License shall be +interpreted to prohibit Licensor from licensing under different terms from this +License any Original Work that Licensor otherwise would have a right to +license. + +5) This section intentionally omitted. + +6) Attribution Rights. You must retain, in the Source Code of any Derivative +Works that You create, all copyright, patent or trademark notices from the +Source Code of the Original Work, as well as any notices of licensing and any +descriptive text identified therein as an "Attribution Notice." You must cause +the Source Code for any Derivative Works that You create to carry a prominent +Attribution Notice reasonably calculated to inform recipients that You have +modified the Original Work. + +7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that +the copyright in and to the Original Work and the patent rights granted herein +by Licensor are owned by the Licensor or are sublicensed to You under the terms +of this License with the permission of the contributor(s) of those copyrights +and patent rights. Except as expressly stated in the immediately proceeding +sentence, the Original Work is provided under this License on an "AS IS" BASIS +and WITHOUT WARRANTY, either express or implied, including, without limitation, +the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. +This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No +license to Original Work is granted hereunder except under this disclaimer. + +8) Limitation of Liability. Under no circumstances and under no legal theory, +whether in tort (including negligence), contract, or otherwise, shall the +Licensor be liable to any person for any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License +or the use of the Original Work including, without limitation, damages for loss +of goodwill, work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses. This limitation of liability shall not +apply to liability for death or personal injury resulting from Licensor's +negligence to the extent applicable law prohibits such limitation. Some +jurisdictions do not allow the exclusion or limitation of incidental or +consequential damages, so this exclusion and limitation may not apply to You. + +9) Acceptance and Termination. If You distribute copies of the Original Work or +a Derivative Work, You must make a reasonable effort under the circumstances to +obtain the express assent of recipients to the terms of this License. Nothing +else but this License (or another written agreement between Licensor and You) +grants You permission to create Derivative Works based upon the Original Work +or to exercise any of the rights granted in Section 1 herein, and any attempt +to do so except under the terms of this License (or another written agreement +between Licensor and You) is expressly prohibited by U.S. copyright law, the +equivalent laws of other countries, and by international treaty. Therefore, by +exercising any of the rights granted to You in Section 1 herein, You indicate +Your acceptance of this License and all of its terms and conditions. + +10) Termination for Patent Action. This License shall terminate automatically +and You may no longer exercise any of the rights granted to You by this License +as of the date You commence an action, including a cross-claim or counterclaim, +for patent infringement (i) against Licensor with respect to a patent +applicable to software or (ii) against any entity with respect to a patent +applicable to the Original Work (but excluding combinations of the Original +Work with other software or hardware). + +11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this +License may be brought only in the courts of a jurisdiction wherein the +Licensor resides or in which Licensor conducts its primary business, and under +the laws of that jurisdiction excluding its conflict-of-law provisions. The +application of the United Nations Convention on Contracts for the International +Sale of Goods is expressly excluded. Any use of the Original Work outside the +scope of this License or after its termination shall be subject to the +requirements and penalties of the U.S. Copyright Act, 17 U.S.C. 101 et seq., +the equivalent laws of other countries, and international treaty. This section +shall survive the termination of this License. + +12) Attorneys Fees. In any action to enforce the terms of this License or +seeking damages relating thereto, the prevailing party shall be entitled to +recover its costs and expenses, including, without limitation, reasonable +attorneys' fees and costs incurred in connection with such action, including +any appeal of such action. This section shall survive the termination of this +License. + +13) Miscellaneous. This License represents the complete agreement concerning +the subject matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent necessary to +make it enforceable. + +14) Definition of "You" in This License. "You" throughout this License, whether +in upper or lower case, means an individual or a legal entity exercising rights +under, and complying with all of the terms of, this License. For legal +entities, "You" includes any entity that controls, is controlled by, or is +under common control with you. For purposes of this definition, "control" means +(i) the power, direct or indirect, to cause the direction or management of such +entity, whether by contract or otherwise, or (ii) ownership of fifty percent +(50%) or more of the outstanding shares, or (iii) beneficial ownership of such +entity. + +15) Right to Use. You may use the Original Work in all ways not otherwise +restricted or conditioned by this License or by law, and Licensor promises not +to interfere with or be responsible for such uses by You. + +This license is Copyright (C) 2003 Lawrence E. Rosen. All rights reserved. +Permission is hereby granted to copy and distribute this license without +modification. This license may not be modified without the express written +permission of its copyright owner. + +-------------------- +xdg_user_dirs +-------------------- + Copyright (c) 2007 Red Hat, inc + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + +-------------------- +libc++abi +-------------------- +============================================================================== +The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: +============================================================================== + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +---- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + +============================================================================== +Software from third parties included in the LLVM Project: +============================================================================== +The LLVM Project contains third party software which is under different license +terms. All such code will be identified clearly using at least one of two +mechanisms: +1) It will be in a separate directory tree with its own `LICENSE.txt` or + `LICENSE` file at the top containing the specific license and restrictions + which apply to that software, or +2) It will contain specific license and restriction terms at the top of every + file. + +============================================================================== +Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy): +============================================================================== + +The libc++abi library is dual licensed under both the University of Illinois +"BSD-Like" license and the MIT license. As a user of this code you may choose +to use it under either license. As a contributor, you agree to allow your code +to be used under both. + +Full text of the relevant licenses is included below. + +============================================================================== + +University of Illinois/NCSA +Open Source License + +Copyright (c) 2009-2019 by the contributors listed in CREDITS.TXT + +All rights reserved. + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +SOFTWARE. + +============================================================================== + +Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-------------------- +quiche +-------------------- +// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +abseil-cpp +-------------------- + + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +-------------------- +boringssl +-------------------- +BoringSSL is a fork of OpenSSL. As such, large parts of it fall under OpenSSL +licensing. Files that are completely new have a Google copyright and an ISC +license. This license is reproduced at the bottom of this file. + +Contributors to BoringSSL are required to follow the CLA rules for Chromium: +https://cla.developers.google.com/clas + +Files in third_party/ have their own licenses, as described therein. The MIT +license, for third_party/fiat, which, unlike other third_party directories, is +compiled into non-test libraries, is included below. + +The OpenSSL toolkit stays under a dual license, i.e. both the conditions of the +OpenSSL License and the original SSLeay license apply to the toolkit. See below +for the actual license texts. Actually both licenses are BSD-style Open Source +licenses. In case of any license issues related to OpenSSL please contact +openssl-core@openssl.org. + +The following are Google-internal bug numbers where explicit permission from +some authors is recorded for use of their work. (This is purely for our own +record keeping.) + 27287199 + 27287880 + 27287883 + + OpenSSL License + --------------- + +/* ==================================================================== + * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + + Original SSLeay License + ----------------------- + +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + + +ISC license used for completely new code in BoringSSL: + +/* Copyright (c) 2015, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + + +The code in third_party/fiat carries the MIT license: + +Copyright (c) 2015-2016 the fiat-crypto authors (see +https://github.com/mit-plv/fiat-crypto/blob/master/AUTHORS). + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +Licenses for support code +------------------------- + +Parts of the TLS test suite are under the Go license. This code is not included +in BoringSSL (i.e. libcrypto and libssl) when compiled, however, so +distributing code linked against BoringSSL does not trigger this license: + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +BoringSSL uses the Chromium test infrastructure to run a continuous build, +trybots etc. The scripts which manage this, and the script for generating build +metadata, are under the Chromium license. Distributing code linked against +BoringSSL does not trigger this license. + +Copyright 2015 The Chromium Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +fiat +-------------------- +The MIT License (MIT) + +Copyright (c) 2015-2016 the fiat-crypto authors (see +https://github.com/mit-plv/fiat-crypto/blob/master/AUTHORS). + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +-------------------- +breakpad +-------------------- +Copyright (c) 2006, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1996 - 2011, Daniel Stenberg, . + +All rights reserved. + +Permission to use, copy, modify, and distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright +notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN +NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of a copyright holder shall not +be used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization of the copyright holder. + + +Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + +@APPLE_LICENSE_HEADER_START@ + +This file contains Original Code and/or Modifications of Original Code +as defined in and that are subject to the Apple Public Source License +Version 2.0 (the 'License'). You may not use this file except in +compliance with the License. Please obtain a copy of the License at +http://www.opensource.apple.com/apsl/ and read it before using this +file. + +The Original Code and all software distributed under the License are +distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, +INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. +Please see the License for the specific language governing rights and +limitations under the License. + +@APPLE_LICENSE_HEADER_END@ + + +Copyright 2007-2008 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy +of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations under +the License. + +-------------------- +brotli +-------------------- +Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +-------------------- +ced +-------------------- +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +crashpad +-------------------- + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +-------------------- +icu +-------------------- +COPYRIGHT AND PERMISSION NOTICE (ICU 58 and later) + +Copyright © 1991-2020 Unicode, Inc. All rights reserved. +Distributed under the Terms of Use in https://www.unicode.org/copyright.html. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Unicode data files and any associated documentation +(the "Data Files") or Unicode software and any associated documentation +(the "Software") to deal in the Data Files or Software +without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, and/or sell copies of +the Data Files or Software, and to permit persons to whom the Data Files +or Software are furnished to do so, provided that either +(a) this copyright and permission notice appear with all copies +of the Data Files or Software, or +(b) this copyright and permission notice appear in associated +Documentation. + +THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT OF THIRD PARTY RIGHTS. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS +NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL +DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THE DATA FILES OR SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, +use or other dealings in these Data Files or Software without prior +written authorization of the copyright holder. + +--------------------- + +Third-Party Software Licenses + +This section contains third-party software notices and/or additional +terms for licensed third-party software components included within ICU +libraries. + +1. ICU License - ICU 1.8.1 to ICU 57.1 + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1995-2016 International Business Machines Corporation and others +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, and/or sell copies of the Software, and to permit persons +to whom the Software is furnished to do so, provided that the above +copyright notice(s) and this permission notice appear in all copies of +the Software and that both the above copyright notice(s) and this +permission notice appear in supporting documentation. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY +SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF +CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, use +or other dealings in this Software without prior written authorization +of the copyright holder. + +All trademarks and registered trademarks mentioned herein are the +property of their respective owners. + +2. Chinese/Japanese Word Break Dictionary Data (cjdict.txt) + + # The Google Chrome software developed by Google is licensed under + # the BSD license. Other software included in this distribution is + # provided under other licenses, as set forth below. + # + # The BSD License + # http://opensource.org/licenses/bsd-license.php + # Copyright (C) 2006-2008, Google Inc. + # + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided that the following conditions are met: + # + # Redistributions of source code must retain the above copyright notice, + # this list of conditions and the following disclaimer. + # Redistributions in binary form must reproduce the above + # copyright notice, this list of conditions and the following + # disclaimer in the documentation and/or other materials provided with + # the distribution. + # Neither the name of Google Inc. nor the names of its + # contributors may be used to endorse or promote products derived from + # this software without specific prior written permission. + # + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + # + # + # The word list in cjdict.txt are generated by combining three word lists + # listed below with further processing for compound word breaking. The + # frequency is generated with an iterative training against Google web + # corpora. + # + # * Libtabe (Chinese) + # - https://sourceforge.net/project/?group_id=1519 + # - Its license terms and conditions are shown below. + # + # * IPADIC (Japanese) + # - http://chasen.aist-nara.ac.jp/chasen/distribution.html + # - Its license terms and conditions are shown below. + # + # ---------COPYING.libtabe ---- BEGIN-------------------- + # + # /* + # * Copyright (c) 1999 TaBE Project. + # * Copyright (c) 1999 Pai-Hsiang Hsiao. + # * All rights reserved. + # * + # * Redistribution and use in source and binary forms, with or without + # * modification, are permitted provided that the following conditions + # * are met: + # * + # * . Redistributions of source code must retain the above copyright + # * notice, this list of conditions and the following disclaimer. + # * . Redistributions in binary form must reproduce the above copyright + # * notice, this list of conditions and the following disclaimer in + # * the documentation and/or other materials provided with the + # * distribution. + # * . Neither the name of the TaBE Project nor the names of its + # * contributors may be used to endorse or promote products derived + # * from this software without specific prior written permission. + # * + # * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + # * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + # * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + # * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + # * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + # * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + # * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + # * OF THE POSSIBILITY OF SUCH DAMAGE. + # */ + # + # /* + # * Copyright (c) 1999 Computer Systems and Communication Lab, + # * Institute of Information Science, Academia + # * Sinica. All rights reserved. + # * + # * Redistribution and use in source and binary forms, with or without + # * modification, are permitted provided that the following conditions + # * are met: + # * + # * . Redistributions of source code must retain the above copyright + # * notice, this list of conditions and the following disclaimer. + # * . Redistributions in binary form must reproduce the above copyright + # * notice, this list of conditions and the following disclaimer in + # * the documentation and/or other materials provided with the + # * distribution. + # * . Neither the name of the Computer Systems and Communication Lab + # * nor the names of its contributors may be used to endorse or + # * promote products derived from this software without specific + # * prior written permission. + # * + # * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + # * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + # * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + # * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + # * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + # * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + # * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + # * OF THE POSSIBILITY OF SUCH DAMAGE. + # */ + # + # Copyright 1996 Chih-Hao Tsai @ Beckman Institute, + # University of Illinois + # c-tsai4@uiuc.edu http://casper.beckman.uiuc.edu/~c-tsai4 + # + # ---------------COPYING.libtabe-----END-------------------------------- + # + # + # ---------------COPYING.ipadic-----BEGIN------------------------------- + # + # Copyright 2000, 2001, 2002, 2003 Nara Institute of Science + # and Technology. All Rights Reserved. + # + # Use, reproduction, and distribution of this software is permitted. + # Any copy of this software, whether in its original form or modified, + # must include both the above copyright notice and the following + # paragraphs. + # + # Nara Institute of Science and Technology (NAIST), + # the copyright holders, disclaims all warranties with regard to this + # software, including all implied warranties of merchantability and + # fitness, in no event shall NAIST be liable for + # any special, indirect or consequential damages or any damages + # whatsoever resulting from loss of use, data or profits, whether in an + # action of contract, negligence or other tortuous action, arising out + # of or in connection with the use or performance of this software. + # + # A large portion of the dictionary entries + # originate from ICOT Free Software. The following conditions for ICOT + # Free Software applies to the current dictionary as well. + # + # Each User may also freely distribute the Program, whether in its + # original form or modified, to any third party or parties, PROVIDED + # that the provisions of Section 3 ("NO WARRANTY") will ALWAYS appear + # on, or be attached to, the Program, which is distributed substantially + # in the same form as set out herein and that such intended + # distribution, if actually made, will neither violate or otherwise + # contravene any of the laws and regulations of the countries having + # jurisdiction over the User or the intended distribution itself. + # + # NO WARRANTY + # + # The program was produced on an experimental basis in the course of the + # research and development conducted during the project and is provided + # to users as so produced on an experimental basis. Accordingly, the + # program is provided without any warranty whatsoever, whether express, + # implied, statutory or otherwise. The term "warranty" used herein + # includes, but is not limited to, any warranty of the quality, + # performance, merchantability and fitness for a particular purpose of + # the program and the nonexistence of any infringement or violation of + # any right of any third party. + # + # Each user of the program will agree and understand, and be deemed to + # have agreed and understood, that there is no warranty whatsoever for + # the program and, accordingly, the entire risk arising from or + # otherwise connected with the program is assumed by the user. + # + # Therefore, neither ICOT, the copyright holder, or any other + # organization that participated in or was otherwise related to the + # development of the program and their respective officials, directors, + # officers and other employees shall be held liable for any and all + # damages, including, without limitation, general, special, incidental + # and consequential damages, arising out of or otherwise in connection + # with the use or inability to use the program or any product, material + # or result produced or otherwise obtained by using the program, + # regardless of whether they have been advised of, or otherwise had + # knowledge of, the possibility of such damages at any time during the + # project or thereafter. Each user will be deemed to have agreed to the + # foregoing by his or her commencement of use of the program. The term + # "use" as used herein includes, but is not limited to, the use, + # modification, copying and distribution of the program and the + # production of secondary products from the program. + # + # In the case where the program, whether in its original form or + # modified, was distributed or delivered to or received by a user from + # any person, organization or entity other than ICOT, unless it makes or + # grants independently of ICOT any specific warranty to the user in + # writing, such person, organization or entity, will also be exempted + # from and not be held liable to the user for any such damages as noted + # above as far as the program is concerned. + # + # ---------------COPYING.ipadic-----END---------------------------------- + +3. Lao Word Break Dictionary Data (laodict.txt) + + # Copyright (c) 2013 International Business Machines Corporation + # and others. All Rights Reserved. + # + # Project: https://github.com/veer66/lao-dictionary + # Dictionary: https://github.com/veer66/lao-dictionary/blob/master/Lao-Dictionary.txt + # License: https://github.com/veer66/lao-dictionary/blob/master/Lao-Dictionary-LICENSE.txt + # (copied below) + # + # This file is derived from the above dictionary, with slight + # modifications. + # ---------------------------------------------------------------------- + # Copyright (C) 2013 Brian Eugene Wilson, Robert Martin Campbell. + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, + # are permitted provided that the following conditions are met: + # + # + # Redistributions of source code must retain the above copyright notice, this + # list of conditions and the following disclaimer. Redistributions in + # binary form must reproduce the above copyright notice, this list of + # conditions and the following disclaimer in the documentation and/or + # other materials provided with the distribution. + # + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + # OF THE POSSIBILITY OF SUCH DAMAGE. + # -------------------------------------------------------------------------- + +4. Burmese Word Break Dictionary Data (burmesedict.txt) + + # Copyright (c) 2014 International Business Machines Corporation + # and others. All Rights Reserved. + # + # This list is part of a project hosted at: + # github.com/kanyawtech/myanmar-karen-word-lists + # + # -------------------------------------------------------------------------- + # Copyright (c) 2013, LeRoy Benjamin Sharon + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided that the following conditions + # are met: Redistributions of source code must retain the above + # copyright notice, this list of conditions and the following + # disclaimer. Redistributions in binary form must reproduce the + # above copyright notice, this list of conditions and the following + # disclaimer in the documentation and/or other materials provided + # with the distribution. + # + # Neither the name Myanmar Karen Word Lists, nor the names of its + # contributors may be used to endorse or promote products derived + # from this software without specific prior written permission. + # + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS + # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + # SUCH DAMAGE. + # -------------------------------------------------------------------------- + +5. Time Zone Database + + ICU uses the public domain data and code derived from Time Zone +Database for its time zone support. The ownership of the TZ database +is explained in BCP 175: Procedure for Maintaining the Time Zone +Database section 7. + + # 7. Database Ownership + # + # The TZ database itself is not an IETF Contribution or an IETF + # document. Rather it is a pre-existing and regularly updated work + # that is in the public domain, and is intended to remain in the + # public domain. Therefore, BCPs 78 [RFC5378] and 79 [RFC3979] do + # not apply to the TZ Database or contributions that individuals make + # to it. Should any claims be made and substantiated against the TZ + # Database, the organization that is providing the IANA + # Considerations defined in this RFC, under the memorandum of + # understanding with the IETF, currently ICANN, may act in accordance + # with all competent court orders. No ownership claims will be made + # by ICANN or the IETF Trust on the database or the code. Any person + # making a contribution to the database or code waives all rights to + # future claims in that contribution or in the TZ Database. + +6. Google double-conversion + +Copyright 2006-2011, the V8 project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +jsoncpp +-------------------- +The JsonCpp library's source code, including accompanying documentation, +tests and demonstration applications, are licensed under the following +conditions... + +The author (Baptiste Lepilleur) explicitly disclaims copyright in all +jurisdictions which recognize such a disclaimer. In such jurisdictions, +this software is released into the Public Domain. + +In jurisdictions which do not recognize Public Domain property (e.g. Germany as of +2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is +released under the terms of the MIT License (see below). + +In jurisdictions which recognize Public Domain property, the user of this +software may choose to accept it either as 1) Public Domain, 2) under the +conditions of the MIT License (see below), or 3) under the terms of dual +Public Domain/MIT License conditions described here, as they choose. + +The MIT License is about as close to Public Domain as a license can get, and is +described in clear, concise terms at: + + http://en.wikipedia.org/wiki/MIT_License + +The full text of the MIT License follows: + +======================================================================== +Copyright (c) 2007-2010 Baptiste Lepilleur + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +======================================================================== +(END LICENSE TEXT) + +The MIT license is compatible with both the GPL and commercial +software, affording one all of the rights of Public Domain with the +minor nuisance of being required to keep the above copyright notice +and license text in the source code. Note also that by accepting the +Public Domain "license" you can re-license your copy using whatever +license you like. + +-------------------- +modp_b64 +-------------------- + * MODP_B64 - High performance base64 encoder/decoder + * Version 1.3 -- 17-Mar-2006 + * http://modp.com/release/base64 + * + * Copyright (c) 2005, 2006 Nick Galbreath -- nickg [at] modp [dot] com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the modp.com nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------- +perfetto +-------------------- + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright (c) 2017, The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +-------------------- +protobuf +-------------------- +Copyright 2008 Google Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Code generated by the Protocol Buffer compiler is owned by the owner +of the input file used when generating it. This code is not +standalone and requires a support library to be linked with it. This +support library is itself covered by the above license. + +-------------------- +zlib +-------------------- +version 1.2.11, January 15th, 2017 + +Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. From 7533e4b83389fb6e4970b587874f8deeb40e7cb3 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Tue, 29 Jun 2021 13:59:42 +0530 Subject: [PATCH 30/42] void* -> real type def for cronet fn & test: add regex --- bin/cronet.dart | 6 +- bin/prepare_cronet.dart | 7 +- example_dart/bin/example_dart.dart | 1 + lib/src/dylib_handler.dart | 8 +- lib/src/http_callback_handler.dart | 2 +- lib/src/http_client.dart | 40 ++-- lib/src/http_client_request.dart | 26 +- lib/src/wrapper/generated_bindings.dart | 262 +++++++++++++++------ src/wrapper.cc | 60 +++-- src/wrapper.h | 45 ++-- test/cronet_test.dart | 3 +- third_party/cronet_impl/sample_executor.cc | 42 ++-- 12 files changed, 317 insertions(+), 185 deletions(-) diff --git a/bin/cronet.dart b/bin/cronet.dart index d2d9848..00281fd 100644 --- a/bin/cronet.dart +++ b/bin/cronet.dart @@ -2,16 +2,16 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'prepare_cronet.dart'; +import 'package:cli_util/cli_logging.dart' show Ansi, Logger; import 'package:cronet/src/constants.dart'; -import 'package:cli_util/cli_logging.dart' show Ansi, Logger; +import 'prepare_cronet.dart'; Future main(List platforms) async { final logger = Logger.standard(); final ansi = Ansi(Ansi.terminalSupportsAnsi); if (platforms.isEmpty || platforms.contains('-h')) { - logger.stderr( + logger.stdout( 'Please run: dart run cronet ${ansi.red}.${ansi.none}'); return; } diff --git a/bin/prepare_cronet.dart b/bin/prepare_cronet.dart index 04156e0..50ed39c 100644 --- a/bin/prepare_cronet.dart +++ b/bin/prepare_cronet.dart @@ -8,10 +8,9 @@ import 'dart:io' show Directory, File, HttpClient, Process; import 'package:archive/archive.dart'; import 'package:archive/archive_io.dart'; -import 'package:cronet/src/third_party/ffigen/find_resource.dart'; -import 'package:cronet/src/constants.dart'; - import 'package:cli_util/cli_logging.dart' show Ansi, Logger; +import 'package:cronet/src/constants.dart'; +import 'package:cronet/src/third_party/ffigen/find_resource.dart'; /// Builds the `wrapper` shared library for linux. bool buildWrapperLinux() { @@ -97,7 +96,7 @@ void extract(String fileName, [String dir = '']) { ..createSync(recursive: true) ..writeAsBytesSync(data); } else { - Directory(dir + filename).create(recursive: true); + Directory(dir + filename).createSync(recursive: true); } } } diff --git a/example_dart/bin/example_dart.dart b/example_dart/bin/example_dart.dart index 0a084d2..da563d3 100644 --- a/example_dart/bin/example_dart.dart +++ b/example_dart/bin/example_dart.dart @@ -1,4 +1,5 @@ import 'dart:convert'; + import 'package:cronet/cronet.dart'; /* Trying to re-impliment: https://chromium.googlesource.com/chromium/src/+/master/components/cronet/native/sample/main.cc */ diff --git a/lib/src/dylib_handler.dart b/lib/src/dylib_handler.dart index 93fd0f0..0554865 100644 --- a/lib/src/dylib_handler.dart +++ b/lib/src/dylib_handler.dart @@ -125,10 +125,12 @@ DynamicLibrary loadDylib(String name) { final logger = Logger.standard(); final ansi = Ansi(Ansi.terminalSupportsAnsi); - logger.stderr( - '${ansi.red}Failed to open the library. Make sure that required binaries are in place.${ansi.none}'); + logger + .stderr('${ansi.red}Failed to open the library. Make sure that required' + ' binaries are in place.${ansi.none}'); logger.stdout( - 'To download the binaries, please run the following from the root of your project:'); + 'To download the binaries, please run the following from the root of' + ' your project:'); logger.stdout('${ansi.yellow}dart run cronet ${ansi.none}'); logger.stdout('${ansi.green}Valid platforms are:'); for (final platform in validPlatforms) { diff --git a/lib/src/http_callback_handler.dart b/lib/src/http_callback_handler.dart index ef16c01..6bd1500 100644 --- a/lib/src/http_callback_handler.dart +++ b/lib/src/http_callback_handler.dart @@ -60,7 +60,7 @@ class CallbackHandler { void cleanUpRequest( Pointer reqPtr, void Function() cleanUpClient) { receivePort.close(); - wrapper.RemoveRequest(reqPtr.cast()); + wrapper.RemoveRequest(reqPtr.cast()); cleanUpClient(); } diff --git a/lib/src/http_client.dart b/lib/src/http_client.dart index 81bebd1..c19f8dd 100644 --- a/lib/src/http_client.dart +++ b/lib/src/http_client.dart @@ -13,11 +13,11 @@ import 'exceptions.dart'; import 'http_client_request.dart'; import 'quic_hint.dart'; import 'third_party/cronet/generated_bindings.dart'; -import 'wrapper/generated_bindings.dart' as wrapper; +import 'wrapper/generated_bindings.dart'; // Cronet library is loaded in global scope. final _cronet = Cronet(loadCronet()); -final _wrapper = wrapper.Wrapper(loadWrapper()); +final _wrapper = Wrapper(loadWrapper()); /// A client that receives content, such as web pages, /// from a server using the HTTP, HTTPS, HTTP2, Quic etc. protocol. @@ -45,8 +45,8 @@ class HttpClient { final List quicHints; final Pointer _cronetEngine; - // Keep all the request reference in a list so if the client is being explicitly closed, - // we can clean up the requests. + // Keep all the request reference in a list so if the client is being + // explicitly closed, we can clean up the requests. final _requests = List.empty(growable: true); var _stop = false; @@ -71,25 +71,26 @@ class HttpClient { if (_cronetEngine == nullptr) throw Error(); // Initialize Dart Native API dynamically. _wrapper.InitDartApiDL(NativeApi.initializeApiDLData); - _wrapper.RegisterHttpClient( - this, _cronetEngine.cast()); + _wrapper.RegisterHttpClient(this, _cronetEngine.cast()); // Registers few cronet functions that are required by the wrapper. + // Casting because of https://github.com/dart-lang/ffigen/issues/22 _wrapper.InitCronetApi( - _cronet.addresses.Cronet_Engine_Shutdown.cast(), - _cronet.addresses.Cronet_Engine_Destroy.cast(), - _cronet.addresses.Cronet_Buffer_Create.cast(), - _cronet.addresses.Cronet_Buffer_InitWithAlloc.cast(), - _cronet.addresses.Cronet_UrlRequestCallback_CreateWith.cast(), - _cronet.addresses.Cronet_UrlRequest_InitWithParams.cast()); + _cronet.addresses.Cronet_Engine_Shutdown.cast(), + _cronet.addresses.Cronet_Engine_Destroy.cast(), + _cronet.addresses.Cronet_Buffer_Create.cast(), + _cronet.addresses.Cronet_Buffer_InitWithAlloc.cast(), + _cronet.addresses.Cronet_UrlRequestCallback_CreateWith.cast(), + _cronet.addresses.Cronet_UrlRequest_InitWithParams.cast()); // Registers few cronet functions that are required by the executor // run from the wrapper for executing network requests. + // Casting because of https://github.com/dart-lang/ffigen/issues/22 _wrapper.InitCronetExecutorApi( - _cronet.addresses.Cronet_Executor_CreateWith.cast(), - _cronet.addresses.Cronet_Executor_SetClientContext.cast(), - _cronet.addresses.Cronet_Executor_GetClientContext.cast(), - _cronet.addresses.Cronet_Executor_Destroy.cast(), - _cronet.addresses.Cronet_Runnable_Run.cast(), - _cronet.addresses.Cronet_Runnable_Destroy.cast()); + _cronet.addresses.Cronet_Executor_CreateWith.cast(), + _cronet.addresses.Cronet_Executor_SetClientContext.cast(), + _cronet.addresses.Cronet_Executor_GetClientContext.cast(), + _cronet.addresses.Cronet_Executor_Destroy.cast(), + _cronet.addresses.Cronet_Runnable_Run.cast(), + _cronet.addresses.Cronet_Runnable_Destroy.cast()); // Starting the engine with parameters. final engineParams = _cronet.Cronet_EngineParams_Create(); if (engineParams == nullptr) throw Error(); @@ -144,7 +145,8 @@ class HttpClient { /// Shuts down the [HttpClient]. /// /// The HttpClient will be kept alive until all active connections are done. - /// Trying to establish a new connection after calling close, will throw an exception. + /// Trying to establish a new connection after calling close, will throw an + /// exception. void close() { _stop = true; } diff --git a/lib/src/http_client_request.dart b/lib/src/http_client_request.dart index 0c1f469..2e14da2 100644 --- a/lib/src/http_client_request.dart +++ b/lib/src/http_client_request.dart @@ -14,14 +14,14 @@ import 'exceptions.dart'; import 'http_callback_handler.dart'; import 'http_client_response.dart'; import 'third_party/cronet/generated_bindings.dart'; -import 'wrapper/generated_bindings.dart' as wrapper; +import 'wrapper/generated_bindings.dart'; /// HTTP request for a client connection. /// /// It handles all of the Http Requests made by [HttpClient]. /// Provides two ways to get data from the request. -/// [registerCallbacks] or a [HttpClientResponse] which is a [Stream>]. -/// Either of them can be used at a time. +/// [registerCallbacks] or a [HttpClientResponse] which is a +/// [Stream>]. Either of them can be used at a time. /// /// Example Usage: /// ```dart @@ -35,7 +35,8 @@ import 'wrapper/generated_bindings.dart' as wrapper; /// }); /// ``` abstract class HttpClientRequest implements io.IOSink { - /// Returns [Future] of [HttpClientResponse] which can be listened for server response. + /// Returns [Future] of [HttpClientResponse] which can be listened for server + /// response. /// /// Throws [UrlRequestException] if request can't be initiated. @override @@ -65,7 +66,7 @@ class HttpClientRequestImpl implements HttpClientRequest { final Uri _uri; final String _method; final Cronet _cronet; - final wrapper.Wrapper _wrapper; + final Wrapper _wrapper; final Pointer _cronetEngine; final CallbackHandler _callbackHandler; final Pointer _request; @@ -78,7 +79,8 @@ class HttpClientRequestImpl implements HttpClientRequest { @override Encoding encoding; - /// Initiates a [HttpClientRequestImpl]. It is meant to be used by a [HttpClient]. + /// Initiates a [HttpClientRequestImpl]. It is meant to be used by a + /// [HttpClient]. HttpClientRequestImpl(this._uri, this._method, this._cronet, this._wrapper, this._cronetEngine, this._clientCleanup, {this.encoding = utf8}) @@ -87,8 +89,7 @@ class HttpClientRequestImpl implements HttpClientRequest { _request = _cronet.Cronet_UrlRequest_Create() { // Register the native port to C side. _wrapper.RegisterCallbackHandler( - _callbackHandler.receivePort.sendPort.nativePort, - _request.cast()); + _callbackHandler.receivePort.sendPort.nativePort, _request.cast()); } // Starts the request. @@ -99,10 +100,10 @@ class HttpClientRequestImpl implements HttpClientRequest { requestParams, _method.toNativeUtf8().cast()); final res = _wrapper.Cronet_UrlRequest_Init( - _request.cast(), - _cronetEngine.cast(), + _request.cast(), + _cronetEngine.cast(), _uri.toString().toNativeUtf8().cast(), - requestParams.cast(), + requestParams.cast(), _callbackHandler.executor); if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { @@ -116,7 +117,8 @@ class HttpClientRequestImpl implements HttpClientRequest { _callbackHandler.listen(_request, () => _clientCleanup(this)); } - /// Returns [Future] of [HttpClientResponse] which can be listened for server response. + /// Returns [Future] of [HttpClientResponse] which can be listened for server + /// response. /// /// Throws [UrlRequestException] if request can't be initiated. @override diff --git a/lib/src/wrapper/generated_bindings.dart b/lib/src/wrapper/generated_bindings.dart index 9665421..91e1dda 100644 --- a/lib/src/wrapper/generated_bindings.dart +++ b/lib/src/wrapper/generated_bindings.dart @@ -40,20 +40,22 @@ class Wrapper { _InitDartApiDL_ptr.asFunction<_dart_InitDartApiDL>(); void InitCronetApi( - ffi.Pointer shutdown, - ffi.Pointer destroy, - ffi.Pointer buffer_create, - ffi.Pointer buffer_InitWithAlloc, - ffi.Pointer UrlRequestCallback_CreateWith, - ffi.Pointer UrlRequest_InitWithParams, + ffi.Pointer> Cronet_Engine_Shutdown, + ffi.Pointer> Cronet_Engine_Destroy, + ffi.Pointer> Cronet_Buffer_Create, + ffi.Pointer> Cronet_Buffer_InitWithAlloc, + ffi.Pointer> + Cronet_UrlRequestCallback_CreateWith, + ffi.Pointer> + Cronet_UrlRequest_InitWithParams, ) { return _InitCronetApi( - shutdown, - destroy, - buffer_create, - buffer_InitWithAlloc, - UrlRequestCallback_CreateWith, - UrlRequest_InitWithParams, + Cronet_Engine_Shutdown, + Cronet_Engine_Destroy, + Cronet_Buffer_Create, + Cronet_Buffer_InitWithAlloc, + Cronet_UrlRequestCallback_CreateWith, + Cronet_UrlRequest_InitWithParams, ); } @@ -63,20 +65,22 @@ class Wrapper { _InitCronetApi_ptr.asFunction<_dart_InitCronetApi>(); void InitCronetExecutorApi( - ffi.Pointer executor_createWith, - ffi.Pointer executor_setClientContext, - ffi.Pointer executor_getClientContext, - ffi.Pointer executor_destroy, - ffi.Pointer runnable_run, - ffi.Pointer runnable_destroy, + ffi.Pointer> Cronet_Executor_CreateWith, + ffi.Pointer> + Cronet_Executor_SetClientContext, + ffi.Pointer> + Cronet_Executor_GetClientContext, + ffi.Pointer> Cronet_Executor_Destroy, + ffi.Pointer> Cronet_Runnable_Run, + ffi.Pointer> Cronet_Runnable_Destroy, ) { return _InitCronetExecutorApi( - executor_createWith, - executor_setClientContext, - executor_getClientContext, - executor_destroy, - runnable_run, - runnable_destroy, + Cronet_Executor_CreateWith, + Cronet_Executor_SetClientContext, + Cronet_Executor_GetClientContext, + Cronet_Executor_Destroy, + Cronet_Runnable_Run, + Cronet_Runnable_Destroy, ); } @@ -110,7 +114,7 @@ class Wrapper { void RegisterHttpClient( Object h, - ffi.Pointer ce, + ffi.Pointer ce, ) { return _RegisterHttpClient( h, @@ -125,7 +129,7 @@ class Wrapper { void RegisterCallbackHandler( int nativePort, - ffi.Pointer rp, + ffi.Pointer rp, ) { return _RegisterCallbackHandler( nativePort, @@ -140,7 +144,7 @@ class Wrapper { _RegisterCallbackHandler_ptr.asFunction<_dart_RegisterCallbackHandler>(); void RemoveRequest( - ffi.Pointer rp, + ffi.Pointer rp, ) { return _RemoveRequest( rp, @@ -153,10 +157,10 @@ class Wrapper { _RemoveRequest_ptr.asFunction<_dart_RemoveRequest>(); int Cronet_UrlRequest_Init( - ffi.Pointer self, - ffi.Pointer engine, + ffi.Pointer self, + ffi.Pointer engine, ffi.Pointer url, - ffi.Pointer params, + ffi.Pointer params, ffi.Pointer _executor, ) { return _Cronet_UrlRequest_Init( @@ -175,11 +179,23 @@ class Wrapper { _Cronet_UrlRequest_Init_ptr.asFunction<_dart_Cronet_UrlRequest_Init>(); } -class Cronet_Engine extends ffi.Opaque {} +class Cronet_EnginePtr extends ffi.Opaque {} -class Cronet_UrlRequest extends ffi.Opaque {} +class Cronet_BufferPtr extends ffi.Opaque {} -class Cronet_UrlRequestParams extends ffi.Opaque {} +class Cronet_UrlRequestCallbackPtr extends ffi.Opaque {} + +class Cronet_UrlRequestPtr extends ffi.Opaque {} + +class Cronet_UrlResponseInfoPtr extends ffi.Opaque {} + +class Cronet_ErrorPtr extends ffi.Opaque {} + +class Cronet_UrlRequestParamsPtr extends ffi.Opaque {} + +class Cronet_ExecutorPtr extends ffi.Opaque {} + +class Cronet_RunnablePtr extends ffi.Opaque {} typedef _c_InitDartApiDL = ffi.IntPtr Function( ffi.Pointer data, @@ -189,40 +205,148 @@ typedef _dart_InitDartApiDL = int Function( ffi.Pointer data, ); +typedef _typedefC_1 = ffi.Int32 Function( + ffi.Pointer, +); + +typedef _typedefC_2 = ffi.Void Function( + ffi.Pointer, +); + +typedef _typedefC_3 = ffi.Pointer Function(); + +typedef _typedefC_4 = ffi.Void Function( + ffi.Pointer, + ffi.Uint64, +); + +typedef Cronet_UrlRequestCallback_OnRedirectReceivedFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_UrlRequestCallback_OnResponseStartedFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_UrlRequestCallback_OnReadCompletedFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Uint64, +); + +typedef Cronet_UrlRequestCallback_OnSucceededFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_UrlRequestCallback_OnFailedFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_UrlRequestCallback_OnCanceledFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef _typedefC_5 = ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction>, + ffi.Pointer< + ffi.NativeFunction>, + ffi.Pointer< + ffi.NativeFunction>, + ffi.Pointer>, + ffi.Pointer>, + ffi.Pointer>, +); + +typedef _typedefC_6 = ffi.Int32 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + typedef _c_InitCronetApi = ffi.Void Function( - ffi.Pointer shutdown, - ffi.Pointer destroy, - ffi.Pointer buffer_create, - ffi.Pointer buffer_InitWithAlloc, - ffi.Pointer UrlRequestCallback_CreateWith, - ffi.Pointer UrlRequest_InitWithParams, + ffi.Pointer> Cronet_Engine_Shutdown, + ffi.Pointer> Cronet_Engine_Destroy, + ffi.Pointer> Cronet_Buffer_Create, + ffi.Pointer> Cronet_Buffer_InitWithAlloc, + ffi.Pointer> + Cronet_UrlRequestCallback_CreateWith, + ffi.Pointer> Cronet_UrlRequest_InitWithParams, ); typedef _dart_InitCronetApi = void Function( - ffi.Pointer shutdown, - ffi.Pointer destroy, - ffi.Pointer buffer_create, - ffi.Pointer buffer_InitWithAlloc, - ffi.Pointer UrlRequestCallback_CreateWith, - ffi.Pointer UrlRequest_InitWithParams, + ffi.Pointer> Cronet_Engine_Shutdown, + ffi.Pointer> Cronet_Engine_Destroy, + ffi.Pointer> Cronet_Buffer_Create, + ffi.Pointer> Cronet_Buffer_InitWithAlloc, + ffi.Pointer> + Cronet_UrlRequestCallback_CreateWith, + ffi.Pointer> Cronet_UrlRequest_InitWithParams, +); + +typedef Cronet_Executor_ExecuteFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, +); + +typedef _typedefC_7 = ffi.Pointer Function( + ffi.Pointer>, +); + +typedef _typedefC_8 = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, +); + +typedef _typedefC_9 = ffi.Pointer Function( + ffi.Pointer, +); + +typedef _typedefC_10 = ffi.Void Function( + ffi.Pointer, +); + +typedef _typedefC_11 = ffi.Void Function( + ffi.Pointer, +); + +typedef _typedefC_12 = ffi.Void Function( + ffi.Pointer, ); typedef _c_InitCronetExecutorApi = ffi.Void Function( - ffi.Pointer executor_createWith, - ffi.Pointer executor_setClientContext, - ffi.Pointer executor_getClientContext, - ffi.Pointer executor_destroy, - ffi.Pointer runnable_run, - ffi.Pointer runnable_destroy, + ffi.Pointer> Cronet_Executor_CreateWith, + ffi.Pointer> Cronet_Executor_SetClientContext, + ffi.Pointer> Cronet_Executor_GetClientContext, + ffi.Pointer> Cronet_Executor_Destroy, + ffi.Pointer> Cronet_Runnable_Run, + ffi.Pointer> Cronet_Runnable_Destroy, ); typedef _dart_InitCronetExecutorApi = void Function( - ffi.Pointer executor_createWith, - ffi.Pointer executor_setClientContext, - ffi.Pointer executor_getClientContext, - ffi.Pointer executor_destroy, - ffi.Pointer runnable_run, - ffi.Pointer runnable_destroy, + ffi.Pointer> Cronet_Executor_CreateWith, + ffi.Pointer> Cronet_Executor_SetClientContext, + ffi.Pointer> Cronet_Executor_GetClientContext, + ffi.Pointer> Cronet_Executor_Destroy, + ffi.Pointer> Cronet_Runnable_Run, + ffi.Pointer> Cronet_Runnable_Destroy, ); typedef _c_Create_Executor = ffi.Pointer Function(); @@ -239,44 +363,44 @@ typedef _dart_Destroy_Executor = void Function( typedef _c_RegisterHttpClient = ffi.Void Function( ffi.Handle h, - ffi.Pointer ce, + ffi.Pointer ce, ); typedef _dart_RegisterHttpClient = void Function( Object h, - ffi.Pointer ce, + ffi.Pointer ce, ); typedef _c_RegisterCallbackHandler = ffi.Void Function( ffi.Int64 nativePort, - ffi.Pointer rp, + ffi.Pointer rp, ); typedef _dart_RegisterCallbackHandler = void Function( int nativePort, - ffi.Pointer rp, + ffi.Pointer rp, ); typedef _c_RemoveRequest = ffi.Void Function( - ffi.Pointer rp, + ffi.Pointer rp, ); typedef _dart_RemoveRequest = void Function( - ffi.Pointer rp, + ffi.Pointer rp, ); typedef _c_Cronet_UrlRequest_Init = ffi.Int32 Function( - ffi.Pointer self, - ffi.Pointer engine, + ffi.Pointer self, + ffi.Pointer engine, ffi.Pointer url, - ffi.Pointer params, + ffi.Pointer params, ffi.Pointer _executor, ); typedef _dart_Cronet_UrlRequest_Init = int Function( - ffi.Pointer self, - ffi.Pointer engine, + ffi.Pointer self, + ffi.Pointer engine, ffi.Pointer url, - ffi.Pointer params, + ffi.Pointer params, ffi.Pointer _executor, ); diff --git a/src/wrapper.cc b/src/wrapper.cc index 59a28fe..ed138e3 100644 --- a/src/wrapper.cc +++ b/src/wrapper.cc @@ -41,37 +41,35 @@ intptr_t InitDartApiDL(void *data) { return Dart_InitializeApiDL(data); } //////////////////////////////////////////////////////////////////////////////// // Initialize required cronet functions -void InitCronetApi(void *shutdown, void *destroy, void *buffer_create, - void *buffer_InitWithAlloc, - void *UrlRequestCallback_CreateWith, - void *UrlRequest_InitWithParams) { - if (!(shutdown && destroy && buffer_create && buffer_InitWithAlloc && - UrlRequestCallback_CreateWith && UrlRequest_InitWithParams)) { +void InitCronetApi( + Cronet_RESULT (*Cronet_Engine_Shutdown)(Cronet_EnginePtr), + void (*Cronet_Engine_Destroy)(Cronet_EnginePtr), + Cronet_BufferPtr (*Cronet_Buffer_Create)(void), + void (*Cronet_Buffer_InitWithAlloc)(Cronet_BufferPtr, uint64_t), + Cronet_UrlRequestCallbackPtr (*Cronet_UrlRequestCallback_CreateWith)( + Cronet_UrlRequestCallback_OnRedirectReceivedFunc, + Cronet_UrlRequestCallback_OnResponseStartedFunc, + Cronet_UrlRequestCallback_OnReadCompletedFunc, + Cronet_UrlRequestCallback_OnSucceededFunc, + Cronet_UrlRequestCallback_OnFailedFunc, + Cronet_UrlRequestCallback_OnCanceledFunc), + Cronet_RESULT (*Cronet_UrlRequest_InitWithParams)( + Cronet_UrlRequestPtr, Cronet_EnginePtr, Cronet_String, + Cronet_UrlRequestParamsPtr, Cronet_UrlRequestCallbackPtr, + Cronet_ExecutorPtr)) { + if (!(Cronet_Engine_Shutdown && Cronet_Engine_Destroy && + Cronet_Buffer_Create && Cronet_Buffer_InitWithAlloc && + Cronet_UrlRequestCallback_CreateWith && + Cronet_UrlRequest_InitWithParams)) { std::cerr << "Invalid pointer(s): null" << std::endl; return; } - _Cronet_Engine_Shutdown = - reinterpret_cast(shutdown); - _Cronet_Engine_Destroy = - reinterpret_cast(destroy); - _Cronet_Buffer_Create = - reinterpret_cast(buffer_create); - _Cronet_Buffer_InitWithAlloc = - reinterpret_cast( - buffer_InitWithAlloc); - _Cronet_UrlRequestCallback_CreateWith = - reinterpret_cast( - UrlRequestCallback_CreateWith); - _Cronet_UrlRequest_InitWithParams = reinterpret_cast(UrlRequest_InitWithParams); + _Cronet_Engine_Shutdown = Cronet_Engine_Shutdown; + _Cronet_Engine_Destroy = Cronet_Engine_Destroy; + _Cronet_Buffer_Create = Cronet_Buffer_Create; + _Cronet_Buffer_InitWithAlloc = Cronet_Buffer_InitWithAlloc; + _Cronet_UrlRequestCallback_CreateWith = Cronet_UrlRequestCallback_CreateWith; + _Cronet_UrlRequest_InitWithParams = Cronet_UrlRequest_InitWithParams; } //////////////////////////////////////////////////////////////////////////////// @@ -130,8 +128,7 @@ Dart_CObject CallbackArgBuilder(int num, ...) { c_request_data.type = Dart_CObject_kExternalTypedData; c_request_data.value.as_external_typed_data.type = Dart_TypedData_kUint64; - c_request_data.value.as_external_typed_data.length = - sizeof(uint64_t) * num; + c_request_data.value.as_external_typed_data.length = sizeof(uint64_t) * num; c_request_data.value.as_external_typed_data.data = static_cast(request_buffer); c_request_data.value.as_external_typed_data.peer = request_buffer; @@ -181,9 +178,6 @@ void OnResponseStarted(Cronet_UrlRequestCallbackPtr self, DispatchCallback("OnResponseStarted", request, CallbackArgBuilder(2, info, buffer)); - - // // Started reading the response. - // _Cronet_UrlRequest_Read(request, buffer); } void OnReadCompleted(Cronet_UrlRequestCallbackPtr self, diff --git a/src/wrapper.h b/src/wrapper.h index 69628cd..c6a6a4d 100644 --- a/src/wrapper.h +++ b/src/wrapper.h @@ -8,7 +8,6 @@ #include "../third_party/cronet/cronet.idl_c.h" #include "../third_party/dart-sdk/dart_api_dl.h" - #include "wrapper_export.h" #include @@ -21,16 +20,34 @@ extern "C" { #include DART_EXPORT intptr_t InitDartApiDL(void *data); -DART_EXPORT void InitCronetApi(void *shutdown, void *destroy, - void *buffer_create, void *buffer_InitWithAlloc, - void *UrlRequestCallback_CreateWith, - void *UrlRequest_InitWithParams); -DART_EXPORT void InitCronetExecutorApi(void *executor_createWith, - void *executor_setClientContext, - void *executor_getClientContext, - void *executor_destroy, - void *runnable_run, - void *runnable_destroy); +DART_EXPORT void InitCronetApi( + Cronet_RESULT (*Cronet_Engine_Shutdown)(Cronet_EnginePtr), + void (*Cronet_Engine_Destroy)(Cronet_EnginePtr), + Cronet_BufferPtr (*Cronet_Buffer_Create)(void), + void (*Cronet_Buffer_InitWithAlloc)(Cronet_BufferPtr, uint64_t), + Cronet_UrlRequestCallbackPtr (*Cronet_UrlRequestCallback_CreateWith)( + Cronet_UrlRequestCallback_OnRedirectReceivedFunc, + Cronet_UrlRequestCallback_OnResponseStartedFunc, + Cronet_UrlRequestCallback_OnReadCompletedFunc, + Cronet_UrlRequestCallback_OnSucceededFunc, + Cronet_UrlRequestCallback_OnFailedFunc, + Cronet_UrlRequestCallback_OnCanceledFunc), + Cronet_RESULT (*Cronet_UrlRequest_InitWithParams)( + Cronet_UrlRequestPtr, Cronet_EnginePtr, Cronet_String, + Cronet_UrlRequestParamsPtr, Cronet_UrlRequestCallbackPtr, + Cronet_ExecutorPtr)); + +DART_EXPORT void InitCronetExecutorApi( + Cronet_ExecutorPtr (*Cronet_Executor_CreateWith)( + Cronet_Executor_ExecuteFunc), + void (*Cronet_Executor_SetClientContext)(Cronet_ExecutorPtr, + Cronet_ClientContext), + Cronet_ClientContext (*Cronet_Executor_GetClientContext)( + Cronet_ExecutorPtr), + void (*Cronet_Executor_Destroy)(Cronet_ExecutorPtr), + void (*Cronet_Runnable_Run)(Cronet_RunnablePtr), + void (*Cronet_Runnable_Destroy)(Cronet_RunnablePtr)); + typedef void *ExecutorPtr; DART_EXPORT ExecutorPtr Create_Executor(); @@ -43,12 +60,6 @@ DART_EXPORT void RemoveRequest(Cronet_UrlRequest *rp); DART_EXPORT Cronet_RESULT Cronet_UrlRequest_Init( Cronet_UrlRequest *self, Cronet_Engine *engine, Cronet_String url, Cronet_UrlRequestParams *params, ExecutorPtr _executor); - -/* executor only */ - -typedef void (*Cronet_Executor_ExecuteFunc)(Cronet_Executor *self, - Cronet_Runnable *command); - #ifdef __cplusplus } #endif diff --git a/test/cronet_test.dart b/test/cronet_test.dart index b7bb175..59b04c7 100644 --- a/test/cronet_test.dart +++ b/test/cronet_test.dart @@ -18,7 +18,8 @@ void main() { }); test('Gets the version string', () { - expect(client.httpClientVersion, TypeMatcher()); + final exp = RegExp(r'^\d{2}.\d.\d{4}.\d{3}$'); + expect(true, exp.hasMatch(client.httpClientVersion)); }); test('Gets the user agent', () { diff --git a/third_party/cronet_impl/sample_executor.cc b/third_party/cronet_impl/sample_executor.cc index 561e2ab..ab51100 100644 --- a/third_party/cronet_impl/sample_executor.cc +++ b/third_party/cronet_impl/sample_executor.cc @@ -18,32 +18,28 @@ void (*_Cronet_Executor_Destroy)(Cronet_ExecutorPtr self); void (*_Cronet_Runnable_Run)(Cronet_RunnablePtr self); void (*_Cronet_Runnable_Destroy)(Cronet_RunnablePtr self); -void InitCronetExecutorApi(void *executor_createWith, - void *executor_setClientContext, - void *executor_getClientContext, - void *executor_destroy, void *runnable_run, - void *runnable_destroy) { - if (!(executor_createWith && executor_setClientContext && - executor_getClientContext && executor_destroy && runnable_run && - runnable_destroy)) { +void InitCronetExecutorApi( + Cronet_ExecutorPtr (*Cronet_Executor_CreateWith)( + Cronet_Executor_ExecuteFunc), + void (*Cronet_Executor_SetClientContext)(Cronet_ExecutorPtr, + Cronet_ClientContext), + Cronet_ClientContext (*Cronet_Executor_GetClientContext)( + Cronet_ExecutorPtr), + void (*Cronet_Executor_Destroy)(Cronet_ExecutorPtr), + void (*Cronet_Runnable_Run)(Cronet_RunnablePtr), + void (*Cronet_Runnable_Destroy)(Cronet_RunnablePtr)) { + if (!(Cronet_Executor_CreateWith && Cronet_Executor_SetClientContext && + Cronet_Executor_GetClientContext && Cronet_Executor_Destroy && + Cronet_Runnable_Run && Cronet_Runnable_Destroy)) { std::cerr << "Invalid pointer(s): null" << std::endl; return; } - _Cronet_Executor_CreateWith = - reinterpret_cast( - executor_createWith); - _Cronet_Executor_SetClientContext = - reinterpret_cast( - executor_setClientContext); - _Cronet_Executor_GetClientContext = - reinterpret_cast( - executor_getClientContext); - _Cronet_Executor_Destroy = - reinterpret_cast(executor_destroy); - _Cronet_Runnable_Run = - reinterpret_cast(runnable_run); - _Cronet_Runnable_Destroy = - reinterpret_cast(runnable_destroy); + _Cronet_Executor_CreateWith = Cronet_Executor_CreateWith; + _Cronet_Executor_SetClientContext = Cronet_Executor_SetClientContext; + _Cronet_Executor_GetClientContext = Cronet_Executor_GetClientContext; + _Cronet_Executor_Destroy = Cronet_Executor_Destroy; + _Cronet_Runnable_Run = Cronet_Runnable_Run; + _Cronet_Runnable_Destroy = Cronet_Runnable_Destroy; } SampleExecutor::SampleExecutor() From f9a1e1e79286391b8f17f1f3576646d8972feefd Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Wed, 30 Jun 2021 09:58:29 +0530 Subject: [PATCH 31/42] setup script, cmake based build & set dylibs as global --- README.md | 10 +- bin/cronet.dart | 35 ------ bin/prepare_cronet.dart | 137 ---------------------- bin/setup.dart | 135 +++++++++++++++++++++ lib/src/constants.dart | 2 + lib/src/globals.dart | 13 ++ lib/src/http_callback_handler.dart | 22 ++-- lib/src/http_client.dart | 81 ++++++------- lib/src/http_client_request.dart | 24 ++-- src/CMakeLists.txt | 25 ++-- bin/build.dart => tool/build_wrapper.dart | 22 +--- 11 files changed, 231 insertions(+), 275 deletions(-) delete mode 100644 bin/cronet.dart delete mode 100644 bin/prepare_cronet.dart create mode 100644 bin/setup.dart create mode 100644 lib/src/globals.dart rename bin/build.dart => tool/build_wrapper.dart (73%) diff --git a/README.md b/README.md index 9bf4468..a6f0167 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This is a [GSoC 2021 project](https://summerofcode.withgoogle.com/projects/#4757 ```bash dart pub get - dart run cronet # Downloads the cronet binaries. + dart run cronet:setup # Downloads the cronet binaries. ``` 3. Import @@ -48,12 +48,10 @@ This is a [GSoC 2021 project](https://summerofcode.withgoogle.com/projects/#4757 ```bash cd example_dart -dart run cronet # Downloads the cronet binaries. +dart run cronet:setup # Downloads the cronet binaries. dart run ``` -Replace `` with `linux64` or `windows64`. - ## Run Tests ```bash @@ -66,8 +64,8 @@ You can also test your cronet build independently by following [BUILD.md](third_ ## Building Your Own -1. Make sure you've downloaded your custom version of cronet shared library and filename follows the pattern `cronet.86.0.4240.198.` with a prefix `lib` if on `linux`. Else, you can build cronet from [source](https://www.chromium.org/developers/how-tos/get-the-code) using the [provided instuctions](https://chromium.googlesource.com/chromium/src/+/master/components/cronet/build_instructions.md). Then copy the library to the root of your project. For linux, you can also place the files under `.dart_tool/cronet/linux64` for 64bit linux systems. +1. Make sure you've downloaded your custom version of cronet shared library and filename follows the pattern `cronet.86.0.4240.198.` with a prefix `lib` if on `linux`. Else, you can build cronet from [source](https://www.chromium.org/developers/how-tos/get-the-code) using the [provided instuctions](https://chromium.googlesource.com/chromium/src/+/master/components/cronet/build_instructions.md). Then copy the library to the designated folder. For linux, the files are under `.dart_tool/cronet/linux64`. -2. Run `dart run cronet:build` from the root of your project. +2. Run `dart run cronet:setup build` from the root of your project. **Note for Windows:** Run `step 3` from `x64 Native Tools Command Prompt for VS 2019` shell. diff --git a/bin/cronet.dart b/bin/cronet.dart deleted file mode 100644 index 00281fd..0000000 --- a/bin/cronet.dart +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'package:cli_util/cli_logging.dart' show Ansi, Logger; -import 'package:cronet/src/constants.dart'; - -import 'prepare_cronet.dart'; - -Future main(List platforms) async { - final logger = Logger.standard(); - final ansi = Ansi(Ansi.terminalSupportsAnsi); - if (platforms.isEmpty || platforms.contains('-h')) { - logger.stdout( - 'Please run: dart run cronet ${ansi.red}.${ansi.none}'); - return; - } - for (final platform in platforms) { - if (!validPlatforms.contains(platform)) { - logger - .stderr('${ansi.red}$platform is not a valid platform.${ansi.none}'); - logger.stdout('Valid platfroms are:${ansi.yellow}'); - for (final valid in validPlatforms) { - logger.stdout(valid); - } - logger.stdout(ansi.none); - return; - } - - if (platform.startsWith('linux')) { - if (!buildWrapperLinux()) return; - } - await downloadCronetBinaries(platform); - } -} diff --git a/bin/prepare_cronet.dart b/bin/prepare_cronet.dart deleted file mode 100644 index 50ed39c..0000000 --- a/bin/prepare_cronet.dart +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// Contains the nessesary setup code only. Not meant to be exposed. - -import 'dart:io' show Directory, File, HttpClient, Process; - -import 'package:archive/archive.dart'; -import 'package:archive/archive_io.dart'; -import 'package:cli_util/cli_logging.dart' show Ansi, Logger; -import 'package:cronet/src/constants.dart'; -import 'package:cronet/src/third_party/ffigen/find_resource.dart'; - -/// Builds the `wrapper` shared library for linux. -bool buildWrapperLinux() { - final wrapperPath = wrapperSourcePath(); - final pwd = Directory.current; - const compiler = 'g++'; - const cppV = '-std=c++11'; - const options = [ - '-fPIC', - '-rdynamic', - '-shared', - '-W', - '-ldl', - '-DDART_SHARED_LIB' - ]; - const outputName = 'libwrapper.so'; - const sources = [ - 'wrapper.cc', - '../third_party/cronet_impl/sample_executor.cc', - '../third_party/dart-sdk/dart_api_dl.c', - ]; - const includes = [ - '-I../third_party/cronet/', - '-I../third_party/dart-sdk/', - ]; - Directory.current = Directory(wrapperPath); - print('Building Wrapper...'); - var result = Process.runSync( - compiler, [cppV] + options + sources + ['-o', outputName] + includes); - Directory.current = pwd; - print(result.stdout); - print(result.stderr); - if (result.exitCode != 0) return false; - print("Copying wrapper to project's .dart_tool..."); - Directory('.dart_tool/cronet/linux64').createSync(recursive: true); - File('$wrapperPath/$outputName') - .copySync('.dart_tool/cronet/linux64/$outputName'); - if (result.exitCode != 0) return false; - return true; -} - -/// Builds the `wrapper` shared library for windows. -bool buildWrapperWindows() { - final logger = Logger.standard(); - final ansi = Ansi(Ansi.terminalSupportsAnsi); - final wrapperPath = wrapperSourcePath(); - final pwd = Directory.current; - Directory.current = Directory(wrapperPath); - logger.stdout('Building Wrapper...'); - try { - final result = Process.runSync('cmake', ['CMakeLists.txt', '-B', 'out']); - print(result.stdout); - print(result.stderr); - } catch (error) { - Directory.current = pwd; - logger.stdout("${ansi.red}Build failed.${ansi.none}"); - logger.stdout( - 'Open ${ansi.yellow}x64 Native Tools Command Prompt for VS 2019.${ansi.none} Then run:\n'); - logger.stdout('cd ${pwd.path}\ndart run cronet:build'); - return false; - } - var result = Process.runSync('cmake', ['--build', 'out']); - print(result.stdout); - print(result.stderr); - if (result.exitCode != 0) return false; - Directory.current = pwd; - Directory('.dart_tool\\cronet\\windows64').createSync(recursive: true); - File('$wrapperPath\\out\\Debug\\wrapper.dll') - .copySync('.dart_tool\\cronet\\windows64\\wrapper.dll'); - return true; -} - -// Extracts a tar.gz file. -void extract(String fileName, [String dir = '']) { - final tarGzFile = File(fileName).readAsBytesSync(); - final archive = GZipDecoder().decodeBytes(tarGzFile, verify: true); - final tarData = TarDecoder().decodeBytes(archive, verify: true); - for (final file in tarData) { - final filename = file.name; - if (file.isFile) { - final data = file.content as List; - File(dir + filename) - ..createSync(recursive: true) - ..writeAsBytesSync(data); - } else { - Directory(dir + filename).createSync(recursive: true); - } - } -} - -/// Places downloaded binaries to proper location. -void placeBinaries(String platform, String fileName) { - print('Extracting Cronet for $platform'); - Directory('.dart_tool/cronet').createSync(recursive: true); - extract(fileName, '.dart_tool/cronet/'); - print('Done! Cleaning up...'); - - File(fileName).deleteSync(); - print('Done! Cronet support for $platform is now available!'); -} - -/// Download `cronet` library from Github Releases. -Future downloadCronetBinaries(String platform) async { - if (!isCronetAvailable(platform)) { - final fileName = platform + '.tar.gz'; - print('Downloading Cronet for $platform'); - final downloadUrl = cronetBinaryUrl + fileName; - print(downloadUrl); - try { - final request = await HttpClient().getUrl(Uri.parse(downloadUrl)); - final response = await request.close(); - final fileSink = File(fileName).openWrite(); - await response.pipe(fileSink); - await fileSink.flush(); - await fileSink.close(); - } catch (error) { - Exception("Can't download. Check your network connection!"); - } - - placeBinaries(platform, fileName); - } else { - print("Cronet $platform is already available. No need to download."); - } -} diff --git a/bin/setup.dart b/bin/setup.dart new file mode 100644 index 0000000..e74df47 --- /dev/null +++ b/bin/setup.dart @@ -0,0 +1,135 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:archive/archive.dart'; +import 'package:cli_util/cli_logging.dart' show Ansi, Logger; +import 'package:cronet/src/constants.dart'; +import 'package:cronet/src/third_party/ffigen/find_resource.dart'; + +// Extracts a tar.gz file. +void extract(String fileName, [String dir = '']) { + final tarGzFile = File(fileName).readAsBytesSync(); + final archive = GZipDecoder().decodeBytes(tarGzFile, verify: true); + final tarData = TarDecoder().decodeBytes(archive, verify: true); + for (final file in tarData) { + final filename = file.name; + if (file.isFile) { + final data = file.content as List; + File(dir + filename) + ..createSync(recursive: true) + ..writeAsBytesSync(data); + } else { + Directory(dir + filename).createSync(recursive: true); + } + } +} + +/// Places downloaded binaries to proper location. +void placeBinaries(String platform, String fileName) { + final logger = Logger.standard(); + final ansi = Ansi(Ansi.terminalSupportsAnsi); + logger.stdout('${ansi.yellow}Extracting Cronet for $platform${ansi.none}'); + Directory(binaryStorageDir).createSync(recursive: true); + extract(fileName, binaryStorageDir); + logger.stdout('Done! Cleaning up...'); + + File(fileName).deleteSync(); + logger.stdout( + '${ansi.green}Done! Cronet support for $platform is now available!${ansi.none}'); +} + +/// Download `cronet` library from Github Releases. +Future downloadCronetBinaries(String platform) async { + final logger = Logger.standard(); + final ansi = Ansi(Ansi.terminalSupportsAnsi); + if (!isCronetAvailable(platform)) { + final fileName = platform + '.tar.gz'; + logger.stdout('Downloading Cronet for $platform'); + final downloadUrl = cronetBinaryUrl + fileName; + logger.stdout(downloadUrl); + try { + final request = await HttpClient().getUrl(Uri.parse(downloadUrl)); + final response = await request.close(); + final fileSink = File(fileName).openWrite(); + await response.pipe(fileSink); + await fileSink.flush(); + await fileSink.close(); + } catch (error) { + Exception("Can't download. Check your network connection!"); + } + + placeBinaries(platform, fileName); + } else { + logger.stdout('${ansi.yellow}Cronet $platform is already available.' + ' No need to download.${ansi.none}'); + } +} + +/// Builds wrapper from source for the current platform. +void buildWrapper() { + final logger = Logger.standard(); + final ansi = Ansi(Ansi.terminalSupportsAnsi); + final wrapperPath = wrapperSourcePath(); + final pwd = Directory.current; + Directory.current = Directory(wrapperPath); + logger.stdout('Building Wrapper...'); + try { + final result = Process.runSync( + 'cmake', ['CMakeLists.txt', '-B', 'out/${Platform.operatingSystem}']); + print(result.stdout); + print(result.stderr); + } catch (error) { + Directory.current = pwd; + logger.stdout("${ansi.red}Build failed.${ansi.none}"); + if (Platform.isWindows) { + logger.stdout( + 'Open ${ansi.yellow}x64 Native Tools Command Prompt for VS 2019.${ansi.none} Then run:\n'); + logger.stdout('cd ${pwd.path}\ndart run cronet:setup build'); + } + return; + } + var result = + Process.runSync('cmake', ['--build', 'out/${Platform.operatingSystem}']); + print(result.stdout); + print(result.stderr); + if (result.exitCode != 0) return; + Directory.current = pwd; + final moveLocation = '$binaryStorageDir${Platform.operatingSystem}64'; + Directory(moveLocation).createSync(recursive: true); + final buildOutputPath = Platform.isLinux + ? '$wrapperPath/out/${Platform.operatingSystem}/${getWrapperName()}' + : '$wrapperPath\\out\\${Platform.operatingSystem}\\Debug\\${getWrapperName()}'; + File(buildOutputPath).copySync('$moveLocation/${getWrapperName()}'); + logger.stdout( + '${ansi.green}Wrapper moved to $moveLocation. Success!${ansi.none}'); + return; +} + +Future main(List args) async { + const docStr = """ +dart run cronet:setup [option] +Downloads the cronet binaries.\n +clean\tClean downloaded or built binaries. +build\tBuilds the wrapper. Requires cmake. + """; + final logger = Logger.standard(); + if (args.length > 1) { + logger.stderr('Expected 1 argument only.'); + logger.stdout(docStr); + } else if (args.contains('-h')) { + logger.stdout(docStr); + } else if (args.contains('clean')) { + logger.stdout('cleaning...'); + Directory(binaryStorageDir).deleteSync(recursive: true); + logger.stdout('Done!'); + } else if (args.contains('build')) { + buildWrapper(); + } else { + for (final platform in validPlatforms) { + await downloadCronetBinaries(platform); + } + } +} diff --git a/lib/src/constants.dart b/lib/src/constants.dart index 0c8052d..b0d6168 100644 --- a/lib/src/constants.dart +++ b/lib/src/constants.dart @@ -11,6 +11,8 @@ const cronetBinaryUrl = 'https://github.com/unsuitable001/cronet.dart/releases/download/$release/'; const cronetVersion = "86.0.4240.198"; +const binaryStorageDir = '.dart_tool/cronet/'; + String getDylibName(String name, [String platform = '']) { var ext = '.so'; var prefix = 'lib'; diff --git a/lib/src/globals.dart b/lib/src/globals.dart new file mode 100644 index 0000000..17c11b2 --- /dev/null +++ b/lib/src/globals.dart @@ -0,0 +1,13 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dylib_handler.dart'; +import 'third_party/cronet/generated_bindings.dart'; +import 'wrapper/generated_bindings.dart'; + +final _cronet = Cronet(loadCronet()); +Cronet get cronet => _cronet; + +final _wrapper = Wrapper(loadWrapper()); +Wrapper get wrapper => _wrapper; diff --git a/lib/src/http_callback_handler.dart b/lib/src/http_callback_handler.dart index 6bd1500..81dd8f5 100644 --- a/lib/src/http_callback_handler.dart +++ b/lib/src/http_callback_handler.dart @@ -11,8 +11,8 @@ import 'dart:typed_data'; import 'package:ffi/ffi.dart'; import 'exceptions.dart'; +import 'globals.dart'; import 'third_party/cronet/generated_bindings.dart'; -import 'wrapper/generated_bindings.dart' as wrpr; /// Deserializes the message sent by cronet and it's wrapper. class _CallbackRequestMessage { @@ -35,8 +35,6 @@ class _CallbackRequestMessage { /// data that are sent by [NativePort] from native cronet library. class CallbackHandler { final ReceivePort receivePort; - final Cronet cronet; - final wrpr.Wrapper wrapper; final Pointer executor; // These are a part of HttpClientRequest Public API. @@ -47,7 +45,7 @@ class CallbackHandler { final _controller = StreamController>(); /// Registers the [NativePort] to the cronet side. - CallbackHandler(this.cronet, this.wrapper, this.executor, this.receivePort); + CallbackHandler(this.executor, this.receivePort); /// [Stream] controller for [HttpClientResponse] Stream> get stream { @@ -102,12 +100,12 @@ class CallbackHandler { case 'OnRedirectReceived': { log('New Location: ${Pointer.fromAddress(args[0]).cast().toDartString()}'); + // If NOT a 3XX status code, throw Exception. statusChecker( Pointer.fromAddress(args[1]).cast(), 300, 399, - () => cleanUpRequest(reqPtr, - cleanUpClient)); // If NOT a 3XX status code, throw Exception. + () => cleanUpRequest(reqPtr, cleanUpClient)); if (followRedirects && maxRedirects > 0) { final res = cronet.Cronet_UrlRequest_FollowRedirect(reqPtr); if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { @@ -140,9 +138,9 @@ class CallbackHandler { break; // Read a chunk of data. // - // This is where we actually read the response from the server. Data gets added - // to the stream here. ReadDataCallback is invoked here with data received and no - // of bytes read. + // This is where we actually read the response from the server. Data + // gets added to the stream here. ReadDataCallback is invoked here with + // data received and no of bytes read. case 'OnReadCompleted': { final request = Pointer.fromAddress(args[0]); @@ -166,7 +164,7 @@ class CallbackHandler { } } break; - // In case of network error, we will shut everything down after this. + // In case of network error, we will shut down everything. case 'OnFailed': { final errorPtr = Pointer.fromAddress(args[0]).cast(); @@ -180,7 +178,7 @@ class CallbackHandler { cronet.Cronet_UrlRequest_Destroy(reqPtr); } break; - // when the request is cancelled, we will shut everything down after this. + // When the request is cancelled, we will shut down everything. case 'OnCanceled': { cleanUpRequest(reqPtr, cleanUpClient); @@ -188,7 +186,7 @@ class CallbackHandler { cronet.Cronet_UrlRequest_Destroy(reqPtr); } break; - // When the request is succesfully done, we will shut everything down after this. + // When the request is succesfully done, we will shut down everything. case 'OnSucceeded': { cleanUpRequest(reqPtr, cleanUpClient); diff --git a/lib/src/http_client.dart b/lib/src/http_client.dart index c19f8dd..b023c55 100644 --- a/lib/src/http_client.dart +++ b/lib/src/http_client.dart @@ -7,17 +7,12 @@ import 'dart:ffi'; import 'package:ffi/ffi.dart'; -import 'dylib_handler.dart'; import 'enums.dart'; import 'exceptions.dart'; +import 'globals.dart'; import 'http_client_request.dart'; import 'quic_hint.dart'; import 'third_party/cronet/generated_bindings.dart'; -import 'wrapper/generated_bindings.dart'; - -// Cronet library is loaded in global scope. -final _cronet = Cronet(loadCronet()); -final _wrapper = Wrapper(loadWrapper()); /// A client that receives content, such as web pages, /// from a server using the HTTP, HTTPS, HTTP2, Quic etc. protocol. @@ -67,47 +62,47 @@ class HttpClient { this.quicHints = const [], this.brotli = true, this.acceptLanguage = 'en_US', - }) : _cronetEngine = _cronet.Cronet_Engine_Create() { + }) : _cronetEngine = cronet.Cronet_Engine_Create() { if (_cronetEngine == nullptr) throw Error(); // Initialize Dart Native API dynamically. - _wrapper.InitDartApiDL(NativeApi.initializeApiDLData); - _wrapper.RegisterHttpClient(this, _cronetEngine.cast()); + wrapper.InitDartApiDL(NativeApi.initializeApiDLData); + wrapper.RegisterHttpClient(this, _cronetEngine.cast()); // Registers few cronet functions that are required by the wrapper. // Casting because of https://github.com/dart-lang/ffigen/issues/22 - _wrapper.InitCronetApi( - _cronet.addresses.Cronet_Engine_Shutdown.cast(), - _cronet.addresses.Cronet_Engine_Destroy.cast(), - _cronet.addresses.Cronet_Buffer_Create.cast(), - _cronet.addresses.Cronet_Buffer_InitWithAlloc.cast(), - _cronet.addresses.Cronet_UrlRequestCallback_CreateWith.cast(), - _cronet.addresses.Cronet_UrlRequest_InitWithParams.cast()); + wrapper.InitCronetApi( + cronet.addresses.Cronet_Engine_Shutdown.cast(), + cronet.addresses.Cronet_Engine_Destroy.cast(), + cronet.addresses.Cronet_Buffer_Create.cast(), + cronet.addresses.Cronet_Buffer_InitWithAlloc.cast(), + cronet.addresses.Cronet_UrlRequestCallback_CreateWith.cast(), + cronet.addresses.Cronet_UrlRequest_InitWithParams.cast()); // Registers few cronet functions that are required by the executor // run from the wrapper for executing network requests. // Casting because of https://github.com/dart-lang/ffigen/issues/22 - _wrapper.InitCronetExecutorApi( - _cronet.addresses.Cronet_Executor_CreateWith.cast(), - _cronet.addresses.Cronet_Executor_SetClientContext.cast(), - _cronet.addresses.Cronet_Executor_GetClientContext.cast(), - _cronet.addresses.Cronet_Executor_Destroy.cast(), - _cronet.addresses.Cronet_Runnable_Run.cast(), - _cronet.addresses.Cronet_Runnable_Destroy.cast()); + wrapper.InitCronetExecutorApi( + cronet.addresses.Cronet_Executor_CreateWith.cast(), + cronet.addresses.Cronet_Executor_SetClientContext.cast(), + cronet.addresses.Cronet_Executor_GetClientContext.cast(), + cronet.addresses.Cronet_Executor_Destroy.cast(), + cronet.addresses.Cronet_Runnable_Run.cast(), + cronet.addresses.Cronet_Runnable_Destroy.cast()); // Starting the engine with parameters. - final engineParams = _cronet.Cronet_EngineParams_Create(); + final engineParams = cronet.Cronet_EngineParams_Create(); if (engineParams == nullptr) throw Error(); - _cronet.Cronet_EngineParams_user_agent_set( + cronet.Cronet_EngineParams_user_agent_set( engineParams, userAgent.toNativeUtf8().cast()); switch (protocol) { case HttpProtocol.quic: - _cronet.Cronet_EngineParams_enable_quic_set(engineParams, true); + cronet.Cronet_EngineParams_enable_quic_set(engineParams, true); break; case HttpProtocol.http2: - _cronet.Cronet_EngineParams_enable_http2_set(engineParams, true); - _cronet.Cronet_EngineParams_enable_quic_set(engineParams, false); + cronet.Cronet_EngineParams_enable_http2_set(engineParams, true); + cronet.Cronet_EngineParams_enable_quic_set(engineParams, false); break; case HttpProtocol.http: - _cronet.Cronet_EngineParams_enable_quic_set(engineParams, false); - _cronet.Cronet_EngineParams_enable_http2_set(engineParams, false); + cronet.Cronet_EngineParams_enable_quic_set(engineParams, false); + cronet.Cronet_EngineParams_enable_http2_set(engineParams, false); break; default: break; @@ -116,26 +111,26 @@ class HttpClient { throw ArgumentError('Quic is not enabled but quic hints are provided.'); } for (final quicHint in quicHints) { - final hint = _cronet.Cronet_QuicHint_Create(); + final hint = cronet.Cronet_QuicHint_Create(); if (hint == nullptr) throw Error(); - _cronet.Cronet_QuicHint_host_set( + cronet.Cronet_QuicHint_host_set( hint, quicHint.host.toNativeUtf8().cast()); - _cronet.Cronet_QuicHint_port_set(hint, quicHint.port); - _cronet.Cronet_QuicHint_alternate_port_set(hint, quicHint.alternatePort); - _cronet.Cronet_EngineParams_quic_hints_add(engineParams, hint); - _cronet.Cronet_QuicHint_Destroy(hint); + cronet.Cronet_QuicHint_port_set(hint, quicHint.port); + cronet.Cronet_QuicHint_alternate_port_set(hint, quicHint.alternatePort); + cronet.Cronet_EngineParams_quic_hints_add(engineParams, hint); + cronet.Cronet_QuicHint_Destroy(hint); } - _cronet.Cronet_EngineParams_enable_brotli_set(engineParams, brotli); - _cronet.Cronet_EngineParams_accept_language_set( + cronet.Cronet_EngineParams_enable_brotli_set(engineParams, brotli); + cronet.Cronet_EngineParams_accept_language_set( engineParams, acceptLanguage.toNativeUtf8().cast()); final res = - _cronet.Cronet_Engine_StartWithParams(_cronetEngine, engineParams); + cronet.Cronet_Engine_StartWithParams(_cronetEngine, engineParams); if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { throw CronetNativeException(res); } - _cronet.Cronet_EngineParams_Destroy(engineParams); + cronet.Cronet_EngineParams_Destroy(engineParams); } void _cleanUpRequests(HttpClientRequest hcr) { @@ -171,8 +166,8 @@ class HttpClient { if (_stop) { throw Exception("Client is closed. Can't open new connections"); } - _requests.add(HttpClientRequestImpl( - url, method, _cronet, _wrapper, _cronetEngine, _cleanUpRequests)); + _requests.add( + HttpClientRequestImpl(url, method, _cronetEngine, _cleanUpRequests)); return _requests.last; }); } @@ -272,7 +267,7 @@ class HttpClient { /// Version string of the Cronet Shared Library currently in use. String get httpClientVersion => - _cronet.Cronet_Engine_GetVersionString(_cronetEngine) + cronet.Cronet_Engine_GetVersionString(_cronetEngine) .cast() .toDartString(); } diff --git a/lib/src/http_client_request.dart b/lib/src/http_client_request.dart index 2e14da2..b95427a 100644 --- a/lib/src/http_client_request.dart +++ b/lib/src/http_client_request.dart @@ -11,10 +11,10 @@ import 'dart:isolate'; import 'package:ffi/ffi.dart'; import 'exceptions.dart'; +import 'globals.dart'; import 'http_callback_handler.dart'; import 'http_client_response.dart'; import 'third_party/cronet/generated_bindings.dart'; -import 'wrapper/generated_bindings.dart'; /// HTTP request for a client connection. /// @@ -65,8 +65,6 @@ abstract class HttpClientRequest implements io.IOSink { class HttpClientRequestImpl implements HttpClientRequest { final Uri _uri; final String _method; - final Cronet _cronet; - final Wrapper _wrapper; final Pointer _cronetEngine; final CallbackHandler _callbackHandler; final Pointer _request; @@ -81,25 +79,25 @@ class HttpClientRequestImpl implements HttpClientRequest { /// Initiates a [HttpClientRequestImpl]. It is meant to be used by a /// [HttpClient]. - HttpClientRequestImpl(this._uri, this._method, this._cronet, this._wrapper, - this._cronetEngine, this._clientCleanup, + HttpClientRequestImpl( + this._uri, this._method, this._cronetEngine, this._clientCleanup, {this.encoding = utf8}) - : _callbackHandler = CallbackHandler( - _cronet, _wrapper, _wrapper.Create_Executor(), ReceivePort()), - _request = _cronet.Cronet_UrlRequest_Create() { + : _callbackHandler = + CallbackHandler(wrapper.Create_Executor(), ReceivePort()), + _request = cronet.Cronet_UrlRequest_Create() { // Register the native port to C side. - _wrapper.RegisterCallbackHandler( + wrapper.RegisterCallbackHandler( _callbackHandler.receivePort.sendPort.nativePort, _request.cast()); } // Starts the request. void _startRequest() { - final requestParams = _cronet.Cronet_UrlRequestParams_Create(); + final requestParams = cronet.Cronet_UrlRequestParams_Create(); if (requestParams == nullptr) throw Error(); - _cronet.Cronet_UrlRequestParams_http_method_set( + cronet.Cronet_UrlRequestParams_http_method_set( requestParams, _method.toNativeUtf8().cast()); - final res = _wrapper.Cronet_UrlRequest_Init( + final res = wrapper.Cronet_UrlRequest_Init( _request.cast(), _cronetEngine.cast(), _uri.toString().toNativeUtf8().cast(), @@ -110,7 +108,7 @@ class HttpClientRequestImpl implements HttpClientRequest { throw UrlRequestException(res); } - final res2 = _cronet.Cronet_UrlRequest_Start(_request); + final res2 = cronet.Cronet_UrlRequest_Start(_request); if (res2 != Cronet_RESULT.Cronet_RESULT_SUCCESS) { throw UrlRequestException(res2); } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3cd8074..7845e74 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,15 +3,14 @@ cmake_minimum_required(VERSION 3.15) set(PROJECT_NAME "cronet") project(${PROJECT_NAME} LANGUAGES C CXX) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This value is used when generating builds using this plugin, so it must # not be changed set(PLUGIN_NAME "wrapper") -add_compile_definitions(WIN32) add_compile_definitions(DART_SHARED_LIB) - add_library(${PLUGIN_NAME} SHARED "wrapper.cc" "../third_party/cronet_impl/sample_executor.cc" @@ -30,18 +29,20 @@ target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/../third_party/cronet" ) - -set(DART_DIR "C:/tools/dart-sdk/bin") -find_library(DART_LIB dart.lib ${DART_DIR}) -target_link_libraries(${PLUGIN_NAME} PRIVATE ${DART_LIB}) - - -set(MSVC_DISABLED_WARNINGS_LIST +if (WIN32) + set(DART_DIR "C:/tools/dart-sdk/bin") + find_library(DART_LIB dart.lib ${DART_DIR}) + target_link_libraries(${PLUGIN_NAME} PRIVATE ${DART_LIB}) +endif (WIN32) + +if (MSVC) + set(MSVC_DISABLED_WARNINGS_LIST "C4152" # nonstandard extension, function/data pointer conversion in expression "C4255" "C4820" "C4255" "C4668" -) -string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR ${MSVC_DISABLED_WARNINGS_LIST}) -set(CMAKE_C_FLAGS "-utf-8 -Wall -WX ${MSVC_DISABLED_WARNINGS_STR}") \ No newline at end of file + ) + string(REPLACE "C" " -wd" MSVC_DISABLED_WARNINGS_STR ${MSVC_DISABLED_WARNINGS_LIST}) + set(CMAKE_C_FLAGS "-utf-8 -Wall -WX ${MSVC_DISABLED_WARNINGS_STR}") +endif (MSVC) diff --git a/bin/build.dart b/tool/build_wrapper.dart similarity index 73% rename from bin/build.dart rename to tool/build_wrapper.dart index 79dcb12..2a62524 100644 --- a/bin/build.dart +++ b/tool/build_wrapper.dart @@ -2,30 +2,18 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'dart:io'; +import 'dart:io' show Directory, File, Platform, Process; import 'package:cli_util/cli_logging.dart' show Ansi, Logger; - import 'package:cronet/src/constants.dart'; import 'package:cronet/src/third_party/ffigen/find_resource.dart'; -import 'prepare_cronet.dart'; - -void main(List args) { +void main() { final logger = Logger.standard(); final ansi = Ansi(Ansi.terminalSupportsAnsi); - - if (args.contains('-h')) { - print('dart run cronet:build'); - } - if (Platform.isLinux) { - buildWrapperLinux(); - } else if (Platform.isWindows) { - buildWrapperWindows(); - } else { - logger.stderr('${ansi.red}Unsupported platform.${ansi.none}'); - return; - } + final result = Process.runSync('dart', ['run', 'cronet:setup', 'build']); + logger.stdout('${result.stdout}'); + logger.stderr('${result.stderr}'); final cronetName = getDylibName('cronet.$cronetVersion'); if (!isCronetAvailable(Platform.isLinux ? 'linux64' : 'windows64')) { logger.stderr('${ansi.yellow}Make sure that your cronet shared library' From 1d511463a3231831536459126bc8510f74547dcd Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Wed, 30 Jun 2021 10:01:54 +0530 Subject: [PATCH 32/42] analyzer: removed unused show from tool/build_wrapper.dart --- tool/build_wrapper.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/build_wrapper.dart b/tool/build_wrapper.dart index 2a62524..ec06bb8 100644 --- a/tool/build_wrapper.dart +++ b/tool/build_wrapper.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'dart:io' show Directory, File, Platform, Process; +import 'dart:io' show Directory, Platform, Process; import 'package:cli_util/cli_logging.dart' show Ansi, Logger; import 'package:cronet/src/constants.dart'; From 2f93cd31900390152ccd3a11adcdb20aa560ccc1 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Wed, 30 Jun 2021 10:05:56 +0530 Subject: [PATCH 33/42] ci: change ci setup command --- .github/workflows/test-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 7f07cc7..07eddcd 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -62,7 +62,7 @@ jobs: run: dart pub get - id: get_binaries name: Download Cronet Binaries - run: pub run cronet linux64 + run: dart run cronet:setup - name: Run VM tests run: dart test --platform vm if: always() && steps.install.outcome == 'success' From 31de14b9701798ccd11a7228fc80804fa86c7701 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Wed, 30 Jun 2021 12:35:13 +0530 Subject: [PATCH 34/42] CronetNativeException -> Error and enum to string mapping --- lib/src/enums.dart | 58 ++++++++++++++++++++++++++++++ lib/src/exceptions.dart | 23 +++++++----- lib/src/http_callback_handler.dart | 6 ++-- lib/src/http_client.dart | 4 +-- lib/src/http_client_request.dart | 12 +++---- 5 files changed, 83 insertions(+), 20 deletions(-) diff --git a/lib/src/enums.dart b/lib/src/enums.dart index 0ea9a26..f945826 100644 --- a/lib/src/enums.dart +++ b/lib/src/enums.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'third_party/cronet/generated_bindings.dart'; + /// Defines the available http protocols supported by Cronet. enum HttpProtocol { /// HTTP/2 with QUIC. @@ -13,3 +15,59 @@ enum HttpProtocol { /// HTTP/1.1. http } + +/// Cronet Error Enum to Error String bindings. +/// +/// ISSUE: https://github.com/dart-lang/ffigen/issues/236 +abstract class CronetResults extends Cronet_RESULT { + // Supports having duplicate integers with the same key. + static const Map _nameToValue = { + 'Cronet_RESULT_SUCCESS': 0, + 'Cronet_RESULT_ILLEGAL_ARGUMENT': -100, + 'Cronet_RESULT_ILLEGAL_ARGUMENT_STORAGE_PATH_MUST_EXIST': -101, + 'Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_PIN': -102, + 'Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HOSTNAME': -103, + 'Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HTTP_METHOD': -104, + 'Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HTTP_HEADER': -105, + 'Cronet_RESULT_ILLEGAL_STATE': -200, + 'Cronet_RESULT_ILLEGAL_STATE_STORAGE_PATH_IN_USE': -201, + 'Cronet_RESULT_ILLEGAL_STATE_CANNOT_SHUTDOWN_ENGINE_FROM_NETWORK_THREAD': + -202, + 'Cronet_RESULT_ILLEGAL_STATE_ENGINE_ALREADY_STARTED': -203, + 'Cronet_RESULT_ILLEGAL_STATE_REQUEST_ALREADY_STARTED': -204, + 'Cronet_RESULT_ILLEGAL_STATE_REQUEST_NOT_INITIALIZED': -205, + 'Cronet_RESULT_ILLEGAL_STATE_REQUEST_ALREADY_INITIALIZED': -206, + 'Cronet_RESULT_ILLEGAL_STATE_REQUEST_NOT_STARTED': -207, + 'Cronet_RESULT_ILLEGAL_STATE_UNEXPECTED_REDIRECT': -208, + 'Cronet_RESULT_ILLEGAL_STATE_UNEXPECTED_READ': -209, + 'Cronet_RESULT_ILLEGAL_STATE_READ_FAILED': -210, + 'Cronet_RESULT_NULL_POINTER': -300, + 'Cronet_RESULT_NULL_POINTER_HOSTNAME': -301, + 'Cronet_RESULT_NULL_POINTER_SHA256_PINS': -302, + 'Cronet_RESULT_NULL_POINTER_EXPIRATION_DATE': -303, + 'Cronet_RESULT_NULL_POINTER_ENGINE': -304, + 'Cronet_RESULT_NULL_POINTER_URL': -305, + 'Cronet_RESULT_NULL_POINTER_CALLBACK': -306, + 'Cronet_RESULT_NULL_POINTER_EXECUTOR': -307, + 'Cronet_RESULT_NULL_POINTER_METHOD': -308, + 'Cronet_RESULT_NULL_POINTER_HEADER_NAME': -309, + 'Cronet_RESULT_NULL_POINTER_HEADER_VALUE': -310, + 'Cronet_RESULT_NULL_POINTER_PARAMS': -311, + 'Cronet_RESULT_NULL_POINTER_REQUEST_FINISHED_INFO_LISTENER_EXECUTOR': -312, + }; + + // Does not support having duplicate integers with the same key, picks the + // (first? last?) name. + static final Map _valueToName = Map.fromEntries( + _nameToValue.entries.map((e) => MapEntry(e.value, e.key))); + + /// A string representation of an enum value. + static String toEnumName(int enumValue) { + return _valueToName[enumValue]!; + } + + /// An int representation of an enum name. + static int toEnumValue(String enumName) { + return _nameToValue[enumName]!; + } +} diff --git a/lib/src/exceptions.dart b/lib/src/exceptions.dart index 5f9dfb6..c9397c6 100644 --- a/lib/src/exceptions.dart +++ b/lib/src/exceptions.dart @@ -4,6 +4,8 @@ import 'dart:io'; +import 'enums.dart'; + class LoggingException implements Exception { const LoggingException(); } @@ -25,24 +27,27 @@ class HttpException implements IOException { } } -/// Errors/Exceptions from Cronet Native Library. -class CronetNativeException implements Exception { +/// Errors from Cronet Native Library. +class CronetNativeError implements Error { final int val; - const CronetNativeException(this.val); - + const CronetNativeError(this.val); @override String toString() { final b = StringBuffer() - ..write('CronetNativeException: Cronet Result: ') - ..write(val); + ..write('CronetNativeError: Cronet Result: ') + ..write(val) + ..write(' : ${CronetResults.toEnumName(val)}'); return b.toString(); } + + @override + StackTrace? get stackTrace => StackTrace.current; } -/// Exceptions occured while performing a request. +/// Error occured while performing a request. /// /// Failing to start a request or failing to complete /// with a proper server response will throw this exception. -class UrlRequestException extends CronetNativeException { - const UrlRequestException(int val) : super(val); +class UrlRequestError extends CronetNativeError { + const UrlRequestError(int val) : super(val); } diff --git a/lib/src/http_callback_handler.dart b/lib/src/http_callback_handler.dart index 81dd8f5..32e7a1d 100644 --- a/lib/src/http_callback_handler.dart +++ b/lib/src/http_callback_handler.dart @@ -110,7 +110,7 @@ class CallbackHandler { final res = cronet.Cronet_UrlRequest_FollowRedirect(reqPtr); if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { cleanUpRequest(reqPtr, cleanUpClient); - throw UrlRequestException(res); + throw UrlRequestError(res); } maxRedirects--; } else { @@ -132,7 +132,7 @@ class CallbackHandler { final res = cronet.Cronet_UrlRequest_Read( reqPtr, Pointer.fromAddress(args[1]).cast()); if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { - throw UrlRequestException(res); + throw UrlRequestError(res); } } break; @@ -159,7 +159,7 @@ class CallbackHandler { final res = cronet.Cronet_UrlRequest_Read(request, buffer); if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { cleanUpRequest(reqPtr, cleanUpClient); - _controller.addError(UrlRequestException(res)); + _controller.addError(UrlRequestError(res)); _controller.close(); } } diff --git a/lib/src/http_client.dart b/lib/src/http_client.dart index b023c55..0d1114a 100644 --- a/lib/src/http_client.dart +++ b/lib/src/http_client.dart @@ -55,7 +55,7 @@ class HttpClient { /// enabled, then [quicHints] can be provided. [userAgent] and /// [acceptLanguage] can also be provided. /// - /// Throws [CronetNativeException] if [HttpClient] can't be created. + /// Throws [CronetNativeError] if [HttpClient] can't be created. HttpClient({ this.userAgent = 'Dart/2.12', this.protocol = HttpProtocol.quic, @@ -128,7 +128,7 @@ class HttpClient { final res = cronet.Cronet_Engine_StartWithParams(_cronetEngine, engineParams); if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { - throw CronetNativeException(res); + throw CronetNativeError(res); } cronet.Cronet_EngineParams_Destroy(engineParams); } diff --git a/lib/src/http_client_request.dart b/lib/src/http_client_request.dart index b95427a..7bc8826 100644 --- a/lib/src/http_client_request.dart +++ b/lib/src/http_client_request.dart @@ -38,7 +38,7 @@ abstract class HttpClientRequest implements io.IOSink { /// Returns [Future] of [HttpClientResponse] which can be listened for server /// response. /// - /// Throws [UrlRequestException] if request can't be initiated. + /// Throws [UrlRequestError] if request can't be initiated. @override Future close(); @@ -46,7 +46,7 @@ abstract class HttpClientRequest implements io.IOSink { /// once the request is successfully made. /// /// If any problems occurs before the response is available, this future will - /// completes with an [UrlRequestException]. + /// completes with an [UrlRequestError]. @override Future get done; @@ -105,12 +105,12 @@ class HttpClientRequestImpl implements HttpClientRequest { _callbackHandler.executor); if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { - throw UrlRequestException(res); + throw UrlRequestError(res); } final res2 = cronet.Cronet_UrlRequest_Start(_request); if (res2 != Cronet_RESULT.Cronet_RESULT_SUCCESS) { - throw UrlRequestException(res2); + throw UrlRequestError(res2); } _callbackHandler.listen(_request, () => _clientCleanup(this)); } @@ -118,7 +118,7 @@ class HttpClientRequestImpl implements HttpClientRequest { /// Returns [Future] of [HttpClientResponse] which can be listened for server /// response. /// - /// Throws [UrlRequestException] if request can't be initiated. + /// Throws [UrlRequestError] if request can't be initiated. @override Future close() { return Future(() { @@ -131,7 +131,7 @@ class HttpClientRequestImpl implements HttpClientRequest { /// once the request is successfully made. /// /// If any problems occurs before the response is available, this future will - /// completes with an [UrlRequestException]. + /// completes with an [UrlRequestError]. @override Future get done => close(); From 2ce69578795058e026f354205d6b59f02b9383e9 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Wed, 30 Jun 2021 23:44:51 +0530 Subject: [PATCH 35/42] add verify option to cronet:setup, fix setup halting --- .gitignore | 5 +- README.md | 3 +- bin/setup.dart | 64 +- .../cronet/generated_bindings.dart | 7077 +++++++++++++++-- lib/src/third_party/ffigen/find_resource.dart | 9 +- src/CMakeLists.txt | 4 - src/wrapper.cc | 2 +- third_party/cronet/cronet.idl_c.h | 1666 ++-- third_party/cronet_sample/BUILD.md | 15 - third_party/cronet_sample/CMakeLists.txt | 28 + 10 files changed, 7415 insertions(+), 1458 deletions(-) delete mode 100644 third_party/cronet_sample/BUILD.md create mode 100644 third_party/cronet_sample/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 6ff88c4..b4a057b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,8 @@ build/ pubspec.lock -# wrapper build directory -src/out +# cmake build directories +out # Directory created by dartdoc. doc/api/ @@ -45,6 +45,7 @@ cronet_binaries/ *.so.* *.dylib *.dll +*.lib # Compiled executables. *.o diff --git a/README.md b/README.md index a6f0167..192ea7f 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,8 @@ dart run cronet # Downloads the cronet binaries. dart test --platform vm ``` -You can also test your cronet build independently by following [BUILD.md](third_party/cronet_sample/BUILD.md). +You can also verify your cronet binaries using `dart run cronet:setup verify`. +Make sure to have `cmake 3.15`. ## Building Your Own diff --git a/bin/setup.dart b/bin/setup.dart index e74df47..2ecf13a 100644 --- a/bin/setup.dart +++ b/bin/setup.dart @@ -51,12 +51,14 @@ Future downloadCronetBinaries(String platform) async { final downloadUrl = cronetBinaryUrl + fileName; logger.stdout(downloadUrl); try { - final request = await HttpClient().getUrl(Uri.parse(downloadUrl)); + final httpClient = HttpClient(); + final request = await httpClient.getUrl(Uri.parse(downloadUrl)); final response = await request.close(); final fileSink = File(fileName).openWrite(); await response.pipe(fileSink); await fileSink.flush(); await fileSink.close(); + httpClient.close(); } catch (error) { Exception("Can't download. Check your network connection!"); } @@ -108,12 +110,65 @@ void buildWrapper() { return; } +/// Verify if cronet binary is working correctly. +void verifyCronetBinary() { + final logger = Logger.standard(); + final ansi = Ansi(Ansi.terminalSupportsAnsi); + final sampleSource = findPackageRoot() + .resolve('third_party/cronet_sample') + .toFilePath(windows: Platform.isWindows); + final buildName = Platform.isLinux ? 'cronet_sample' : 'cronet_sample.exe'; + final pwd = Directory.current; + if (!isCronetAvailable('${Platform.operatingSystem}64')) { + logger.stderr('${ansi.red}Cronet binaries are not available.${ansi.none}'); + logger.stdout('Get the cronet binaries by running: dart run cronet:setup'); + return; + } + // If the sample is NOT built. + if (!File( + '${pwd.path}/.dart_tool/cronet/${Platform.operatingSystem}64/$buildName') + .existsSync()) { + logger.stdout('Building Sample...'); + var result = Process.runSync('cmake', [ + '$sampleSource/CMakeLists.txt', + '-B', + '$sampleSource/out/${Platform.operatingSystem}' + ], environment: { + 'CURRENTDIR': pwd.path + }); + print(result.stdout); + print(result.stderr); + result = Process.runSync( + 'cmake', ['--build', '$sampleSource/out/${Platform.operatingSystem}'], + environment: {'CURRENTDIR': pwd.path}); + print(result.stdout); + print(result.stderr); + final buildOutputPath = Platform.isLinux + ? '$sampleSource/out/${Platform.operatingSystem}/$buildName' + : '$sampleSource\\out\\${Platform.operatingSystem}\\Debug\\$buildName'; + + logger.stdout('Copying...'); + File(buildOutputPath) + .copySync('.dart_tool/cronet/${Platform.operatingSystem}64/$buildName'); + } + + logger.stdout('Verifying...'); + final result = Process.runSync( + '.dart_tool/cronet/${Platform.operatingSystem}64/$buildName', []); + if (result.exitCode == 0) { + logger.stdout('${ansi.green}Verified! Cronet is working fine.${ansi.none}'); + } else { + logger.stderr('${ansi.red}Verification failed!${ansi.none}'); + } +} + Future main(List args) async { const docStr = """ dart run cronet:setup [option] Downloads the cronet binaries.\n clean\tClean downloaded or built binaries. build\tBuilds the wrapper. Requires cmake. +verify\tVerifies the cronet binary. """; final logger = Logger.standard(); if (args.length > 1) { @@ -127,9 +182,12 @@ build\tBuilds the wrapper. Requires cmake. logger.stdout('Done!'); } else if (args.contains('build')) { buildWrapper(); + } else if (args.contains('verify')) { + verifyCronetBinary(); } else { - for (final platform in validPlatforms) { - await downloadCronetBinaries(platform); + // Targeting only 64bit OS. (At least for the time being.) + if (validPlatforms.contains('${Platform.operatingSystem}64')) { + await downloadCronetBinaries('${Platform.operatingSystem}64'); } } } diff --git a/lib/src/third_party/cronet/generated_bindings.dart b/lib/src/third_party/cronet/generated_bindings.dart index 8abfba1..992958a 100644 --- a/lib/src/third_party/cronet/generated_bindings.dart +++ b/lib/src/third_party/cronet/generated_bindings.dart @@ -26,6 +26,7 @@ class Cronet { lookup) : _lookup = lookup; + /// //////////////////// ffi.Pointer Cronet_Buffer_Create() { return _Cronet_Buffer_Create(); } @@ -36,6 +37,74 @@ class Cronet { late final _dart_Cronet_Buffer_Create _Cronet_Buffer_Create = _Cronet_Buffer_Create_ptr.asFunction<_dart_Cronet_Buffer_Create>(); + void Cronet_Buffer_Destroy( + ffi.Pointer self, + ) { + return _Cronet_Buffer_Destroy( + self, + ); + } + + late final _Cronet_Buffer_Destroy_ptr = + _lookup>( + 'Cronet_Buffer_Destroy'); + late final _dart_Cronet_Buffer_Destroy _Cronet_Buffer_Destroy = + _Cronet_Buffer_Destroy_ptr.asFunction<_dart_Cronet_Buffer_Destroy>(); + + void Cronet_Buffer_SetClientContext( + ffi.Pointer self, + ffi.Pointer client_context, + ) { + return _Cronet_Buffer_SetClientContext( + self, + client_context, + ); + } + + late final _Cronet_Buffer_SetClientContext_ptr = + _lookup>( + 'Cronet_Buffer_SetClientContext'); + late final _dart_Cronet_Buffer_SetClientContext + _Cronet_Buffer_SetClientContext = _Cronet_Buffer_SetClientContext_ptr + .asFunction<_dart_Cronet_Buffer_SetClientContext>(); + + ffi.Pointer Cronet_Buffer_GetClientContext( + ffi.Pointer self, + ) { + return _Cronet_Buffer_GetClientContext( + self, + ); + } + + late final _Cronet_Buffer_GetClientContext_ptr = + _lookup>( + 'Cronet_Buffer_GetClientContext'); + late final _dart_Cronet_Buffer_GetClientContext + _Cronet_Buffer_GetClientContext = _Cronet_Buffer_GetClientContext_ptr + .asFunction<_dart_Cronet_Buffer_GetClientContext>(); + + void Cronet_Buffer_InitWithDataAndCallback( + ffi.Pointer self, + ffi.Pointer data, + int size, + ffi.Pointer callback, + ) { + return _Cronet_Buffer_InitWithDataAndCallback( + self, + data, + size, + callback, + ); + } + + late final _Cronet_Buffer_InitWithDataAndCallback_ptr = + _lookup>( + 'Cronet_Buffer_InitWithDataAndCallback'); + late final _dart_Cronet_Buffer_InitWithDataAndCallback + _Cronet_Buffer_InitWithDataAndCallback = + _Cronet_Buffer_InitWithDataAndCallback_ptr.asFunction< + _dart_Cronet_Buffer_InitWithDataAndCallback>(); + void Cronet_Buffer_InitWithAlloc( ffi.Pointer self, int size, @@ -81,6 +150,113 @@ class Cronet { late final _dart_Cronet_Buffer_GetData _Cronet_Buffer_GetData = _Cronet_Buffer_GetData_ptr.asFunction<_dart_Cronet_Buffer_GetData>(); + ffi.Pointer Cronet_Buffer_CreateWith( + ffi.Pointer> + InitWithDataAndCallbackFunc, + ffi.Pointer> + InitWithAllocFunc, + ffi.Pointer> GetSizeFunc, + ffi.Pointer> GetDataFunc, + ) { + return _Cronet_Buffer_CreateWith( + InitWithDataAndCallbackFunc, + InitWithAllocFunc, + GetSizeFunc, + GetDataFunc, + ); + } + + late final _Cronet_Buffer_CreateWith_ptr = + _lookup>( + 'Cronet_Buffer_CreateWith'); + late final _dart_Cronet_Buffer_CreateWith _Cronet_Buffer_CreateWith = + _Cronet_Buffer_CreateWith_ptr.asFunction< + _dart_Cronet_Buffer_CreateWith>(); + + /// //////////////////// + void Cronet_BufferCallback_Destroy( + ffi.Pointer self, + ) { + return _Cronet_BufferCallback_Destroy( + self, + ); + } + + late final _Cronet_BufferCallback_Destroy_ptr = + _lookup>( + 'Cronet_BufferCallback_Destroy'); + late final _dart_Cronet_BufferCallback_Destroy + _Cronet_BufferCallback_Destroy = _Cronet_BufferCallback_Destroy_ptr + .asFunction<_dart_Cronet_BufferCallback_Destroy>(); + + void Cronet_BufferCallback_SetClientContext( + ffi.Pointer self, + ffi.Pointer client_context, + ) { + return _Cronet_BufferCallback_SetClientContext( + self, + client_context, + ); + } + + late final _Cronet_BufferCallback_SetClientContext_ptr = + _lookup>( + 'Cronet_BufferCallback_SetClientContext'); + late final _dart_Cronet_BufferCallback_SetClientContext + _Cronet_BufferCallback_SetClientContext = + _Cronet_BufferCallback_SetClientContext_ptr.asFunction< + _dart_Cronet_BufferCallback_SetClientContext>(); + + ffi.Pointer Cronet_BufferCallback_GetClientContext( + ffi.Pointer self, + ) { + return _Cronet_BufferCallback_GetClientContext( + self, + ); + } + + late final _Cronet_BufferCallback_GetClientContext_ptr = + _lookup>( + 'Cronet_BufferCallback_GetClientContext'); + late final _dart_Cronet_BufferCallback_GetClientContext + _Cronet_BufferCallback_GetClientContext = + _Cronet_BufferCallback_GetClientContext_ptr.asFunction< + _dart_Cronet_BufferCallback_GetClientContext>(); + + void Cronet_BufferCallback_OnDestroy( + ffi.Pointer self, + ffi.Pointer buffer, + ) { + return _Cronet_BufferCallback_OnDestroy( + self, + buffer, + ); + } + + late final _Cronet_BufferCallback_OnDestroy_ptr = + _lookup>( + 'Cronet_BufferCallback_OnDestroy'); + late final _dart_Cronet_BufferCallback_OnDestroy + _Cronet_BufferCallback_OnDestroy = _Cronet_BufferCallback_OnDestroy_ptr + .asFunction<_dart_Cronet_BufferCallback_OnDestroy>(); + + ffi.Pointer Cronet_BufferCallback_CreateWith( + ffi.Pointer> + OnDestroyFunc, + ) { + return _Cronet_BufferCallback_CreateWith( + OnDestroyFunc, + ); + } + + late final _Cronet_BufferCallback_CreateWith_ptr = + _lookup>( + 'Cronet_BufferCallback_CreateWith'); + late final _dart_Cronet_BufferCallback_CreateWith + _Cronet_BufferCallback_CreateWith = _Cronet_BufferCallback_CreateWith_ptr + .asFunction<_dart_Cronet_BufferCallback_CreateWith>(); + + /// //////////////////// void Cronet_Runnable_Destroy( ffi.Pointer self, ) { @@ -95,6 +271,38 @@ class Cronet { late final _dart_Cronet_Runnable_Destroy _Cronet_Runnable_Destroy = _Cronet_Runnable_Destroy_ptr.asFunction<_dart_Cronet_Runnable_Destroy>(); + void Cronet_Runnable_SetClientContext( + ffi.Pointer self, + ffi.Pointer client_context, + ) { + return _Cronet_Runnable_SetClientContext( + self, + client_context, + ); + } + + late final _Cronet_Runnable_SetClientContext_ptr = + _lookup>( + 'Cronet_Runnable_SetClientContext'); + late final _dart_Cronet_Runnable_SetClientContext + _Cronet_Runnable_SetClientContext = _Cronet_Runnable_SetClientContext_ptr + .asFunction<_dart_Cronet_Runnable_SetClientContext>(); + + ffi.Pointer Cronet_Runnable_GetClientContext( + ffi.Pointer self, + ) { + return _Cronet_Runnable_GetClientContext( + self, + ); + } + + late final _Cronet_Runnable_GetClientContext_ptr = + _lookup>( + 'Cronet_Runnable_GetClientContext'); + late final _dart_Cronet_Runnable_GetClientContext + _Cronet_Runnable_GetClientContext = _Cronet_Runnable_GetClientContext_ptr + .asFunction<_dart_Cronet_Runnable_GetClientContext>(); + void Cronet_Runnable_Run( ffi.Pointer self, ) { @@ -109,6 +317,22 @@ class Cronet { late final _dart_Cronet_Runnable_Run _Cronet_Runnable_Run = _Cronet_Runnable_Run_ptr.asFunction<_dart_Cronet_Runnable_Run>(); + ffi.Pointer Cronet_Runnable_CreateWith( + ffi.Pointer> RunFunc, + ) { + return _Cronet_Runnable_CreateWith( + RunFunc, + ); + } + + late final _Cronet_Runnable_CreateWith_ptr = + _lookup>( + 'Cronet_Runnable_CreateWith'); + late final _dart_Cronet_Runnable_CreateWith _Cronet_Runnable_CreateWith = + _Cronet_Runnable_CreateWith_ptr.asFunction< + _dart_Cronet_Runnable_CreateWith>(); + + /// //////////////////// void Cronet_Executor_Destroy( ffi.Pointer self, ) { @@ -186,6 +410,7 @@ class Cronet { _Cronet_Executor_CreateWith_ptr.asFunction< _dart_Cronet_Executor_CreateWith>(); + /// //////////////////// ffi.Pointer Cronet_Engine_Create() { return _Cronet_Engine_Create(); } @@ -210,6 +435,38 @@ class Cronet { late final _dart_Cronet_Engine_Destroy _Cronet_Engine_Destroy = _Cronet_Engine_Destroy_ptr.asFunction<_dart_Cronet_Engine_Destroy>(); + void Cronet_Engine_SetClientContext( + ffi.Pointer self, + ffi.Pointer client_context, + ) { + return _Cronet_Engine_SetClientContext( + self, + client_context, + ); + } + + late final _Cronet_Engine_SetClientContext_ptr = + _lookup>( + 'Cronet_Engine_SetClientContext'); + late final _dart_Cronet_Engine_SetClientContext + _Cronet_Engine_SetClientContext = _Cronet_Engine_SetClientContext_ptr + .asFunction<_dart_Cronet_Engine_SetClientContext>(); + + ffi.Pointer Cronet_Engine_GetClientContext( + ffi.Pointer self, + ) { + return _Cronet_Engine_GetClientContext( + self, + ); + } + + late final _Cronet_Engine_GetClientContext_ptr = + _lookup>( + 'Cronet_Engine_GetClientContext'); + late final _dart_Cronet_Engine_GetClientContext + _Cronet_Engine_GetClientContext = _Cronet_Engine_GetClientContext_ptr + .asFunction<_dart_Cronet_Engine_GetClientContext>(); + int Cronet_Engine_StartWithParams( ffi.Pointer self, ffi.Pointer params, @@ -291,6 +548,367 @@ class Cronet { _Cronet_Engine_GetVersionString = _Cronet_Engine_GetVersionString_ptr .asFunction<_dart_Cronet_Engine_GetVersionString>(); + ffi.Pointer Cronet_Engine_GetDefaultUserAgent( + ffi.Pointer self, + ) { + return _Cronet_Engine_GetDefaultUserAgent( + self, + ); + } + + late final _Cronet_Engine_GetDefaultUserAgent_ptr = + _lookup>( + 'Cronet_Engine_GetDefaultUserAgent'); + late final _dart_Cronet_Engine_GetDefaultUserAgent + _Cronet_Engine_GetDefaultUserAgent = + _Cronet_Engine_GetDefaultUserAgent_ptr.asFunction< + _dart_Cronet_Engine_GetDefaultUserAgent>(); + + void Cronet_Engine_AddRequestFinishedListener( + ffi.Pointer self, + ffi.Pointer listener, + ffi.Pointer executor, + ) { + return _Cronet_Engine_AddRequestFinishedListener( + self, + listener, + executor, + ); + } + + late final _Cronet_Engine_AddRequestFinishedListener_ptr = + _lookup>( + 'Cronet_Engine_AddRequestFinishedListener'); + late final _dart_Cronet_Engine_AddRequestFinishedListener + _Cronet_Engine_AddRequestFinishedListener = + _Cronet_Engine_AddRequestFinishedListener_ptr.asFunction< + _dart_Cronet_Engine_AddRequestFinishedListener>(); + + void Cronet_Engine_RemoveRequestFinishedListener( + ffi.Pointer self, + ffi.Pointer listener, + ) { + return _Cronet_Engine_RemoveRequestFinishedListener( + self, + listener, + ); + } + + late final _Cronet_Engine_RemoveRequestFinishedListener_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_Engine_RemoveRequestFinishedListener>>( + 'Cronet_Engine_RemoveRequestFinishedListener'); + late final _dart_Cronet_Engine_RemoveRequestFinishedListener + _Cronet_Engine_RemoveRequestFinishedListener = + _Cronet_Engine_RemoveRequestFinishedListener_ptr.asFunction< + _dart_Cronet_Engine_RemoveRequestFinishedListener>(); + + ffi.Pointer Cronet_Engine_CreateWith( + ffi.Pointer> + StartWithParamsFunc, + ffi.Pointer> + StartNetLogToFileFunc, + ffi.Pointer> + StopNetLogFunc, + ffi.Pointer> ShutdownFunc, + ffi.Pointer> + GetVersionStringFunc, + ffi.Pointer> + GetDefaultUserAgentFunc, + ffi.Pointer< + ffi.NativeFunction> + AddRequestFinishedListenerFunc, + ffi.Pointer< + ffi.NativeFunction> + RemoveRequestFinishedListenerFunc, + ) { + return _Cronet_Engine_CreateWith( + StartWithParamsFunc, + StartNetLogToFileFunc, + StopNetLogFunc, + ShutdownFunc, + GetVersionStringFunc, + GetDefaultUserAgentFunc, + AddRequestFinishedListenerFunc, + RemoveRequestFinishedListenerFunc, + ); + } + + late final _Cronet_Engine_CreateWith_ptr = + _lookup>( + 'Cronet_Engine_CreateWith'); + late final _dart_Cronet_Engine_CreateWith _Cronet_Engine_CreateWith = + _Cronet_Engine_CreateWith_ptr.asFunction< + _dart_Cronet_Engine_CreateWith>(); + + /// //////////////////// + void Cronet_UrlRequestStatusListener_Destroy( + ffi.Pointer self, + ) { + return _Cronet_UrlRequestStatusListener_Destroy( + self, + ); + } + + late final _Cronet_UrlRequestStatusListener_Destroy_ptr = + _lookup>( + 'Cronet_UrlRequestStatusListener_Destroy'); + late final _dart_Cronet_UrlRequestStatusListener_Destroy + _Cronet_UrlRequestStatusListener_Destroy = + _Cronet_UrlRequestStatusListener_Destroy_ptr.asFunction< + _dart_Cronet_UrlRequestStatusListener_Destroy>(); + + void Cronet_UrlRequestStatusListener_SetClientContext( + ffi.Pointer self, + ffi.Pointer client_context, + ) { + return _Cronet_UrlRequestStatusListener_SetClientContext( + self, + client_context, + ); + } + + late final _Cronet_UrlRequestStatusListener_SetClientContext_ptr = _lookup< + ffi.NativeFunction< + _c_Cronet_UrlRequestStatusListener_SetClientContext>>( + 'Cronet_UrlRequestStatusListener_SetClientContext'); + late final _dart_Cronet_UrlRequestStatusListener_SetClientContext + _Cronet_UrlRequestStatusListener_SetClientContext = + _Cronet_UrlRequestStatusListener_SetClientContext_ptr.asFunction< + _dart_Cronet_UrlRequestStatusListener_SetClientContext>(); + + ffi.Pointer Cronet_UrlRequestStatusListener_GetClientContext( + ffi.Pointer self, + ) { + return _Cronet_UrlRequestStatusListener_GetClientContext( + self, + ); + } + + late final _Cronet_UrlRequestStatusListener_GetClientContext_ptr = _lookup< + ffi.NativeFunction< + _c_Cronet_UrlRequestStatusListener_GetClientContext>>( + 'Cronet_UrlRequestStatusListener_GetClientContext'); + late final _dart_Cronet_UrlRequestStatusListener_GetClientContext + _Cronet_UrlRequestStatusListener_GetClientContext = + _Cronet_UrlRequestStatusListener_GetClientContext_ptr.asFunction< + _dart_Cronet_UrlRequestStatusListener_GetClientContext>(); + + void Cronet_UrlRequestStatusListener_OnStatus( + ffi.Pointer self, + int status, + ) { + return _Cronet_UrlRequestStatusListener_OnStatus( + self, + status, + ); + } + + late final _Cronet_UrlRequestStatusListener_OnStatus_ptr = + _lookup>( + 'Cronet_UrlRequestStatusListener_OnStatus'); + late final _dart_Cronet_UrlRequestStatusListener_OnStatus + _Cronet_UrlRequestStatusListener_OnStatus = + _Cronet_UrlRequestStatusListener_OnStatus_ptr.asFunction< + _dart_Cronet_UrlRequestStatusListener_OnStatus>(); + + ffi.Pointer + Cronet_UrlRequestStatusListener_CreateWith( + ffi.Pointer< + ffi.NativeFunction> + OnStatusFunc, + ) { + return _Cronet_UrlRequestStatusListener_CreateWith( + OnStatusFunc, + ); + } + + late final _Cronet_UrlRequestStatusListener_CreateWith_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlRequestStatusListener_CreateWith>>( + 'Cronet_UrlRequestStatusListener_CreateWith'); + late final _dart_Cronet_UrlRequestStatusListener_CreateWith + _Cronet_UrlRequestStatusListener_CreateWith = + _Cronet_UrlRequestStatusListener_CreateWith_ptr.asFunction< + _dart_Cronet_UrlRequestStatusListener_CreateWith>(); + + /// //////////////////// + void Cronet_UrlRequestCallback_Destroy( + ffi.Pointer self, + ) { + return _Cronet_UrlRequestCallback_Destroy( + self, + ); + } + + late final _Cronet_UrlRequestCallback_Destroy_ptr = + _lookup>( + 'Cronet_UrlRequestCallback_Destroy'); + late final _dart_Cronet_UrlRequestCallback_Destroy + _Cronet_UrlRequestCallback_Destroy = + _Cronet_UrlRequestCallback_Destroy_ptr.asFunction< + _dart_Cronet_UrlRequestCallback_Destroy>(); + + void Cronet_UrlRequestCallback_SetClientContext( + ffi.Pointer self, + ffi.Pointer client_context, + ) { + return _Cronet_UrlRequestCallback_SetClientContext( + self, + client_context, + ); + } + + late final _Cronet_UrlRequestCallback_SetClientContext_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlRequestCallback_SetClientContext>>( + 'Cronet_UrlRequestCallback_SetClientContext'); + late final _dart_Cronet_UrlRequestCallback_SetClientContext + _Cronet_UrlRequestCallback_SetClientContext = + _Cronet_UrlRequestCallback_SetClientContext_ptr.asFunction< + _dart_Cronet_UrlRequestCallback_SetClientContext>(); + + ffi.Pointer Cronet_UrlRequestCallback_GetClientContext( + ffi.Pointer self, + ) { + return _Cronet_UrlRequestCallback_GetClientContext( + self, + ); + } + + late final _Cronet_UrlRequestCallback_GetClientContext_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlRequestCallback_GetClientContext>>( + 'Cronet_UrlRequestCallback_GetClientContext'); + late final _dart_Cronet_UrlRequestCallback_GetClientContext + _Cronet_UrlRequestCallback_GetClientContext = + _Cronet_UrlRequestCallback_GetClientContext_ptr.asFunction< + _dart_Cronet_UrlRequestCallback_GetClientContext>(); + + void Cronet_UrlRequestCallback_OnRedirectReceived( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ffi.Pointer new_location_url, + ) { + return _Cronet_UrlRequestCallback_OnRedirectReceived( + self, + request, + info, + new_location_url, + ); + } + + late final _Cronet_UrlRequestCallback_OnRedirectReceived_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlRequestCallback_OnRedirectReceived>>( + 'Cronet_UrlRequestCallback_OnRedirectReceived'); + late final _dart_Cronet_UrlRequestCallback_OnRedirectReceived + _Cronet_UrlRequestCallback_OnRedirectReceived = + _Cronet_UrlRequestCallback_OnRedirectReceived_ptr.asFunction< + _dart_Cronet_UrlRequestCallback_OnRedirectReceived>(); + + void Cronet_UrlRequestCallback_OnResponseStarted( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ) { + return _Cronet_UrlRequestCallback_OnResponseStarted( + self, + request, + info, + ); + } + + late final _Cronet_UrlRequestCallback_OnResponseStarted_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlRequestCallback_OnResponseStarted>>( + 'Cronet_UrlRequestCallback_OnResponseStarted'); + late final _dart_Cronet_UrlRequestCallback_OnResponseStarted + _Cronet_UrlRequestCallback_OnResponseStarted = + _Cronet_UrlRequestCallback_OnResponseStarted_ptr.asFunction< + _dart_Cronet_UrlRequestCallback_OnResponseStarted>(); + + void Cronet_UrlRequestCallback_OnReadCompleted( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ffi.Pointer buffer, + int bytes_read, + ) { + return _Cronet_UrlRequestCallback_OnReadCompleted( + self, + request, + info, + buffer, + bytes_read, + ); + } + + late final _Cronet_UrlRequestCallback_OnReadCompleted_ptr = + _lookup>( + 'Cronet_UrlRequestCallback_OnReadCompleted'); + late final _dart_Cronet_UrlRequestCallback_OnReadCompleted + _Cronet_UrlRequestCallback_OnReadCompleted = + _Cronet_UrlRequestCallback_OnReadCompleted_ptr.asFunction< + _dart_Cronet_UrlRequestCallback_OnReadCompleted>(); + + void Cronet_UrlRequestCallback_OnSucceeded( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ) { + return _Cronet_UrlRequestCallback_OnSucceeded( + self, + request, + info, + ); + } + + late final _Cronet_UrlRequestCallback_OnSucceeded_ptr = + _lookup>( + 'Cronet_UrlRequestCallback_OnSucceeded'); + late final _dart_Cronet_UrlRequestCallback_OnSucceeded + _Cronet_UrlRequestCallback_OnSucceeded = + _Cronet_UrlRequestCallback_OnSucceeded_ptr.asFunction< + _dart_Cronet_UrlRequestCallback_OnSucceeded>(); + + void Cronet_UrlRequestCallback_OnFailed( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ffi.Pointer error, + ) { + return _Cronet_UrlRequestCallback_OnFailed( + self, + request, + info, + error, + ); + } + + late final _Cronet_UrlRequestCallback_OnFailed_ptr = + _lookup>( + 'Cronet_UrlRequestCallback_OnFailed'); + late final _dart_Cronet_UrlRequestCallback_OnFailed + _Cronet_UrlRequestCallback_OnFailed = + _Cronet_UrlRequestCallback_OnFailed_ptr.asFunction< + _dart_Cronet_UrlRequestCallback_OnFailed>(); + + void Cronet_UrlRequestCallback_OnCanceled( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ) { + return _Cronet_UrlRequestCallback_OnCanceled( + self, + request, + info, + ); + } + + late final _Cronet_UrlRequestCallback_OnCanceled_ptr = + _lookup>( + 'Cronet_UrlRequestCallback_OnCanceled'); + late final _dart_Cronet_UrlRequestCallback_OnCanceled + _Cronet_UrlRequestCallback_OnCanceled = + _Cronet_UrlRequestCallback_OnCanceled_ptr.asFunction< + _dart_Cronet_UrlRequestCallback_OnCanceled>(); + ffi.Pointer Cronet_UrlRequestCallback_CreateWith( ffi.Pointer< ffi.NativeFunction< @@ -328,54 +946,356 @@ class Cronet { _dart_Cronet_UrlRequestCallback_CreateWith>(); /// //////////////////// - ffi.Pointer Cronet_UrlRequest_Create() { - return _Cronet_UrlRequest_Create(); + ffi.Pointer Cronet_UploadDataSink_Create() { + return _Cronet_UploadDataSink_Create(); } - late final _Cronet_UrlRequest_Create_ptr = - _lookup>( - 'Cronet_UrlRequest_Create'); - late final _dart_Cronet_UrlRequest_Create _Cronet_UrlRequest_Create = - _Cronet_UrlRequest_Create_ptr.asFunction< - _dart_Cronet_UrlRequest_Create>(); + late final _Cronet_UploadDataSink_Create_ptr = + _lookup>( + 'Cronet_UploadDataSink_Create'); + late final _dart_Cronet_UploadDataSink_Create _Cronet_UploadDataSink_Create = + _Cronet_UploadDataSink_Create_ptr.asFunction< + _dart_Cronet_UploadDataSink_Create>(); - void Cronet_UrlRequest_Destroy( - ffi.Pointer self, + void Cronet_UploadDataSink_Destroy( + ffi.Pointer self, ) { - return _Cronet_UrlRequest_Destroy( + return _Cronet_UploadDataSink_Destroy( self, ); } - late final _Cronet_UrlRequest_Destroy_ptr = - _lookup>( - 'Cronet_UrlRequest_Destroy'); - late final _dart_Cronet_UrlRequest_Destroy _Cronet_UrlRequest_Destroy = - _Cronet_UrlRequest_Destroy_ptr.asFunction< - _dart_Cronet_UrlRequest_Destroy>(); + late final _Cronet_UploadDataSink_Destroy_ptr = + _lookup>( + 'Cronet_UploadDataSink_Destroy'); + late final _dart_Cronet_UploadDataSink_Destroy + _Cronet_UploadDataSink_Destroy = _Cronet_UploadDataSink_Destroy_ptr + .asFunction<_dart_Cronet_UploadDataSink_Destroy>(); - void Cronet_UrlRequest_SetClientContext( - ffi.Pointer self, + void Cronet_UploadDataSink_SetClientContext( + ffi.Pointer self, ffi.Pointer client_context, ) { - return _Cronet_UrlRequest_SetClientContext( + return _Cronet_UploadDataSink_SetClientContext( self, client_context, ); } - late final _Cronet_UrlRequest_SetClientContext_ptr = - _lookup>( - 'Cronet_UrlRequest_SetClientContext'); - late final _dart_Cronet_UrlRequest_SetClientContext - _Cronet_UrlRequest_SetClientContext = - _Cronet_UrlRequest_SetClientContext_ptr.asFunction< - _dart_Cronet_UrlRequest_SetClientContext>(); + late final _Cronet_UploadDataSink_SetClientContext_ptr = + _lookup>( + 'Cronet_UploadDataSink_SetClientContext'); + late final _dart_Cronet_UploadDataSink_SetClientContext + _Cronet_UploadDataSink_SetClientContext = + _Cronet_UploadDataSink_SetClientContext_ptr.asFunction< + _dart_Cronet_UploadDataSink_SetClientContext>(); - ffi.Pointer Cronet_UrlRequest_GetClientContext( - ffi.Pointer self, + ffi.Pointer Cronet_UploadDataSink_GetClientContext( + ffi.Pointer self, ) { - return _Cronet_UrlRequest_GetClientContext( + return _Cronet_UploadDataSink_GetClientContext( + self, + ); + } + + late final _Cronet_UploadDataSink_GetClientContext_ptr = + _lookup>( + 'Cronet_UploadDataSink_GetClientContext'); + late final _dart_Cronet_UploadDataSink_GetClientContext + _Cronet_UploadDataSink_GetClientContext = + _Cronet_UploadDataSink_GetClientContext_ptr.asFunction< + _dart_Cronet_UploadDataSink_GetClientContext>(); + + void Cronet_UploadDataSink_OnReadSucceeded( + ffi.Pointer self, + int bytes_read, + bool final_chunk, + ) { + return _Cronet_UploadDataSink_OnReadSucceeded( + self, + bytes_read, + final_chunk ? 1 : 0, + ); + } + + late final _Cronet_UploadDataSink_OnReadSucceeded_ptr = + _lookup>( + 'Cronet_UploadDataSink_OnReadSucceeded'); + late final _dart_Cronet_UploadDataSink_OnReadSucceeded + _Cronet_UploadDataSink_OnReadSucceeded = + _Cronet_UploadDataSink_OnReadSucceeded_ptr.asFunction< + _dart_Cronet_UploadDataSink_OnReadSucceeded>(); + + void Cronet_UploadDataSink_OnReadError( + ffi.Pointer self, + ffi.Pointer error_message, + ) { + return _Cronet_UploadDataSink_OnReadError( + self, + error_message, + ); + } + + late final _Cronet_UploadDataSink_OnReadError_ptr = + _lookup>( + 'Cronet_UploadDataSink_OnReadError'); + late final _dart_Cronet_UploadDataSink_OnReadError + _Cronet_UploadDataSink_OnReadError = + _Cronet_UploadDataSink_OnReadError_ptr.asFunction< + _dart_Cronet_UploadDataSink_OnReadError>(); + + void Cronet_UploadDataSink_OnRewindSucceeded( + ffi.Pointer self, + ) { + return _Cronet_UploadDataSink_OnRewindSucceeded( + self, + ); + } + + late final _Cronet_UploadDataSink_OnRewindSucceeded_ptr = + _lookup>( + 'Cronet_UploadDataSink_OnRewindSucceeded'); + late final _dart_Cronet_UploadDataSink_OnRewindSucceeded + _Cronet_UploadDataSink_OnRewindSucceeded = + _Cronet_UploadDataSink_OnRewindSucceeded_ptr.asFunction< + _dart_Cronet_UploadDataSink_OnRewindSucceeded>(); + + void Cronet_UploadDataSink_OnRewindError( + ffi.Pointer self, + ffi.Pointer error_message, + ) { + return _Cronet_UploadDataSink_OnRewindError( + self, + error_message, + ); + } + + late final _Cronet_UploadDataSink_OnRewindError_ptr = + _lookup>( + 'Cronet_UploadDataSink_OnRewindError'); + late final _dart_Cronet_UploadDataSink_OnRewindError + _Cronet_UploadDataSink_OnRewindError = + _Cronet_UploadDataSink_OnRewindError_ptr.asFunction< + _dart_Cronet_UploadDataSink_OnRewindError>(); + + ffi.Pointer Cronet_UploadDataSink_CreateWith( + ffi.Pointer> + OnReadSucceededFunc, + ffi.Pointer> + OnReadErrorFunc, + ffi.Pointer> + OnRewindSucceededFunc, + ffi.Pointer> + OnRewindErrorFunc, + ) { + return _Cronet_UploadDataSink_CreateWith( + OnReadSucceededFunc, + OnReadErrorFunc, + OnRewindSucceededFunc, + OnRewindErrorFunc, + ); + } + + late final _Cronet_UploadDataSink_CreateWith_ptr = + _lookup>( + 'Cronet_UploadDataSink_CreateWith'); + late final _dart_Cronet_UploadDataSink_CreateWith + _Cronet_UploadDataSink_CreateWith = _Cronet_UploadDataSink_CreateWith_ptr + .asFunction<_dart_Cronet_UploadDataSink_CreateWith>(); + + /// //////////////////// + void Cronet_UploadDataProvider_Destroy( + ffi.Pointer self, + ) { + return _Cronet_UploadDataProvider_Destroy( + self, + ); + } + + late final _Cronet_UploadDataProvider_Destroy_ptr = + _lookup>( + 'Cronet_UploadDataProvider_Destroy'); + late final _dart_Cronet_UploadDataProvider_Destroy + _Cronet_UploadDataProvider_Destroy = + _Cronet_UploadDataProvider_Destroy_ptr.asFunction< + _dart_Cronet_UploadDataProvider_Destroy>(); + + void Cronet_UploadDataProvider_SetClientContext( + ffi.Pointer self, + ffi.Pointer client_context, + ) { + return _Cronet_UploadDataProvider_SetClientContext( + self, + client_context, + ); + } + + late final _Cronet_UploadDataProvider_SetClientContext_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UploadDataProvider_SetClientContext>>( + 'Cronet_UploadDataProvider_SetClientContext'); + late final _dart_Cronet_UploadDataProvider_SetClientContext + _Cronet_UploadDataProvider_SetClientContext = + _Cronet_UploadDataProvider_SetClientContext_ptr.asFunction< + _dart_Cronet_UploadDataProvider_SetClientContext>(); + + ffi.Pointer Cronet_UploadDataProvider_GetClientContext( + ffi.Pointer self, + ) { + return _Cronet_UploadDataProvider_GetClientContext( + self, + ); + } + + late final _Cronet_UploadDataProvider_GetClientContext_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UploadDataProvider_GetClientContext>>( + 'Cronet_UploadDataProvider_GetClientContext'); + late final _dart_Cronet_UploadDataProvider_GetClientContext + _Cronet_UploadDataProvider_GetClientContext = + _Cronet_UploadDataProvider_GetClientContext_ptr.asFunction< + _dart_Cronet_UploadDataProvider_GetClientContext>(); + + int Cronet_UploadDataProvider_GetLength( + ffi.Pointer self, + ) { + return _Cronet_UploadDataProvider_GetLength( + self, + ); + } + + late final _Cronet_UploadDataProvider_GetLength_ptr = + _lookup>( + 'Cronet_UploadDataProvider_GetLength'); + late final _dart_Cronet_UploadDataProvider_GetLength + _Cronet_UploadDataProvider_GetLength = + _Cronet_UploadDataProvider_GetLength_ptr.asFunction< + _dart_Cronet_UploadDataProvider_GetLength>(); + + void Cronet_UploadDataProvider_Read( + ffi.Pointer self, + ffi.Pointer upload_data_sink, + ffi.Pointer buffer, + ) { + return _Cronet_UploadDataProvider_Read( + self, + upload_data_sink, + buffer, + ); + } + + late final _Cronet_UploadDataProvider_Read_ptr = + _lookup>( + 'Cronet_UploadDataProvider_Read'); + late final _dart_Cronet_UploadDataProvider_Read + _Cronet_UploadDataProvider_Read = _Cronet_UploadDataProvider_Read_ptr + .asFunction<_dart_Cronet_UploadDataProvider_Read>(); + + void Cronet_UploadDataProvider_Rewind( + ffi.Pointer self, + ffi.Pointer upload_data_sink, + ) { + return _Cronet_UploadDataProvider_Rewind( + self, + upload_data_sink, + ); + } + + late final _Cronet_UploadDataProvider_Rewind_ptr = + _lookup>( + 'Cronet_UploadDataProvider_Rewind'); + late final _dart_Cronet_UploadDataProvider_Rewind + _Cronet_UploadDataProvider_Rewind = _Cronet_UploadDataProvider_Rewind_ptr + .asFunction<_dart_Cronet_UploadDataProvider_Rewind>(); + + void Cronet_UploadDataProvider_Close( + ffi.Pointer self, + ) { + return _Cronet_UploadDataProvider_Close( + self, + ); + } + + late final _Cronet_UploadDataProvider_Close_ptr = + _lookup>( + 'Cronet_UploadDataProvider_Close'); + late final _dart_Cronet_UploadDataProvider_Close + _Cronet_UploadDataProvider_Close = _Cronet_UploadDataProvider_Close_ptr + .asFunction<_dart_Cronet_UploadDataProvider_Close>(); + + ffi.Pointer Cronet_UploadDataProvider_CreateWith( + ffi.Pointer> + GetLengthFunc, + ffi.Pointer> + ReadFunc, + ffi.Pointer> + RewindFunc, + ffi.Pointer> + CloseFunc, + ) { + return _Cronet_UploadDataProvider_CreateWith( + GetLengthFunc, + ReadFunc, + RewindFunc, + CloseFunc, + ); + } + + late final _Cronet_UploadDataProvider_CreateWith_ptr = + _lookup>( + 'Cronet_UploadDataProvider_CreateWith'); + late final _dart_Cronet_UploadDataProvider_CreateWith + _Cronet_UploadDataProvider_CreateWith = + _Cronet_UploadDataProvider_CreateWith_ptr.asFunction< + _dart_Cronet_UploadDataProvider_CreateWith>(); + + /// //////////////////// + ffi.Pointer Cronet_UrlRequest_Create() { + return _Cronet_UrlRequest_Create(); + } + + late final _Cronet_UrlRequest_Create_ptr = + _lookup>( + 'Cronet_UrlRequest_Create'); + late final _dart_Cronet_UrlRequest_Create _Cronet_UrlRequest_Create = + _Cronet_UrlRequest_Create_ptr.asFunction< + _dart_Cronet_UrlRequest_Create>(); + + void Cronet_UrlRequest_Destroy( + ffi.Pointer self, + ) { + return _Cronet_UrlRequest_Destroy( + self, + ); + } + + late final _Cronet_UrlRequest_Destroy_ptr = + _lookup>( + 'Cronet_UrlRequest_Destroy'); + late final _dart_Cronet_UrlRequest_Destroy _Cronet_UrlRequest_Destroy = + _Cronet_UrlRequest_Destroy_ptr.asFunction< + _dart_Cronet_UrlRequest_Destroy>(); + + void Cronet_UrlRequest_SetClientContext( + ffi.Pointer self, + ffi.Pointer client_context, + ) { + return _Cronet_UrlRequest_SetClientContext( + self, + client_context, + ); + } + + late final _Cronet_UrlRequest_SetClientContext_ptr = + _lookup>( + 'Cronet_UrlRequest_SetClientContext'); + late final _dart_Cronet_UrlRequest_SetClientContext + _Cronet_UrlRequest_SetClientContext = + _Cronet_UrlRequest_SetClientContext_ptr.asFunction< + _dart_Cronet_UrlRequest_SetClientContext>(); + + ffi.Pointer Cronet_UrlRequest_GetClientContext( + ffi.Pointer self, + ) { + return _Cronet_UrlRequest_GetClientContext( self, ); } @@ -473,6 +1393,39 @@ class Cronet { _Cronet_UrlRequest_Cancel_ptr.asFunction< _dart_Cronet_UrlRequest_Cancel>(); + bool Cronet_UrlRequest_IsDone( + ffi.Pointer self, + ) { + return _Cronet_UrlRequest_IsDone( + self, + ) != + 0; + } + + late final _Cronet_UrlRequest_IsDone_ptr = + _lookup>( + 'Cronet_UrlRequest_IsDone'); + late final _dart_Cronet_UrlRequest_IsDone _Cronet_UrlRequest_IsDone = + _Cronet_UrlRequest_IsDone_ptr.asFunction< + _dart_Cronet_UrlRequest_IsDone>(); + + void Cronet_UrlRequest_GetStatus( + ffi.Pointer self, + ffi.Pointer listener, + ) { + return _Cronet_UrlRequest_GetStatus( + self, + listener, + ); + } + + late final _Cronet_UrlRequest_GetStatus_ptr = + _lookup>( + 'Cronet_UrlRequest_GetStatus'); + late final _dart_Cronet_UrlRequest_GetStatus _Cronet_UrlRequest_GetStatus = + _Cronet_UrlRequest_GetStatus_ptr.asFunction< + _dart_Cronet_UrlRequest_GetStatus>(); + ffi.Pointer Cronet_UrlRequest_CreateWith( ffi.Pointer> InitWithParamsFunc, @@ -503,6 +1456,231 @@ class Cronet { _Cronet_UrlRequest_CreateWith_ptr.asFunction< _dart_Cronet_UrlRequest_CreateWith>(); + /// //////////////////// + void Cronet_RequestFinishedInfoListener_Destroy( + ffi.Pointer self, + ) { + return _Cronet_RequestFinishedInfoListener_Destroy( + self, + ); + } + + late final _Cronet_RequestFinishedInfoListener_Destroy_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_RequestFinishedInfoListener_Destroy>>( + 'Cronet_RequestFinishedInfoListener_Destroy'); + late final _dart_Cronet_RequestFinishedInfoListener_Destroy + _Cronet_RequestFinishedInfoListener_Destroy = + _Cronet_RequestFinishedInfoListener_Destroy_ptr.asFunction< + _dart_Cronet_RequestFinishedInfoListener_Destroy>(); + + void Cronet_RequestFinishedInfoListener_SetClientContext( + ffi.Pointer self, + ffi.Pointer client_context, + ) { + return _Cronet_RequestFinishedInfoListener_SetClientContext( + self, + client_context, + ); + } + + late final _Cronet_RequestFinishedInfoListener_SetClientContext_ptr = _lookup< + ffi.NativeFunction< + _c_Cronet_RequestFinishedInfoListener_SetClientContext>>( + 'Cronet_RequestFinishedInfoListener_SetClientContext'); + late final _dart_Cronet_RequestFinishedInfoListener_SetClientContext + _Cronet_RequestFinishedInfoListener_SetClientContext = + _Cronet_RequestFinishedInfoListener_SetClientContext_ptr.asFunction< + _dart_Cronet_RequestFinishedInfoListener_SetClientContext>(); + + ffi.Pointer Cronet_RequestFinishedInfoListener_GetClientContext( + ffi.Pointer self, + ) { + return _Cronet_RequestFinishedInfoListener_GetClientContext( + self, + ); + } + + late final _Cronet_RequestFinishedInfoListener_GetClientContext_ptr = _lookup< + ffi.NativeFunction< + _c_Cronet_RequestFinishedInfoListener_GetClientContext>>( + 'Cronet_RequestFinishedInfoListener_GetClientContext'); + late final _dart_Cronet_RequestFinishedInfoListener_GetClientContext + _Cronet_RequestFinishedInfoListener_GetClientContext = + _Cronet_RequestFinishedInfoListener_GetClientContext_ptr.asFunction< + _dart_Cronet_RequestFinishedInfoListener_GetClientContext>(); + + void Cronet_RequestFinishedInfoListener_OnRequestFinished( + ffi.Pointer self, + ffi.Pointer request_info, + ffi.Pointer response_info, + ffi.Pointer error, + ) { + return _Cronet_RequestFinishedInfoListener_OnRequestFinished( + self, + request_info, + response_info, + error, + ); + } + + late final _Cronet_RequestFinishedInfoListener_OnRequestFinished_ptr = + _lookup< + ffi.NativeFunction< + _c_Cronet_RequestFinishedInfoListener_OnRequestFinished>>( + 'Cronet_RequestFinishedInfoListener_OnRequestFinished'); + late final _dart_Cronet_RequestFinishedInfoListener_OnRequestFinished + _Cronet_RequestFinishedInfoListener_OnRequestFinished = + _Cronet_RequestFinishedInfoListener_OnRequestFinished_ptr.asFunction< + _dart_Cronet_RequestFinishedInfoListener_OnRequestFinished>(); + + ffi.Pointer + Cronet_RequestFinishedInfoListener_CreateWith( + ffi.Pointer< + ffi.NativeFunction< + Cronet_RequestFinishedInfoListener_OnRequestFinishedFunc>> + OnRequestFinishedFunc, + ) { + return _Cronet_RequestFinishedInfoListener_CreateWith( + OnRequestFinishedFunc, + ); + } + + late final _Cronet_RequestFinishedInfoListener_CreateWith_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_RequestFinishedInfoListener_CreateWith>>( + 'Cronet_RequestFinishedInfoListener_CreateWith'); + late final _dart_Cronet_RequestFinishedInfoListener_CreateWith + _Cronet_RequestFinishedInfoListener_CreateWith = + _Cronet_RequestFinishedInfoListener_CreateWith_ptr.asFunction< + _dart_Cronet_RequestFinishedInfoListener_CreateWith>(); + + /// //////////////////// + ffi.Pointer Cronet_Error_Create() { + return _Cronet_Error_Create(); + } + + late final _Cronet_Error_Create_ptr = + _lookup>( + 'Cronet_Error_Create'); + late final _dart_Cronet_Error_Create _Cronet_Error_Create = + _Cronet_Error_Create_ptr.asFunction<_dart_Cronet_Error_Create>(); + + void Cronet_Error_Destroy( + ffi.Pointer self, + ) { + return _Cronet_Error_Destroy( + self, + ); + } + + late final _Cronet_Error_Destroy_ptr = + _lookup>( + 'Cronet_Error_Destroy'); + late final _dart_Cronet_Error_Destroy _Cronet_Error_Destroy = + _Cronet_Error_Destroy_ptr.asFunction<_dart_Cronet_Error_Destroy>(); + + void Cronet_Error_error_code_set( + ffi.Pointer self, + int error_code, + ) { + return _Cronet_Error_error_code_set( + self, + error_code, + ); + } + + late final _Cronet_Error_error_code_set_ptr = + _lookup>( + 'Cronet_Error_error_code_set'); + late final _dart_Cronet_Error_error_code_set _Cronet_Error_error_code_set = + _Cronet_Error_error_code_set_ptr.asFunction< + _dart_Cronet_Error_error_code_set>(); + + void Cronet_Error_message_set( + ffi.Pointer self, + ffi.Pointer message, + ) { + return _Cronet_Error_message_set( + self, + message, + ); + } + + late final _Cronet_Error_message_set_ptr = + _lookup>( + 'Cronet_Error_message_set'); + late final _dart_Cronet_Error_message_set _Cronet_Error_message_set = + _Cronet_Error_message_set_ptr.asFunction< + _dart_Cronet_Error_message_set>(); + + void Cronet_Error_internal_error_code_set( + ffi.Pointer self, + int internal_error_code, + ) { + return _Cronet_Error_internal_error_code_set( + self, + internal_error_code, + ); + } + + late final _Cronet_Error_internal_error_code_set_ptr = + _lookup>( + 'Cronet_Error_internal_error_code_set'); + late final _dart_Cronet_Error_internal_error_code_set + _Cronet_Error_internal_error_code_set = + _Cronet_Error_internal_error_code_set_ptr.asFunction< + _dart_Cronet_Error_internal_error_code_set>(); + + void Cronet_Error_immediately_retryable_set( + ffi.Pointer self, + bool immediately_retryable, + ) { + return _Cronet_Error_immediately_retryable_set( + self, + immediately_retryable ? 1 : 0, + ); + } + + late final _Cronet_Error_immediately_retryable_set_ptr = + _lookup>( + 'Cronet_Error_immediately_retryable_set'); + late final _dart_Cronet_Error_immediately_retryable_set + _Cronet_Error_immediately_retryable_set = + _Cronet_Error_immediately_retryable_set_ptr.asFunction< + _dart_Cronet_Error_immediately_retryable_set>(); + + void Cronet_Error_quic_detailed_error_code_set( + ffi.Pointer self, + int quic_detailed_error_code, + ) { + return _Cronet_Error_quic_detailed_error_code_set( + self, + quic_detailed_error_code, + ); + } + + late final _Cronet_Error_quic_detailed_error_code_set_ptr = + _lookup>( + 'Cronet_Error_quic_detailed_error_code_set'); + late final _dart_Cronet_Error_quic_detailed_error_code_set + _Cronet_Error_quic_detailed_error_code_set = + _Cronet_Error_quic_detailed_error_code_set_ptr.asFunction< + _dart_Cronet_Error_quic_detailed_error_code_set>(); + + int Cronet_Error_error_code_get( + ffi.Pointer self, + ) { + return _Cronet_Error_error_code_get( + self, + ); + } + + late final _Cronet_Error_error_code_get_ptr = + _lookup>( + 'Cronet_Error_error_code_get'); + late final _dart_Cronet_Error_error_code_get _Cronet_Error_error_code_get = + _Cronet_Error_error_code_get_ptr.asFunction< + _dart_Cronet_Error_error_code_get>(); + ffi.Pointer Cronet_Error_message_get( ffi.Pointer self, ) { @@ -534,6 +1712,39 @@ class Cronet { _Cronet_Error_internal_error_code_get_ptr.asFunction< _dart_Cronet_Error_internal_error_code_get>(); + bool Cronet_Error_immediately_retryable_get( + ffi.Pointer self, + ) { + return _Cronet_Error_immediately_retryable_get( + self, + ) != + 0; + } + + late final _Cronet_Error_immediately_retryable_get_ptr = + _lookup>( + 'Cronet_Error_immediately_retryable_get'); + late final _dart_Cronet_Error_immediately_retryable_get + _Cronet_Error_immediately_retryable_get = + _Cronet_Error_immediately_retryable_get_ptr.asFunction< + _dart_Cronet_Error_immediately_retryable_get>(); + + int Cronet_Error_quic_detailed_error_code_get( + ffi.Pointer self, + ) { + return _Cronet_Error_quic_detailed_error_code_get( + self, + ); + } + + late final _Cronet_Error_quic_detailed_error_code_get_ptr = + _lookup>( + 'Cronet_Error_quic_detailed_error_code_get'); + late final _dart_Cronet_Error_quic_detailed_error_code_get + _Cronet_Error_quic_detailed_error_code_get = + _Cronet_Error_quic_detailed_error_code_get_ptr.asFunction< + _dart_Cronet_Error_quic_detailed_error_code_get>(); + /// //////////////////// ffi.Pointer Cronet_QuicHint_Create() { return _Cronet_QuicHint_Create(); @@ -611,16 +1822,258 @@ class Cronet { _Cronet_QuicHint_alternate_port_set_ptr.asFunction< _dart_Cronet_QuicHint_alternate_port_set>(); - /// //////////////////// - ffi.Pointer Cronet_EngineParams_Create() { - return _Cronet_EngineParams_Create(); + ffi.Pointer Cronet_QuicHint_host_get( + ffi.Pointer self, + ) { + return _Cronet_QuicHint_host_get( + self, + ); } - late final _Cronet_EngineParams_Create_ptr = - _lookup>( - 'Cronet_EngineParams_Create'); - late final _dart_Cronet_EngineParams_Create _Cronet_EngineParams_Create = - _Cronet_EngineParams_Create_ptr.asFunction< + late final _Cronet_QuicHint_host_get_ptr = + _lookup>( + 'Cronet_QuicHint_host_get'); + late final _dart_Cronet_QuicHint_host_get _Cronet_QuicHint_host_get = + _Cronet_QuicHint_host_get_ptr.asFunction< + _dart_Cronet_QuicHint_host_get>(); + + int Cronet_QuicHint_port_get( + ffi.Pointer self, + ) { + return _Cronet_QuicHint_port_get( + self, + ); + } + + late final _Cronet_QuicHint_port_get_ptr = + _lookup>( + 'Cronet_QuicHint_port_get'); + late final _dart_Cronet_QuicHint_port_get _Cronet_QuicHint_port_get = + _Cronet_QuicHint_port_get_ptr.asFunction< + _dart_Cronet_QuicHint_port_get>(); + + int Cronet_QuicHint_alternate_port_get( + ffi.Pointer self, + ) { + return _Cronet_QuicHint_alternate_port_get( + self, + ); + } + + late final _Cronet_QuicHint_alternate_port_get_ptr = + _lookup>( + 'Cronet_QuicHint_alternate_port_get'); + late final _dart_Cronet_QuicHint_alternate_port_get + _Cronet_QuicHint_alternate_port_get = + _Cronet_QuicHint_alternate_port_get_ptr.asFunction< + _dart_Cronet_QuicHint_alternate_port_get>(); + + /// //////////////////// + ffi.Pointer Cronet_PublicKeyPins_Create() { + return _Cronet_PublicKeyPins_Create(); + } + + late final _Cronet_PublicKeyPins_Create_ptr = + _lookup>( + 'Cronet_PublicKeyPins_Create'); + late final _dart_Cronet_PublicKeyPins_Create _Cronet_PublicKeyPins_Create = + _Cronet_PublicKeyPins_Create_ptr.asFunction< + _dart_Cronet_PublicKeyPins_Create>(); + + void Cronet_PublicKeyPins_Destroy( + ffi.Pointer self, + ) { + return _Cronet_PublicKeyPins_Destroy( + self, + ); + } + + late final _Cronet_PublicKeyPins_Destroy_ptr = + _lookup>( + 'Cronet_PublicKeyPins_Destroy'); + late final _dart_Cronet_PublicKeyPins_Destroy _Cronet_PublicKeyPins_Destroy = + _Cronet_PublicKeyPins_Destroy_ptr.asFunction< + _dart_Cronet_PublicKeyPins_Destroy>(); + + void Cronet_PublicKeyPins_host_set( + ffi.Pointer self, + ffi.Pointer host, + ) { + return _Cronet_PublicKeyPins_host_set( + self, + host, + ); + } + + late final _Cronet_PublicKeyPins_host_set_ptr = + _lookup>( + 'Cronet_PublicKeyPins_host_set'); + late final _dart_Cronet_PublicKeyPins_host_set + _Cronet_PublicKeyPins_host_set = _Cronet_PublicKeyPins_host_set_ptr + .asFunction<_dart_Cronet_PublicKeyPins_host_set>(); + + void Cronet_PublicKeyPins_pins_sha256_add( + ffi.Pointer self, + ffi.Pointer element, + ) { + return _Cronet_PublicKeyPins_pins_sha256_add( + self, + element, + ); + } + + late final _Cronet_PublicKeyPins_pins_sha256_add_ptr = + _lookup>( + 'Cronet_PublicKeyPins_pins_sha256_add'); + late final _dart_Cronet_PublicKeyPins_pins_sha256_add + _Cronet_PublicKeyPins_pins_sha256_add = + _Cronet_PublicKeyPins_pins_sha256_add_ptr.asFunction< + _dart_Cronet_PublicKeyPins_pins_sha256_add>(); + + void Cronet_PublicKeyPins_include_subdomains_set( + ffi.Pointer self, + bool include_subdomains, + ) { + return _Cronet_PublicKeyPins_include_subdomains_set( + self, + include_subdomains ? 1 : 0, + ); + } + + late final _Cronet_PublicKeyPins_include_subdomains_set_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_PublicKeyPins_include_subdomains_set>>( + 'Cronet_PublicKeyPins_include_subdomains_set'); + late final _dart_Cronet_PublicKeyPins_include_subdomains_set + _Cronet_PublicKeyPins_include_subdomains_set = + _Cronet_PublicKeyPins_include_subdomains_set_ptr.asFunction< + _dart_Cronet_PublicKeyPins_include_subdomains_set>(); + + void Cronet_PublicKeyPins_expiration_date_set( + ffi.Pointer self, + int expiration_date, + ) { + return _Cronet_PublicKeyPins_expiration_date_set( + self, + expiration_date, + ); + } + + late final _Cronet_PublicKeyPins_expiration_date_set_ptr = + _lookup>( + 'Cronet_PublicKeyPins_expiration_date_set'); + late final _dart_Cronet_PublicKeyPins_expiration_date_set + _Cronet_PublicKeyPins_expiration_date_set = + _Cronet_PublicKeyPins_expiration_date_set_ptr.asFunction< + _dart_Cronet_PublicKeyPins_expiration_date_set>(); + + ffi.Pointer Cronet_PublicKeyPins_host_get( + ffi.Pointer self, + ) { + return _Cronet_PublicKeyPins_host_get( + self, + ); + } + + late final _Cronet_PublicKeyPins_host_get_ptr = + _lookup>( + 'Cronet_PublicKeyPins_host_get'); + late final _dart_Cronet_PublicKeyPins_host_get + _Cronet_PublicKeyPins_host_get = _Cronet_PublicKeyPins_host_get_ptr + .asFunction<_dart_Cronet_PublicKeyPins_host_get>(); + + int Cronet_PublicKeyPins_pins_sha256_size( + ffi.Pointer self, + ) { + return _Cronet_PublicKeyPins_pins_sha256_size( + self, + ); + } + + late final _Cronet_PublicKeyPins_pins_sha256_size_ptr = + _lookup>( + 'Cronet_PublicKeyPins_pins_sha256_size'); + late final _dart_Cronet_PublicKeyPins_pins_sha256_size + _Cronet_PublicKeyPins_pins_sha256_size = + _Cronet_PublicKeyPins_pins_sha256_size_ptr.asFunction< + _dart_Cronet_PublicKeyPins_pins_sha256_size>(); + + ffi.Pointer Cronet_PublicKeyPins_pins_sha256_at( + ffi.Pointer self, + int index, + ) { + return _Cronet_PublicKeyPins_pins_sha256_at( + self, + index, + ); + } + + late final _Cronet_PublicKeyPins_pins_sha256_at_ptr = + _lookup>( + 'Cronet_PublicKeyPins_pins_sha256_at'); + late final _dart_Cronet_PublicKeyPins_pins_sha256_at + _Cronet_PublicKeyPins_pins_sha256_at = + _Cronet_PublicKeyPins_pins_sha256_at_ptr.asFunction< + _dart_Cronet_PublicKeyPins_pins_sha256_at>(); + + void Cronet_PublicKeyPins_pins_sha256_clear( + ffi.Pointer self, + ) { + return _Cronet_PublicKeyPins_pins_sha256_clear( + self, + ); + } + + late final _Cronet_PublicKeyPins_pins_sha256_clear_ptr = + _lookup>( + 'Cronet_PublicKeyPins_pins_sha256_clear'); + late final _dart_Cronet_PublicKeyPins_pins_sha256_clear + _Cronet_PublicKeyPins_pins_sha256_clear = + _Cronet_PublicKeyPins_pins_sha256_clear_ptr.asFunction< + _dart_Cronet_PublicKeyPins_pins_sha256_clear>(); + + bool Cronet_PublicKeyPins_include_subdomains_get( + ffi.Pointer self, + ) { + return _Cronet_PublicKeyPins_include_subdomains_get( + self, + ) != + 0; + } + + late final _Cronet_PublicKeyPins_include_subdomains_get_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_PublicKeyPins_include_subdomains_get>>( + 'Cronet_PublicKeyPins_include_subdomains_get'); + late final _dart_Cronet_PublicKeyPins_include_subdomains_get + _Cronet_PublicKeyPins_include_subdomains_get = + _Cronet_PublicKeyPins_include_subdomains_get_ptr.asFunction< + _dart_Cronet_PublicKeyPins_include_subdomains_get>(); + + int Cronet_PublicKeyPins_expiration_date_get( + ffi.Pointer self, + ) { + return _Cronet_PublicKeyPins_expiration_date_get( + self, + ); + } + + late final _Cronet_PublicKeyPins_expiration_date_get_ptr = + _lookup>( + 'Cronet_PublicKeyPins_expiration_date_get'); + late final _dart_Cronet_PublicKeyPins_expiration_date_get + _Cronet_PublicKeyPins_expiration_date_get = + _Cronet_PublicKeyPins_expiration_date_get_ptr.asFunction< + _dart_Cronet_PublicKeyPins_expiration_date_get>(); + + /// //////////////////// + ffi.Pointer Cronet_EngineParams_Create() { + return _Cronet_EngineParams_Create(); + } + + late final _Cronet_EngineParams_Create_ptr = + _lookup>( + 'Cronet_EngineParams_Create'); + late final _dart_Cronet_EngineParams_Create _Cronet_EngineParams_Create = + _Cronet_EngineParams_Create_ptr.asFunction< _dart_Cronet_EngineParams_Create>(); void Cronet_EngineParams_Destroy( @@ -818,6 +2271,385 @@ class Cronet { _Cronet_EngineParams_quic_hints_add_ptr.asFunction< _dart_Cronet_EngineParams_quic_hints_add>(); + void Cronet_EngineParams_public_key_pins_add( + ffi.Pointer self, + ffi.Pointer element, + ) { + return _Cronet_EngineParams_public_key_pins_add( + self, + element, + ); + } + + late final _Cronet_EngineParams_public_key_pins_add_ptr = + _lookup>( + 'Cronet_EngineParams_public_key_pins_add'); + late final _dart_Cronet_EngineParams_public_key_pins_add + _Cronet_EngineParams_public_key_pins_add = + _Cronet_EngineParams_public_key_pins_add_ptr.asFunction< + _dart_Cronet_EngineParams_public_key_pins_add>(); + + void + Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_set( + ffi.Pointer self, + bool enable_public_key_pinning_bypass_for_local_trust_anchors, + ) { + return _Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_set( + self, + enable_public_key_pinning_bypass_for_local_trust_anchors ? 1 : 0, + ); + } + + late final _Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_set_ptr = + _lookup< + ffi.NativeFunction< + _c_Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_set>>( + 'Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_set'); + late final _dart_Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_set + _Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_set = + _Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_set_ptr + .asFunction< + _dart_Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_set>(); + + void Cronet_EngineParams_network_thread_priority_set( + ffi.Pointer self, + double network_thread_priority, + ) { + return _Cronet_EngineParams_network_thread_priority_set( + self, + network_thread_priority, + ); + } + + late final _Cronet_EngineParams_network_thread_priority_set_ptr = _lookup< + ffi.NativeFunction< + _c_Cronet_EngineParams_network_thread_priority_set>>( + 'Cronet_EngineParams_network_thread_priority_set'); + late final _dart_Cronet_EngineParams_network_thread_priority_set + _Cronet_EngineParams_network_thread_priority_set = + _Cronet_EngineParams_network_thread_priority_set_ptr.asFunction< + _dart_Cronet_EngineParams_network_thread_priority_set>(); + + void Cronet_EngineParams_experimental_options_set( + ffi.Pointer self, + ffi.Pointer experimental_options, + ) { + return _Cronet_EngineParams_experimental_options_set( + self, + experimental_options, + ); + } + + late final _Cronet_EngineParams_experimental_options_set_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_EngineParams_experimental_options_set>>( + 'Cronet_EngineParams_experimental_options_set'); + late final _dart_Cronet_EngineParams_experimental_options_set + _Cronet_EngineParams_experimental_options_set = + _Cronet_EngineParams_experimental_options_set_ptr.asFunction< + _dart_Cronet_EngineParams_experimental_options_set>(); + + bool Cronet_EngineParams_enable_check_result_get( + ffi.Pointer self, + ) { + return _Cronet_EngineParams_enable_check_result_get( + self, + ) != + 0; + } + + late final _Cronet_EngineParams_enable_check_result_get_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_EngineParams_enable_check_result_get>>( + 'Cronet_EngineParams_enable_check_result_get'); + late final _dart_Cronet_EngineParams_enable_check_result_get + _Cronet_EngineParams_enable_check_result_get = + _Cronet_EngineParams_enable_check_result_get_ptr.asFunction< + _dart_Cronet_EngineParams_enable_check_result_get>(); + + ffi.Pointer Cronet_EngineParams_user_agent_get( + ffi.Pointer self, + ) { + return _Cronet_EngineParams_user_agent_get( + self, + ); + } + + late final _Cronet_EngineParams_user_agent_get_ptr = + _lookup>( + 'Cronet_EngineParams_user_agent_get'); + late final _dart_Cronet_EngineParams_user_agent_get + _Cronet_EngineParams_user_agent_get = + _Cronet_EngineParams_user_agent_get_ptr.asFunction< + _dart_Cronet_EngineParams_user_agent_get>(); + + ffi.Pointer Cronet_EngineParams_accept_language_get( + ffi.Pointer self, + ) { + return _Cronet_EngineParams_accept_language_get( + self, + ); + } + + late final _Cronet_EngineParams_accept_language_get_ptr = + _lookup>( + 'Cronet_EngineParams_accept_language_get'); + late final _dart_Cronet_EngineParams_accept_language_get + _Cronet_EngineParams_accept_language_get = + _Cronet_EngineParams_accept_language_get_ptr.asFunction< + _dart_Cronet_EngineParams_accept_language_get>(); + + ffi.Pointer Cronet_EngineParams_storage_path_get( + ffi.Pointer self, + ) { + return _Cronet_EngineParams_storage_path_get( + self, + ); + } + + late final _Cronet_EngineParams_storage_path_get_ptr = + _lookup>( + 'Cronet_EngineParams_storage_path_get'); + late final _dart_Cronet_EngineParams_storage_path_get + _Cronet_EngineParams_storage_path_get = + _Cronet_EngineParams_storage_path_get_ptr.asFunction< + _dart_Cronet_EngineParams_storage_path_get>(); + + bool Cronet_EngineParams_enable_quic_get( + ffi.Pointer self, + ) { + return _Cronet_EngineParams_enable_quic_get( + self, + ) != + 0; + } + + late final _Cronet_EngineParams_enable_quic_get_ptr = + _lookup>( + 'Cronet_EngineParams_enable_quic_get'); + late final _dart_Cronet_EngineParams_enable_quic_get + _Cronet_EngineParams_enable_quic_get = + _Cronet_EngineParams_enable_quic_get_ptr.asFunction< + _dart_Cronet_EngineParams_enable_quic_get>(); + + bool Cronet_EngineParams_enable_http2_get( + ffi.Pointer self, + ) { + return _Cronet_EngineParams_enable_http2_get( + self, + ) != + 0; + } + + late final _Cronet_EngineParams_enable_http2_get_ptr = + _lookup>( + 'Cronet_EngineParams_enable_http2_get'); + late final _dart_Cronet_EngineParams_enable_http2_get + _Cronet_EngineParams_enable_http2_get = + _Cronet_EngineParams_enable_http2_get_ptr.asFunction< + _dart_Cronet_EngineParams_enable_http2_get>(); + + bool Cronet_EngineParams_enable_brotli_get( + ffi.Pointer self, + ) { + return _Cronet_EngineParams_enable_brotli_get( + self, + ) != + 0; + } + + late final _Cronet_EngineParams_enable_brotli_get_ptr = + _lookup>( + 'Cronet_EngineParams_enable_brotli_get'); + late final _dart_Cronet_EngineParams_enable_brotli_get + _Cronet_EngineParams_enable_brotli_get = + _Cronet_EngineParams_enable_brotli_get_ptr.asFunction< + _dart_Cronet_EngineParams_enable_brotli_get>(); + + int Cronet_EngineParams_http_cache_mode_get( + ffi.Pointer self, + ) { + return _Cronet_EngineParams_http_cache_mode_get( + self, + ); + } + + late final _Cronet_EngineParams_http_cache_mode_get_ptr = + _lookup>( + 'Cronet_EngineParams_http_cache_mode_get'); + late final _dart_Cronet_EngineParams_http_cache_mode_get + _Cronet_EngineParams_http_cache_mode_get = + _Cronet_EngineParams_http_cache_mode_get_ptr.asFunction< + _dart_Cronet_EngineParams_http_cache_mode_get>(); + + int Cronet_EngineParams_http_cache_max_size_get( + ffi.Pointer self, + ) { + return _Cronet_EngineParams_http_cache_max_size_get( + self, + ); + } + + late final _Cronet_EngineParams_http_cache_max_size_get_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_EngineParams_http_cache_max_size_get>>( + 'Cronet_EngineParams_http_cache_max_size_get'); + late final _dart_Cronet_EngineParams_http_cache_max_size_get + _Cronet_EngineParams_http_cache_max_size_get = + _Cronet_EngineParams_http_cache_max_size_get_ptr.asFunction< + _dart_Cronet_EngineParams_http_cache_max_size_get>(); + + int Cronet_EngineParams_quic_hints_size( + ffi.Pointer self, + ) { + return _Cronet_EngineParams_quic_hints_size( + self, + ); + } + + late final _Cronet_EngineParams_quic_hints_size_ptr = + _lookup>( + 'Cronet_EngineParams_quic_hints_size'); + late final _dart_Cronet_EngineParams_quic_hints_size + _Cronet_EngineParams_quic_hints_size = + _Cronet_EngineParams_quic_hints_size_ptr.asFunction< + _dart_Cronet_EngineParams_quic_hints_size>(); + + ffi.Pointer Cronet_EngineParams_quic_hints_at( + ffi.Pointer self, + int index, + ) { + return _Cronet_EngineParams_quic_hints_at( + self, + index, + ); + } + + late final _Cronet_EngineParams_quic_hints_at_ptr = + _lookup>( + 'Cronet_EngineParams_quic_hints_at'); + late final _dart_Cronet_EngineParams_quic_hints_at + _Cronet_EngineParams_quic_hints_at = + _Cronet_EngineParams_quic_hints_at_ptr.asFunction< + _dart_Cronet_EngineParams_quic_hints_at>(); + + void Cronet_EngineParams_quic_hints_clear( + ffi.Pointer self, + ) { + return _Cronet_EngineParams_quic_hints_clear( + self, + ); + } + + late final _Cronet_EngineParams_quic_hints_clear_ptr = + _lookup>( + 'Cronet_EngineParams_quic_hints_clear'); + late final _dart_Cronet_EngineParams_quic_hints_clear + _Cronet_EngineParams_quic_hints_clear = + _Cronet_EngineParams_quic_hints_clear_ptr.asFunction< + _dart_Cronet_EngineParams_quic_hints_clear>(); + + int Cronet_EngineParams_public_key_pins_size( + ffi.Pointer self, + ) { + return _Cronet_EngineParams_public_key_pins_size( + self, + ); + } + + late final _Cronet_EngineParams_public_key_pins_size_ptr = + _lookup>( + 'Cronet_EngineParams_public_key_pins_size'); + late final _dart_Cronet_EngineParams_public_key_pins_size + _Cronet_EngineParams_public_key_pins_size = + _Cronet_EngineParams_public_key_pins_size_ptr.asFunction< + _dart_Cronet_EngineParams_public_key_pins_size>(); + + ffi.Pointer Cronet_EngineParams_public_key_pins_at( + ffi.Pointer self, + int index, + ) { + return _Cronet_EngineParams_public_key_pins_at( + self, + index, + ); + } + + late final _Cronet_EngineParams_public_key_pins_at_ptr = + _lookup>( + 'Cronet_EngineParams_public_key_pins_at'); + late final _dart_Cronet_EngineParams_public_key_pins_at + _Cronet_EngineParams_public_key_pins_at = + _Cronet_EngineParams_public_key_pins_at_ptr.asFunction< + _dart_Cronet_EngineParams_public_key_pins_at>(); + + void Cronet_EngineParams_public_key_pins_clear( + ffi.Pointer self, + ) { + return _Cronet_EngineParams_public_key_pins_clear( + self, + ); + } + + late final _Cronet_EngineParams_public_key_pins_clear_ptr = + _lookup>( + 'Cronet_EngineParams_public_key_pins_clear'); + late final _dart_Cronet_EngineParams_public_key_pins_clear + _Cronet_EngineParams_public_key_pins_clear = + _Cronet_EngineParams_public_key_pins_clear_ptr.asFunction< + _dart_Cronet_EngineParams_public_key_pins_clear>(); + + bool + Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_get( + ffi.Pointer self, + ) { + return _Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_get( + self, + ) != + 0; + } + + late final _Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_get_ptr = + _lookup< + ffi.NativeFunction< + _c_Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_get>>( + 'Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_get'); + late final _dart_Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_get + _Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_get = + _Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_get_ptr + .asFunction< + _dart_Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_get>(); + + double Cronet_EngineParams_network_thread_priority_get( + ffi.Pointer self, + ) { + return _Cronet_EngineParams_network_thread_priority_get( + self, + ); + } + + late final _Cronet_EngineParams_network_thread_priority_get_ptr = _lookup< + ffi.NativeFunction< + _c_Cronet_EngineParams_network_thread_priority_get>>( + 'Cronet_EngineParams_network_thread_priority_get'); + late final _dart_Cronet_EngineParams_network_thread_priority_get + _Cronet_EngineParams_network_thread_priority_get = + _Cronet_EngineParams_network_thread_priority_get_ptr.asFunction< + _dart_Cronet_EngineParams_network_thread_priority_get>(); + + ffi.Pointer Cronet_EngineParams_experimental_options_get( + ffi.Pointer self, + ) { + return _Cronet_EngineParams_experimental_options_get( + self, + ); + } + + late final _Cronet_EngineParams_experimental_options_get_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_EngineParams_experimental_options_get>>( + 'Cronet_EngineParams_experimental_options_get'); + late final _dart_Cronet_EngineParams_experimental_options_get + _Cronet_EngineParams_experimental_options_get = + _Cronet_EngineParams_experimental_options_get_ptr.asFunction< + _dart_Cronet_EngineParams_experimental_options_get>(); + /// //////////////////// ffi.Pointer Cronet_HttpHeader_Create() { return _Cronet_HttpHeader_Create(); @@ -879,8 +2711,293 @@ class Cronet { _Cronet_HttpHeader_value_set_ptr.asFunction< _dart_Cronet_HttpHeader_value_set>(); - int Cronet_UrlResponseInfo_http_status_code_get( - ffi.Pointer self, + ffi.Pointer Cronet_HttpHeader_name_get( + ffi.Pointer self, + ) { + return _Cronet_HttpHeader_name_get( + self, + ); + } + + late final _Cronet_HttpHeader_name_get_ptr = + _lookup>( + 'Cronet_HttpHeader_name_get'); + late final _dart_Cronet_HttpHeader_name_get _Cronet_HttpHeader_name_get = + _Cronet_HttpHeader_name_get_ptr.asFunction< + _dart_Cronet_HttpHeader_name_get>(); + + ffi.Pointer Cronet_HttpHeader_value_get( + ffi.Pointer self, + ) { + return _Cronet_HttpHeader_value_get( + self, + ); + } + + late final _Cronet_HttpHeader_value_get_ptr = + _lookup>( + 'Cronet_HttpHeader_value_get'); + late final _dart_Cronet_HttpHeader_value_get _Cronet_HttpHeader_value_get = + _Cronet_HttpHeader_value_get_ptr.asFunction< + _dart_Cronet_HttpHeader_value_get>(); + + /// //////////////////// + ffi.Pointer Cronet_UrlResponseInfo_Create() { + return _Cronet_UrlResponseInfo_Create(); + } + + late final _Cronet_UrlResponseInfo_Create_ptr = + _lookup>( + 'Cronet_UrlResponseInfo_Create'); + late final _dart_Cronet_UrlResponseInfo_Create + _Cronet_UrlResponseInfo_Create = _Cronet_UrlResponseInfo_Create_ptr + .asFunction<_dart_Cronet_UrlResponseInfo_Create>(); + + void Cronet_UrlResponseInfo_Destroy( + ffi.Pointer self, + ) { + return _Cronet_UrlResponseInfo_Destroy( + self, + ); + } + + late final _Cronet_UrlResponseInfo_Destroy_ptr = + _lookup>( + 'Cronet_UrlResponseInfo_Destroy'); + late final _dart_Cronet_UrlResponseInfo_Destroy + _Cronet_UrlResponseInfo_Destroy = _Cronet_UrlResponseInfo_Destroy_ptr + .asFunction<_dart_Cronet_UrlResponseInfo_Destroy>(); + + void Cronet_UrlResponseInfo_url_set( + ffi.Pointer self, + ffi.Pointer url, + ) { + return _Cronet_UrlResponseInfo_url_set( + self, + url, + ); + } + + late final _Cronet_UrlResponseInfo_url_set_ptr = + _lookup>( + 'Cronet_UrlResponseInfo_url_set'); + late final _dart_Cronet_UrlResponseInfo_url_set + _Cronet_UrlResponseInfo_url_set = _Cronet_UrlResponseInfo_url_set_ptr + .asFunction<_dart_Cronet_UrlResponseInfo_url_set>(); + + void Cronet_UrlResponseInfo_url_chain_add( + ffi.Pointer self, + ffi.Pointer element, + ) { + return _Cronet_UrlResponseInfo_url_chain_add( + self, + element, + ); + } + + late final _Cronet_UrlResponseInfo_url_chain_add_ptr = + _lookup>( + 'Cronet_UrlResponseInfo_url_chain_add'); + late final _dart_Cronet_UrlResponseInfo_url_chain_add + _Cronet_UrlResponseInfo_url_chain_add = + _Cronet_UrlResponseInfo_url_chain_add_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_url_chain_add>(); + + void Cronet_UrlResponseInfo_http_status_code_set( + ffi.Pointer self, + int http_status_code, + ) { + return _Cronet_UrlResponseInfo_http_status_code_set( + self, + http_status_code, + ); + } + + late final _Cronet_UrlResponseInfo_http_status_code_set_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlResponseInfo_http_status_code_set>>( + 'Cronet_UrlResponseInfo_http_status_code_set'); + late final _dart_Cronet_UrlResponseInfo_http_status_code_set + _Cronet_UrlResponseInfo_http_status_code_set = + _Cronet_UrlResponseInfo_http_status_code_set_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_http_status_code_set>(); + + void Cronet_UrlResponseInfo_http_status_text_set( + ffi.Pointer self, + ffi.Pointer http_status_text, + ) { + return _Cronet_UrlResponseInfo_http_status_text_set( + self, + http_status_text, + ); + } + + late final _Cronet_UrlResponseInfo_http_status_text_set_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlResponseInfo_http_status_text_set>>( + 'Cronet_UrlResponseInfo_http_status_text_set'); + late final _dart_Cronet_UrlResponseInfo_http_status_text_set + _Cronet_UrlResponseInfo_http_status_text_set = + _Cronet_UrlResponseInfo_http_status_text_set_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_http_status_text_set>(); + + void Cronet_UrlResponseInfo_all_headers_list_add( + ffi.Pointer self, + ffi.Pointer element, + ) { + return _Cronet_UrlResponseInfo_all_headers_list_add( + self, + element, + ); + } + + late final _Cronet_UrlResponseInfo_all_headers_list_add_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlResponseInfo_all_headers_list_add>>( + 'Cronet_UrlResponseInfo_all_headers_list_add'); + late final _dart_Cronet_UrlResponseInfo_all_headers_list_add + _Cronet_UrlResponseInfo_all_headers_list_add = + _Cronet_UrlResponseInfo_all_headers_list_add_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_all_headers_list_add>(); + + void Cronet_UrlResponseInfo_was_cached_set( + ffi.Pointer self, + bool was_cached, + ) { + return _Cronet_UrlResponseInfo_was_cached_set( + self, + was_cached ? 1 : 0, + ); + } + + late final _Cronet_UrlResponseInfo_was_cached_set_ptr = + _lookup>( + 'Cronet_UrlResponseInfo_was_cached_set'); + late final _dart_Cronet_UrlResponseInfo_was_cached_set + _Cronet_UrlResponseInfo_was_cached_set = + _Cronet_UrlResponseInfo_was_cached_set_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_was_cached_set>(); + + void Cronet_UrlResponseInfo_negotiated_protocol_set( + ffi.Pointer self, + ffi.Pointer negotiated_protocol, + ) { + return _Cronet_UrlResponseInfo_negotiated_protocol_set( + self, + negotiated_protocol, + ); + } + + late final _Cronet_UrlResponseInfo_negotiated_protocol_set_ptr = _lookup< + ffi.NativeFunction< + _c_Cronet_UrlResponseInfo_negotiated_protocol_set>>( + 'Cronet_UrlResponseInfo_negotiated_protocol_set'); + late final _dart_Cronet_UrlResponseInfo_negotiated_protocol_set + _Cronet_UrlResponseInfo_negotiated_protocol_set = + _Cronet_UrlResponseInfo_negotiated_protocol_set_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_negotiated_protocol_set>(); + + void Cronet_UrlResponseInfo_proxy_server_set( + ffi.Pointer self, + ffi.Pointer proxy_server, + ) { + return _Cronet_UrlResponseInfo_proxy_server_set( + self, + proxy_server, + ); + } + + late final _Cronet_UrlResponseInfo_proxy_server_set_ptr = + _lookup>( + 'Cronet_UrlResponseInfo_proxy_server_set'); + late final _dart_Cronet_UrlResponseInfo_proxy_server_set + _Cronet_UrlResponseInfo_proxy_server_set = + _Cronet_UrlResponseInfo_proxy_server_set_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_proxy_server_set>(); + + void Cronet_UrlResponseInfo_received_byte_count_set( + ffi.Pointer self, + int received_byte_count, + ) { + return _Cronet_UrlResponseInfo_received_byte_count_set( + self, + received_byte_count, + ); + } + + late final _Cronet_UrlResponseInfo_received_byte_count_set_ptr = _lookup< + ffi.NativeFunction< + _c_Cronet_UrlResponseInfo_received_byte_count_set>>( + 'Cronet_UrlResponseInfo_received_byte_count_set'); + late final _dart_Cronet_UrlResponseInfo_received_byte_count_set + _Cronet_UrlResponseInfo_received_byte_count_set = + _Cronet_UrlResponseInfo_received_byte_count_set_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_received_byte_count_set>(); + + ffi.Pointer Cronet_UrlResponseInfo_url_get( + ffi.Pointer self, + ) { + return _Cronet_UrlResponseInfo_url_get( + self, + ); + } + + late final _Cronet_UrlResponseInfo_url_get_ptr = + _lookup>( + 'Cronet_UrlResponseInfo_url_get'); + late final _dart_Cronet_UrlResponseInfo_url_get + _Cronet_UrlResponseInfo_url_get = _Cronet_UrlResponseInfo_url_get_ptr + .asFunction<_dart_Cronet_UrlResponseInfo_url_get>(); + + int Cronet_UrlResponseInfo_url_chain_size( + ffi.Pointer self, + ) { + return _Cronet_UrlResponseInfo_url_chain_size( + self, + ); + } + + late final _Cronet_UrlResponseInfo_url_chain_size_ptr = + _lookup>( + 'Cronet_UrlResponseInfo_url_chain_size'); + late final _dart_Cronet_UrlResponseInfo_url_chain_size + _Cronet_UrlResponseInfo_url_chain_size = + _Cronet_UrlResponseInfo_url_chain_size_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_url_chain_size>(); + + ffi.Pointer Cronet_UrlResponseInfo_url_chain_at( + ffi.Pointer self, + int index, + ) { + return _Cronet_UrlResponseInfo_url_chain_at( + self, + index, + ); + } + + late final _Cronet_UrlResponseInfo_url_chain_at_ptr = + _lookup>( + 'Cronet_UrlResponseInfo_url_chain_at'); + late final _dart_Cronet_UrlResponseInfo_url_chain_at + _Cronet_UrlResponseInfo_url_chain_at = + _Cronet_UrlResponseInfo_url_chain_at_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_url_chain_at>(); + + void Cronet_UrlResponseInfo_url_chain_clear( + ffi.Pointer self, + ) { + return _Cronet_UrlResponseInfo_url_chain_clear( + self, + ); + } + + late final _Cronet_UrlResponseInfo_url_chain_clear_ptr = + _lookup>( + 'Cronet_UrlResponseInfo_url_chain_clear'); + late final _dart_Cronet_UrlResponseInfo_url_chain_clear + _Cronet_UrlResponseInfo_url_chain_clear = + _Cronet_UrlResponseInfo_url_chain_clear_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_url_chain_clear>(); + + int Cronet_UrlResponseInfo_http_status_code_get( + ffi.Pointer self, ) { return _Cronet_UrlResponseInfo_http_status_code_get( self, @@ -911,6 +3028,123 @@ class Cronet { _Cronet_UrlResponseInfo_http_status_text_get_ptr.asFunction< _dart_Cronet_UrlResponseInfo_http_status_text_get>(); + int Cronet_UrlResponseInfo_all_headers_list_size( + ffi.Pointer self, + ) { + return _Cronet_UrlResponseInfo_all_headers_list_size( + self, + ); + } + + late final _Cronet_UrlResponseInfo_all_headers_list_size_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlResponseInfo_all_headers_list_size>>( + 'Cronet_UrlResponseInfo_all_headers_list_size'); + late final _dart_Cronet_UrlResponseInfo_all_headers_list_size + _Cronet_UrlResponseInfo_all_headers_list_size = + _Cronet_UrlResponseInfo_all_headers_list_size_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_all_headers_list_size>(); + + ffi.Pointer Cronet_UrlResponseInfo_all_headers_list_at( + ffi.Pointer self, + int index, + ) { + return _Cronet_UrlResponseInfo_all_headers_list_at( + self, + index, + ); + } + + late final _Cronet_UrlResponseInfo_all_headers_list_at_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlResponseInfo_all_headers_list_at>>( + 'Cronet_UrlResponseInfo_all_headers_list_at'); + late final _dart_Cronet_UrlResponseInfo_all_headers_list_at + _Cronet_UrlResponseInfo_all_headers_list_at = + _Cronet_UrlResponseInfo_all_headers_list_at_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_all_headers_list_at>(); + + void Cronet_UrlResponseInfo_all_headers_list_clear( + ffi.Pointer self, + ) { + return _Cronet_UrlResponseInfo_all_headers_list_clear( + self, + ); + } + + late final _Cronet_UrlResponseInfo_all_headers_list_clear_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlResponseInfo_all_headers_list_clear>>( + 'Cronet_UrlResponseInfo_all_headers_list_clear'); + late final _dart_Cronet_UrlResponseInfo_all_headers_list_clear + _Cronet_UrlResponseInfo_all_headers_list_clear = + _Cronet_UrlResponseInfo_all_headers_list_clear_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_all_headers_list_clear>(); + + bool Cronet_UrlResponseInfo_was_cached_get( + ffi.Pointer self, + ) { + return _Cronet_UrlResponseInfo_was_cached_get( + self, + ) != + 0; + } + + late final _Cronet_UrlResponseInfo_was_cached_get_ptr = + _lookup>( + 'Cronet_UrlResponseInfo_was_cached_get'); + late final _dart_Cronet_UrlResponseInfo_was_cached_get + _Cronet_UrlResponseInfo_was_cached_get = + _Cronet_UrlResponseInfo_was_cached_get_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_was_cached_get>(); + + ffi.Pointer Cronet_UrlResponseInfo_negotiated_protocol_get( + ffi.Pointer self, + ) { + return _Cronet_UrlResponseInfo_negotiated_protocol_get( + self, + ); + } + + late final _Cronet_UrlResponseInfo_negotiated_protocol_get_ptr = _lookup< + ffi.NativeFunction< + _c_Cronet_UrlResponseInfo_negotiated_protocol_get>>( + 'Cronet_UrlResponseInfo_negotiated_protocol_get'); + late final _dart_Cronet_UrlResponseInfo_negotiated_protocol_get + _Cronet_UrlResponseInfo_negotiated_protocol_get = + _Cronet_UrlResponseInfo_negotiated_protocol_get_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_negotiated_protocol_get>(); + + ffi.Pointer Cronet_UrlResponseInfo_proxy_server_get( + ffi.Pointer self, + ) { + return _Cronet_UrlResponseInfo_proxy_server_get( + self, + ); + } + + late final _Cronet_UrlResponseInfo_proxy_server_get_ptr = + _lookup>( + 'Cronet_UrlResponseInfo_proxy_server_get'); + late final _dart_Cronet_UrlResponseInfo_proxy_server_get + _Cronet_UrlResponseInfo_proxy_server_get = + _Cronet_UrlResponseInfo_proxy_server_get_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_proxy_server_get>(); + + int Cronet_UrlResponseInfo_received_byte_count_get( + ffi.Pointer self, + ) { + return _Cronet_UrlResponseInfo_received_byte_count_get( + self, + ); + } + + late final _Cronet_UrlResponseInfo_received_byte_count_get_ptr = _lookup< + ffi.NativeFunction< + _c_Cronet_UrlResponseInfo_received_byte_count_get>>( + 'Cronet_UrlResponseInfo_received_byte_count_get'); + late final _dart_Cronet_UrlResponseInfo_received_byte_count_get + _Cronet_UrlResponseInfo_received_byte_count_get = + _Cronet_UrlResponseInfo_received_byte_count_get_ptr.asFunction< + _dart_Cronet_UrlResponseInfo_received_byte_count_get>(); + /// //////////////////// ffi.Pointer Cronet_UrlRequestParams_Create() { return _Cronet_UrlRequestParams_Create(); @@ -974,832 +3208,4489 @@ class Cronet { _Cronet_UrlRequestParams_request_headers_add_ptr.asFunction< _dart_Cronet_UrlRequestParams_request_headers_add>(); - late final addresses = _SymbolAddresses(this); -} + void Cronet_UrlRequestParams_disable_cache_set( + ffi.Pointer self, + bool disable_cache, + ) { + return _Cronet_UrlRequestParams_disable_cache_set( + self, + disable_cache ? 1 : 0, + ); + } -class _SymbolAddresses { - final Cronet _library; - _SymbolAddresses(this._library); - ffi.Pointer> - get Cronet_Buffer_Create => _library._Cronet_Buffer_Create_ptr; - ffi.Pointer> - get Cronet_Buffer_InitWithAlloc => - _library._Cronet_Buffer_InitWithAlloc_ptr; - ffi.Pointer> - get Cronet_Runnable_Destroy => _library._Cronet_Runnable_Destroy_ptr; - ffi.Pointer> - get Cronet_Runnable_Run => _library._Cronet_Runnable_Run_ptr; - ffi.Pointer> - get Cronet_Executor_Destroy => _library._Cronet_Executor_Destroy_ptr; - ffi.Pointer> - get Cronet_Executor_SetClientContext => - _library._Cronet_Executor_SetClientContext_ptr; - ffi.Pointer> - get Cronet_Executor_GetClientContext => - _library._Cronet_Executor_GetClientContext_ptr; - ffi.Pointer> - get Cronet_Executor_CreateWith => - _library._Cronet_Executor_CreateWith_ptr; - ffi.Pointer> - get Cronet_Engine_Destroy => _library._Cronet_Engine_Destroy_ptr; - ffi.Pointer> - get Cronet_Engine_Shutdown => _library._Cronet_Engine_Shutdown_ptr; - ffi.Pointer> - get Cronet_UrlRequestCallback_CreateWith => - _library._Cronet_UrlRequestCallback_CreateWith_ptr; - ffi.Pointer> - get Cronet_UrlRequest_InitWithParams => - _library._Cronet_UrlRequest_InitWithParams_ptr; -} + late final _Cronet_UrlRequestParams_disable_cache_set_ptr = + _lookup>( + 'Cronet_UrlRequestParams_disable_cache_set'); + late final _dart_Cronet_UrlRequestParams_disable_cache_set + _Cronet_UrlRequestParams_disable_cache_set = + _Cronet_UrlRequestParams_disable_cache_set_ptr.asFunction< + _dart_Cronet_UrlRequestParams_disable_cache_set>(); -class Cronet_Buffer extends ffi.Opaque {} + void Cronet_UrlRequestParams_priority_set( + ffi.Pointer self, + int priority, + ) { + return _Cronet_UrlRequestParams_priority_set( + self, + priority, + ); + } -class Cronet_BufferCallback extends ffi.Opaque {} + late final _Cronet_UrlRequestParams_priority_set_ptr = + _lookup>( + 'Cronet_UrlRequestParams_priority_set'); + late final _dart_Cronet_UrlRequestParams_priority_set + _Cronet_UrlRequestParams_priority_set = + _Cronet_UrlRequestParams_priority_set_ptr.asFunction< + _dart_Cronet_UrlRequestParams_priority_set>(); -class Cronet_Runnable extends ffi.Opaque {} + void Cronet_UrlRequestParams_upload_data_provider_set( + ffi.Pointer self, + ffi.Pointer upload_data_provider, + ) { + return _Cronet_UrlRequestParams_upload_data_provider_set( + self, + upload_data_provider, + ); + } -class Cronet_Executor extends ffi.Opaque {} + late final _Cronet_UrlRequestParams_upload_data_provider_set_ptr = _lookup< + ffi.NativeFunction< + _c_Cronet_UrlRequestParams_upload_data_provider_set>>( + 'Cronet_UrlRequestParams_upload_data_provider_set'); + late final _dart_Cronet_UrlRequestParams_upload_data_provider_set + _Cronet_UrlRequestParams_upload_data_provider_set = + _Cronet_UrlRequestParams_upload_data_provider_set_ptr.asFunction< + _dart_Cronet_UrlRequestParams_upload_data_provider_set>(); -class Cronet_Engine extends ffi.Opaque {} + void Cronet_UrlRequestParams_upload_data_provider_executor_set( + ffi.Pointer self, + ffi.Pointer upload_data_provider_executor, + ) { + return _Cronet_UrlRequestParams_upload_data_provider_executor_set( + self, + upload_data_provider_executor, + ); + } -class Cronet_UrlRequestStatusListener extends ffi.Opaque {} + late final _Cronet_UrlRequestParams_upload_data_provider_executor_set_ptr = + _lookup< + ffi.NativeFunction< + _c_Cronet_UrlRequestParams_upload_data_provider_executor_set>>( + 'Cronet_UrlRequestParams_upload_data_provider_executor_set'); + late final _dart_Cronet_UrlRequestParams_upload_data_provider_executor_set + _Cronet_UrlRequestParams_upload_data_provider_executor_set = + _Cronet_UrlRequestParams_upload_data_provider_executor_set_ptr.asFunction< + _dart_Cronet_UrlRequestParams_upload_data_provider_executor_set>(); + + void Cronet_UrlRequestParams_allow_direct_executor_set( + ffi.Pointer self, + bool allow_direct_executor, + ) { + return _Cronet_UrlRequestParams_allow_direct_executor_set( + self, + allow_direct_executor ? 1 : 0, + ); + } -class Cronet_UrlRequestCallback extends ffi.Opaque {} + late final _Cronet_UrlRequestParams_allow_direct_executor_set_ptr = _lookup< + ffi.NativeFunction< + _c_Cronet_UrlRequestParams_allow_direct_executor_set>>( + 'Cronet_UrlRequestParams_allow_direct_executor_set'); + late final _dart_Cronet_UrlRequestParams_allow_direct_executor_set + _Cronet_UrlRequestParams_allow_direct_executor_set = + _Cronet_UrlRequestParams_allow_direct_executor_set_ptr.asFunction< + _dart_Cronet_UrlRequestParams_allow_direct_executor_set>(); -class Cronet_UploadDataSink extends ffi.Opaque {} + void Cronet_UrlRequestParams_annotations_add( + ffi.Pointer self, + ffi.Pointer element, + ) { + return _Cronet_UrlRequestParams_annotations_add( + self, + element, + ); + } -class Cronet_UploadDataProvider extends ffi.Opaque {} + late final _Cronet_UrlRequestParams_annotations_add_ptr = + _lookup>( + 'Cronet_UrlRequestParams_annotations_add'); + late final _dart_Cronet_UrlRequestParams_annotations_add + _Cronet_UrlRequestParams_annotations_add = + _Cronet_UrlRequestParams_annotations_add_ptr.asFunction< + _dart_Cronet_UrlRequestParams_annotations_add>(); -class Cronet_UrlRequest extends ffi.Opaque {} + void Cronet_UrlRequestParams_request_finished_listener_set( + ffi.Pointer self, + ffi.Pointer request_finished_listener, + ) { + return _Cronet_UrlRequestParams_request_finished_listener_set( + self, + request_finished_listener, + ); + } -class Cronet_RequestFinishedInfoListener extends ffi.Opaque {} + late final _Cronet_UrlRequestParams_request_finished_listener_set_ptr = + _lookup< + ffi.NativeFunction< + _c_Cronet_UrlRequestParams_request_finished_listener_set>>( + 'Cronet_UrlRequestParams_request_finished_listener_set'); + late final _dart_Cronet_UrlRequestParams_request_finished_listener_set + _Cronet_UrlRequestParams_request_finished_listener_set = + _Cronet_UrlRequestParams_request_finished_listener_set_ptr.asFunction< + _dart_Cronet_UrlRequestParams_request_finished_listener_set>(); + + void Cronet_UrlRequestParams_request_finished_executor_set( + ffi.Pointer self, + ffi.Pointer request_finished_executor, + ) { + return _Cronet_UrlRequestParams_request_finished_executor_set( + self, + request_finished_executor, + ); + } + + late final _Cronet_UrlRequestParams_request_finished_executor_set_ptr = + _lookup< + ffi.NativeFunction< + _c_Cronet_UrlRequestParams_request_finished_executor_set>>( + 'Cronet_UrlRequestParams_request_finished_executor_set'); + late final _dart_Cronet_UrlRequestParams_request_finished_executor_set + _Cronet_UrlRequestParams_request_finished_executor_set = + _Cronet_UrlRequestParams_request_finished_executor_set_ptr.asFunction< + _dart_Cronet_UrlRequestParams_request_finished_executor_set>(); + + void Cronet_UrlRequestParams_idempotency_set( + ffi.Pointer self, + int idempotency, + ) { + return _Cronet_UrlRequestParams_idempotency_set( + self, + idempotency, + ); + } + + late final _Cronet_UrlRequestParams_idempotency_set_ptr = + _lookup>( + 'Cronet_UrlRequestParams_idempotency_set'); + late final _dart_Cronet_UrlRequestParams_idempotency_set + _Cronet_UrlRequestParams_idempotency_set = + _Cronet_UrlRequestParams_idempotency_set_ptr.asFunction< + _dart_Cronet_UrlRequestParams_idempotency_set>(); + + ffi.Pointer Cronet_UrlRequestParams_http_method_get( + ffi.Pointer self, + ) { + return _Cronet_UrlRequestParams_http_method_get( + self, + ); + } + + late final _Cronet_UrlRequestParams_http_method_get_ptr = + _lookup>( + 'Cronet_UrlRequestParams_http_method_get'); + late final _dart_Cronet_UrlRequestParams_http_method_get + _Cronet_UrlRequestParams_http_method_get = + _Cronet_UrlRequestParams_http_method_get_ptr.asFunction< + _dart_Cronet_UrlRequestParams_http_method_get>(); + + int Cronet_UrlRequestParams_request_headers_size( + ffi.Pointer self, + ) { + return _Cronet_UrlRequestParams_request_headers_size( + self, + ); + } + + late final _Cronet_UrlRequestParams_request_headers_size_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlRequestParams_request_headers_size>>( + 'Cronet_UrlRequestParams_request_headers_size'); + late final _dart_Cronet_UrlRequestParams_request_headers_size + _Cronet_UrlRequestParams_request_headers_size = + _Cronet_UrlRequestParams_request_headers_size_ptr.asFunction< + _dart_Cronet_UrlRequestParams_request_headers_size>(); + + ffi.Pointer Cronet_UrlRequestParams_request_headers_at( + ffi.Pointer self, + int index, + ) { + return _Cronet_UrlRequestParams_request_headers_at( + self, + index, + ); + } + + late final _Cronet_UrlRequestParams_request_headers_at_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlRequestParams_request_headers_at>>( + 'Cronet_UrlRequestParams_request_headers_at'); + late final _dart_Cronet_UrlRequestParams_request_headers_at + _Cronet_UrlRequestParams_request_headers_at = + _Cronet_UrlRequestParams_request_headers_at_ptr.asFunction< + _dart_Cronet_UrlRequestParams_request_headers_at>(); + + void Cronet_UrlRequestParams_request_headers_clear( + ffi.Pointer self, + ) { + return _Cronet_UrlRequestParams_request_headers_clear( + self, + ); + } + + late final _Cronet_UrlRequestParams_request_headers_clear_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_UrlRequestParams_request_headers_clear>>( + 'Cronet_UrlRequestParams_request_headers_clear'); + late final _dart_Cronet_UrlRequestParams_request_headers_clear + _Cronet_UrlRequestParams_request_headers_clear = + _Cronet_UrlRequestParams_request_headers_clear_ptr.asFunction< + _dart_Cronet_UrlRequestParams_request_headers_clear>(); + + bool Cronet_UrlRequestParams_disable_cache_get( + ffi.Pointer self, + ) { + return _Cronet_UrlRequestParams_disable_cache_get( + self, + ) != + 0; + } + + late final _Cronet_UrlRequestParams_disable_cache_get_ptr = + _lookup>( + 'Cronet_UrlRequestParams_disable_cache_get'); + late final _dart_Cronet_UrlRequestParams_disable_cache_get + _Cronet_UrlRequestParams_disable_cache_get = + _Cronet_UrlRequestParams_disable_cache_get_ptr.asFunction< + _dart_Cronet_UrlRequestParams_disable_cache_get>(); + + int Cronet_UrlRequestParams_priority_get( + ffi.Pointer self, + ) { + return _Cronet_UrlRequestParams_priority_get( + self, + ); + } + + late final _Cronet_UrlRequestParams_priority_get_ptr = + _lookup>( + 'Cronet_UrlRequestParams_priority_get'); + late final _dart_Cronet_UrlRequestParams_priority_get + _Cronet_UrlRequestParams_priority_get = + _Cronet_UrlRequestParams_priority_get_ptr.asFunction< + _dart_Cronet_UrlRequestParams_priority_get>(); + + ffi.Pointer + Cronet_UrlRequestParams_upload_data_provider_get( + ffi.Pointer self, + ) { + return _Cronet_UrlRequestParams_upload_data_provider_get( + self, + ); + } + + late final _Cronet_UrlRequestParams_upload_data_provider_get_ptr = _lookup< + ffi.NativeFunction< + _c_Cronet_UrlRequestParams_upload_data_provider_get>>( + 'Cronet_UrlRequestParams_upload_data_provider_get'); + late final _dart_Cronet_UrlRequestParams_upload_data_provider_get + _Cronet_UrlRequestParams_upload_data_provider_get = + _Cronet_UrlRequestParams_upload_data_provider_get_ptr.asFunction< + _dart_Cronet_UrlRequestParams_upload_data_provider_get>(); + + ffi.Pointer + Cronet_UrlRequestParams_upload_data_provider_executor_get( + ffi.Pointer self, + ) { + return _Cronet_UrlRequestParams_upload_data_provider_executor_get( + self, + ); + } + + late final _Cronet_UrlRequestParams_upload_data_provider_executor_get_ptr = + _lookup< + ffi.NativeFunction< + _c_Cronet_UrlRequestParams_upload_data_provider_executor_get>>( + 'Cronet_UrlRequestParams_upload_data_provider_executor_get'); + late final _dart_Cronet_UrlRequestParams_upload_data_provider_executor_get + _Cronet_UrlRequestParams_upload_data_provider_executor_get = + _Cronet_UrlRequestParams_upload_data_provider_executor_get_ptr.asFunction< + _dart_Cronet_UrlRequestParams_upload_data_provider_executor_get>(); + + bool Cronet_UrlRequestParams_allow_direct_executor_get( + ffi.Pointer self, + ) { + return _Cronet_UrlRequestParams_allow_direct_executor_get( + self, + ) != + 0; + } + + late final _Cronet_UrlRequestParams_allow_direct_executor_get_ptr = _lookup< + ffi.NativeFunction< + _c_Cronet_UrlRequestParams_allow_direct_executor_get>>( + 'Cronet_UrlRequestParams_allow_direct_executor_get'); + late final _dart_Cronet_UrlRequestParams_allow_direct_executor_get + _Cronet_UrlRequestParams_allow_direct_executor_get = + _Cronet_UrlRequestParams_allow_direct_executor_get_ptr.asFunction< + _dart_Cronet_UrlRequestParams_allow_direct_executor_get>(); + + int Cronet_UrlRequestParams_annotations_size( + ffi.Pointer self, + ) { + return _Cronet_UrlRequestParams_annotations_size( + self, + ); + } + + late final _Cronet_UrlRequestParams_annotations_size_ptr = + _lookup>( + 'Cronet_UrlRequestParams_annotations_size'); + late final _dart_Cronet_UrlRequestParams_annotations_size + _Cronet_UrlRequestParams_annotations_size = + _Cronet_UrlRequestParams_annotations_size_ptr.asFunction< + _dart_Cronet_UrlRequestParams_annotations_size>(); + + ffi.Pointer Cronet_UrlRequestParams_annotations_at( + ffi.Pointer self, + int index, + ) { + return _Cronet_UrlRequestParams_annotations_at( + self, + index, + ); + } + + late final _Cronet_UrlRequestParams_annotations_at_ptr = + _lookup>( + 'Cronet_UrlRequestParams_annotations_at'); + late final _dart_Cronet_UrlRequestParams_annotations_at + _Cronet_UrlRequestParams_annotations_at = + _Cronet_UrlRequestParams_annotations_at_ptr.asFunction< + _dart_Cronet_UrlRequestParams_annotations_at>(); + + void Cronet_UrlRequestParams_annotations_clear( + ffi.Pointer self, + ) { + return _Cronet_UrlRequestParams_annotations_clear( + self, + ); + } + + late final _Cronet_UrlRequestParams_annotations_clear_ptr = + _lookup>( + 'Cronet_UrlRequestParams_annotations_clear'); + late final _dart_Cronet_UrlRequestParams_annotations_clear + _Cronet_UrlRequestParams_annotations_clear = + _Cronet_UrlRequestParams_annotations_clear_ptr.asFunction< + _dart_Cronet_UrlRequestParams_annotations_clear>(); + + ffi.Pointer + Cronet_UrlRequestParams_request_finished_listener_get( + ffi.Pointer self, + ) { + return _Cronet_UrlRequestParams_request_finished_listener_get( + self, + ); + } + + late final _Cronet_UrlRequestParams_request_finished_listener_get_ptr = + _lookup< + ffi.NativeFunction< + _c_Cronet_UrlRequestParams_request_finished_listener_get>>( + 'Cronet_UrlRequestParams_request_finished_listener_get'); + late final _dart_Cronet_UrlRequestParams_request_finished_listener_get + _Cronet_UrlRequestParams_request_finished_listener_get = + _Cronet_UrlRequestParams_request_finished_listener_get_ptr.asFunction< + _dart_Cronet_UrlRequestParams_request_finished_listener_get>(); + + ffi.Pointer + Cronet_UrlRequestParams_request_finished_executor_get( + ffi.Pointer self, + ) { + return _Cronet_UrlRequestParams_request_finished_executor_get( + self, + ); + } + + late final _Cronet_UrlRequestParams_request_finished_executor_get_ptr = + _lookup< + ffi.NativeFunction< + _c_Cronet_UrlRequestParams_request_finished_executor_get>>( + 'Cronet_UrlRequestParams_request_finished_executor_get'); + late final _dart_Cronet_UrlRequestParams_request_finished_executor_get + _Cronet_UrlRequestParams_request_finished_executor_get = + _Cronet_UrlRequestParams_request_finished_executor_get_ptr.asFunction< + _dart_Cronet_UrlRequestParams_request_finished_executor_get>(); + + int Cronet_UrlRequestParams_idempotency_get( + ffi.Pointer self, + ) { + return _Cronet_UrlRequestParams_idempotency_get( + self, + ); + } + + late final _Cronet_UrlRequestParams_idempotency_get_ptr = + _lookup>( + 'Cronet_UrlRequestParams_idempotency_get'); + late final _dart_Cronet_UrlRequestParams_idempotency_get + _Cronet_UrlRequestParams_idempotency_get = + _Cronet_UrlRequestParams_idempotency_get_ptr.asFunction< + _dart_Cronet_UrlRequestParams_idempotency_get>(); + + /// //////////////////// + ffi.Pointer Cronet_DateTime_Create() { + return _Cronet_DateTime_Create(); + } + + late final _Cronet_DateTime_Create_ptr = + _lookup>( + 'Cronet_DateTime_Create'); + late final _dart_Cronet_DateTime_Create _Cronet_DateTime_Create = + _Cronet_DateTime_Create_ptr.asFunction<_dart_Cronet_DateTime_Create>(); + + void Cronet_DateTime_Destroy( + ffi.Pointer self, + ) { + return _Cronet_DateTime_Destroy( + self, + ); + } + + late final _Cronet_DateTime_Destroy_ptr = + _lookup>( + 'Cronet_DateTime_Destroy'); + late final _dart_Cronet_DateTime_Destroy _Cronet_DateTime_Destroy = + _Cronet_DateTime_Destroy_ptr.asFunction<_dart_Cronet_DateTime_Destroy>(); + + void Cronet_DateTime_value_set( + ffi.Pointer self, + int value, + ) { + return _Cronet_DateTime_value_set( + self, + value, + ); + } + + late final _Cronet_DateTime_value_set_ptr = + _lookup>( + 'Cronet_DateTime_value_set'); + late final _dart_Cronet_DateTime_value_set _Cronet_DateTime_value_set = + _Cronet_DateTime_value_set_ptr.asFunction< + _dart_Cronet_DateTime_value_set>(); + + int Cronet_DateTime_value_get( + ffi.Pointer self, + ) { + return _Cronet_DateTime_value_get( + self, + ); + } + + late final _Cronet_DateTime_value_get_ptr = + _lookup>( + 'Cronet_DateTime_value_get'); + late final _dart_Cronet_DateTime_value_get _Cronet_DateTime_value_get = + _Cronet_DateTime_value_get_ptr.asFunction< + _dart_Cronet_DateTime_value_get>(); + + /// //////////////////// + ffi.Pointer Cronet_Metrics_Create() { + return _Cronet_Metrics_Create(); + } + + late final _Cronet_Metrics_Create_ptr = + _lookup>( + 'Cronet_Metrics_Create'); + late final _dart_Cronet_Metrics_Create _Cronet_Metrics_Create = + _Cronet_Metrics_Create_ptr.asFunction<_dart_Cronet_Metrics_Create>(); + + void Cronet_Metrics_Destroy( + ffi.Pointer self, + ) { + return _Cronet_Metrics_Destroy( + self, + ); + } + + late final _Cronet_Metrics_Destroy_ptr = + _lookup>( + 'Cronet_Metrics_Destroy'); + late final _dart_Cronet_Metrics_Destroy _Cronet_Metrics_Destroy = + _Cronet_Metrics_Destroy_ptr.asFunction<_dart_Cronet_Metrics_Destroy>(); + + void Cronet_Metrics_request_start_set( + ffi.Pointer self, + ffi.Pointer request_start, + ) { + return _Cronet_Metrics_request_start_set( + self, + request_start, + ); + } + + late final _Cronet_Metrics_request_start_set_ptr = + _lookup>( + 'Cronet_Metrics_request_start_set'); + late final _dart_Cronet_Metrics_request_start_set + _Cronet_Metrics_request_start_set = _Cronet_Metrics_request_start_set_ptr + .asFunction<_dart_Cronet_Metrics_request_start_set>(); + + void Cronet_Metrics_request_start_move( + ffi.Pointer self, + ffi.Pointer request_start, + ) { + return _Cronet_Metrics_request_start_move( + self, + request_start, + ); + } + + late final _Cronet_Metrics_request_start_move_ptr = + _lookup>( + 'Cronet_Metrics_request_start_move'); + late final _dart_Cronet_Metrics_request_start_move + _Cronet_Metrics_request_start_move = + _Cronet_Metrics_request_start_move_ptr.asFunction< + _dart_Cronet_Metrics_request_start_move>(); + + void Cronet_Metrics_dns_start_set( + ffi.Pointer self, + ffi.Pointer dns_start, + ) { + return _Cronet_Metrics_dns_start_set( + self, + dns_start, + ); + } + + late final _Cronet_Metrics_dns_start_set_ptr = + _lookup>( + 'Cronet_Metrics_dns_start_set'); + late final _dart_Cronet_Metrics_dns_start_set _Cronet_Metrics_dns_start_set = + _Cronet_Metrics_dns_start_set_ptr.asFunction< + _dart_Cronet_Metrics_dns_start_set>(); + + void Cronet_Metrics_dns_start_move( + ffi.Pointer self, + ffi.Pointer dns_start, + ) { + return _Cronet_Metrics_dns_start_move( + self, + dns_start, + ); + } + + late final _Cronet_Metrics_dns_start_move_ptr = + _lookup>( + 'Cronet_Metrics_dns_start_move'); + late final _dart_Cronet_Metrics_dns_start_move + _Cronet_Metrics_dns_start_move = _Cronet_Metrics_dns_start_move_ptr + .asFunction<_dart_Cronet_Metrics_dns_start_move>(); + + void Cronet_Metrics_dns_end_set( + ffi.Pointer self, + ffi.Pointer dns_end, + ) { + return _Cronet_Metrics_dns_end_set( + self, + dns_end, + ); + } + + late final _Cronet_Metrics_dns_end_set_ptr = + _lookup>( + 'Cronet_Metrics_dns_end_set'); + late final _dart_Cronet_Metrics_dns_end_set _Cronet_Metrics_dns_end_set = + _Cronet_Metrics_dns_end_set_ptr.asFunction< + _dart_Cronet_Metrics_dns_end_set>(); + + void Cronet_Metrics_dns_end_move( + ffi.Pointer self, + ffi.Pointer dns_end, + ) { + return _Cronet_Metrics_dns_end_move( + self, + dns_end, + ); + } + + late final _Cronet_Metrics_dns_end_move_ptr = + _lookup>( + 'Cronet_Metrics_dns_end_move'); + late final _dart_Cronet_Metrics_dns_end_move _Cronet_Metrics_dns_end_move = + _Cronet_Metrics_dns_end_move_ptr.asFunction< + _dart_Cronet_Metrics_dns_end_move>(); + + void Cronet_Metrics_connect_start_set( + ffi.Pointer self, + ffi.Pointer connect_start, + ) { + return _Cronet_Metrics_connect_start_set( + self, + connect_start, + ); + } + + late final _Cronet_Metrics_connect_start_set_ptr = + _lookup>( + 'Cronet_Metrics_connect_start_set'); + late final _dart_Cronet_Metrics_connect_start_set + _Cronet_Metrics_connect_start_set = _Cronet_Metrics_connect_start_set_ptr + .asFunction<_dart_Cronet_Metrics_connect_start_set>(); + + void Cronet_Metrics_connect_start_move( + ffi.Pointer self, + ffi.Pointer connect_start, + ) { + return _Cronet_Metrics_connect_start_move( + self, + connect_start, + ); + } + + late final _Cronet_Metrics_connect_start_move_ptr = + _lookup>( + 'Cronet_Metrics_connect_start_move'); + late final _dart_Cronet_Metrics_connect_start_move + _Cronet_Metrics_connect_start_move = + _Cronet_Metrics_connect_start_move_ptr.asFunction< + _dart_Cronet_Metrics_connect_start_move>(); + + void Cronet_Metrics_connect_end_set( + ffi.Pointer self, + ffi.Pointer connect_end, + ) { + return _Cronet_Metrics_connect_end_set( + self, + connect_end, + ); + } + + late final _Cronet_Metrics_connect_end_set_ptr = + _lookup>( + 'Cronet_Metrics_connect_end_set'); + late final _dart_Cronet_Metrics_connect_end_set + _Cronet_Metrics_connect_end_set = _Cronet_Metrics_connect_end_set_ptr + .asFunction<_dart_Cronet_Metrics_connect_end_set>(); + + void Cronet_Metrics_connect_end_move( + ffi.Pointer self, + ffi.Pointer connect_end, + ) { + return _Cronet_Metrics_connect_end_move( + self, + connect_end, + ); + } + + late final _Cronet_Metrics_connect_end_move_ptr = + _lookup>( + 'Cronet_Metrics_connect_end_move'); + late final _dart_Cronet_Metrics_connect_end_move + _Cronet_Metrics_connect_end_move = _Cronet_Metrics_connect_end_move_ptr + .asFunction<_dart_Cronet_Metrics_connect_end_move>(); + + void Cronet_Metrics_ssl_start_set( + ffi.Pointer self, + ffi.Pointer ssl_start, + ) { + return _Cronet_Metrics_ssl_start_set( + self, + ssl_start, + ); + } + + late final _Cronet_Metrics_ssl_start_set_ptr = + _lookup>( + 'Cronet_Metrics_ssl_start_set'); + late final _dart_Cronet_Metrics_ssl_start_set _Cronet_Metrics_ssl_start_set = + _Cronet_Metrics_ssl_start_set_ptr.asFunction< + _dart_Cronet_Metrics_ssl_start_set>(); + + void Cronet_Metrics_ssl_start_move( + ffi.Pointer self, + ffi.Pointer ssl_start, + ) { + return _Cronet_Metrics_ssl_start_move( + self, + ssl_start, + ); + } + + late final _Cronet_Metrics_ssl_start_move_ptr = + _lookup>( + 'Cronet_Metrics_ssl_start_move'); + late final _dart_Cronet_Metrics_ssl_start_move + _Cronet_Metrics_ssl_start_move = _Cronet_Metrics_ssl_start_move_ptr + .asFunction<_dart_Cronet_Metrics_ssl_start_move>(); + + void Cronet_Metrics_ssl_end_set( + ffi.Pointer self, + ffi.Pointer ssl_end, + ) { + return _Cronet_Metrics_ssl_end_set( + self, + ssl_end, + ); + } + + late final _Cronet_Metrics_ssl_end_set_ptr = + _lookup>( + 'Cronet_Metrics_ssl_end_set'); + late final _dart_Cronet_Metrics_ssl_end_set _Cronet_Metrics_ssl_end_set = + _Cronet_Metrics_ssl_end_set_ptr.asFunction< + _dart_Cronet_Metrics_ssl_end_set>(); + + void Cronet_Metrics_ssl_end_move( + ffi.Pointer self, + ffi.Pointer ssl_end, + ) { + return _Cronet_Metrics_ssl_end_move( + self, + ssl_end, + ); + } + + late final _Cronet_Metrics_ssl_end_move_ptr = + _lookup>( + 'Cronet_Metrics_ssl_end_move'); + late final _dart_Cronet_Metrics_ssl_end_move _Cronet_Metrics_ssl_end_move = + _Cronet_Metrics_ssl_end_move_ptr.asFunction< + _dart_Cronet_Metrics_ssl_end_move>(); + + void Cronet_Metrics_sending_start_set( + ffi.Pointer self, + ffi.Pointer sending_start, + ) { + return _Cronet_Metrics_sending_start_set( + self, + sending_start, + ); + } + + late final _Cronet_Metrics_sending_start_set_ptr = + _lookup>( + 'Cronet_Metrics_sending_start_set'); + late final _dart_Cronet_Metrics_sending_start_set + _Cronet_Metrics_sending_start_set = _Cronet_Metrics_sending_start_set_ptr + .asFunction<_dart_Cronet_Metrics_sending_start_set>(); + + void Cronet_Metrics_sending_start_move( + ffi.Pointer self, + ffi.Pointer sending_start, + ) { + return _Cronet_Metrics_sending_start_move( + self, + sending_start, + ); + } + + late final _Cronet_Metrics_sending_start_move_ptr = + _lookup>( + 'Cronet_Metrics_sending_start_move'); + late final _dart_Cronet_Metrics_sending_start_move + _Cronet_Metrics_sending_start_move = + _Cronet_Metrics_sending_start_move_ptr.asFunction< + _dart_Cronet_Metrics_sending_start_move>(); + + void Cronet_Metrics_sending_end_set( + ffi.Pointer self, + ffi.Pointer sending_end, + ) { + return _Cronet_Metrics_sending_end_set( + self, + sending_end, + ); + } + + late final _Cronet_Metrics_sending_end_set_ptr = + _lookup>( + 'Cronet_Metrics_sending_end_set'); + late final _dart_Cronet_Metrics_sending_end_set + _Cronet_Metrics_sending_end_set = _Cronet_Metrics_sending_end_set_ptr + .asFunction<_dart_Cronet_Metrics_sending_end_set>(); + + void Cronet_Metrics_sending_end_move( + ffi.Pointer self, + ffi.Pointer sending_end, + ) { + return _Cronet_Metrics_sending_end_move( + self, + sending_end, + ); + } + + late final _Cronet_Metrics_sending_end_move_ptr = + _lookup>( + 'Cronet_Metrics_sending_end_move'); + late final _dart_Cronet_Metrics_sending_end_move + _Cronet_Metrics_sending_end_move = _Cronet_Metrics_sending_end_move_ptr + .asFunction<_dart_Cronet_Metrics_sending_end_move>(); + + void Cronet_Metrics_push_start_set( + ffi.Pointer self, + ffi.Pointer push_start, + ) { + return _Cronet_Metrics_push_start_set( + self, + push_start, + ); + } + + late final _Cronet_Metrics_push_start_set_ptr = + _lookup>( + 'Cronet_Metrics_push_start_set'); + late final _dart_Cronet_Metrics_push_start_set + _Cronet_Metrics_push_start_set = _Cronet_Metrics_push_start_set_ptr + .asFunction<_dart_Cronet_Metrics_push_start_set>(); + + void Cronet_Metrics_push_start_move( + ffi.Pointer self, + ffi.Pointer push_start, + ) { + return _Cronet_Metrics_push_start_move( + self, + push_start, + ); + } + + late final _Cronet_Metrics_push_start_move_ptr = + _lookup>( + 'Cronet_Metrics_push_start_move'); + late final _dart_Cronet_Metrics_push_start_move + _Cronet_Metrics_push_start_move = _Cronet_Metrics_push_start_move_ptr + .asFunction<_dart_Cronet_Metrics_push_start_move>(); + + void Cronet_Metrics_push_end_set( + ffi.Pointer self, + ffi.Pointer push_end, + ) { + return _Cronet_Metrics_push_end_set( + self, + push_end, + ); + } + + late final _Cronet_Metrics_push_end_set_ptr = + _lookup>( + 'Cronet_Metrics_push_end_set'); + late final _dart_Cronet_Metrics_push_end_set _Cronet_Metrics_push_end_set = + _Cronet_Metrics_push_end_set_ptr.asFunction< + _dart_Cronet_Metrics_push_end_set>(); + + void Cronet_Metrics_push_end_move( + ffi.Pointer self, + ffi.Pointer push_end, + ) { + return _Cronet_Metrics_push_end_move( + self, + push_end, + ); + } + + late final _Cronet_Metrics_push_end_move_ptr = + _lookup>( + 'Cronet_Metrics_push_end_move'); + late final _dart_Cronet_Metrics_push_end_move _Cronet_Metrics_push_end_move = + _Cronet_Metrics_push_end_move_ptr.asFunction< + _dart_Cronet_Metrics_push_end_move>(); + + void Cronet_Metrics_response_start_set( + ffi.Pointer self, + ffi.Pointer response_start, + ) { + return _Cronet_Metrics_response_start_set( + self, + response_start, + ); + } + + late final _Cronet_Metrics_response_start_set_ptr = + _lookup>( + 'Cronet_Metrics_response_start_set'); + late final _dart_Cronet_Metrics_response_start_set + _Cronet_Metrics_response_start_set = + _Cronet_Metrics_response_start_set_ptr.asFunction< + _dart_Cronet_Metrics_response_start_set>(); + + void Cronet_Metrics_response_start_move( + ffi.Pointer self, + ffi.Pointer response_start, + ) { + return _Cronet_Metrics_response_start_move( + self, + response_start, + ); + } + + late final _Cronet_Metrics_response_start_move_ptr = + _lookup>( + 'Cronet_Metrics_response_start_move'); + late final _dart_Cronet_Metrics_response_start_move + _Cronet_Metrics_response_start_move = + _Cronet_Metrics_response_start_move_ptr.asFunction< + _dart_Cronet_Metrics_response_start_move>(); + + void Cronet_Metrics_request_end_set( + ffi.Pointer self, + ffi.Pointer request_end, + ) { + return _Cronet_Metrics_request_end_set( + self, + request_end, + ); + } + + late final _Cronet_Metrics_request_end_set_ptr = + _lookup>( + 'Cronet_Metrics_request_end_set'); + late final _dart_Cronet_Metrics_request_end_set + _Cronet_Metrics_request_end_set = _Cronet_Metrics_request_end_set_ptr + .asFunction<_dart_Cronet_Metrics_request_end_set>(); + + void Cronet_Metrics_request_end_move( + ffi.Pointer self, + ffi.Pointer request_end, + ) { + return _Cronet_Metrics_request_end_move( + self, + request_end, + ); + } + + late final _Cronet_Metrics_request_end_move_ptr = + _lookup>( + 'Cronet_Metrics_request_end_move'); + late final _dart_Cronet_Metrics_request_end_move + _Cronet_Metrics_request_end_move = _Cronet_Metrics_request_end_move_ptr + .asFunction<_dart_Cronet_Metrics_request_end_move>(); + + void Cronet_Metrics_socket_reused_set( + ffi.Pointer self, + bool socket_reused, + ) { + return _Cronet_Metrics_socket_reused_set( + self, + socket_reused ? 1 : 0, + ); + } + + late final _Cronet_Metrics_socket_reused_set_ptr = + _lookup>( + 'Cronet_Metrics_socket_reused_set'); + late final _dart_Cronet_Metrics_socket_reused_set + _Cronet_Metrics_socket_reused_set = _Cronet_Metrics_socket_reused_set_ptr + .asFunction<_dart_Cronet_Metrics_socket_reused_set>(); + + void Cronet_Metrics_sent_byte_count_set( + ffi.Pointer self, + int sent_byte_count, + ) { + return _Cronet_Metrics_sent_byte_count_set( + self, + sent_byte_count, + ); + } + + late final _Cronet_Metrics_sent_byte_count_set_ptr = + _lookup>( + 'Cronet_Metrics_sent_byte_count_set'); + late final _dart_Cronet_Metrics_sent_byte_count_set + _Cronet_Metrics_sent_byte_count_set = + _Cronet_Metrics_sent_byte_count_set_ptr.asFunction< + _dart_Cronet_Metrics_sent_byte_count_set>(); + + void Cronet_Metrics_received_byte_count_set( + ffi.Pointer self, + int received_byte_count, + ) { + return _Cronet_Metrics_received_byte_count_set( + self, + received_byte_count, + ); + } + + late final _Cronet_Metrics_received_byte_count_set_ptr = + _lookup>( + 'Cronet_Metrics_received_byte_count_set'); + late final _dart_Cronet_Metrics_received_byte_count_set + _Cronet_Metrics_received_byte_count_set = + _Cronet_Metrics_received_byte_count_set_ptr.asFunction< + _dart_Cronet_Metrics_received_byte_count_set>(); + + ffi.Pointer Cronet_Metrics_request_start_get( + ffi.Pointer self, + ) { + return _Cronet_Metrics_request_start_get( + self, + ); + } + + late final _Cronet_Metrics_request_start_get_ptr = + _lookup>( + 'Cronet_Metrics_request_start_get'); + late final _dart_Cronet_Metrics_request_start_get + _Cronet_Metrics_request_start_get = _Cronet_Metrics_request_start_get_ptr + .asFunction<_dart_Cronet_Metrics_request_start_get>(); + + ffi.Pointer Cronet_Metrics_dns_start_get( + ffi.Pointer self, + ) { + return _Cronet_Metrics_dns_start_get( + self, + ); + } + + late final _Cronet_Metrics_dns_start_get_ptr = + _lookup>( + 'Cronet_Metrics_dns_start_get'); + late final _dart_Cronet_Metrics_dns_start_get _Cronet_Metrics_dns_start_get = + _Cronet_Metrics_dns_start_get_ptr.asFunction< + _dart_Cronet_Metrics_dns_start_get>(); + + ffi.Pointer Cronet_Metrics_dns_end_get( + ffi.Pointer self, + ) { + return _Cronet_Metrics_dns_end_get( + self, + ); + } + + late final _Cronet_Metrics_dns_end_get_ptr = + _lookup>( + 'Cronet_Metrics_dns_end_get'); + late final _dart_Cronet_Metrics_dns_end_get _Cronet_Metrics_dns_end_get = + _Cronet_Metrics_dns_end_get_ptr.asFunction< + _dart_Cronet_Metrics_dns_end_get>(); + + ffi.Pointer Cronet_Metrics_connect_start_get( + ffi.Pointer self, + ) { + return _Cronet_Metrics_connect_start_get( + self, + ); + } + + late final _Cronet_Metrics_connect_start_get_ptr = + _lookup>( + 'Cronet_Metrics_connect_start_get'); + late final _dart_Cronet_Metrics_connect_start_get + _Cronet_Metrics_connect_start_get = _Cronet_Metrics_connect_start_get_ptr + .asFunction<_dart_Cronet_Metrics_connect_start_get>(); + + ffi.Pointer Cronet_Metrics_connect_end_get( + ffi.Pointer self, + ) { + return _Cronet_Metrics_connect_end_get( + self, + ); + } + + late final _Cronet_Metrics_connect_end_get_ptr = + _lookup>( + 'Cronet_Metrics_connect_end_get'); + late final _dart_Cronet_Metrics_connect_end_get + _Cronet_Metrics_connect_end_get = _Cronet_Metrics_connect_end_get_ptr + .asFunction<_dart_Cronet_Metrics_connect_end_get>(); + + ffi.Pointer Cronet_Metrics_ssl_start_get( + ffi.Pointer self, + ) { + return _Cronet_Metrics_ssl_start_get( + self, + ); + } + + late final _Cronet_Metrics_ssl_start_get_ptr = + _lookup>( + 'Cronet_Metrics_ssl_start_get'); + late final _dart_Cronet_Metrics_ssl_start_get _Cronet_Metrics_ssl_start_get = + _Cronet_Metrics_ssl_start_get_ptr.asFunction< + _dart_Cronet_Metrics_ssl_start_get>(); + + ffi.Pointer Cronet_Metrics_ssl_end_get( + ffi.Pointer self, + ) { + return _Cronet_Metrics_ssl_end_get( + self, + ); + } + + late final _Cronet_Metrics_ssl_end_get_ptr = + _lookup>( + 'Cronet_Metrics_ssl_end_get'); + late final _dart_Cronet_Metrics_ssl_end_get _Cronet_Metrics_ssl_end_get = + _Cronet_Metrics_ssl_end_get_ptr.asFunction< + _dart_Cronet_Metrics_ssl_end_get>(); + + ffi.Pointer Cronet_Metrics_sending_start_get( + ffi.Pointer self, + ) { + return _Cronet_Metrics_sending_start_get( + self, + ); + } + + late final _Cronet_Metrics_sending_start_get_ptr = + _lookup>( + 'Cronet_Metrics_sending_start_get'); + late final _dart_Cronet_Metrics_sending_start_get + _Cronet_Metrics_sending_start_get = _Cronet_Metrics_sending_start_get_ptr + .asFunction<_dart_Cronet_Metrics_sending_start_get>(); + + ffi.Pointer Cronet_Metrics_sending_end_get( + ffi.Pointer self, + ) { + return _Cronet_Metrics_sending_end_get( + self, + ); + } + + late final _Cronet_Metrics_sending_end_get_ptr = + _lookup>( + 'Cronet_Metrics_sending_end_get'); + late final _dart_Cronet_Metrics_sending_end_get + _Cronet_Metrics_sending_end_get = _Cronet_Metrics_sending_end_get_ptr + .asFunction<_dart_Cronet_Metrics_sending_end_get>(); + + ffi.Pointer Cronet_Metrics_push_start_get( + ffi.Pointer self, + ) { + return _Cronet_Metrics_push_start_get( + self, + ); + } + + late final _Cronet_Metrics_push_start_get_ptr = + _lookup>( + 'Cronet_Metrics_push_start_get'); + late final _dart_Cronet_Metrics_push_start_get + _Cronet_Metrics_push_start_get = _Cronet_Metrics_push_start_get_ptr + .asFunction<_dart_Cronet_Metrics_push_start_get>(); + + ffi.Pointer Cronet_Metrics_push_end_get( + ffi.Pointer self, + ) { + return _Cronet_Metrics_push_end_get( + self, + ); + } + + late final _Cronet_Metrics_push_end_get_ptr = + _lookup>( + 'Cronet_Metrics_push_end_get'); + late final _dart_Cronet_Metrics_push_end_get _Cronet_Metrics_push_end_get = + _Cronet_Metrics_push_end_get_ptr.asFunction< + _dart_Cronet_Metrics_push_end_get>(); + + ffi.Pointer Cronet_Metrics_response_start_get( + ffi.Pointer self, + ) { + return _Cronet_Metrics_response_start_get( + self, + ); + } + + late final _Cronet_Metrics_response_start_get_ptr = + _lookup>( + 'Cronet_Metrics_response_start_get'); + late final _dart_Cronet_Metrics_response_start_get + _Cronet_Metrics_response_start_get = + _Cronet_Metrics_response_start_get_ptr.asFunction< + _dart_Cronet_Metrics_response_start_get>(); + + ffi.Pointer Cronet_Metrics_request_end_get( + ffi.Pointer self, + ) { + return _Cronet_Metrics_request_end_get( + self, + ); + } + + late final _Cronet_Metrics_request_end_get_ptr = + _lookup>( + 'Cronet_Metrics_request_end_get'); + late final _dart_Cronet_Metrics_request_end_get + _Cronet_Metrics_request_end_get = _Cronet_Metrics_request_end_get_ptr + .asFunction<_dart_Cronet_Metrics_request_end_get>(); + + bool Cronet_Metrics_socket_reused_get( + ffi.Pointer self, + ) { + return _Cronet_Metrics_socket_reused_get( + self, + ) != + 0; + } + + late final _Cronet_Metrics_socket_reused_get_ptr = + _lookup>( + 'Cronet_Metrics_socket_reused_get'); + late final _dart_Cronet_Metrics_socket_reused_get + _Cronet_Metrics_socket_reused_get = _Cronet_Metrics_socket_reused_get_ptr + .asFunction<_dart_Cronet_Metrics_socket_reused_get>(); + + int Cronet_Metrics_sent_byte_count_get( + ffi.Pointer self, + ) { + return _Cronet_Metrics_sent_byte_count_get( + self, + ); + } + + late final _Cronet_Metrics_sent_byte_count_get_ptr = + _lookup>( + 'Cronet_Metrics_sent_byte_count_get'); + late final _dart_Cronet_Metrics_sent_byte_count_get + _Cronet_Metrics_sent_byte_count_get = + _Cronet_Metrics_sent_byte_count_get_ptr.asFunction< + _dart_Cronet_Metrics_sent_byte_count_get>(); + + int Cronet_Metrics_received_byte_count_get( + ffi.Pointer self, + ) { + return _Cronet_Metrics_received_byte_count_get( + self, + ); + } + + late final _Cronet_Metrics_received_byte_count_get_ptr = + _lookup>( + 'Cronet_Metrics_received_byte_count_get'); + late final _dart_Cronet_Metrics_received_byte_count_get + _Cronet_Metrics_received_byte_count_get = + _Cronet_Metrics_received_byte_count_get_ptr.asFunction< + _dart_Cronet_Metrics_received_byte_count_get>(); + + /// //////////////////// + ffi.Pointer Cronet_RequestFinishedInfo_Create() { + return _Cronet_RequestFinishedInfo_Create(); + } + + late final _Cronet_RequestFinishedInfo_Create_ptr = + _lookup>( + 'Cronet_RequestFinishedInfo_Create'); + late final _dart_Cronet_RequestFinishedInfo_Create + _Cronet_RequestFinishedInfo_Create = + _Cronet_RequestFinishedInfo_Create_ptr.asFunction< + _dart_Cronet_RequestFinishedInfo_Create>(); + + void Cronet_RequestFinishedInfo_Destroy( + ffi.Pointer self, + ) { + return _Cronet_RequestFinishedInfo_Destroy( + self, + ); + } + + late final _Cronet_RequestFinishedInfo_Destroy_ptr = + _lookup>( + 'Cronet_RequestFinishedInfo_Destroy'); + late final _dart_Cronet_RequestFinishedInfo_Destroy + _Cronet_RequestFinishedInfo_Destroy = + _Cronet_RequestFinishedInfo_Destroy_ptr.asFunction< + _dart_Cronet_RequestFinishedInfo_Destroy>(); + + void Cronet_RequestFinishedInfo_metrics_set( + ffi.Pointer self, + ffi.Pointer metrics, + ) { + return _Cronet_RequestFinishedInfo_metrics_set( + self, + metrics, + ); + } + + late final _Cronet_RequestFinishedInfo_metrics_set_ptr = + _lookup>( + 'Cronet_RequestFinishedInfo_metrics_set'); + late final _dart_Cronet_RequestFinishedInfo_metrics_set + _Cronet_RequestFinishedInfo_metrics_set = + _Cronet_RequestFinishedInfo_metrics_set_ptr.asFunction< + _dart_Cronet_RequestFinishedInfo_metrics_set>(); + + void Cronet_RequestFinishedInfo_metrics_move( + ffi.Pointer self, + ffi.Pointer metrics, + ) { + return _Cronet_RequestFinishedInfo_metrics_move( + self, + metrics, + ); + } + + late final _Cronet_RequestFinishedInfo_metrics_move_ptr = + _lookup>( + 'Cronet_RequestFinishedInfo_metrics_move'); + late final _dart_Cronet_RequestFinishedInfo_metrics_move + _Cronet_RequestFinishedInfo_metrics_move = + _Cronet_RequestFinishedInfo_metrics_move_ptr.asFunction< + _dart_Cronet_RequestFinishedInfo_metrics_move>(); + + void Cronet_RequestFinishedInfo_annotations_add( + ffi.Pointer self, + ffi.Pointer element, + ) { + return _Cronet_RequestFinishedInfo_annotations_add( + self, + element, + ); + } + + late final _Cronet_RequestFinishedInfo_annotations_add_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_RequestFinishedInfo_annotations_add>>( + 'Cronet_RequestFinishedInfo_annotations_add'); + late final _dart_Cronet_RequestFinishedInfo_annotations_add + _Cronet_RequestFinishedInfo_annotations_add = + _Cronet_RequestFinishedInfo_annotations_add_ptr.asFunction< + _dart_Cronet_RequestFinishedInfo_annotations_add>(); + + void Cronet_RequestFinishedInfo_finished_reason_set( + ffi.Pointer self, + int finished_reason, + ) { + return _Cronet_RequestFinishedInfo_finished_reason_set( + self, + finished_reason, + ); + } + + late final _Cronet_RequestFinishedInfo_finished_reason_set_ptr = _lookup< + ffi.NativeFunction< + _c_Cronet_RequestFinishedInfo_finished_reason_set>>( + 'Cronet_RequestFinishedInfo_finished_reason_set'); + late final _dart_Cronet_RequestFinishedInfo_finished_reason_set + _Cronet_RequestFinishedInfo_finished_reason_set = + _Cronet_RequestFinishedInfo_finished_reason_set_ptr.asFunction< + _dart_Cronet_RequestFinishedInfo_finished_reason_set>(); + + ffi.Pointer Cronet_RequestFinishedInfo_metrics_get( + ffi.Pointer self, + ) { + return _Cronet_RequestFinishedInfo_metrics_get( + self, + ); + } + + late final _Cronet_RequestFinishedInfo_metrics_get_ptr = + _lookup>( + 'Cronet_RequestFinishedInfo_metrics_get'); + late final _dart_Cronet_RequestFinishedInfo_metrics_get + _Cronet_RequestFinishedInfo_metrics_get = + _Cronet_RequestFinishedInfo_metrics_get_ptr.asFunction< + _dart_Cronet_RequestFinishedInfo_metrics_get>(); + + int Cronet_RequestFinishedInfo_annotations_size( + ffi.Pointer self, + ) { + return _Cronet_RequestFinishedInfo_annotations_size( + self, + ); + } + + late final _Cronet_RequestFinishedInfo_annotations_size_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_RequestFinishedInfo_annotations_size>>( + 'Cronet_RequestFinishedInfo_annotations_size'); + late final _dart_Cronet_RequestFinishedInfo_annotations_size + _Cronet_RequestFinishedInfo_annotations_size = + _Cronet_RequestFinishedInfo_annotations_size_ptr.asFunction< + _dart_Cronet_RequestFinishedInfo_annotations_size>(); + + ffi.Pointer Cronet_RequestFinishedInfo_annotations_at( + ffi.Pointer self, + int index, + ) { + return _Cronet_RequestFinishedInfo_annotations_at( + self, + index, + ); + } + + late final _Cronet_RequestFinishedInfo_annotations_at_ptr = + _lookup>( + 'Cronet_RequestFinishedInfo_annotations_at'); + late final _dart_Cronet_RequestFinishedInfo_annotations_at + _Cronet_RequestFinishedInfo_annotations_at = + _Cronet_RequestFinishedInfo_annotations_at_ptr.asFunction< + _dart_Cronet_RequestFinishedInfo_annotations_at>(); + + void Cronet_RequestFinishedInfo_annotations_clear( + ffi.Pointer self, + ) { + return _Cronet_RequestFinishedInfo_annotations_clear( + self, + ); + } + + late final _Cronet_RequestFinishedInfo_annotations_clear_ptr = _lookup< + ffi.NativeFunction<_c_Cronet_RequestFinishedInfo_annotations_clear>>( + 'Cronet_RequestFinishedInfo_annotations_clear'); + late final _dart_Cronet_RequestFinishedInfo_annotations_clear + _Cronet_RequestFinishedInfo_annotations_clear = + _Cronet_RequestFinishedInfo_annotations_clear_ptr.asFunction< + _dart_Cronet_RequestFinishedInfo_annotations_clear>(); + + int Cronet_RequestFinishedInfo_finished_reason_get( + ffi.Pointer self, + ) { + return _Cronet_RequestFinishedInfo_finished_reason_get( + self, + ); + } + + late final _Cronet_RequestFinishedInfo_finished_reason_get_ptr = _lookup< + ffi.NativeFunction< + _c_Cronet_RequestFinishedInfo_finished_reason_get>>( + 'Cronet_RequestFinishedInfo_finished_reason_get'); + late final _dart_Cronet_RequestFinishedInfo_finished_reason_get + _Cronet_RequestFinishedInfo_finished_reason_get = + _Cronet_RequestFinishedInfo_finished_reason_get_ptr.asFunction< + _dart_Cronet_RequestFinishedInfo_finished_reason_get>(); + + late final addresses = _SymbolAddresses(this); +} + +class _SymbolAddresses { + final Cronet _library; + _SymbolAddresses(this._library); + ffi.Pointer> + get Cronet_Buffer_Create => _library._Cronet_Buffer_Create_ptr; + ffi.Pointer> + get Cronet_Buffer_InitWithAlloc => + _library._Cronet_Buffer_InitWithAlloc_ptr; + ffi.Pointer> + get Cronet_Runnable_Destroy => _library._Cronet_Runnable_Destroy_ptr; + ffi.Pointer> + get Cronet_Runnable_Run => _library._Cronet_Runnable_Run_ptr; + ffi.Pointer> + get Cronet_Executor_Destroy => _library._Cronet_Executor_Destroy_ptr; + ffi.Pointer> + get Cronet_Executor_SetClientContext => + _library._Cronet_Executor_SetClientContext_ptr; + ffi.Pointer> + get Cronet_Executor_GetClientContext => + _library._Cronet_Executor_GetClientContext_ptr; + ffi.Pointer> + get Cronet_Executor_CreateWith => + _library._Cronet_Executor_CreateWith_ptr; + ffi.Pointer> + get Cronet_Engine_Destroy => _library._Cronet_Engine_Destroy_ptr; + ffi.Pointer> + get Cronet_Engine_Shutdown => _library._Cronet_Engine_Shutdown_ptr; + ffi.Pointer> + get Cronet_UrlRequestCallback_CreateWith => + _library._Cronet_UrlRequestCallback_CreateWith_ptr; + ffi.Pointer> + get Cronet_UrlRequest_InitWithParams => + _library._Cronet_UrlRequest_InitWithParams_ptr; +} + +class Cronet_Buffer extends ffi.Opaque {} + +class Cronet_BufferCallback extends ffi.Opaque {} + +class Cronet_Runnable extends ffi.Opaque {} + +class Cronet_Executor extends ffi.Opaque {} + +class Cronet_Engine extends ffi.Opaque {} + +class Cronet_UrlRequestStatusListener extends ffi.Opaque {} + +class Cronet_UrlRequestCallback extends ffi.Opaque {} + +class Cronet_UploadDataSink extends ffi.Opaque {} + +class Cronet_UploadDataProvider extends ffi.Opaque {} + +class Cronet_UrlRequest extends ffi.Opaque {} + +class Cronet_RequestFinishedInfoListener extends ffi.Opaque {} + +class Cronet_Error extends ffi.Opaque {} + +class Cronet_QuicHint extends ffi.Opaque {} + +class Cronet_PublicKeyPins extends ffi.Opaque {} + +class Cronet_EngineParams extends ffi.Opaque {} + +class Cronet_HttpHeader extends ffi.Opaque {} + +class Cronet_UrlResponseInfo extends ffi.Opaque {} + +class Cronet_UrlRequestParams extends ffi.Opaque {} + +class Cronet_DateTime extends ffi.Opaque {} + +class Cronet_Metrics extends ffi.Opaque {} + +class Cronet_RequestFinishedInfo extends ffi.Opaque {} + +abstract class Cronet_RESULT { + static const int Cronet_RESULT_SUCCESS = 0; + static const int Cronet_RESULT_ILLEGAL_ARGUMENT = -100; + static const int Cronet_RESULT_ILLEGAL_ARGUMENT_STORAGE_PATH_MUST_EXIST = + -101; + static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_PIN = -102; + static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HOSTNAME = -103; + static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HTTP_METHOD = -104; + static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HTTP_HEADER = -105; + static const int Cronet_RESULT_ILLEGAL_STATE = -200; + static const int Cronet_RESULT_ILLEGAL_STATE_STORAGE_PATH_IN_USE = -201; + static const int + Cronet_RESULT_ILLEGAL_STATE_CANNOT_SHUTDOWN_ENGINE_FROM_NETWORK_THREAD = + -202; + static const int Cronet_RESULT_ILLEGAL_STATE_ENGINE_ALREADY_STARTED = -203; + static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_ALREADY_STARTED = -204; + static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_NOT_INITIALIZED = -205; + static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_ALREADY_INITIALIZED = + -206; + static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_NOT_STARTED = -207; + static const int Cronet_RESULT_ILLEGAL_STATE_UNEXPECTED_REDIRECT = -208; + static const int Cronet_RESULT_ILLEGAL_STATE_UNEXPECTED_READ = -209; + static const int Cronet_RESULT_ILLEGAL_STATE_READ_FAILED = -210; + static const int Cronet_RESULT_NULL_POINTER = -300; + static const int Cronet_RESULT_NULL_POINTER_HOSTNAME = -301; + static const int Cronet_RESULT_NULL_POINTER_SHA256_PINS = -302; + static const int Cronet_RESULT_NULL_POINTER_EXPIRATION_DATE = -303; + static const int Cronet_RESULT_NULL_POINTER_ENGINE = -304; + static const int Cronet_RESULT_NULL_POINTER_URL = -305; + static const int Cronet_RESULT_NULL_POINTER_CALLBACK = -306; + static const int Cronet_RESULT_NULL_POINTER_EXECUTOR = -307; + static const int Cronet_RESULT_NULL_POINTER_METHOD = -308; + static const int Cronet_RESULT_NULL_POINTER_HEADER_NAME = -309; + static const int Cronet_RESULT_NULL_POINTER_HEADER_VALUE = -310; + static const int Cronet_RESULT_NULL_POINTER_PARAMS = -311; + static const int + Cronet_RESULT_NULL_POINTER_REQUEST_FINISHED_INFO_LISTENER_EXECUTOR = -312; +} + +abstract class Cronet_Error_ERROR_CODE { + static const int Cronet_Error_ERROR_CODE_ERROR_CALLBACK = 0; + static const int Cronet_Error_ERROR_CODE_ERROR_HOSTNAME_NOT_RESOLVED = 1; + static const int Cronet_Error_ERROR_CODE_ERROR_INTERNET_DISCONNECTED = 2; + static const int Cronet_Error_ERROR_CODE_ERROR_NETWORK_CHANGED = 3; + static const int Cronet_Error_ERROR_CODE_ERROR_TIMED_OUT = 4; + static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_CLOSED = 5; + static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_TIMED_OUT = 6; + static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_REFUSED = 7; + static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_RESET = 8; + static const int Cronet_Error_ERROR_CODE_ERROR_ADDRESS_UNREACHABLE = 9; + static const int Cronet_Error_ERROR_CODE_ERROR_QUIC_PROTOCOL_FAILED = 10; + static const int Cronet_Error_ERROR_CODE_ERROR_OTHER = 11; +} + +abstract class Cronet_EngineParams_HTTP_CACHE_MODE { + static const int Cronet_EngineParams_HTTP_CACHE_MODE_DISABLED = 0; + static const int Cronet_EngineParams_HTTP_CACHE_MODE_IN_MEMORY = 1; + static const int Cronet_EngineParams_HTTP_CACHE_MODE_DISK_NO_HTTP = 2; + static const int Cronet_EngineParams_HTTP_CACHE_MODE_DISK = 3; +} + +abstract class Cronet_UrlRequestParams_REQUEST_PRIORITY { + static const int + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_IDLE = 0; + static const int + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_LOWEST = 1; + static const int + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_LOW = 2; + static const int + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_MEDIUM = 3; + static const int + Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_HIGHEST = 4; +} + +abstract class Cronet_UrlRequestParams_IDEMPOTENCY { + static const int Cronet_UrlRequestParams_IDEMPOTENCY_DEFAULT_IDEMPOTENCY = 0; + static const int Cronet_UrlRequestParams_IDEMPOTENCY_IDEMPOTENT = 1; + static const int Cronet_UrlRequestParams_IDEMPOTENCY_NOT_IDEMPOTENT = 2; +} + +abstract class Cronet_RequestFinishedInfo_FINISHED_REASON { + static const int Cronet_RequestFinishedInfo_FINISHED_REASON_SUCCEEDED = 0; + static const int Cronet_RequestFinishedInfo_FINISHED_REASON_FAILED = 1; + static const int Cronet_RequestFinishedInfo_FINISHED_REASON_CANCELED = 2; +} + +abstract class Cronet_UrlRequestStatusListener_Status { + static const int Cronet_UrlRequestStatusListener_Status_INVALID = -1; + static const int Cronet_UrlRequestStatusListener_Status_IDLE = 0; + static const int + Cronet_UrlRequestStatusListener_Status_WAITING_FOR_STALLED_SOCKET_POOL = + 1; + static const int + Cronet_UrlRequestStatusListener_Status_WAITING_FOR_AVAILABLE_SOCKET = 2; + static const int Cronet_UrlRequestStatusListener_Status_WAITING_FOR_DELEGATE = + 3; + static const int Cronet_UrlRequestStatusListener_Status_WAITING_FOR_CACHE = 4; + static const int Cronet_UrlRequestStatusListener_Status_DOWNLOADING_PAC_FILE = + 5; + static const int + Cronet_UrlRequestStatusListener_Status_RESOLVING_PROXY_FOR_URL = 6; + static const int + Cronet_UrlRequestStatusListener_Status_RESOLVING_HOST_IN_PAC_FILE = 7; + static const int + Cronet_UrlRequestStatusListener_Status_ESTABLISHING_PROXY_TUNNEL = 8; + static const int Cronet_UrlRequestStatusListener_Status_RESOLVING_HOST = 9; + static const int Cronet_UrlRequestStatusListener_Status_CONNECTING = 10; + static const int Cronet_UrlRequestStatusListener_Status_SSL_HANDSHAKE = 11; + static const int Cronet_UrlRequestStatusListener_Status_SENDING_REQUEST = 12; + static const int Cronet_UrlRequestStatusListener_Status_WAITING_FOR_RESPONSE = + 13; + static const int Cronet_UrlRequestStatusListener_Status_READING_RESPONSE = 14; +} + +typedef Native_Cronet_Buffer_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_Buffer_Create = ffi.Pointer Function(); + +typedef _c_Cronet_Buffer_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Buffer_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Buffer_SetClientContext = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _dart_Cronet_Buffer_SetClientContext = void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _c_Cronet_Buffer_GetClientContext = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Buffer_GetClientContext = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Buffer_InitWithDataAndCallback = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer data, + ffi.Uint64 size, + ffi.Pointer callback, +); + +typedef _dart_Cronet_Buffer_InitWithDataAndCallback = void Function( + ffi.Pointer self, + ffi.Pointer data, + int size, + ffi.Pointer callback, +); + +typedef Native_Cronet_Buffer_InitWithAlloc = ffi.Void Function( + ffi.Pointer self, + ffi.Uint64 size, +); + +typedef _dart_Cronet_Buffer_InitWithAlloc = void Function( + ffi.Pointer self, + int size, +); + +typedef _c_Cronet_Buffer_GetSize = ffi.Uint64 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Buffer_GetSize = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Buffer_GetData = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Buffer_GetData = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef Cronet_Buffer_InitWithDataAndCallbackFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Uint64, + ffi.Pointer, +); + +typedef Cronet_Buffer_InitWithAllocFunc = ffi.Void Function( + ffi.Pointer, + ffi.Uint64, +); + +typedef Cronet_Buffer_GetSizeFunc = ffi.Uint64 Function( + ffi.Pointer, +); + +typedef Cronet_Buffer_GetDataFunc = ffi.Pointer Function( + ffi.Pointer, +); + +typedef _c_Cronet_Buffer_CreateWith = ffi.Pointer Function( + ffi.Pointer> + InitWithDataAndCallbackFunc, + ffi.Pointer> + InitWithAllocFunc, + ffi.Pointer> GetSizeFunc, + ffi.Pointer> GetDataFunc, +); + +typedef _dart_Cronet_Buffer_CreateWith = ffi.Pointer Function( + ffi.Pointer> + InitWithDataAndCallbackFunc, + ffi.Pointer> + InitWithAllocFunc, + ffi.Pointer> GetSizeFunc, + ffi.Pointer> GetDataFunc, +); + +typedef _c_Cronet_BufferCallback_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_BufferCallback_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_BufferCallback_SetClientContext = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _dart_Cronet_BufferCallback_SetClientContext = void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _c_Cronet_BufferCallback_GetClientContext = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_BufferCallback_GetClientContext = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _c_Cronet_BufferCallback_OnDestroy = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer buffer, +); + +typedef _dart_Cronet_BufferCallback_OnDestroy = void Function( + ffi.Pointer self, + ffi.Pointer buffer, +); + +typedef Cronet_BufferCallback_OnDestroyFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, +); + +typedef _c_Cronet_BufferCallback_CreateWith = ffi.Pointer + Function( + ffi.Pointer> + OnDestroyFunc, +); + +typedef _dart_Cronet_BufferCallback_CreateWith + = ffi.Pointer Function( + ffi.Pointer> + OnDestroyFunc, +); + +typedef Native_Cronet_Runnable_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Runnable_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Runnable_SetClientContext = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _dart_Cronet_Runnable_SetClientContext = void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _c_Cronet_Runnable_GetClientContext = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Runnable_GetClientContext = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef Native_Cronet_Runnable_Run = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Runnable_Run = void Function( + ffi.Pointer self, +); + +typedef Cronet_Runnable_RunFunc = ffi.Void Function( + ffi.Pointer, +); + +typedef _c_Cronet_Runnable_CreateWith = ffi.Pointer Function( + ffi.Pointer> RunFunc, +); + +typedef _dart_Cronet_Runnable_CreateWith = ffi.Pointer + Function( + ffi.Pointer> RunFunc, +); + +typedef Native_Cronet_Executor_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Executor_Destroy = void Function( + ffi.Pointer self, +); + +typedef Native_Cronet_Executor_SetClientContext = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _dart_Cronet_Executor_SetClientContext = void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef Native_Cronet_Executor_GetClientContext = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Executor_GetClientContext = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Executor_Execute = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer command, +); + +typedef _dart_Cronet_Executor_Execute = void Function( + ffi.Pointer self, + ffi.Pointer command, +); + +typedef Cronet_Executor_ExecuteFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, +); + +typedef Native_Cronet_Executor_CreateWith = ffi.Pointer + Function( + ffi.Pointer> ExecuteFunc, +); + +typedef _dart_Cronet_Executor_CreateWith = ffi.Pointer + Function( + ffi.Pointer> ExecuteFunc, +); + +typedef _c_Cronet_Engine_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_Engine_Create = ffi.Pointer Function(); + +typedef Native_Cronet_Engine_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Engine_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Engine_SetClientContext = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _dart_Cronet_Engine_SetClientContext = void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _c_Cronet_Engine_GetClientContext = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Engine_GetClientContext = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Engine_StartWithParams = ffi.Int32 Function( + ffi.Pointer self, + ffi.Pointer params, +); + +typedef _dart_Cronet_Engine_StartWithParams = int Function( + ffi.Pointer self, + ffi.Pointer params, +); + +typedef _c_Cronet_Engine_StartNetLogToFile = ffi.Uint8 Function( + ffi.Pointer self, + ffi.Pointer file_name, + ffi.Uint8 log_all, +); + +typedef _dart_Cronet_Engine_StartNetLogToFile = int Function( + ffi.Pointer self, + ffi.Pointer file_name, + int log_all, +); + +typedef _c_Cronet_Engine_StopNetLog = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Engine_StopNetLog = void Function( + ffi.Pointer self, +); + +typedef Native_Cronet_Engine_Shutdown = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Engine_Shutdown = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Engine_GetVersionString = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Engine_GetVersionString = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Engine_GetDefaultUserAgent = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Engine_GetDefaultUserAgent = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Engine_AddRequestFinishedListener = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer listener, + ffi.Pointer executor, +); + +typedef _dart_Cronet_Engine_AddRequestFinishedListener = void Function( + ffi.Pointer self, + ffi.Pointer listener, + ffi.Pointer executor, +); + +typedef _c_Cronet_Engine_RemoveRequestFinishedListener = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer listener, +); + +typedef _dart_Cronet_Engine_RemoveRequestFinishedListener = void Function( + ffi.Pointer self, + ffi.Pointer listener, +); + +typedef Cronet_Engine_StartWithParamsFunc = ffi.Int32 Function( + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_Engine_StartNetLogToFileFunc = ffi.Uint8 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Uint8, +); + +typedef Cronet_Engine_StopNetLogFunc = ffi.Void Function( + ffi.Pointer, +); + +typedef Cronet_Engine_ShutdownFunc = ffi.Int32 Function( + ffi.Pointer, +); + +typedef Cronet_Engine_GetVersionStringFunc = ffi.Pointer Function( + ffi.Pointer, +); + +typedef Cronet_Engine_GetDefaultUserAgentFunc = ffi.Pointer Function( + ffi.Pointer, +); + +typedef Cronet_Engine_AddRequestFinishedListenerFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_Engine_RemoveRequestFinishedListenerFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, +); + +typedef _c_Cronet_Engine_CreateWith = ffi.Pointer Function( + ffi.Pointer> + StartWithParamsFunc, + ffi.Pointer> + StartNetLogToFileFunc, + ffi.Pointer> StopNetLogFunc, + ffi.Pointer> ShutdownFunc, + ffi.Pointer> + GetVersionStringFunc, + ffi.Pointer> + GetDefaultUserAgentFunc, + ffi.Pointer> + AddRequestFinishedListenerFunc, + ffi.Pointer< + ffi.NativeFunction> + RemoveRequestFinishedListenerFunc, +); + +typedef _dart_Cronet_Engine_CreateWith = ffi.Pointer Function( + ffi.Pointer> + StartWithParamsFunc, + ffi.Pointer> + StartNetLogToFileFunc, + ffi.Pointer> StopNetLogFunc, + ffi.Pointer> ShutdownFunc, + ffi.Pointer> + GetVersionStringFunc, + ffi.Pointer> + GetDefaultUserAgentFunc, + ffi.Pointer> + AddRequestFinishedListenerFunc, + ffi.Pointer< + ffi.NativeFunction> + RemoveRequestFinishedListenerFunc, +); + +typedef _c_Cronet_UrlRequestStatusListener_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequestStatusListener_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequestStatusListener_SetClientContext = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _dart_Cronet_UrlRequestStatusListener_SetClientContext = void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _c_Cronet_UrlRequestStatusListener_GetClientContext + = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequestStatusListener_GetClientContext + = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequestStatusListener_OnStatus = ffi.Void Function( + ffi.Pointer self, + ffi.Int32 status, +); + +typedef _dart_Cronet_UrlRequestStatusListener_OnStatus = void Function( + ffi.Pointer self, + int status, +); + +typedef Cronet_UrlRequestStatusListener_OnStatusFunc = ffi.Void Function( + ffi.Pointer, + ffi.Int32, +); + +typedef _c_Cronet_UrlRequestStatusListener_CreateWith + = ffi.Pointer Function( + ffi.Pointer> + OnStatusFunc, +); + +typedef _dart_Cronet_UrlRequestStatusListener_CreateWith + = ffi.Pointer Function( + ffi.Pointer> + OnStatusFunc, +); + +typedef _c_Cronet_UrlRequestCallback_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequestCallback_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequestCallback_SetClientContext = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _dart_Cronet_UrlRequestCallback_SetClientContext = void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _c_Cronet_UrlRequestCallback_GetClientContext = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequestCallback_GetClientContext = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequestCallback_OnRedirectReceived = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ffi.Pointer new_location_url, +); + +typedef _dart_Cronet_UrlRequestCallback_OnRedirectReceived = void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ffi.Pointer new_location_url, +); + +typedef _c_Cronet_UrlRequestCallback_OnResponseStarted = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, +); + +typedef _dart_Cronet_UrlRequestCallback_OnResponseStarted = void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, +); + +typedef _c_Cronet_UrlRequestCallback_OnReadCompleted = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ffi.Pointer buffer, + ffi.Uint64 bytes_read, +); + +typedef _dart_Cronet_UrlRequestCallback_OnReadCompleted = void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ffi.Pointer buffer, + int bytes_read, +); + +typedef _c_Cronet_UrlRequestCallback_OnSucceeded = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, +); + +typedef _dart_Cronet_UrlRequestCallback_OnSucceeded = void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, +); + +typedef _c_Cronet_UrlRequestCallback_OnFailed = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ffi.Pointer error, +); + +typedef _dart_Cronet_UrlRequestCallback_OnFailed = void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ffi.Pointer error, +); + +typedef _c_Cronet_UrlRequestCallback_OnCanceled = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, +); + +typedef _dart_Cronet_UrlRequestCallback_OnCanceled = void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, +); + +typedef Cronet_UrlRequestCallback_OnRedirectReceivedFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_UrlRequestCallback_OnResponseStartedFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_UrlRequestCallback_OnReadCompletedFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Uint64, +); + +typedef Cronet_UrlRequestCallback_OnSucceededFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_UrlRequestCallback_OnFailedFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_UrlRequestCallback_OnCanceledFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef Native_Cronet_UrlRequestCallback_CreateWith + = ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction> + OnRedirectReceivedFunc, + ffi.Pointer< + ffi.NativeFunction> + OnResponseStartedFunc, + ffi.Pointer> + OnReadCompletedFunc, + ffi.Pointer> + OnSucceededFunc, + ffi.Pointer> + OnFailedFunc, + ffi.Pointer> + OnCanceledFunc, +); + +typedef _dart_Cronet_UrlRequestCallback_CreateWith + = ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction> + OnRedirectReceivedFunc, + ffi.Pointer< + ffi.NativeFunction> + OnResponseStartedFunc, + ffi.Pointer> + OnReadCompletedFunc, + ffi.Pointer> + OnSucceededFunc, + ffi.Pointer> + OnFailedFunc, + ffi.Pointer> + OnCanceledFunc, +); + +typedef _c_Cronet_UploadDataSink_Create = ffi.Pointer + Function(); + +typedef _dart_Cronet_UploadDataSink_Create = ffi.Pointer + Function(); + +typedef _c_Cronet_UploadDataSink_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UploadDataSink_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UploadDataSink_SetClientContext = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _dart_Cronet_UploadDataSink_SetClientContext = void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _c_Cronet_UploadDataSink_GetClientContext = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UploadDataSink_GetClientContext = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UploadDataSink_OnReadSucceeded = ffi.Void Function( + ffi.Pointer self, + ffi.Uint64 bytes_read, + ffi.Uint8 final_chunk, +); + +typedef _dart_Cronet_UploadDataSink_OnReadSucceeded = void Function( + ffi.Pointer self, + int bytes_read, + int final_chunk, +); + +typedef _c_Cronet_UploadDataSink_OnReadError = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer error_message, +); + +typedef _dart_Cronet_UploadDataSink_OnReadError = void Function( + ffi.Pointer self, + ffi.Pointer error_message, +); + +typedef _c_Cronet_UploadDataSink_OnRewindSucceeded = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UploadDataSink_OnRewindSucceeded = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UploadDataSink_OnRewindError = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer error_message, +); + +typedef _dart_Cronet_UploadDataSink_OnRewindError = void Function( + ffi.Pointer self, + ffi.Pointer error_message, +); + +typedef Cronet_UploadDataSink_OnReadSucceededFunc = ffi.Void Function( + ffi.Pointer, + ffi.Uint64, + ffi.Uint8, +); + +typedef Cronet_UploadDataSink_OnReadErrorFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_UploadDataSink_OnRewindSucceededFunc = ffi.Void Function( + ffi.Pointer, +); + +typedef Cronet_UploadDataSink_OnRewindErrorFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, +); + +typedef _c_Cronet_UploadDataSink_CreateWith = ffi.Pointer + Function( + ffi.Pointer> + OnReadSucceededFunc, + ffi.Pointer> + OnReadErrorFunc, + ffi.Pointer> + OnRewindSucceededFunc, + ffi.Pointer> + OnRewindErrorFunc, +); + +typedef _dart_Cronet_UploadDataSink_CreateWith + = ffi.Pointer Function( + ffi.Pointer> + OnReadSucceededFunc, + ffi.Pointer> + OnReadErrorFunc, + ffi.Pointer> + OnRewindSucceededFunc, + ffi.Pointer> + OnRewindErrorFunc, +); + +typedef _c_Cronet_UploadDataProvider_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UploadDataProvider_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UploadDataProvider_SetClientContext = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _dart_Cronet_UploadDataProvider_SetClientContext = void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _c_Cronet_UploadDataProvider_GetClientContext = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UploadDataProvider_GetClientContext = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UploadDataProvider_GetLength = ffi.Int64 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UploadDataProvider_GetLength = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UploadDataProvider_Read = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer upload_data_sink, + ffi.Pointer buffer, +); + +typedef _dart_Cronet_UploadDataProvider_Read = void Function( + ffi.Pointer self, + ffi.Pointer upload_data_sink, + ffi.Pointer buffer, +); + +typedef _c_Cronet_UploadDataProvider_Rewind = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer upload_data_sink, +); + +typedef _dart_Cronet_UploadDataProvider_Rewind = void Function( + ffi.Pointer self, + ffi.Pointer upload_data_sink, +); + +typedef _c_Cronet_UploadDataProvider_Close = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UploadDataProvider_Close = void Function( + ffi.Pointer self, +); + +typedef Cronet_UploadDataProvider_GetLengthFunc = ffi.Int64 Function( + ffi.Pointer, +); + +typedef Cronet_UploadDataProvider_ReadFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_UploadDataProvider_RewindFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_UploadDataProvider_CloseFunc = ffi.Void Function( + ffi.Pointer, +); + +typedef _c_Cronet_UploadDataProvider_CreateWith + = ffi.Pointer Function( + ffi.Pointer> + GetLengthFunc, + ffi.Pointer> ReadFunc, + ffi.Pointer> + RewindFunc, + ffi.Pointer> + CloseFunc, +); + +typedef _dart_Cronet_UploadDataProvider_CreateWith + = ffi.Pointer Function( + ffi.Pointer> + GetLengthFunc, + ffi.Pointer> ReadFunc, + ffi.Pointer> + RewindFunc, + ffi.Pointer> + CloseFunc, +); + +typedef _c_Cronet_UrlRequest_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_UrlRequest_Create = ffi.Pointer + Function(); + +typedef _c_Cronet_UrlRequest_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequest_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequest_SetClientContext = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _dart_Cronet_UrlRequest_SetClientContext = void Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _c_Cronet_UrlRequest_GetClientContext = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequest_GetClientContext = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef Native_Cronet_UrlRequest_InitWithParams = ffi.Int32 Function( + ffi.Pointer self, + ffi.Pointer engine, + ffi.Pointer url, + ffi.Pointer params, + ffi.Pointer callback, + ffi.Pointer executor, +); + +typedef _dart_Cronet_UrlRequest_InitWithParams = int Function( + ffi.Pointer self, + ffi.Pointer engine, + ffi.Pointer url, + ffi.Pointer params, + ffi.Pointer callback, + ffi.Pointer executor, +); + +typedef _c_Cronet_UrlRequest_Start = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequest_Start = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequest_FollowRedirect = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequest_FollowRedirect = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequest_Read = ffi.Int32 Function( + ffi.Pointer self, + ffi.Pointer buffer, +); + +typedef _dart_Cronet_UrlRequest_Read = int Function( + ffi.Pointer self, + ffi.Pointer buffer, +); + +typedef _c_Cronet_UrlRequest_Cancel = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequest_Cancel = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequest_IsDone = ffi.Uint8 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequest_IsDone = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequest_GetStatus = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer listener, +); + +typedef _dart_Cronet_UrlRequest_GetStatus = void Function( + ffi.Pointer self, + ffi.Pointer listener, +); + +typedef Cronet_UrlRequest_InitWithParamsFunc = ffi.Int32 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_UrlRequest_StartFunc = ffi.Int32 Function( + ffi.Pointer, +); + +typedef Cronet_UrlRequest_FollowRedirectFunc = ffi.Int32 Function( + ffi.Pointer, +); + +typedef Cronet_UrlRequest_ReadFunc = ffi.Int32 Function( + ffi.Pointer, + ffi.Pointer, +); + +typedef Cronet_UrlRequest_CancelFunc = ffi.Void Function( + ffi.Pointer, +); + +typedef Cronet_UrlRequest_IsDoneFunc = ffi.Uint8 Function( + ffi.Pointer, +); + +typedef Cronet_UrlRequest_GetStatusFunc = ffi.Void Function( + ffi.Pointer, + ffi.Pointer, +); + +typedef _c_Cronet_UrlRequest_CreateWith = ffi.Pointer + Function( + ffi.Pointer> + InitWithParamsFunc, + ffi.Pointer> StartFunc, + ffi.Pointer> + FollowRedirectFunc, + ffi.Pointer> ReadFunc, + ffi.Pointer> CancelFunc, + ffi.Pointer> IsDoneFunc, + ffi.Pointer> + GetStatusFunc, +); + +typedef _dart_Cronet_UrlRequest_CreateWith = ffi.Pointer + Function( + ffi.Pointer> + InitWithParamsFunc, + ffi.Pointer> StartFunc, + ffi.Pointer> + FollowRedirectFunc, + ffi.Pointer> ReadFunc, + ffi.Pointer> CancelFunc, + ffi.Pointer> IsDoneFunc, + ffi.Pointer> + GetStatusFunc, +); + +typedef _c_Cronet_RequestFinishedInfoListener_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_RequestFinishedInfoListener_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_RequestFinishedInfoListener_SetClientContext = ffi.Void + Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _dart_Cronet_RequestFinishedInfoListener_SetClientContext = void + Function( + ffi.Pointer self, + ffi.Pointer client_context, +); + +typedef _c_Cronet_RequestFinishedInfoListener_GetClientContext + = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_RequestFinishedInfoListener_GetClientContext + = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_RequestFinishedInfoListener_OnRequestFinished = ffi.Void + Function( + ffi.Pointer self, + ffi.Pointer request_info, + ffi.Pointer response_info, + ffi.Pointer error, +); + +typedef _dart_Cronet_RequestFinishedInfoListener_OnRequestFinished = void + Function( + ffi.Pointer self, + ffi.Pointer request_info, + ffi.Pointer response_info, + ffi.Pointer error, +); + +typedef Cronet_RequestFinishedInfoListener_OnRequestFinishedFunc = ffi.Void + Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, +); + +typedef _c_Cronet_RequestFinishedInfoListener_CreateWith + = ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + Cronet_RequestFinishedInfoListener_OnRequestFinishedFunc>> + OnRequestFinishedFunc, +); + +typedef _dart_Cronet_RequestFinishedInfoListener_CreateWith + = ffi.Pointer Function( + ffi.Pointer< + ffi.NativeFunction< + Cronet_RequestFinishedInfoListener_OnRequestFinishedFunc>> + OnRequestFinishedFunc, +); + +typedef _c_Cronet_Error_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_Error_Create = ffi.Pointer Function(); + +typedef _c_Cronet_Error_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Error_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Error_error_code_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int32 error_code, +); + +typedef _dart_Cronet_Error_error_code_set = void Function( + ffi.Pointer self, + int error_code, +); + +typedef _c_Cronet_Error_message_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer message, +); + +typedef _dart_Cronet_Error_message_set = void Function( + ffi.Pointer self, + ffi.Pointer message, +); + +typedef _c_Cronet_Error_internal_error_code_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int32 internal_error_code, +); + +typedef _dart_Cronet_Error_internal_error_code_set = void Function( + ffi.Pointer self, + int internal_error_code, +); + +typedef _c_Cronet_Error_immediately_retryable_set = ffi.Void Function( + ffi.Pointer self, + ffi.Uint8 immediately_retryable, +); + +typedef _dart_Cronet_Error_immediately_retryable_set = void Function( + ffi.Pointer self, + int immediately_retryable, +); + +typedef _c_Cronet_Error_quic_detailed_error_code_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int32 quic_detailed_error_code, +); + +typedef _dart_Cronet_Error_quic_detailed_error_code_set = void Function( + ffi.Pointer self, + int quic_detailed_error_code, +); + +typedef _c_Cronet_Error_error_code_get = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Error_error_code_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Error_message_get = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Error_message_get = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Error_internal_error_code_get = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Error_internal_error_code_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Error_immediately_retryable_get = ffi.Uint8 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Error_immediately_retryable_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_Error_quic_detailed_error_code_get = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_Error_quic_detailed_error_code_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_QuicHint_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_QuicHint_Create = ffi.Pointer Function(); + +typedef _c_Cronet_QuicHint_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_QuicHint_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_QuicHint_host_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer host, +); + +typedef _dart_Cronet_QuicHint_host_set = void Function( + ffi.Pointer self, + ffi.Pointer host, +); + +typedef _c_Cronet_QuicHint_port_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int32 port, +); + +typedef _dart_Cronet_QuicHint_port_set = void Function( + ffi.Pointer self, + int port, +); + +typedef _c_Cronet_QuicHint_alternate_port_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int32 alternate_port, +); + +typedef _dart_Cronet_QuicHint_alternate_port_set = void Function( + ffi.Pointer self, + int alternate_port, +); + +typedef _c_Cronet_QuicHint_host_get = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_QuicHint_host_get = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_QuicHint_port_get = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_QuicHint_port_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_QuicHint_alternate_port_get = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_QuicHint_alternate_port_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_PublicKeyPins_Create = ffi.Pointer + Function(); + +typedef _dart_Cronet_PublicKeyPins_Create = ffi.Pointer + Function(); + +typedef _c_Cronet_PublicKeyPins_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_PublicKeyPins_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_PublicKeyPins_host_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer host, +); + +typedef _dart_Cronet_PublicKeyPins_host_set = void Function( + ffi.Pointer self, + ffi.Pointer host, +); + +typedef _c_Cronet_PublicKeyPins_pins_sha256_add = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _dart_Cronet_PublicKeyPins_pins_sha256_add = void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _c_Cronet_PublicKeyPins_include_subdomains_set = ffi.Void Function( + ffi.Pointer self, + ffi.Uint8 include_subdomains, +); + +typedef _dart_Cronet_PublicKeyPins_include_subdomains_set = void Function( + ffi.Pointer self, + int include_subdomains, +); + +typedef _c_Cronet_PublicKeyPins_expiration_date_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int64 expiration_date, +); + +typedef _dart_Cronet_PublicKeyPins_expiration_date_set = void Function( + ffi.Pointer self, + int expiration_date, +); + +typedef _c_Cronet_PublicKeyPins_host_get = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_PublicKeyPins_host_get = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_PublicKeyPins_pins_sha256_size = ffi.Uint32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_PublicKeyPins_pins_sha256_size = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_PublicKeyPins_pins_sha256_at = ffi.Pointer Function( + ffi.Pointer self, + ffi.Uint32 index, +); + +typedef _dart_Cronet_PublicKeyPins_pins_sha256_at = ffi.Pointer + Function( + ffi.Pointer self, + int index, +); + +typedef _c_Cronet_PublicKeyPins_pins_sha256_clear = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_PublicKeyPins_pins_sha256_clear = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_PublicKeyPins_include_subdomains_get = ffi.Uint8 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_PublicKeyPins_include_subdomains_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_PublicKeyPins_expiration_date_get = ffi.Int64 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_PublicKeyPins_expiration_date_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_Create = ffi.Pointer + Function(); + +typedef _dart_Cronet_EngineParams_Create = ffi.Pointer + Function(); + +typedef _c_Cronet_EngineParams_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_enable_check_result_set = ffi.Void Function( + ffi.Pointer self, + ffi.Uint8 enable_check_result, +); + +typedef _dart_Cronet_EngineParams_enable_check_result_set = void Function( + ffi.Pointer self, + int enable_check_result, +); + +typedef _c_Cronet_EngineParams_user_agent_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer user_agent, +); + +typedef _dart_Cronet_EngineParams_user_agent_set = void Function( + ffi.Pointer self, + ffi.Pointer user_agent, +); + +typedef _c_Cronet_EngineParams_accept_language_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer accept_language, +); + +typedef _dart_Cronet_EngineParams_accept_language_set = void Function( + ffi.Pointer self, + ffi.Pointer accept_language, +); + +typedef _c_Cronet_EngineParams_storage_path_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer storage_path, +); + +typedef _dart_Cronet_EngineParams_storage_path_set = void Function( + ffi.Pointer self, + ffi.Pointer storage_path, +); + +typedef _c_Cronet_EngineParams_enable_quic_set = ffi.Void Function( + ffi.Pointer self, + ffi.Uint8 enable_quic, +); + +typedef _dart_Cronet_EngineParams_enable_quic_set = void Function( + ffi.Pointer self, + int enable_quic, +); + +typedef _c_Cronet_EngineParams_enable_http2_set = ffi.Void Function( + ffi.Pointer self, + ffi.Uint8 enable_http2, +); + +typedef _dart_Cronet_EngineParams_enable_http2_set = void Function( + ffi.Pointer self, + int enable_http2, +); + +typedef _c_Cronet_EngineParams_enable_brotli_set = ffi.Void Function( + ffi.Pointer self, + ffi.Uint8 enable_brotli, +); + +typedef _dart_Cronet_EngineParams_enable_brotli_set = void Function( + ffi.Pointer self, + int enable_brotli, +); + +typedef _c_Cronet_EngineParams_http_cache_mode_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int32 http_cache_mode, +); + +typedef _dart_Cronet_EngineParams_http_cache_mode_set = void Function( + ffi.Pointer self, + int http_cache_mode, +); + +typedef _c_Cronet_EngineParams_http_cache_max_size_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int64 http_cache_max_size, +); + +typedef _dart_Cronet_EngineParams_http_cache_max_size_set = void Function( + ffi.Pointer self, + int http_cache_max_size, +); + +typedef _c_Cronet_EngineParams_quic_hints_add = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _dart_Cronet_EngineParams_quic_hints_add = void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _c_Cronet_EngineParams_public_key_pins_add = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _dart_Cronet_EngineParams_public_key_pins_add = void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _c_Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_set + = ffi.Void Function( + ffi.Pointer self, + ffi.Uint8 enable_public_key_pinning_bypass_for_local_trust_anchors, +); + +typedef _dart_Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_set + = void Function( + ffi.Pointer self, + int enable_public_key_pinning_bypass_for_local_trust_anchors, +); + +typedef _c_Cronet_EngineParams_network_thread_priority_set = ffi.Void Function( + ffi.Pointer self, + ffi.Double network_thread_priority, +); + +typedef _dart_Cronet_EngineParams_network_thread_priority_set = void Function( + ffi.Pointer self, + double network_thread_priority, +); + +typedef _c_Cronet_EngineParams_experimental_options_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer experimental_options, +); + +typedef _dart_Cronet_EngineParams_experimental_options_set = void Function( + ffi.Pointer self, + ffi.Pointer experimental_options, +); + +typedef _c_Cronet_EngineParams_enable_check_result_get = ffi.Uint8 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_enable_check_result_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_user_agent_get = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_user_agent_get = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_accept_language_get = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_accept_language_get = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_storage_path_get = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_storage_path_get = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_enable_quic_get = ffi.Uint8 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_enable_quic_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_enable_http2_get = ffi.Uint8 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_enable_http2_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_enable_brotli_get = ffi.Uint8 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_enable_brotli_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_http_cache_mode_get = ffi.Int32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_http_cache_mode_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_http_cache_max_size_get = ffi.Int64 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_http_cache_max_size_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_quic_hints_size = ffi.Uint32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_quic_hints_size = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_quic_hints_at = ffi.Pointer + Function( + ffi.Pointer self, + ffi.Uint32 index, +); + +typedef _dart_Cronet_EngineParams_quic_hints_at = ffi.Pointer + Function( + ffi.Pointer self, + int index, +); + +typedef _c_Cronet_EngineParams_quic_hints_clear = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_quic_hints_clear = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_public_key_pins_size = ffi.Uint32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_public_key_pins_size = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_public_key_pins_at + = ffi.Pointer Function( + ffi.Pointer self, + ffi.Uint32 index, +); + +typedef _dart_Cronet_EngineParams_public_key_pins_at + = ffi.Pointer Function( + ffi.Pointer self, + int index, +); + +typedef _c_Cronet_EngineParams_public_key_pins_clear = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_public_key_pins_clear = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_get + = ffi.Uint8 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_get + = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_network_thread_priority_get = ffi.Double + Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_network_thread_priority_get = double Function( + ffi.Pointer self, +); + +typedef _c_Cronet_EngineParams_experimental_options_get = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_EngineParams_experimental_options_get + = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_HttpHeader_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_HttpHeader_Create = ffi.Pointer + Function(); + +typedef _c_Cronet_HttpHeader_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_HttpHeader_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_HttpHeader_name_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer name, +); + +typedef _dart_Cronet_HttpHeader_name_set = void Function( + ffi.Pointer self, + ffi.Pointer name, +); + +typedef _c_Cronet_HttpHeader_value_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer value, +); + +typedef _dart_Cronet_HttpHeader_value_set = void Function( + ffi.Pointer self, + ffi.Pointer value, +); + +typedef _c_Cronet_HttpHeader_name_get = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_HttpHeader_name_get = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_HttpHeader_value_get = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_HttpHeader_value_get = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlResponseInfo_Create = ffi.Pointer + Function(); + +typedef _dart_Cronet_UrlResponseInfo_Create + = ffi.Pointer Function(); + +typedef _c_Cronet_UrlResponseInfo_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlResponseInfo_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlResponseInfo_url_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer url, +); + +typedef _dart_Cronet_UrlResponseInfo_url_set = void Function( + ffi.Pointer self, + ffi.Pointer url, +); + +typedef _c_Cronet_UrlResponseInfo_url_chain_add = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _dart_Cronet_UrlResponseInfo_url_chain_add = void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _c_Cronet_UrlResponseInfo_http_status_code_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int32 http_status_code, +); + +typedef _dart_Cronet_UrlResponseInfo_http_status_code_set = void Function( + ffi.Pointer self, + int http_status_code, +); + +typedef _c_Cronet_UrlResponseInfo_http_status_text_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer http_status_text, +); + +typedef _dart_Cronet_UrlResponseInfo_http_status_text_set = void Function( + ffi.Pointer self, + ffi.Pointer http_status_text, +); + +typedef _c_Cronet_UrlResponseInfo_all_headers_list_add = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _dart_Cronet_UrlResponseInfo_all_headers_list_add = void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _c_Cronet_UrlResponseInfo_was_cached_set = ffi.Void Function( + ffi.Pointer self, + ffi.Uint8 was_cached, +); + +typedef _dart_Cronet_UrlResponseInfo_was_cached_set = void Function( + ffi.Pointer self, + int was_cached, +); + +typedef _c_Cronet_UrlResponseInfo_negotiated_protocol_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer negotiated_protocol, +); + +typedef _dart_Cronet_UrlResponseInfo_negotiated_protocol_set = void Function( + ffi.Pointer self, + ffi.Pointer negotiated_protocol, +); + +typedef _c_Cronet_UrlResponseInfo_proxy_server_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer proxy_server, +); + +typedef _dart_Cronet_UrlResponseInfo_proxy_server_set = void Function( + ffi.Pointer self, + ffi.Pointer proxy_server, +); + +typedef _c_Cronet_UrlResponseInfo_received_byte_count_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int64 received_byte_count, +); + +typedef _dart_Cronet_UrlResponseInfo_received_byte_count_set = void Function( + ffi.Pointer self, + int received_byte_count, +); + +typedef _c_Cronet_UrlResponseInfo_url_get = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlResponseInfo_url_get = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlResponseInfo_url_chain_size = ffi.Uint32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlResponseInfo_url_chain_size = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlResponseInfo_url_chain_at = ffi.Pointer Function( + ffi.Pointer self, + ffi.Uint32 index, +); + +typedef _dart_Cronet_UrlResponseInfo_url_chain_at = ffi.Pointer + Function( + ffi.Pointer self, + int index, +); -class Cronet_Error extends ffi.Opaque {} +typedef _c_Cronet_UrlResponseInfo_url_chain_clear = ffi.Void Function( + ffi.Pointer self, +); -class Cronet_QuicHint extends ffi.Opaque {} +typedef _dart_Cronet_UrlResponseInfo_url_chain_clear = void Function( + ffi.Pointer self, +); -class Cronet_PublicKeyPins extends ffi.Opaque {} +typedef _c_Cronet_UrlResponseInfo_http_status_code_get = ffi.Int32 Function( + ffi.Pointer self, +); -class Cronet_EngineParams extends ffi.Opaque {} +typedef _dart_Cronet_UrlResponseInfo_http_status_code_get = int Function( + ffi.Pointer self, +); -class Cronet_HttpHeader extends ffi.Opaque {} +typedef _c_Cronet_UrlResponseInfo_http_status_text_get = ffi.Pointer + Function( + ffi.Pointer self, +); -class Cronet_UrlResponseInfo extends ffi.Opaque {} +typedef _dart_Cronet_UrlResponseInfo_http_status_text_get + = ffi.Pointer Function( + ffi.Pointer self, +); -class Cronet_UrlRequestParams extends ffi.Opaque {} +typedef _c_Cronet_UrlResponseInfo_all_headers_list_size = ffi.Uint32 Function( + ffi.Pointer self, +); -class Cronet_DateTime extends ffi.Opaque {} +typedef _dart_Cronet_UrlResponseInfo_all_headers_list_size = int Function( + ffi.Pointer self, +); -class Cronet_Metrics extends ffi.Opaque {} +typedef _c_Cronet_UrlResponseInfo_all_headers_list_at + = ffi.Pointer Function( + ffi.Pointer self, + ffi.Uint32 index, +); -class Cronet_RequestFinishedInfo extends ffi.Opaque {} +typedef _dart_Cronet_UrlResponseInfo_all_headers_list_at + = ffi.Pointer Function( + ffi.Pointer self, + int index, +); -abstract class Cronet_RESULT { - static const int Cronet_RESULT_SUCCESS = 0; - static const int Cronet_RESULT_ILLEGAL_ARGUMENT = -100; - static const int Cronet_RESULT_ILLEGAL_ARGUMENT_STORAGE_PATH_MUST_EXIST = - -101; - static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_PIN = -102; - static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HOSTNAME = -103; - static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HTTP_METHOD = -104; - static const int Cronet_RESULT_ILLEGAL_ARGUMENT_INVALID_HTTP_HEADER = -105; - static const int Cronet_RESULT_ILLEGAL_STATE = -200; - static const int Cronet_RESULT_ILLEGAL_STATE_STORAGE_PATH_IN_USE = -201; - static const int - Cronet_RESULT_ILLEGAL_STATE_CANNOT_SHUTDOWN_ENGINE_FROM_NETWORK_THREAD = - -202; - static const int Cronet_RESULT_ILLEGAL_STATE_ENGINE_ALREADY_STARTED = -203; - static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_ALREADY_STARTED = -204; - static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_NOT_INITIALIZED = -205; - static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_ALREADY_INITIALIZED = - -206; - static const int Cronet_RESULT_ILLEGAL_STATE_REQUEST_NOT_STARTED = -207; - static const int Cronet_RESULT_ILLEGAL_STATE_UNEXPECTED_REDIRECT = -208; - static const int Cronet_RESULT_ILLEGAL_STATE_UNEXPECTED_READ = -209; - static const int Cronet_RESULT_ILLEGAL_STATE_READ_FAILED = -210; - static const int Cronet_RESULT_NULL_POINTER = -300; - static const int Cronet_RESULT_NULL_POINTER_HOSTNAME = -301; - static const int Cronet_RESULT_NULL_POINTER_SHA256_PINS = -302; - static const int Cronet_RESULT_NULL_POINTER_EXPIRATION_DATE = -303; - static const int Cronet_RESULT_NULL_POINTER_ENGINE = -304; - static const int Cronet_RESULT_NULL_POINTER_URL = -305; - static const int Cronet_RESULT_NULL_POINTER_CALLBACK = -306; - static const int Cronet_RESULT_NULL_POINTER_EXECUTOR = -307; - static const int Cronet_RESULT_NULL_POINTER_METHOD = -308; - static const int Cronet_RESULT_NULL_POINTER_HEADER_NAME = -309; - static const int Cronet_RESULT_NULL_POINTER_HEADER_VALUE = -310; - static const int Cronet_RESULT_NULL_POINTER_PARAMS = -311; - static const int - Cronet_RESULT_NULL_POINTER_REQUEST_FINISHED_INFO_LISTENER_EXECUTOR = -312; -} +typedef _c_Cronet_UrlResponseInfo_all_headers_list_clear = ffi.Void Function( + ffi.Pointer self, +); -abstract class Cronet_Error_ERROR_CODE { - static const int Cronet_Error_ERROR_CODE_ERROR_CALLBACK = 0; - static const int Cronet_Error_ERROR_CODE_ERROR_HOSTNAME_NOT_RESOLVED = 1; - static const int Cronet_Error_ERROR_CODE_ERROR_INTERNET_DISCONNECTED = 2; - static const int Cronet_Error_ERROR_CODE_ERROR_NETWORK_CHANGED = 3; - static const int Cronet_Error_ERROR_CODE_ERROR_TIMED_OUT = 4; - static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_CLOSED = 5; - static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_TIMED_OUT = 6; - static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_REFUSED = 7; - static const int Cronet_Error_ERROR_CODE_ERROR_CONNECTION_RESET = 8; - static const int Cronet_Error_ERROR_CODE_ERROR_ADDRESS_UNREACHABLE = 9; - static const int Cronet_Error_ERROR_CODE_ERROR_QUIC_PROTOCOL_FAILED = 10; - static const int Cronet_Error_ERROR_CODE_ERROR_OTHER = 11; -} +typedef _dart_Cronet_UrlResponseInfo_all_headers_list_clear = void Function( + ffi.Pointer self, +); -abstract class Cronet_EngineParams_HTTP_CACHE_MODE { - static const int Cronet_EngineParams_HTTP_CACHE_MODE_DISABLED = 0; - static const int Cronet_EngineParams_HTTP_CACHE_MODE_IN_MEMORY = 1; - static const int Cronet_EngineParams_HTTP_CACHE_MODE_DISK_NO_HTTP = 2; - static const int Cronet_EngineParams_HTTP_CACHE_MODE_DISK = 3; -} +typedef _c_Cronet_UrlResponseInfo_was_cached_get = ffi.Uint8 Function( + ffi.Pointer self, +); -abstract class Cronet_UrlRequestParams_REQUEST_PRIORITY { - static const int - Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_IDLE = 0; - static const int - Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_LOWEST = 1; - static const int - Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_LOW = 2; - static const int - Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_MEDIUM = 3; - static const int - Cronet_UrlRequestParams_REQUEST_PRIORITY_REQUEST_PRIORITY_HIGHEST = 4; -} +typedef _dart_Cronet_UrlResponseInfo_was_cached_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlResponseInfo_negotiated_protocol_get + = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlResponseInfo_negotiated_protocol_get + = ffi.Pointer Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlResponseInfo_proxy_server_get = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlResponseInfo_proxy_server_get = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlResponseInfo_received_byte_count_get = ffi.Int64 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlResponseInfo_received_byte_count_get = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequestParams_Create = ffi.Pointer + Function(); + +typedef _dart_Cronet_UrlRequestParams_Create + = ffi.Pointer Function(); + +typedef _c_Cronet_UrlRequestParams_Destroy = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequestParams_Destroy = void Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequestParams_http_method_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer http_method, +); + +typedef _dart_Cronet_UrlRequestParams_http_method_set = void Function( + ffi.Pointer self, + ffi.Pointer http_method, +); + +typedef _c_Cronet_UrlRequestParams_request_headers_add = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _dart_Cronet_UrlRequestParams_request_headers_add = void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _c_Cronet_UrlRequestParams_disable_cache_set = ffi.Void Function( + ffi.Pointer self, + ffi.Uint8 disable_cache, +); + +typedef _dart_Cronet_UrlRequestParams_disable_cache_set = void Function( + ffi.Pointer self, + int disable_cache, +); + +typedef _c_Cronet_UrlRequestParams_priority_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int32 priority, +); + +typedef _dart_Cronet_UrlRequestParams_priority_set = void Function( + ffi.Pointer self, + int priority, +); + +typedef _c_Cronet_UrlRequestParams_upload_data_provider_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer upload_data_provider, +); + +typedef _dart_Cronet_UrlRequestParams_upload_data_provider_set = void Function( + ffi.Pointer self, + ffi.Pointer upload_data_provider, +); + +typedef _c_Cronet_UrlRequestParams_upload_data_provider_executor_set = ffi.Void + Function( + ffi.Pointer self, + ffi.Pointer upload_data_provider_executor, +); + +typedef _dart_Cronet_UrlRequestParams_upload_data_provider_executor_set = void + Function( + ffi.Pointer self, + ffi.Pointer upload_data_provider_executor, +); + +typedef _c_Cronet_UrlRequestParams_allow_direct_executor_set = ffi.Void + Function( + ffi.Pointer self, + ffi.Uint8 allow_direct_executor, +); + +typedef _dart_Cronet_UrlRequestParams_allow_direct_executor_set = void Function( + ffi.Pointer self, + int allow_direct_executor, +); + +typedef _c_Cronet_UrlRequestParams_annotations_add = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _dart_Cronet_UrlRequestParams_annotations_add = void Function( + ffi.Pointer self, + ffi.Pointer element, +); + +typedef _c_Cronet_UrlRequestParams_request_finished_listener_set = ffi.Void + Function( + ffi.Pointer self, + ffi.Pointer request_finished_listener, +); + +typedef _dart_Cronet_UrlRequestParams_request_finished_listener_set = void + Function( + ffi.Pointer self, + ffi.Pointer request_finished_listener, +); + +typedef _c_Cronet_UrlRequestParams_request_finished_executor_set = ffi.Void + Function( + ffi.Pointer self, + ffi.Pointer request_finished_executor, +); + +typedef _dart_Cronet_UrlRequestParams_request_finished_executor_set = void + Function( + ffi.Pointer self, + ffi.Pointer request_finished_executor, +); + +typedef _c_Cronet_UrlRequestParams_idempotency_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int32 idempotency, +); + +typedef _dart_Cronet_UrlRequestParams_idempotency_set = void Function( + ffi.Pointer self, + int idempotency, +); + +typedef _c_Cronet_UrlRequestParams_http_method_get = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequestParams_http_method_get = ffi.Pointer + Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequestParams_request_headers_size = ffi.Uint32 Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequestParams_request_headers_size = int Function( + ffi.Pointer self, +); + +typedef _c_Cronet_UrlRequestParams_request_headers_at + = ffi.Pointer Function( + ffi.Pointer self, + ffi.Uint32 index, +); + +typedef _dart_Cronet_UrlRequestParams_request_headers_at + = ffi.Pointer Function( + ffi.Pointer self, + int index, +); + +typedef _c_Cronet_UrlRequestParams_request_headers_clear = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_Cronet_UrlRequestParams_request_headers_clear = void Function( + ffi.Pointer self, +); -abstract class Cronet_UrlRequestParams_IDEMPOTENCY { - static const int Cronet_UrlRequestParams_IDEMPOTENCY_DEFAULT_IDEMPOTENCY = 0; - static const int Cronet_UrlRequestParams_IDEMPOTENCY_IDEMPOTENT = 1; - static const int Cronet_UrlRequestParams_IDEMPOTENCY_NOT_IDEMPOTENT = 2; -} +typedef _c_Cronet_UrlRequestParams_disable_cache_get = ffi.Uint8 Function( + ffi.Pointer self, +); -abstract class Cronet_RequestFinishedInfo_FINISHED_REASON { - static const int Cronet_RequestFinishedInfo_FINISHED_REASON_SUCCEEDED = 0; - static const int Cronet_RequestFinishedInfo_FINISHED_REASON_FAILED = 1; - static const int Cronet_RequestFinishedInfo_FINISHED_REASON_CANCELED = 2; -} +typedef _dart_Cronet_UrlRequestParams_disable_cache_get = int Function( + ffi.Pointer self, +); -abstract class Cronet_UrlRequestStatusListener_Status { - static const int Cronet_UrlRequestStatusListener_Status_INVALID = -1; - static const int Cronet_UrlRequestStatusListener_Status_IDLE = 0; - static const int - Cronet_UrlRequestStatusListener_Status_WAITING_FOR_STALLED_SOCKET_POOL = - 1; - static const int - Cronet_UrlRequestStatusListener_Status_WAITING_FOR_AVAILABLE_SOCKET = 2; - static const int Cronet_UrlRequestStatusListener_Status_WAITING_FOR_DELEGATE = - 3; - static const int Cronet_UrlRequestStatusListener_Status_WAITING_FOR_CACHE = 4; - static const int Cronet_UrlRequestStatusListener_Status_DOWNLOADING_PAC_FILE = - 5; - static const int - Cronet_UrlRequestStatusListener_Status_RESOLVING_PROXY_FOR_URL = 6; - static const int - Cronet_UrlRequestStatusListener_Status_RESOLVING_HOST_IN_PAC_FILE = 7; - static const int - Cronet_UrlRequestStatusListener_Status_ESTABLISHING_PROXY_TUNNEL = 8; - static const int Cronet_UrlRequestStatusListener_Status_RESOLVING_HOST = 9; - static const int Cronet_UrlRequestStatusListener_Status_CONNECTING = 10; - static const int Cronet_UrlRequestStatusListener_Status_SSL_HANDSHAKE = 11; - static const int Cronet_UrlRequestStatusListener_Status_SENDING_REQUEST = 12; - static const int Cronet_UrlRequestStatusListener_Status_WAITING_FOR_RESPONSE = - 13; - static const int Cronet_UrlRequestStatusListener_Status_READING_RESPONSE = 14; -} +typedef _c_Cronet_UrlRequestParams_priority_get = ffi.Int32 Function( + ffi.Pointer self, +); -typedef Native_Cronet_Buffer_Create = ffi.Pointer Function(); +typedef _dart_Cronet_UrlRequestParams_priority_get = int Function( + ffi.Pointer self, +); -typedef _dart_Cronet_Buffer_Create = ffi.Pointer Function(); +typedef _c_Cronet_UrlRequestParams_upload_data_provider_get + = ffi.Pointer Function( + ffi.Pointer self, +); -typedef Native_Cronet_Buffer_InitWithAlloc = ffi.Void Function( - ffi.Pointer self, - ffi.Uint64 size, +typedef _dart_Cronet_UrlRequestParams_upload_data_provider_get + = ffi.Pointer Function( + ffi.Pointer self, ); -typedef _dart_Cronet_Buffer_InitWithAlloc = void Function( - ffi.Pointer self, - int size, +typedef _c_Cronet_UrlRequestParams_upload_data_provider_executor_get + = ffi.Pointer Function( + ffi.Pointer self, ); -typedef _c_Cronet_Buffer_GetSize = ffi.Uint64 Function( - ffi.Pointer self, +typedef _dart_Cronet_UrlRequestParams_upload_data_provider_executor_get + = ffi.Pointer Function( + ffi.Pointer self, ); -typedef _dart_Cronet_Buffer_GetSize = int Function( - ffi.Pointer self, +typedef _c_Cronet_UrlRequestParams_allow_direct_executor_get = ffi.Uint8 + Function( + ffi.Pointer self, ); -typedef _c_Cronet_Buffer_GetData = ffi.Pointer Function( - ffi.Pointer self, +typedef _dart_Cronet_UrlRequestParams_allow_direct_executor_get = int Function( + ffi.Pointer self, ); -typedef _dart_Cronet_Buffer_GetData = ffi.Pointer Function( - ffi.Pointer self, +typedef _c_Cronet_UrlRequestParams_annotations_size = ffi.Uint32 Function( + ffi.Pointer self, ); -typedef Native_Cronet_Runnable_Destroy = ffi.Void Function( - ffi.Pointer self, +typedef _dart_Cronet_UrlRequestParams_annotations_size = int Function( + ffi.Pointer self, ); -typedef _dart_Cronet_Runnable_Destroy = void Function( - ffi.Pointer self, +typedef _c_Cronet_UrlRequestParams_annotations_at = ffi.Pointer + Function( + ffi.Pointer self, + ffi.Uint32 index, ); -typedef Native_Cronet_Runnable_Run = ffi.Void Function( - ffi.Pointer self, +typedef _dart_Cronet_UrlRequestParams_annotations_at = ffi.Pointer + Function( + ffi.Pointer self, + int index, ); -typedef _dart_Cronet_Runnable_Run = void Function( - ffi.Pointer self, +typedef _c_Cronet_UrlRequestParams_annotations_clear = ffi.Void Function( + ffi.Pointer self, ); -typedef Native_Cronet_Executor_Destroy = ffi.Void Function( - ffi.Pointer self, +typedef _dart_Cronet_UrlRequestParams_annotations_clear = void Function( + ffi.Pointer self, ); -typedef _dart_Cronet_Executor_Destroy = void Function( - ffi.Pointer self, +typedef _c_Cronet_UrlRequestParams_request_finished_listener_get + = ffi.Pointer Function( + ffi.Pointer self, ); -typedef Native_Cronet_Executor_SetClientContext = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer client_context, +typedef _dart_Cronet_UrlRequestParams_request_finished_listener_get + = ffi.Pointer Function( + ffi.Pointer self, ); -typedef _dart_Cronet_Executor_SetClientContext = void Function( - ffi.Pointer self, - ffi.Pointer client_context, +typedef _c_Cronet_UrlRequestParams_request_finished_executor_get + = ffi.Pointer Function( + ffi.Pointer self, ); -typedef Native_Cronet_Executor_GetClientContext = ffi.Pointer - Function( - ffi.Pointer self, +typedef _dart_Cronet_UrlRequestParams_request_finished_executor_get + = ffi.Pointer Function( + ffi.Pointer self, ); -typedef _dart_Cronet_Executor_GetClientContext = ffi.Pointer Function( - ffi.Pointer self, +typedef _c_Cronet_UrlRequestParams_idempotency_get = ffi.Int32 Function( + ffi.Pointer self, ); -typedef _c_Cronet_Executor_Execute = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer command, +typedef _dart_Cronet_UrlRequestParams_idempotency_get = int Function( + ffi.Pointer self, ); -typedef _dart_Cronet_Executor_Execute = void Function( - ffi.Pointer self, - ffi.Pointer command, +typedef _c_Cronet_DateTime_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_DateTime_Create = ffi.Pointer Function(); + +typedef _c_Cronet_DateTime_Destroy = ffi.Void Function( + ffi.Pointer self, ); -typedef Cronet_Executor_ExecuteFunc = ffi.Void Function( - ffi.Pointer, - ffi.Pointer, +typedef _dart_Cronet_DateTime_Destroy = void Function( + ffi.Pointer self, ); -typedef Native_Cronet_Executor_CreateWith = ffi.Pointer - Function( - ffi.Pointer> ExecuteFunc, +typedef _c_Cronet_DateTime_value_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int64 value, ); -typedef _dart_Cronet_Executor_CreateWith = ffi.Pointer - Function( - ffi.Pointer> ExecuteFunc, +typedef _dart_Cronet_DateTime_value_set = void Function( + ffi.Pointer self, + int value, ); -typedef _c_Cronet_Engine_Create = ffi.Pointer Function(); +typedef _c_Cronet_DateTime_value_get = ffi.Int64 Function( + ffi.Pointer self, +); -typedef _dart_Cronet_Engine_Create = ffi.Pointer Function(); +typedef _dart_Cronet_DateTime_value_get = int Function( + ffi.Pointer self, +); -typedef Native_Cronet_Engine_Destroy = ffi.Void Function( - ffi.Pointer self, +typedef _c_Cronet_Metrics_Create = ffi.Pointer Function(); + +typedef _dart_Cronet_Metrics_Create = ffi.Pointer Function(); + +typedef _c_Cronet_Metrics_Destroy = ffi.Void Function( + ffi.Pointer self, ); -typedef _dart_Cronet_Engine_Destroy = void Function( - ffi.Pointer self, +typedef _dart_Cronet_Metrics_Destroy = void Function( + ffi.Pointer self, ); -typedef _c_Cronet_Engine_StartWithParams = ffi.Int32 Function( - ffi.Pointer self, - ffi.Pointer params, +typedef _c_Cronet_Metrics_request_start_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer request_start, ); -typedef _dart_Cronet_Engine_StartWithParams = int Function( - ffi.Pointer self, - ffi.Pointer params, +typedef _dart_Cronet_Metrics_request_start_set = void Function( + ffi.Pointer self, + ffi.Pointer request_start, ); -typedef _c_Cronet_Engine_StartNetLogToFile = ffi.Uint8 Function( - ffi.Pointer self, - ffi.Pointer file_name, - ffi.Uint8 log_all, +typedef _c_Cronet_Metrics_request_start_move = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer request_start, ); -typedef _dart_Cronet_Engine_StartNetLogToFile = int Function( - ffi.Pointer self, - ffi.Pointer file_name, - int log_all, +typedef _dart_Cronet_Metrics_request_start_move = void Function( + ffi.Pointer self, + ffi.Pointer request_start, ); -typedef _c_Cronet_Engine_StopNetLog = ffi.Void Function( - ffi.Pointer self, +typedef _c_Cronet_Metrics_dns_start_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer dns_start, ); -typedef _dart_Cronet_Engine_StopNetLog = void Function( - ffi.Pointer self, +typedef _dart_Cronet_Metrics_dns_start_set = void Function( + ffi.Pointer self, + ffi.Pointer dns_start, ); -typedef Native_Cronet_Engine_Shutdown = ffi.Int32 Function( - ffi.Pointer self, +typedef _c_Cronet_Metrics_dns_start_move = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer dns_start, ); -typedef _dart_Cronet_Engine_Shutdown = int Function( - ffi.Pointer self, +typedef _dart_Cronet_Metrics_dns_start_move = void Function( + ffi.Pointer self, + ffi.Pointer dns_start, ); -typedef _c_Cronet_Engine_GetVersionString = ffi.Pointer Function( - ffi.Pointer self, +typedef _c_Cronet_Metrics_dns_end_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer dns_end, ); -typedef _dart_Cronet_Engine_GetVersionString = ffi.Pointer Function( - ffi.Pointer self, +typedef _dart_Cronet_Metrics_dns_end_set = void Function( + ffi.Pointer self, + ffi.Pointer dns_end, ); -typedef Cronet_UrlRequestCallback_OnRedirectReceivedFunc = ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, +typedef _c_Cronet_Metrics_dns_end_move = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer dns_end, ); -typedef Cronet_UrlRequestCallback_OnResponseStartedFunc = ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, +typedef _dart_Cronet_Metrics_dns_end_move = void Function( + ffi.Pointer self, + ffi.Pointer dns_end, ); -typedef Cronet_UrlRequestCallback_OnReadCompletedFunc = ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Uint64, +typedef _c_Cronet_Metrics_connect_start_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer connect_start, ); -typedef Cronet_UrlRequestCallback_OnSucceededFunc = ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, +typedef _dart_Cronet_Metrics_connect_start_set = void Function( + ffi.Pointer self, + ffi.Pointer connect_start, ); -typedef Cronet_UrlRequestCallback_OnFailedFunc = ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, +typedef _c_Cronet_Metrics_connect_start_move = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer connect_start, ); -typedef Cronet_UrlRequestCallback_OnCanceledFunc = ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, +typedef _dart_Cronet_Metrics_connect_start_move = void Function( + ffi.Pointer self, + ffi.Pointer connect_start, ); -typedef Native_Cronet_UrlRequestCallback_CreateWith - = ffi.Pointer Function( - ffi.Pointer< - ffi.NativeFunction> - OnRedirectReceivedFunc, - ffi.Pointer< - ffi.NativeFunction> - OnResponseStartedFunc, - ffi.Pointer> - OnReadCompletedFunc, - ffi.Pointer> - OnSucceededFunc, - ffi.Pointer> - OnFailedFunc, - ffi.Pointer> - OnCanceledFunc, +typedef _c_Cronet_Metrics_connect_end_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer connect_end, ); -typedef _dart_Cronet_UrlRequestCallback_CreateWith - = ffi.Pointer Function( - ffi.Pointer< - ffi.NativeFunction> - OnRedirectReceivedFunc, - ffi.Pointer< - ffi.NativeFunction> - OnResponseStartedFunc, - ffi.Pointer> - OnReadCompletedFunc, - ffi.Pointer> - OnSucceededFunc, - ffi.Pointer> - OnFailedFunc, - ffi.Pointer> - OnCanceledFunc, +typedef _dart_Cronet_Metrics_connect_end_set = void Function( + ffi.Pointer self, + ffi.Pointer connect_end, ); -typedef _c_Cronet_UrlRequest_Create = ffi.Pointer Function(); +typedef _c_Cronet_Metrics_connect_end_move = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer connect_end, +); -typedef _dart_Cronet_UrlRequest_Create = ffi.Pointer - Function(); +typedef _dart_Cronet_Metrics_connect_end_move = void Function( + ffi.Pointer self, + ffi.Pointer connect_end, +); -typedef _c_Cronet_UrlRequest_Destroy = ffi.Void Function( - ffi.Pointer self, +typedef _c_Cronet_Metrics_ssl_start_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer ssl_start, ); -typedef _dart_Cronet_UrlRequest_Destroy = void Function( - ffi.Pointer self, +typedef _dart_Cronet_Metrics_ssl_start_set = void Function( + ffi.Pointer self, + ffi.Pointer ssl_start, ); -typedef _c_Cronet_UrlRequest_SetClientContext = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer client_context, +typedef _c_Cronet_Metrics_ssl_start_move = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer ssl_start, ); -typedef _dart_Cronet_UrlRequest_SetClientContext = void Function( - ffi.Pointer self, - ffi.Pointer client_context, +typedef _dart_Cronet_Metrics_ssl_start_move = void Function( + ffi.Pointer self, + ffi.Pointer ssl_start, ); -typedef _c_Cronet_UrlRequest_GetClientContext = ffi.Pointer Function( - ffi.Pointer self, +typedef _c_Cronet_Metrics_ssl_end_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer ssl_end, ); -typedef _dart_Cronet_UrlRequest_GetClientContext = ffi.Pointer - Function( - ffi.Pointer self, +typedef _dart_Cronet_Metrics_ssl_end_set = void Function( + ffi.Pointer self, + ffi.Pointer ssl_end, ); -typedef Native_Cronet_UrlRequest_InitWithParams = ffi.Int32 Function( - ffi.Pointer self, - ffi.Pointer engine, - ffi.Pointer url, - ffi.Pointer params, - ffi.Pointer callback, - ffi.Pointer executor, +typedef _c_Cronet_Metrics_ssl_end_move = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer ssl_end, +); + +typedef _dart_Cronet_Metrics_ssl_end_move = void Function( + ffi.Pointer self, + ffi.Pointer ssl_end, +); + +typedef _c_Cronet_Metrics_sending_start_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer sending_start, +); + +typedef _dart_Cronet_Metrics_sending_start_set = void Function( + ffi.Pointer self, + ffi.Pointer sending_start, +); + +typedef _c_Cronet_Metrics_sending_start_move = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer sending_start, +); + +typedef _dart_Cronet_Metrics_sending_start_move = void Function( + ffi.Pointer self, + ffi.Pointer sending_start, ); -typedef _dart_Cronet_UrlRequest_InitWithParams = int Function( - ffi.Pointer self, - ffi.Pointer engine, - ffi.Pointer url, - ffi.Pointer params, - ffi.Pointer callback, - ffi.Pointer executor, +typedef _c_Cronet_Metrics_sending_end_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer sending_end, ); -typedef _c_Cronet_UrlRequest_Start = ffi.Int32 Function( - ffi.Pointer self, +typedef _dart_Cronet_Metrics_sending_end_set = void Function( + ffi.Pointer self, + ffi.Pointer sending_end, ); -typedef _dart_Cronet_UrlRequest_Start = int Function( - ffi.Pointer self, +typedef _c_Cronet_Metrics_sending_end_move = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer sending_end, ); -typedef _c_Cronet_UrlRequest_FollowRedirect = ffi.Int32 Function( - ffi.Pointer self, +typedef _dart_Cronet_Metrics_sending_end_move = void Function( + ffi.Pointer self, + ffi.Pointer sending_end, ); -typedef _dart_Cronet_UrlRequest_FollowRedirect = int Function( - ffi.Pointer self, +typedef _c_Cronet_Metrics_push_start_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer push_start, ); -typedef _c_Cronet_UrlRequest_Read = ffi.Int32 Function( - ffi.Pointer self, - ffi.Pointer buffer, +typedef _dart_Cronet_Metrics_push_start_set = void Function( + ffi.Pointer self, + ffi.Pointer push_start, ); -typedef _dart_Cronet_UrlRequest_Read = int Function( - ffi.Pointer self, - ffi.Pointer buffer, +typedef _c_Cronet_Metrics_push_start_move = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer push_start, ); -typedef _c_Cronet_UrlRequest_Cancel = ffi.Void Function( - ffi.Pointer self, +typedef _dart_Cronet_Metrics_push_start_move = void Function( + ffi.Pointer self, + ffi.Pointer push_start, ); -typedef _dart_Cronet_UrlRequest_Cancel = void Function( - ffi.Pointer self, +typedef _c_Cronet_Metrics_push_end_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer push_end, ); -typedef Cronet_UrlRequest_InitWithParamsFunc = ffi.Int32 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, +typedef _dart_Cronet_Metrics_push_end_set = void Function( + ffi.Pointer self, + ffi.Pointer push_end, ); -typedef Cronet_UrlRequest_StartFunc = ffi.Int32 Function( - ffi.Pointer, +typedef _c_Cronet_Metrics_push_end_move = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer push_end, ); -typedef Cronet_UrlRequest_FollowRedirectFunc = ffi.Int32 Function( - ffi.Pointer, +typedef _dart_Cronet_Metrics_push_end_move = void Function( + ffi.Pointer self, + ffi.Pointer push_end, ); -typedef Cronet_UrlRequest_ReadFunc = ffi.Int32 Function( - ffi.Pointer, - ffi.Pointer, +typedef _c_Cronet_Metrics_response_start_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer response_start, ); -typedef Cronet_UrlRequest_CancelFunc = ffi.Void Function( - ffi.Pointer, +typedef _dart_Cronet_Metrics_response_start_set = void Function( + ffi.Pointer self, + ffi.Pointer response_start, ); -typedef Cronet_UrlRequest_IsDoneFunc = ffi.Uint8 Function( - ffi.Pointer, +typedef _c_Cronet_Metrics_response_start_move = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer response_start, ); -typedef Cronet_UrlRequest_GetStatusFunc = ffi.Void Function( - ffi.Pointer, - ffi.Pointer, +typedef _dart_Cronet_Metrics_response_start_move = void Function( + ffi.Pointer self, + ffi.Pointer response_start, ); -typedef _c_Cronet_UrlRequest_CreateWith = ffi.Pointer - Function( - ffi.Pointer> - InitWithParamsFunc, - ffi.Pointer> StartFunc, - ffi.Pointer> - FollowRedirectFunc, - ffi.Pointer> ReadFunc, - ffi.Pointer> CancelFunc, - ffi.Pointer> IsDoneFunc, - ffi.Pointer> - GetStatusFunc, +typedef _c_Cronet_Metrics_request_end_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer request_end, ); -typedef _dart_Cronet_UrlRequest_CreateWith = ffi.Pointer - Function( - ffi.Pointer> - InitWithParamsFunc, - ffi.Pointer> StartFunc, - ffi.Pointer> - FollowRedirectFunc, - ffi.Pointer> ReadFunc, - ffi.Pointer> CancelFunc, - ffi.Pointer> IsDoneFunc, - ffi.Pointer> - GetStatusFunc, +typedef _dart_Cronet_Metrics_request_end_set = void Function( + ffi.Pointer self, + ffi.Pointer request_end, ); -typedef _c_Cronet_Error_message_get = ffi.Pointer Function( - ffi.Pointer self, +typedef _c_Cronet_Metrics_request_end_move = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer request_end, ); -typedef _dart_Cronet_Error_message_get = ffi.Pointer Function( - ffi.Pointer self, +typedef _dart_Cronet_Metrics_request_end_move = void Function( + ffi.Pointer self, + ffi.Pointer request_end, ); -typedef _c_Cronet_Error_internal_error_code_get = ffi.Int32 Function( - ffi.Pointer self, +typedef _c_Cronet_Metrics_socket_reused_set = ffi.Void Function( + ffi.Pointer self, + ffi.Uint8 socket_reused, ); -typedef _dart_Cronet_Error_internal_error_code_get = int Function( - ffi.Pointer self, +typedef _dart_Cronet_Metrics_socket_reused_set = void Function( + ffi.Pointer self, + int socket_reused, ); -typedef _c_Cronet_QuicHint_Create = ffi.Pointer Function(); +typedef _c_Cronet_Metrics_sent_byte_count_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int64 sent_byte_count, +); -typedef _dart_Cronet_QuicHint_Create = ffi.Pointer Function(); +typedef _dart_Cronet_Metrics_sent_byte_count_set = void Function( + ffi.Pointer self, + int sent_byte_count, +); -typedef _c_Cronet_QuicHint_Destroy = ffi.Void Function( - ffi.Pointer self, +typedef _c_Cronet_Metrics_received_byte_count_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int64 received_byte_count, ); -typedef _dart_Cronet_QuicHint_Destroy = void Function( - ffi.Pointer self, +typedef _dart_Cronet_Metrics_received_byte_count_set = void Function( + ffi.Pointer self, + int received_byte_count, ); -typedef _c_Cronet_QuicHint_host_set = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer host, +typedef _c_Cronet_Metrics_request_start_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _dart_Cronet_QuicHint_host_set = void Function( - ffi.Pointer self, - ffi.Pointer host, +typedef _dart_Cronet_Metrics_request_start_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _c_Cronet_QuicHint_port_set = ffi.Void Function( - ffi.Pointer self, - ffi.Int32 port, +typedef _c_Cronet_Metrics_dns_start_get = ffi.Pointer Function( + ffi.Pointer self, ); -typedef _dart_Cronet_QuicHint_port_set = void Function( - ffi.Pointer self, - int port, +typedef _dart_Cronet_Metrics_dns_start_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _c_Cronet_QuicHint_alternate_port_set = ffi.Void Function( - ffi.Pointer self, - ffi.Int32 alternate_port, +typedef _c_Cronet_Metrics_dns_end_get = ffi.Pointer Function( + ffi.Pointer self, ); -typedef _dart_Cronet_QuicHint_alternate_port_set = void Function( - ffi.Pointer self, - int alternate_port, +typedef _dart_Cronet_Metrics_dns_end_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _c_Cronet_EngineParams_Create = ffi.Pointer - Function(); +typedef _c_Cronet_Metrics_connect_start_get = ffi.Pointer + Function( + ffi.Pointer self, +); -typedef _dart_Cronet_EngineParams_Create = ffi.Pointer - Function(); +typedef _dart_Cronet_Metrics_connect_start_get = ffi.Pointer + Function( + ffi.Pointer self, +); -typedef _c_Cronet_EngineParams_Destroy = ffi.Void Function( - ffi.Pointer self, +typedef _c_Cronet_Metrics_connect_end_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _dart_Cronet_EngineParams_Destroy = void Function( - ffi.Pointer self, +typedef _dart_Cronet_Metrics_connect_end_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _c_Cronet_EngineParams_enable_check_result_set = ffi.Void Function( - ffi.Pointer self, - ffi.Uint8 enable_check_result, +typedef _c_Cronet_Metrics_ssl_start_get = ffi.Pointer Function( + ffi.Pointer self, ); -typedef _dart_Cronet_EngineParams_enable_check_result_set = void Function( - ffi.Pointer self, - int enable_check_result, +typedef _dart_Cronet_Metrics_ssl_start_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _c_Cronet_EngineParams_user_agent_set = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer user_agent, +typedef _c_Cronet_Metrics_ssl_end_get = ffi.Pointer Function( + ffi.Pointer self, ); -typedef _dart_Cronet_EngineParams_user_agent_set = void Function( - ffi.Pointer self, - ffi.Pointer user_agent, +typedef _dart_Cronet_Metrics_ssl_end_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _c_Cronet_EngineParams_accept_language_set = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer accept_language, +typedef _c_Cronet_Metrics_sending_start_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _dart_Cronet_EngineParams_accept_language_set = void Function( - ffi.Pointer self, - ffi.Pointer accept_language, +typedef _dart_Cronet_Metrics_sending_start_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _c_Cronet_EngineParams_storage_path_set = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer storage_path, +typedef _c_Cronet_Metrics_sending_end_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _dart_Cronet_EngineParams_storage_path_set = void Function( - ffi.Pointer self, - ffi.Pointer storage_path, +typedef _dart_Cronet_Metrics_sending_end_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _c_Cronet_EngineParams_enable_quic_set = ffi.Void Function( - ffi.Pointer self, - ffi.Uint8 enable_quic, +typedef _c_Cronet_Metrics_push_start_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _dart_Cronet_EngineParams_enable_quic_set = void Function( - ffi.Pointer self, - int enable_quic, +typedef _dart_Cronet_Metrics_push_start_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _c_Cronet_EngineParams_enable_http2_set = ffi.Void Function( - ffi.Pointer self, - ffi.Uint8 enable_http2, +typedef _c_Cronet_Metrics_push_end_get = ffi.Pointer Function( + ffi.Pointer self, ); -typedef _dart_Cronet_EngineParams_enable_http2_set = void Function( - ffi.Pointer self, - int enable_http2, +typedef _dart_Cronet_Metrics_push_end_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _c_Cronet_EngineParams_enable_brotli_set = ffi.Void Function( - ffi.Pointer self, - ffi.Uint8 enable_brotli, +typedef _c_Cronet_Metrics_response_start_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _dart_Cronet_EngineParams_enable_brotli_set = void Function( - ffi.Pointer self, - int enable_brotli, +typedef _dart_Cronet_Metrics_response_start_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _c_Cronet_EngineParams_http_cache_mode_set = ffi.Void Function( - ffi.Pointer self, - ffi.Int32 http_cache_mode, +typedef _c_Cronet_Metrics_request_end_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _dart_Cronet_EngineParams_http_cache_mode_set = void Function( - ffi.Pointer self, - int http_cache_mode, +typedef _dart_Cronet_Metrics_request_end_get = ffi.Pointer + Function( + ffi.Pointer self, ); -typedef _c_Cronet_EngineParams_http_cache_max_size_set = ffi.Void Function( - ffi.Pointer self, - ffi.Int64 http_cache_max_size, +typedef _c_Cronet_Metrics_socket_reused_get = ffi.Uint8 Function( + ffi.Pointer self, ); -typedef _dart_Cronet_EngineParams_http_cache_max_size_set = void Function( - ffi.Pointer self, - int http_cache_max_size, +typedef _dart_Cronet_Metrics_socket_reused_get = int Function( + ffi.Pointer self, ); -typedef _c_Cronet_EngineParams_quic_hints_add = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer element, +typedef _c_Cronet_Metrics_sent_byte_count_get = ffi.Int64 Function( + ffi.Pointer self, ); -typedef _dart_Cronet_EngineParams_quic_hints_add = void Function( - ffi.Pointer self, - ffi.Pointer element, +typedef _dart_Cronet_Metrics_sent_byte_count_get = int Function( + ffi.Pointer self, ); -typedef _c_Cronet_HttpHeader_Create = ffi.Pointer Function(); +typedef _c_Cronet_Metrics_received_byte_count_get = ffi.Int64 Function( + ffi.Pointer self, +); -typedef _dart_Cronet_HttpHeader_Create = ffi.Pointer - Function(); +typedef _dart_Cronet_Metrics_received_byte_count_get = int Function( + ffi.Pointer self, +); -typedef _c_Cronet_HttpHeader_Destroy = ffi.Void Function( - ffi.Pointer self, +typedef _c_Cronet_RequestFinishedInfo_Create + = ffi.Pointer Function(); + +typedef _dart_Cronet_RequestFinishedInfo_Create + = ffi.Pointer Function(); + +typedef _c_Cronet_RequestFinishedInfo_Destroy = ffi.Void Function( + ffi.Pointer self, ); -typedef _dart_Cronet_HttpHeader_Destroy = void Function( - ffi.Pointer self, +typedef _dart_Cronet_RequestFinishedInfo_Destroy = void Function( + ffi.Pointer self, ); -typedef _c_Cronet_HttpHeader_name_set = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer name, +typedef _c_Cronet_RequestFinishedInfo_metrics_set = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer metrics, ); -typedef _dart_Cronet_HttpHeader_name_set = void Function( - ffi.Pointer self, - ffi.Pointer name, +typedef _dart_Cronet_RequestFinishedInfo_metrics_set = void Function( + ffi.Pointer self, + ffi.Pointer metrics, ); -typedef _c_Cronet_HttpHeader_value_set = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer value, +typedef _c_Cronet_RequestFinishedInfo_metrics_move = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer metrics, ); -typedef _dart_Cronet_HttpHeader_value_set = void Function( - ffi.Pointer self, - ffi.Pointer value, +typedef _dart_Cronet_RequestFinishedInfo_metrics_move = void Function( + ffi.Pointer self, + ffi.Pointer metrics, ); -typedef _c_Cronet_UrlResponseInfo_http_status_code_get = ffi.Int32 Function( - ffi.Pointer self, +typedef _c_Cronet_RequestFinishedInfo_annotations_add = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer element, ); -typedef _dart_Cronet_UrlResponseInfo_http_status_code_get = int Function( - ffi.Pointer self, +typedef _dart_Cronet_RequestFinishedInfo_annotations_add = void Function( + ffi.Pointer self, + ffi.Pointer element, ); -typedef _c_Cronet_UrlResponseInfo_http_status_text_get = ffi.Pointer +typedef _c_Cronet_RequestFinishedInfo_finished_reason_set = ffi.Void Function( + ffi.Pointer self, + ffi.Int32 finished_reason, +); + +typedef _dart_Cronet_RequestFinishedInfo_finished_reason_set = void Function( + ffi.Pointer self, + int finished_reason, +); + +typedef _c_Cronet_RequestFinishedInfo_metrics_get = ffi.Pointer Function( - ffi.Pointer self, + ffi.Pointer self, ); -typedef _dart_Cronet_UrlResponseInfo_http_status_text_get - = ffi.Pointer Function( - ffi.Pointer self, +typedef _dart_Cronet_RequestFinishedInfo_metrics_get + = ffi.Pointer Function( + ffi.Pointer self, ); -typedef _c_Cronet_UrlRequestParams_Create = ffi.Pointer - Function(); +typedef _c_Cronet_RequestFinishedInfo_annotations_size = ffi.Uint32 Function( + ffi.Pointer self, +); -typedef _dart_Cronet_UrlRequestParams_Create - = ffi.Pointer Function(); +typedef _dart_Cronet_RequestFinishedInfo_annotations_size = int Function( + ffi.Pointer self, +); -typedef _c_Cronet_UrlRequestParams_Destroy = ffi.Void Function( - ffi.Pointer self, +typedef _c_Cronet_RequestFinishedInfo_annotations_at = ffi.Pointer + Function( + ffi.Pointer self, + ffi.Uint32 index, ); -typedef _dart_Cronet_UrlRequestParams_Destroy = void Function( - ffi.Pointer self, +typedef _dart_Cronet_RequestFinishedInfo_annotations_at = ffi.Pointer + Function( + ffi.Pointer self, + int index, ); -typedef _c_Cronet_UrlRequestParams_http_method_set = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer http_method, +typedef _c_Cronet_RequestFinishedInfo_annotations_clear = ffi.Void Function( + ffi.Pointer self, ); -typedef _dart_Cronet_UrlRequestParams_http_method_set = void Function( - ffi.Pointer self, - ffi.Pointer http_method, +typedef _dart_Cronet_RequestFinishedInfo_annotations_clear = void Function( + ffi.Pointer self, ); -typedef _c_Cronet_UrlRequestParams_request_headers_add = ffi.Void Function( - ffi.Pointer self, - ffi.Pointer element, +typedef _c_Cronet_RequestFinishedInfo_finished_reason_get = ffi.Int32 Function( + ffi.Pointer self, ); -typedef _dart_Cronet_UrlRequestParams_request_headers_add = void Function( - ffi.Pointer self, - ffi.Pointer element, +typedef _dart_Cronet_RequestFinishedInfo_finished_reason_get = int Function( + ffi.Pointer self, ); diff --git a/lib/src/third_party/ffigen/find_resource.dart b/lib/src/third_party/ffigen/find_resource.dart index 698c14f..9c1968b 100644 --- a/lib/src/third_party/ffigen/find_resource.dart +++ b/lib/src/third_party/ffigen/find_resource.dart @@ -8,7 +8,7 @@ import 'dart:io' show Directory, File, Platform; import 'package:cronet/src/constants.dart'; /// Finds the root [Uri] of our package. -Uri? findPackageRoot() { +Uri findPackageRoot() { var root = Directory.current.uri; do { // Traverse up till .dart_tool/package_config.json is found. @@ -35,15 +35,14 @@ Uri? findPackageRoot() { } } } while (root != (root = root.resolve('..'))); - return null; + print('Unable to fetch package location.' + "Make sure you've added package:cronet as a dependency"); + throw Exception("Cannot resolve package:cronet's rootUri"); } /// Gets the [wrapper]'s source code's path, throws [Exception] if not found. String wrapperSourcePath() { final packagePath = findPackageRoot(); - if (packagePath == null) { - throw Exception("Cannot resolve package:cronet's rootUri"); - } final wrapperSource = packagePath.resolve('src'); if (!Directory.fromUri(wrapperSource).existsSync()) { throw Exception('Cannot find wrapper source!'); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7845e74..ba29e18 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,3 @@ -# CMAKE file for windows build. - cmake_minimum_required(VERSION 3.15) set(PROJECT_NAME "cronet") project(${PROJECT_NAME} LANGUAGES C CXX) @@ -17,8 +15,6 @@ add_library(${PLUGIN_NAME} SHARED "${CMAKE_CURRENT_SOURCE_DIR}/../third_party/dart-sdk/dart_api_dl.c" ) -# apply_standard_settings(${PLUGIN_NAME}) - set_target_properties(${PLUGIN_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden) diff --git a/src/wrapper.cc b/src/wrapper.cc index ed138e3..2409e6b 100644 --- a/src/wrapper.cc +++ b/src/wrapper.cc @@ -89,7 +89,7 @@ void RegisterCallbackHandler(Dart_Port send_port, Cronet_UrlRequestPtr rp) { // This sends the callback name and the associated data with it to the Dart // side via NativePort. // -// Sent data is broken into 3 parts. +// Sent data is broken into 2 parts. // message[0] is the method name, which is a string. // message[1] contains all the data to pass to that method. // diff --git a/third_party/cronet/cronet.idl_c.h b/third_party/cronet/cronet.idl_c.h index 0c18400..e000fdd 100644 --- a/third_party/cronet/cronet.idl_c.h +++ b/third_party/cronet/cronet.idl_c.h @@ -4,8 +4,6 @@ /* DO NOT EDIT. Generated from components/cronet/native/generated/cronet.idl */ -/* ONLY the APIs that are available via the wrapper is ENABLED */ - #ifndef COMPONENTS_CRONET_NATIVE_GENERATED_CRONET_IDL_C_H_ #define COMPONENTS_CRONET_NATIVE_GENERATED_CRONET_IDL_C_H_ #include "cronet_export.h" @@ -16,7 +14,7 @@ extern "C" { #include -#include +#include typedef const char* Cronet_String; typedef void* Cronet_RawDataPtr; @@ -167,114 +165,114 @@ typedef enum Cronet_UrlRequestStatusListener_Status { Cronet_UrlRequestStatusListener_Status_READING_RESPONSE = 14, } Cronet_UrlRequestStatusListener_Status; -// // Declare constants +// Declare constants -// /////////////////////// -// // Concrete interface Cronet_Buffer. +/////////////////////// +// Concrete interface Cronet_Buffer. -// // Create an instance of Cronet_Buffer. +// Create an instance of Cronet_Buffer. CRONET_EXPORT Cronet_BufferPtr Cronet_Buffer_Create(void); -// // Destroy an instance of Cronet_Buffer. -// CRONET_EXPORT void Cronet_Buffer_Destroy(Cronet_BufferPtr self); -// // Set and get app-specific Cronet_ClientContext. -// CRONET_EXPORT void Cronet_Buffer_SetClientContext( -// Cronet_BufferPtr self, -// Cronet_ClientContext client_context); -// CRONET_EXPORT Cronet_ClientContext -// Cronet_Buffer_GetClientContext(Cronet_BufferPtr self); -// // Concrete methods of Cronet_Buffer implemented by Cronet. -// // The app calls them to manipulate Cronet_Buffer. -// CRONET_EXPORT -// void Cronet_Buffer_InitWithDataAndCallback(Cronet_BufferPtr self, -// Cronet_RawDataPtr data, -// uint64_t size, -// Cronet_BufferCallbackPtr callback); +// Destroy an instance of Cronet_Buffer. +CRONET_EXPORT void Cronet_Buffer_Destroy(Cronet_BufferPtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_Buffer_SetClientContext( + Cronet_BufferPtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_Buffer_GetClientContext(Cronet_BufferPtr self); +// Concrete methods of Cronet_Buffer implemented by Cronet. +// The app calls them to manipulate Cronet_Buffer. +CRONET_EXPORT +void Cronet_Buffer_InitWithDataAndCallback(Cronet_BufferPtr self, + Cronet_RawDataPtr data, + uint64_t size, + Cronet_BufferCallbackPtr callback); CRONET_EXPORT void Cronet_Buffer_InitWithAlloc(Cronet_BufferPtr self, uint64_t size); CRONET_EXPORT uint64_t Cronet_Buffer_GetSize(Cronet_BufferPtr self); CRONET_EXPORT Cronet_RawDataPtr Cronet_Buffer_GetData(Cronet_BufferPtr self); -// // Concrete interface Cronet_Buffer is implemented by Cronet. -// // The app can implement these for testing / mocking. -// typedef void (*Cronet_Buffer_InitWithDataAndCallbackFunc)( -// Cronet_BufferPtr self, -// Cronet_RawDataPtr data, -// uint64_t size, -// Cronet_BufferCallbackPtr callback); +// Concrete interface Cronet_Buffer is implemented by Cronet. +// The app can implement these for testing / mocking. +typedef void (*Cronet_Buffer_InitWithDataAndCallbackFunc)( + Cronet_BufferPtr self, + Cronet_RawDataPtr data, + uint64_t size, + Cronet_BufferCallbackPtr callback); typedef void (*Cronet_Buffer_InitWithAllocFunc)(Cronet_BufferPtr self, uint64_t size); -// typedef uint64_t (*Cronet_Buffer_GetSizeFunc)(Cronet_BufferPtr self); -// typedef Cronet_RawDataPtr (*Cronet_Buffer_GetDataFunc)(Cronet_BufferPtr self); -// // Concrete interface Cronet_Buffer is implemented by Cronet. -// // The app can use this for testing / mocking. -// CRONET_EXPORT Cronet_BufferPtr Cronet_Buffer_CreateWith( -// Cronet_Buffer_InitWithDataAndCallbackFunc InitWithDataAndCallbackFunc, -// Cronet_Buffer_InitWithAllocFunc InitWithAllocFunc, -// Cronet_Buffer_GetSizeFunc GetSizeFunc, -// Cronet_Buffer_GetDataFunc GetDataFunc); +typedef uint64_t (*Cronet_Buffer_GetSizeFunc)(Cronet_BufferPtr self); +typedef Cronet_RawDataPtr (*Cronet_Buffer_GetDataFunc)(Cronet_BufferPtr self); +// Concrete interface Cronet_Buffer is implemented by Cronet. +// The app can use this for testing / mocking. +CRONET_EXPORT Cronet_BufferPtr Cronet_Buffer_CreateWith( + Cronet_Buffer_InitWithDataAndCallbackFunc InitWithDataAndCallbackFunc, + Cronet_Buffer_InitWithAllocFunc InitWithAllocFunc, + Cronet_Buffer_GetSizeFunc GetSizeFunc, + Cronet_Buffer_GetDataFunc GetDataFunc); -// /////////////////////// -// // Abstract interface Cronet_BufferCallback is implemented by the app. +/////////////////////// +// Abstract interface Cronet_BufferCallback is implemented by the app. -// // There is no method to create a concrete implementation. +// There is no method to create a concrete implementation. -// // Destroy an instance of Cronet_BufferCallback. -// CRONET_EXPORT void Cronet_BufferCallback_Destroy(Cronet_BufferCallbackPtr self); -// // Set and get app-specific Cronet_ClientContext. -// CRONET_EXPORT void Cronet_BufferCallback_SetClientContext( -// Cronet_BufferCallbackPtr self, -// Cronet_ClientContext client_context); -// CRONET_EXPORT Cronet_ClientContext -// Cronet_BufferCallback_GetClientContext(Cronet_BufferCallbackPtr self); -// // Abstract interface Cronet_BufferCallback is implemented by the app. -// // The following concrete methods forward call to app implementation. -// // The app doesn't normally call them. -// CRONET_EXPORT -// void Cronet_BufferCallback_OnDestroy(Cronet_BufferCallbackPtr self, -// Cronet_BufferPtr buffer); -// // The app implements abstract interface Cronet_BufferCallback by defining -// // custom functions for each method. -// typedef void (*Cronet_BufferCallback_OnDestroyFunc)( -// Cronet_BufferCallbackPtr self, -// Cronet_BufferPtr buffer); -// // The app creates an instance of Cronet_BufferCallback by providing custom -// // functions for each method. -// CRONET_EXPORT Cronet_BufferCallbackPtr Cronet_BufferCallback_CreateWith( -// Cronet_BufferCallback_OnDestroyFunc OnDestroyFunc); +// Destroy an instance of Cronet_BufferCallback. +CRONET_EXPORT void Cronet_BufferCallback_Destroy(Cronet_BufferCallbackPtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_BufferCallback_SetClientContext( + Cronet_BufferCallbackPtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_BufferCallback_GetClientContext(Cronet_BufferCallbackPtr self); +// Abstract interface Cronet_BufferCallback is implemented by the app. +// The following concrete methods forward call to app implementation. +// The app doesn't normally call them. +CRONET_EXPORT +void Cronet_BufferCallback_OnDestroy(Cronet_BufferCallbackPtr self, + Cronet_BufferPtr buffer); +// The app implements abstract interface Cronet_BufferCallback by defining +// custom functions for each method. +typedef void (*Cronet_BufferCallback_OnDestroyFunc)( + Cronet_BufferCallbackPtr self, + Cronet_BufferPtr buffer); +// The app creates an instance of Cronet_BufferCallback by providing custom +// functions for each method. +CRONET_EXPORT Cronet_BufferCallbackPtr Cronet_BufferCallback_CreateWith( + Cronet_BufferCallback_OnDestroyFunc OnDestroyFunc); -// /////////////////////// -// // Abstract interface Cronet_Runnable is implemented by the app. +/////////////////////// +// Abstract interface Cronet_Runnable is implemented by the app. -// // There is no method to create a concrete implementation. +// There is no method to create a concrete implementation. // Destroy an instance of Cronet_Runnable. CRONET_EXPORT void Cronet_Runnable_Destroy(Cronet_RunnablePtr self); -// // Set and get app-specific Cronet_ClientContext. -// CRONET_EXPORT void Cronet_Runnable_SetClientContext( -// Cronet_RunnablePtr self, -// Cronet_ClientContext client_context); -// CRONET_EXPORT Cronet_ClientContext -// Cronet_Runnable_GetClientContext(Cronet_RunnablePtr self); -// // Abstract interface Cronet_Runnable is implemented by the app. -// // The following concrete methods forward call to app implementation. -// // The app doesn't normally call them. +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_Runnable_SetClientContext( + Cronet_RunnablePtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_Runnable_GetClientContext(Cronet_RunnablePtr self); +// Abstract interface Cronet_Runnable is implemented by the app. +// The following concrete methods forward call to app implementation. +// The app doesn't normally call them. CRONET_EXPORT void Cronet_Runnable_Run(Cronet_RunnablePtr self); -// // The app implements abstract interface Cronet_Runnable by defining custom -// // functions for each method. -// typedef void (*Cronet_Runnable_RunFunc)(Cronet_RunnablePtr self); -// // The app creates an instance of Cronet_Runnable by providing custom functions -// // for each method. -// CRONET_EXPORT Cronet_RunnablePtr -// Cronet_Runnable_CreateWith(Cronet_Runnable_RunFunc RunFunc); +// The app implements abstract interface Cronet_Runnable by defining custom +// functions for each method. +typedef void (*Cronet_Runnable_RunFunc)(Cronet_RunnablePtr self); +// The app creates an instance of Cronet_Runnable by providing custom functions +// for each method. +CRONET_EXPORT Cronet_RunnablePtr +Cronet_Runnable_CreateWith(Cronet_Runnable_RunFunc RunFunc); -// /////////////////////// -// // Abstract interface Cronet_Executor is implemented by the app. +/////////////////////// +// Abstract interface Cronet_Executor is implemented by the app. -// // There is no method to create a concrete implementation. +// There is no method to create a concrete implementation. -// // Destroy an instance of Cronet_Executor. +// Destroy an instance of Cronet_Executor. CRONET_EXPORT void Cronet_Executor_Destroy(Cronet_ExecutorPtr self); // Set and get app-specific Cronet_ClientContext. CRONET_EXPORT void Cronet_Executor_SetClientContext( @@ -288,30 +286,30 @@ Cronet_Executor_GetClientContext(Cronet_ExecutorPtr self); CRONET_EXPORT void Cronet_Executor_Execute(Cronet_ExecutorPtr self, Cronet_RunnablePtr command); -// // The app implements abstract interface Cronet_Executor by defining custom -// // functions for each method. +// The app implements abstract interface Cronet_Executor by defining custom +// functions for each method. typedef void (*Cronet_Executor_ExecuteFunc)(Cronet_ExecutorPtr self, Cronet_RunnablePtr command); -// // The app creates an instance of Cronet_Executor by providing custom functions -// // for each method. +// The app creates an instance of Cronet_Executor by providing custom functions +// for each method. CRONET_EXPORT Cronet_ExecutorPtr Cronet_Executor_CreateWith(Cronet_Executor_ExecuteFunc ExecuteFunc); -// /////////////////////// -// // Concrete interface Cronet_Engine. +/////////////////////// +// Concrete interface Cronet_Engine. -// // Create an instance of Cronet_Engine. +// Create an instance of Cronet_Engine. CRONET_EXPORT Cronet_EnginePtr Cronet_Engine_Create(void); -// // Destroy an instance of Cronet_Engine. +// Destroy an instance of Cronet_Engine. CRONET_EXPORT void Cronet_Engine_Destroy(Cronet_EnginePtr self); -// // Set and get app-specific Cronet_ClientContext. -// CRONET_EXPORT void Cronet_Engine_SetClientContext( -// Cronet_EnginePtr self, -// Cronet_ClientContext client_context); -// CRONET_EXPORT Cronet_ClientContext -// Cronet_Engine_GetClientContext(Cronet_EnginePtr self); -// // Concrete methods of Cronet_Engine implemented by Cronet. -// // The app calls them to manipulate Cronet_Engine. +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_Engine_SetClientContext( + Cronet_EnginePtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_Engine_GetClientContext(Cronet_EnginePtr self); +// Concrete methods of Cronet_Engine implemented by Cronet. +// The app calls them to manipulate Cronet_Engine. CRONET_EXPORT Cronet_RESULT Cronet_Engine_StartWithParams(Cronet_EnginePtr self, Cronet_EngineParamsPtr params); @@ -325,17 +323,17 @@ CRONET_EXPORT Cronet_RESULT Cronet_Engine_Shutdown(Cronet_EnginePtr self); CRONET_EXPORT Cronet_String Cronet_Engine_GetVersionString(Cronet_EnginePtr self); -// CRONET_EXPORT -// Cronet_String Cronet_Engine_GetDefaultUserAgent(Cronet_EnginePtr self); -// CRONET_EXPORT -// void Cronet_Engine_AddRequestFinishedListener( -// Cronet_EnginePtr self, -// Cronet_RequestFinishedInfoListenerPtr listener, -// Cronet_ExecutorPtr executor); -// CRONET_EXPORT -// void Cronet_Engine_RemoveRequestFinishedListener( -// Cronet_EnginePtr self, -// Cronet_RequestFinishedInfoListenerPtr listener); +CRONET_EXPORT +Cronet_String Cronet_Engine_GetDefaultUserAgent(Cronet_EnginePtr self); +CRONET_EXPORT +void Cronet_Engine_AddRequestFinishedListener( + Cronet_EnginePtr self, + Cronet_RequestFinishedInfoListenerPtr listener, + Cronet_ExecutorPtr executor); +CRONET_EXPORT +void Cronet_Engine_RemoveRequestFinishedListener( + Cronet_EnginePtr self, + Cronet_RequestFinishedInfoListenerPtr listener); // Concrete interface Cronet_Engine is implemented by Cronet. // The app can implement these for testing / mocking. typedef Cronet_RESULT (*Cronet_Engine_StartWithParamsFunc)( @@ -357,100 +355,100 @@ typedef void (*Cronet_Engine_AddRequestFinishedListenerFunc)( typedef void (*Cronet_Engine_RemoveRequestFinishedListenerFunc)( Cronet_EnginePtr self, Cronet_RequestFinishedInfoListenerPtr listener); -// // Concrete interface Cronet_Engine is implemented by Cronet. -// // The app can use this for testing / mocking. -// CRONET_EXPORT Cronet_EnginePtr Cronet_Engine_CreateWith( -// Cronet_Engine_StartWithParamsFunc StartWithParamsFunc, -// Cronet_Engine_StartNetLogToFileFunc StartNetLogToFileFunc, -// Cronet_Engine_StopNetLogFunc StopNetLogFunc, -// Cronet_Engine_ShutdownFunc ShutdownFunc, -// Cronet_Engine_GetVersionStringFunc GetVersionStringFunc, -// Cronet_Engine_GetDefaultUserAgentFunc GetDefaultUserAgentFunc, -// Cronet_Engine_AddRequestFinishedListenerFunc AddRequestFinishedListenerFunc, -// Cronet_Engine_RemoveRequestFinishedListenerFunc -// RemoveRequestFinishedListenerFunc); +// Concrete interface Cronet_Engine is implemented by Cronet. +// The app can use this for testing / mocking. +CRONET_EXPORT Cronet_EnginePtr Cronet_Engine_CreateWith( + Cronet_Engine_StartWithParamsFunc StartWithParamsFunc, + Cronet_Engine_StartNetLogToFileFunc StartNetLogToFileFunc, + Cronet_Engine_StopNetLogFunc StopNetLogFunc, + Cronet_Engine_ShutdownFunc ShutdownFunc, + Cronet_Engine_GetVersionStringFunc GetVersionStringFunc, + Cronet_Engine_GetDefaultUserAgentFunc GetDefaultUserAgentFunc, + Cronet_Engine_AddRequestFinishedListenerFunc AddRequestFinishedListenerFunc, + Cronet_Engine_RemoveRequestFinishedListenerFunc + RemoveRequestFinishedListenerFunc); -// /////////////////////// -// // Abstract interface Cronet_UrlRequestStatusListener is implemented by the app. +/////////////////////// +// Abstract interface Cronet_UrlRequestStatusListener is implemented by the app. -// // There is no method to create a concrete implementation. +// There is no method to create a concrete implementation. -// // Destroy an instance of Cronet_UrlRequestStatusListener. -// CRONET_EXPORT void Cronet_UrlRequestStatusListener_Destroy( -// Cronet_UrlRequestStatusListenerPtr self); -// // Set and get app-specific Cronet_ClientContext. -// CRONET_EXPORT void Cronet_UrlRequestStatusListener_SetClientContext( -// Cronet_UrlRequestStatusListenerPtr self, -// Cronet_ClientContext client_context); -// CRONET_EXPORT Cronet_ClientContext -// Cronet_UrlRequestStatusListener_GetClientContext( -// Cronet_UrlRequestStatusListenerPtr self); -// // Abstract interface Cronet_UrlRequestStatusListener is implemented by the app. -// // The following concrete methods forward call to app implementation. -// // The app doesn't normally call them. -// CRONET_EXPORT -// void Cronet_UrlRequestStatusListener_OnStatus( -// Cronet_UrlRequestStatusListenerPtr self, -// Cronet_UrlRequestStatusListener_Status status); -// // The app implements abstract interface Cronet_UrlRequestStatusListener by -// // defining custom functions for each method. -// typedef void (*Cronet_UrlRequestStatusListener_OnStatusFunc)( -// Cronet_UrlRequestStatusListenerPtr self, -// Cronet_UrlRequestStatusListener_Status status); -// // The app creates an instance of Cronet_UrlRequestStatusListener by providing -// // custom functions for each method. -// CRONET_EXPORT Cronet_UrlRequestStatusListenerPtr -// Cronet_UrlRequestStatusListener_CreateWith( -// Cronet_UrlRequestStatusListener_OnStatusFunc OnStatusFunc); +// Destroy an instance of Cronet_UrlRequestStatusListener. +CRONET_EXPORT void Cronet_UrlRequestStatusListener_Destroy( + Cronet_UrlRequestStatusListenerPtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_UrlRequestStatusListener_SetClientContext( + Cronet_UrlRequestStatusListenerPtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_UrlRequestStatusListener_GetClientContext( + Cronet_UrlRequestStatusListenerPtr self); +// Abstract interface Cronet_UrlRequestStatusListener is implemented by the app. +// The following concrete methods forward call to app implementation. +// The app doesn't normally call them. +CRONET_EXPORT +void Cronet_UrlRequestStatusListener_OnStatus( + Cronet_UrlRequestStatusListenerPtr self, + Cronet_UrlRequestStatusListener_Status status); +// The app implements abstract interface Cronet_UrlRequestStatusListener by +// defining custom functions for each method. +typedef void (*Cronet_UrlRequestStatusListener_OnStatusFunc)( + Cronet_UrlRequestStatusListenerPtr self, + Cronet_UrlRequestStatusListener_Status status); +// The app creates an instance of Cronet_UrlRequestStatusListener by providing +// custom functions for each method. +CRONET_EXPORT Cronet_UrlRequestStatusListenerPtr +Cronet_UrlRequestStatusListener_CreateWith( + Cronet_UrlRequestStatusListener_OnStatusFunc OnStatusFunc); -// /////////////////////// -// // Abstract interface Cronet_UrlRequestCallback is implemented by the app. +/////////////////////// +// Abstract interface Cronet_UrlRequestCallback is implemented by the app. -// // There is no method to create a concrete implementation. +// There is no method to create a concrete implementation. -// // Destroy an instance of Cronet_UrlRequestCallback. -// CRONET_EXPORT void Cronet_UrlRequestCallback_Destroy( -// Cronet_UrlRequestCallbackPtr self); -// // Set and get app-specific Cronet_ClientContext. -// CRONET_EXPORT void Cronet_UrlRequestCallback_SetClientContext( -// Cronet_UrlRequestCallbackPtr self, -// Cronet_ClientContext client_context); -// CRONET_EXPORT Cronet_ClientContext -// Cronet_UrlRequestCallback_GetClientContext(Cronet_UrlRequestCallbackPtr self); -// // Abstract interface Cronet_UrlRequestCallback is implemented by the app. -// // The following concrete methods forward call to app implementation. -// // The app doesn't normally call them. -// CRONET_EXPORT -// void Cronet_UrlRequestCallback_OnRedirectReceived( -// Cronet_UrlRequestCallbackPtr self, -// Cronet_UrlRequestPtr request, -// Cronet_UrlResponseInfoPtr info, -// Cronet_String new_location_url); -// CRONET_EXPORT -// void Cronet_UrlRequestCallback_OnResponseStarted( -// Cronet_UrlRequestCallbackPtr self, -// Cronet_UrlRequestPtr request, -// Cronet_UrlResponseInfoPtr info); -// CRONET_EXPORT -// void Cronet_UrlRequestCallback_OnReadCompleted( -// Cronet_UrlRequestCallbackPtr self, -// Cronet_UrlRequestPtr request, -// Cronet_UrlResponseInfoPtr info, -// Cronet_BufferPtr buffer, -// uint64_t bytes_read); -// CRONET_EXPORT -// void Cronet_UrlRequestCallback_OnSucceeded(Cronet_UrlRequestCallbackPtr self, -// Cronet_UrlRequestPtr request, -// Cronet_UrlResponseInfoPtr info); -// CRONET_EXPORT -// void Cronet_UrlRequestCallback_OnFailed(Cronet_UrlRequestCallbackPtr self, -// Cronet_UrlRequestPtr request, -// Cronet_UrlResponseInfoPtr info, -// Cronet_ErrorPtr error); -// CRONET_EXPORT -// void Cronet_UrlRequestCallback_OnCanceled(Cronet_UrlRequestCallbackPtr self, -// Cronet_UrlRequestPtr request, -// Cronet_UrlResponseInfoPtr info); +// Destroy an instance of Cronet_UrlRequestCallback. +CRONET_EXPORT void Cronet_UrlRequestCallback_Destroy( + Cronet_UrlRequestCallbackPtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_UrlRequestCallback_SetClientContext( + Cronet_UrlRequestCallbackPtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_UrlRequestCallback_GetClientContext(Cronet_UrlRequestCallbackPtr self); +// Abstract interface Cronet_UrlRequestCallback is implemented by the app. +// The following concrete methods forward call to app implementation. +// The app doesn't normally call them. +CRONET_EXPORT +void Cronet_UrlRequestCallback_OnRedirectReceived( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_String new_location_url); +CRONET_EXPORT +void Cronet_UrlRequestCallback_OnResponseStarted( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); +CRONET_EXPORT +void Cronet_UrlRequestCallback_OnReadCompleted( + Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_BufferPtr buffer, + uint64_t bytes_read); +CRONET_EXPORT +void Cronet_UrlRequestCallback_OnSucceeded(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); +CRONET_EXPORT +void Cronet_UrlRequestCallback_OnFailed(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_ErrorPtr error); +CRONET_EXPORT +void Cronet_UrlRequestCallback_OnCanceled(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); // The app implements abstract interface Cronet_UrlRequestCallback by defining // custom functions for each method. typedef void (*Cronet_UrlRequestCallback_OnRedirectReceivedFunc)( @@ -481,8 +479,8 @@ typedef void (*Cronet_UrlRequestCallback_OnCanceledFunc)( Cronet_UrlRequestCallbackPtr self, Cronet_UrlRequestPtr request, Cronet_UrlResponseInfoPtr info); -// // The app creates an instance of Cronet_UrlRequestCallback by providing custom -// // functions for each method. +// The app creates an instance of Cronet_UrlRequestCallback by providing custom +// functions for each method. CRONET_EXPORT Cronet_UrlRequestCallbackPtr Cronet_UrlRequestCallback_CreateWith( Cronet_UrlRequestCallback_OnRedirectReceivedFunc OnRedirectReceivedFunc, Cronet_UrlRequestCallback_OnResponseStartedFunc OnResponseStartedFunc, @@ -491,104 +489,104 @@ CRONET_EXPORT Cronet_UrlRequestCallbackPtr Cronet_UrlRequestCallback_CreateWith( Cronet_UrlRequestCallback_OnFailedFunc OnFailedFunc, Cronet_UrlRequestCallback_OnCanceledFunc OnCanceledFunc); -// /////////////////////// -// // Concrete interface Cronet_UploadDataSink. +/////////////////////// +// Concrete interface Cronet_UploadDataSink. -// // Create an instance of Cronet_UploadDataSink. -// CRONET_EXPORT Cronet_UploadDataSinkPtr Cronet_UploadDataSink_Create(void); -// // Destroy an instance of Cronet_UploadDataSink. -// CRONET_EXPORT void Cronet_UploadDataSink_Destroy(Cronet_UploadDataSinkPtr self); -// // Set and get app-specific Cronet_ClientContext. -// CRONET_EXPORT void Cronet_UploadDataSink_SetClientContext( -// Cronet_UploadDataSinkPtr self, -// Cronet_ClientContext client_context); -// CRONET_EXPORT Cronet_ClientContext -// Cronet_UploadDataSink_GetClientContext(Cronet_UploadDataSinkPtr self); -// // Concrete methods of Cronet_UploadDataSink implemented by Cronet. -// // The app calls them to manipulate Cronet_UploadDataSink. -// CRONET_EXPORT -// void Cronet_UploadDataSink_OnReadSucceeded(Cronet_UploadDataSinkPtr self, -// uint64_t bytes_read, -// bool final_chunk); -// CRONET_EXPORT -// void Cronet_UploadDataSink_OnReadError(Cronet_UploadDataSinkPtr self, -// Cronet_String error_message); -// CRONET_EXPORT -// void Cronet_UploadDataSink_OnRewindSucceeded(Cronet_UploadDataSinkPtr self); -// CRONET_EXPORT -// void Cronet_UploadDataSink_OnRewindError(Cronet_UploadDataSinkPtr self, -// Cronet_String error_message); -// // Concrete interface Cronet_UploadDataSink is implemented by Cronet. -// // The app can implement these for testing / mocking. -// typedef void (*Cronet_UploadDataSink_OnReadSucceededFunc)( -// Cronet_UploadDataSinkPtr self, -// uint64_t bytes_read, -// bool final_chunk); -// typedef void (*Cronet_UploadDataSink_OnReadErrorFunc)( -// Cronet_UploadDataSinkPtr self, -// Cronet_String error_message); -// typedef void (*Cronet_UploadDataSink_OnRewindSucceededFunc)( -// Cronet_UploadDataSinkPtr self); -// typedef void (*Cronet_UploadDataSink_OnRewindErrorFunc)( -// Cronet_UploadDataSinkPtr self, -// Cronet_String error_message); -// // Concrete interface Cronet_UploadDataSink is implemented by Cronet. -// // The app can use this for testing / mocking. -// CRONET_EXPORT Cronet_UploadDataSinkPtr Cronet_UploadDataSink_CreateWith( -// Cronet_UploadDataSink_OnReadSucceededFunc OnReadSucceededFunc, -// Cronet_UploadDataSink_OnReadErrorFunc OnReadErrorFunc, -// Cronet_UploadDataSink_OnRewindSucceededFunc OnRewindSucceededFunc, -// Cronet_UploadDataSink_OnRewindErrorFunc OnRewindErrorFunc); +// Create an instance of Cronet_UploadDataSink. +CRONET_EXPORT Cronet_UploadDataSinkPtr Cronet_UploadDataSink_Create(void); +// Destroy an instance of Cronet_UploadDataSink. +CRONET_EXPORT void Cronet_UploadDataSink_Destroy(Cronet_UploadDataSinkPtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_UploadDataSink_SetClientContext( + Cronet_UploadDataSinkPtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_UploadDataSink_GetClientContext(Cronet_UploadDataSinkPtr self); +// Concrete methods of Cronet_UploadDataSink implemented by Cronet. +// The app calls them to manipulate Cronet_UploadDataSink. +CRONET_EXPORT +void Cronet_UploadDataSink_OnReadSucceeded(Cronet_UploadDataSinkPtr self, + uint64_t bytes_read, + bool final_chunk); +CRONET_EXPORT +void Cronet_UploadDataSink_OnReadError(Cronet_UploadDataSinkPtr self, + Cronet_String error_message); +CRONET_EXPORT +void Cronet_UploadDataSink_OnRewindSucceeded(Cronet_UploadDataSinkPtr self); +CRONET_EXPORT +void Cronet_UploadDataSink_OnRewindError(Cronet_UploadDataSinkPtr self, + Cronet_String error_message); +// Concrete interface Cronet_UploadDataSink is implemented by Cronet. +// The app can implement these for testing / mocking. +typedef void (*Cronet_UploadDataSink_OnReadSucceededFunc)( + Cronet_UploadDataSinkPtr self, + uint64_t bytes_read, + bool final_chunk); +typedef void (*Cronet_UploadDataSink_OnReadErrorFunc)( + Cronet_UploadDataSinkPtr self, + Cronet_String error_message); +typedef void (*Cronet_UploadDataSink_OnRewindSucceededFunc)( + Cronet_UploadDataSinkPtr self); +typedef void (*Cronet_UploadDataSink_OnRewindErrorFunc)( + Cronet_UploadDataSinkPtr self, + Cronet_String error_message); +// Concrete interface Cronet_UploadDataSink is implemented by Cronet. +// The app can use this for testing / mocking. +CRONET_EXPORT Cronet_UploadDataSinkPtr Cronet_UploadDataSink_CreateWith( + Cronet_UploadDataSink_OnReadSucceededFunc OnReadSucceededFunc, + Cronet_UploadDataSink_OnReadErrorFunc OnReadErrorFunc, + Cronet_UploadDataSink_OnRewindSucceededFunc OnRewindSucceededFunc, + Cronet_UploadDataSink_OnRewindErrorFunc OnRewindErrorFunc); -// /////////////////////// -// // Abstract interface Cronet_UploadDataProvider is implemented by the app. +/////////////////////// +// Abstract interface Cronet_UploadDataProvider is implemented by the app. -// // There is no method to create a concrete implementation. +// There is no method to create a concrete implementation. -// // Destroy an instance of Cronet_UploadDataProvider. -// CRONET_EXPORT void Cronet_UploadDataProvider_Destroy( -// Cronet_UploadDataProviderPtr self); -// // Set and get app-specific Cronet_ClientContext. -// CRONET_EXPORT void Cronet_UploadDataProvider_SetClientContext( -// Cronet_UploadDataProviderPtr self, -// Cronet_ClientContext client_context); -// CRONET_EXPORT Cronet_ClientContext -// Cronet_UploadDataProvider_GetClientContext(Cronet_UploadDataProviderPtr self); -// // Abstract interface Cronet_UploadDataProvider is implemented by the app. -// // The following concrete methods forward call to app implementation. -// // The app doesn't normally call them. -// CRONET_EXPORT -// int64_t Cronet_UploadDataProvider_GetLength(Cronet_UploadDataProviderPtr self); -// CRONET_EXPORT -// void Cronet_UploadDataProvider_Read(Cronet_UploadDataProviderPtr self, -// Cronet_UploadDataSinkPtr upload_data_sink, -// Cronet_BufferPtr buffer); -// CRONET_EXPORT -// void Cronet_UploadDataProvider_Rewind( -// Cronet_UploadDataProviderPtr self, -// Cronet_UploadDataSinkPtr upload_data_sink); -// CRONET_EXPORT -// void Cronet_UploadDataProvider_Close(Cronet_UploadDataProviderPtr self); -// // The app implements abstract interface Cronet_UploadDataProvider by defining -// // custom functions for each method. -// typedef int64_t (*Cronet_UploadDataProvider_GetLengthFunc)( -// Cronet_UploadDataProviderPtr self); -// typedef void (*Cronet_UploadDataProvider_ReadFunc)( -// Cronet_UploadDataProviderPtr self, -// Cronet_UploadDataSinkPtr upload_data_sink, -// Cronet_BufferPtr buffer); -// typedef void (*Cronet_UploadDataProvider_RewindFunc)( -// Cronet_UploadDataProviderPtr self, -// Cronet_UploadDataSinkPtr upload_data_sink); -// typedef void (*Cronet_UploadDataProvider_CloseFunc)( -// Cronet_UploadDataProviderPtr self); -// // The app creates an instance of Cronet_UploadDataProvider by providing custom -// // functions for each method. -// CRONET_EXPORT Cronet_UploadDataProviderPtr Cronet_UploadDataProvider_CreateWith( -// Cronet_UploadDataProvider_GetLengthFunc GetLengthFunc, -// Cronet_UploadDataProvider_ReadFunc ReadFunc, -// Cronet_UploadDataProvider_RewindFunc RewindFunc, -// Cronet_UploadDataProvider_CloseFunc CloseFunc); +// Destroy an instance of Cronet_UploadDataProvider. +CRONET_EXPORT void Cronet_UploadDataProvider_Destroy( + Cronet_UploadDataProviderPtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_UploadDataProvider_SetClientContext( + Cronet_UploadDataProviderPtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_UploadDataProvider_GetClientContext(Cronet_UploadDataProviderPtr self); +// Abstract interface Cronet_UploadDataProvider is implemented by the app. +// The following concrete methods forward call to app implementation. +// The app doesn't normally call them. +CRONET_EXPORT +int64_t Cronet_UploadDataProvider_GetLength(Cronet_UploadDataProviderPtr self); +CRONET_EXPORT +void Cronet_UploadDataProvider_Read(Cronet_UploadDataProviderPtr self, + Cronet_UploadDataSinkPtr upload_data_sink, + Cronet_BufferPtr buffer); +CRONET_EXPORT +void Cronet_UploadDataProvider_Rewind( + Cronet_UploadDataProviderPtr self, + Cronet_UploadDataSinkPtr upload_data_sink); +CRONET_EXPORT +void Cronet_UploadDataProvider_Close(Cronet_UploadDataProviderPtr self); +// The app implements abstract interface Cronet_UploadDataProvider by defining +// custom functions for each method. +typedef int64_t (*Cronet_UploadDataProvider_GetLengthFunc)( + Cronet_UploadDataProviderPtr self); +typedef void (*Cronet_UploadDataProvider_ReadFunc)( + Cronet_UploadDataProviderPtr self, + Cronet_UploadDataSinkPtr upload_data_sink, + Cronet_BufferPtr buffer); +typedef void (*Cronet_UploadDataProvider_RewindFunc)( + Cronet_UploadDataProviderPtr self, + Cronet_UploadDataSinkPtr upload_data_sink); +typedef void (*Cronet_UploadDataProvider_CloseFunc)( + Cronet_UploadDataProviderPtr self); +// The app creates an instance of Cronet_UploadDataProvider by providing custom +// functions for each method. +CRONET_EXPORT Cronet_UploadDataProviderPtr Cronet_UploadDataProvider_CreateWith( + Cronet_UploadDataProvider_GetLengthFunc GetLengthFunc, + Cronet_UploadDataProvider_ReadFunc ReadFunc, + Cronet_UploadDataProvider_RewindFunc RewindFunc, + Cronet_UploadDataProvider_CloseFunc CloseFunc); /////////////////////// // Concrete interface Cronet_UrlRequest. @@ -603,8 +601,8 @@ CRONET_EXPORT void Cronet_UrlRequest_SetClientContext( Cronet_ClientContext client_context); CRONET_EXPORT Cronet_ClientContext Cronet_UrlRequest_GetClientContext(Cronet_UrlRequestPtr self); -// // Concrete methods of Cronet_UrlRequest implemented by Cronet. -// // The app calls them to manipulate Cronet_UrlRequest. +// Concrete methods of Cronet_UrlRequest implemented by Cronet. +// The app calls them to manipulate Cronet_UrlRequest. CRONET_EXPORT Cronet_RESULT Cronet_UrlRequest_InitWithParams( Cronet_UrlRequestPtr self, @@ -622,13 +620,13 @@ Cronet_RESULT Cronet_UrlRequest_Read(Cronet_UrlRequestPtr self, Cronet_BufferPtr buffer); CRONET_EXPORT void Cronet_UrlRequest_Cancel(Cronet_UrlRequestPtr self); -// CRONET_EXPORT -// bool Cronet_UrlRequest_IsDone(Cronet_UrlRequestPtr self); -// CRONET_EXPORT -// void Cronet_UrlRequest_GetStatus(Cronet_UrlRequestPtr self, -// Cronet_UrlRequestStatusListenerPtr listener); -// // Concrete interface Cronet_UrlRequest is implemented by Cronet. -// // The app can implement these for testing / mocking. +CRONET_EXPORT +bool Cronet_UrlRequest_IsDone(Cronet_UrlRequestPtr self); +CRONET_EXPORT +void Cronet_UrlRequest_GetStatus(Cronet_UrlRequestPtr self, + Cronet_UrlRequestStatusListenerPtr listener); +// Concrete interface Cronet_UrlRequest is implemented by Cronet. +// The app can implement these for testing / mocking. typedef Cronet_RESULT (*Cronet_UrlRequest_InitWithParamsFunc)( Cronet_UrlRequestPtr self, Cronet_EnginePtr engine, @@ -646,8 +644,8 @@ typedef bool (*Cronet_UrlRequest_IsDoneFunc)(Cronet_UrlRequestPtr self); typedef void (*Cronet_UrlRequest_GetStatusFunc)( Cronet_UrlRequestPtr self, Cronet_UrlRequestStatusListenerPtr listener); -// // Concrete interface Cronet_UrlRequest is implemented by Cronet. -// // The app can use this for testing / mocking. +// Concrete interface Cronet_UrlRequest is implemented by Cronet. +// The app can use this for testing / mocking. CRONET_EXPORT Cronet_UrlRequestPtr Cronet_UrlRequest_CreateWith( Cronet_UrlRequest_InitWithParamsFunc InitWithParamsFunc, Cronet_UrlRequest_StartFunc StartFunc, @@ -657,77 +655,77 @@ CRONET_EXPORT Cronet_UrlRequestPtr Cronet_UrlRequest_CreateWith( Cronet_UrlRequest_IsDoneFunc IsDoneFunc, Cronet_UrlRequest_GetStatusFunc GetStatusFunc); -// /////////////////////// -// // Abstract interface Cronet_RequestFinishedInfoListener is implemented by the -// // app. +/////////////////////// +// Abstract interface Cronet_RequestFinishedInfoListener is implemented by the +// app. -// // There is no method to create a concrete implementation. +// There is no method to create a concrete implementation. -// // Destroy an instance of Cronet_RequestFinishedInfoListener. -// CRONET_EXPORT void Cronet_RequestFinishedInfoListener_Destroy( -// Cronet_RequestFinishedInfoListenerPtr self); -// // Set and get app-specific Cronet_ClientContext. -// CRONET_EXPORT void Cronet_RequestFinishedInfoListener_SetClientContext( -// Cronet_RequestFinishedInfoListenerPtr self, -// Cronet_ClientContext client_context); -// CRONET_EXPORT Cronet_ClientContext -// Cronet_RequestFinishedInfoListener_GetClientContext( -// Cronet_RequestFinishedInfoListenerPtr self); -// // Abstract interface Cronet_RequestFinishedInfoListener is implemented by the -// // app. The following concrete methods forward call to app implementation. The -// // app doesn't normally call them. -// CRONET_EXPORT -// void Cronet_RequestFinishedInfoListener_OnRequestFinished( -// Cronet_RequestFinishedInfoListenerPtr self, -// Cronet_RequestFinishedInfoPtr request_info, -// Cronet_UrlResponseInfoPtr response_info, -// Cronet_ErrorPtr error); -// // The app implements abstract interface Cronet_RequestFinishedInfoListener by -// // defining custom functions for each method. -// typedef void (*Cronet_RequestFinishedInfoListener_OnRequestFinishedFunc)( -// Cronet_RequestFinishedInfoListenerPtr self, -// Cronet_RequestFinishedInfoPtr request_info, -// Cronet_UrlResponseInfoPtr response_info, -// Cronet_ErrorPtr error); -// // The app creates an instance of Cronet_RequestFinishedInfoListener by -// // providing custom functions for each method. -// CRONET_EXPORT Cronet_RequestFinishedInfoListenerPtr -// Cronet_RequestFinishedInfoListener_CreateWith( -// Cronet_RequestFinishedInfoListener_OnRequestFinishedFunc -// OnRequestFinishedFunc); +// Destroy an instance of Cronet_RequestFinishedInfoListener. +CRONET_EXPORT void Cronet_RequestFinishedInfoListener_Destroy( + Cronet_RequestFinishedInfoListenerPtr self); +// Set and get app-specific Cronet_ClientContext. +CRONET_EXPORT void Cronet_RequestFinishedInfoListener_SetClientContext( + Cronet_RequestFinishedInfoListenerPtr self, + Cronet_ClientContext client_context); +CRONET_EXPORT Cronet_ClientContext +Cronet_RequestFinishedInfoListener_GetClientContext( + Cronet_RequestFinishedInfoListenerPtr self); +// Abstract interface Cronet_RequestFinishedInfoListener is implemented by the +// app. The following concrete methods forward call to app implementation. The +// app doesn't normally call them. +CRONET_EXPORT +void Cronet_RequestFinishedInfoListener_OnRequestFinished( + Cronet_RequestFinishedInfoListenerPtr self, + Cronet_RequestFinishedInfoPtr request_info, + Cronet_UrlResponseInfoPtr response_info, + Cronet_ErrorPtr error); +// The app implements abstract interface Cronet_RequestFinishedInfoListener by +// defining custom functions for each method. +typedef void (*Cronet_RequestFinishedInfoListener_OnRequestFinishedFunc)( + Cronet_RequestFinishedInfoListenerPtr self, + Cronet_RequestFinishedInfoPtr request_info, + Cronet_UrlResponseInfoPtr response_info, + Cronet_ErrorPtr error); +// The app creates an instance of Cronet_RequestFinishedInfoListener by +// providing custom functions for each method. +CRONET_EXPORT Cronet_RequestFinishedInfoListenerPtr +Cronet_RequestFinishedInfoListener_CreateWith( + Cronet_RequestFinishedInfoListener_OnRequestFinishedFunc + OnRequestFinishedFunc); -// /////////////////////// -// // Struct Cronet_Error. -// CRONET_EXPORT Cronet_ErrorPtr Cronet_Error_Create(void); -// CRONET_EXPORT void Cronet_Error_Destroy(Cronet_ErrorPtr self); -// // Cronet_Error setters. -// CRONET_EXPORT -// void Cronet_Error_error_code_set(Cronet_ErrorPtr self, -// const Cronet_Error_ERROR_CODE error_code); -// CRONET_EXPORT -// void Cronet_Error_message_set(Cronet_ErrorPtr self, -// const Cronet_String message); -// CRONET_EXPORT -// void Cronet_Error_internal_error_code_set(Cronet_ErrorPtr self, -// const int32_t internal_error_code); -// CRONET_EXPORT -// void Cronet_Error_immediately_retryable_set(Cronet_ErrorPtr self, -// const bool immediately_retryable); -// CRONET_EXPORT -// void Cronet_Error_quic_detailed_error_code_set( -// Cronet_ErrorPtr self, -// const int32_t quic_detailed_error_code); -// // Cronet_Error getters. -// CRONET_EXPORT -// Cronet_Error_ERROR_CODE Cronet_Error_error_code_get(const Cronet_ErrorPtr self); +/////////////////////// +// Struct Cronet_Error. +CRONET_EXPORT Cronet_ErrorPtr Cronet_Error_Create(void); +CRONET_EXPORT void Cronet_Error_Destroy(Cronet_ErrorPtr self); +// Cronet_Error setters. +CRONET_EXPORT +void Cronet_Error_error_code_set(Cronet_ErrorPtr self, + const Cronet_Error_ERROR_CODE error_code); +CRONET_EXPORT +void Cronet_Error_message_set(Cronet_ErrorPtr self, + const Cronet_String message); +CRONET_EXPORT +void Cronet_Error_internal_error_code_set(Cronet_ErrorPtr self, + const int32_t internal_error_code); +CRONET_EXPORT +void Cronet_Error_immediately_retryable_set(Cronet_ErrorPtr self, + const bool immediately_retryable); +CRONET_EXPORT +void Cronet_Error_quic_detailed_error_code_set( + Cronet_ErrorPtr self, + const int32_t quic_detailed_error_code); +// Cronet_Error getters. +CRONET_EXPORT +Cronet_Error_ERROR_CODE Cronet_Error_error_code_get(const Cronet_ErrorPtr self); CRONET_EXPORT Cronet_String Cronet_Error_message_get(const Cronet_ErrorPtr self); CRONET_EXPORT int32_t Cronet_Error_internal_error_code_get(const Cronet_ErrorPtr self); -// CRONET_EXPORT -// bool Cronet_Error_immediately_retryable_get(const Cronet_ErrorPtr self); -// CRONET_EXPORT -// int32_t Cronet_Error_quic_detailed_error_code_get(const Cronet_ErrorPtr self); +CRONET_EXPORT +bool Cronet_Error_immediately_retryable_get(const Cronet_ErrorPtr self); +CRONET_EXPORT +int32_t Cronet_Error_quic_detailed_error_code_get(const Cronet_ErrorPtr self); /////////////////////// // Struct Cronet_QuicHint. @@ -742,49 +740,49 @@ void Cronet_QuicHint_port_set(Cronet_QuicHintPtr self, const int32_t port); CRONET_EXPORT void Cronet_QuicHint_alternate_port_set(Cronet_QuicHintPtr self, const int32_t alternate_port); -// // Cronet_QuicHint getters. -// CRONET_EXPORT -// Cronet_String Cronet_QuicHint_host_get(const Cronet_QuicHintPtr self); -// CRONET_EXPORT -// int32_t Cronet_QuicHint_port_get(const Cronet_QuicHintPtr self); -// CRONET_EXPORT -// int32_t Cronet_QuicHint_alternate_port_get(const Cronet_QuicHintPtr self); +// Cronet_QuicHint getters. +CRONET_EXPORT +Cronet_String Cronet_QuicHint_host_get(const Cronet_QuicHintPtr self); +CRONET_EXPORT +int32_t Cronet_QuicHint_port_get(const Cronet_QuicHintPtr self); +CRONET_EXPORT +int32_t Cronet_QuicHint_alternate_port_get(const Cronet_QuicHintPtr self); -// /////////////////////// -// // Struct Cronet_PublicKeyPins. -// CRONET_EXPORT Cronet_PublicKeyPinsPtr Cronet_PublicKeyPins_Create(void); -// CRONET_EXPORT void Cronet_PublicKeyPins_Destroy(Cronet_PublicKeyPinsPtr self); -// // Cronet_PublicKeyPins setters. -// CRONET_EXPORT -// void Cronet_PublicKeyPins_host_set(Cronet_PublicKeyPinsPtr self, -// const Cronet_String host); -// CRONET_EXPORT -// void Cronet_PublicKeyPins_pins_sha256_add(Cronet_PublicKeyPinsPtr self, -// const Cronet_String element); -// CRONET_EXPORT -// void Cronet_PublicKeyPins_include_subdomains_set(Cronet_PublicKeyPinsPtr self, -// const bool include_subdomains); -// CRONET_EXPORT -// void Cronet_PublicKeyPins_expiration_date_set(Cronet_PublicKeyPinsPtr self, -// const int64_t expiration_date); -// // Cronet_PublicKeyPins getters. -// CRONET_EXPORT -// Cronet_String Cronet_PublicKeyPins_host_get(const Cronet_PublicKeyPinsPtr self); -// CRONET_EXPORT -// uint32_t Cronet_PublicKeyPins_pins_sha256_size( -// const Cronet_PublicKeyPinsPtr self); -// CRONET_EXPORT -// Cronet_String Cronet_PublicKeyPins_pins_sha256_at( -// const Cronet_PublicKeyPinsPtr self, -// uint32_t index); -// CRONET_EXPORT -// void Cronet_PublicKeyPins_pins_sha256_clear(Cronet_PublicKeyPinsPtr self); -// CRONET_EXPORT -// bool Cronet_PublicKeyPins_include_subdomains_get( -// const Cronet_PublicKeyPinsPtr self); -// CRONET_EXPORT -// int64_t Cronet_PublicKeyPins_expiration_date_get( -// const Cronet_PublicKeyPinsPtr self); +/////////////////////// +// Struct Cronet_PublicKeyPins. +CRONET_EXPORT Cronet_PublicKeyPinsPtr Cronet_PublicKeyPins_Create(void); +CRONET_EXPORT void Cronet_PublicKeyPins_Destroy(Cronet_PublicKeyPinsPtr self); +// Cronet_PublicKeyPins setters. +CRONET_EXPORT +void Cronet_PublicKeyPins_host_set(Cronet_PublicKeyPinsPtr self, + const Cronet_String host); +CRONET_EXPORT +void Cronet_PublicKeyPins_pins_sha256_add(Cronet_PublicKeyPinsPtr self, + const Cronet_String element); +CRONET_EXPORT +void Cronet_PublicKeyPins_include_subdomains_set(Cronet_PublicKeyPinsPtr self, + const bool include_subdomains); +CRONET_EXPORT +void Cronet_PublicKeyPins_expiration_date_set(Cronet_PublicKeyPinsPtr self, + const int64_t expiration_date); +// Cronet_PublicKeyPins getters. +CRONET_EXPORT +Cronet_String Cronet_PublicKeyPins_host_get(const Cronet_PublicKeyPinsPtr self); +CRONET_EXPORT +uint32_t Cronet_PublicKeyPins_pins_sha256_size( + const Cronet_PublicKeyPinsPtr self); +CRONET_EXPORT +Cronet_String Cronet_PublicKeyPins_pins_sha256_at( + const Cronet_PublicKeyPinsPtr self, + uint32_t index); +CRONET_EXPORT +void Cronet_PublicKeyPins_pins_sha256_clear(Cronet_PublicKeyPinsPtr self); +CRONET_EXPORT +bool Cronet_PublicKeyPins_include_subdomains_get( + const Cronet_PublicKeyPinsPtr self); +CRONET_EXPORT +int64_t Cronet_PublicKeyPins_expiration_date_get( + const Cronet_PublicKeyPinsPtr self); /////////////////////// // Struct Cronet_EngineParams. @@ -825,73 +823,73 @@ void Cronet_EngineParams_http_cache_max_size_set( CRONET_EXPORT void Cronet_EngineParams_quic_hints_add(Cronet_EngineParamsPtr self, const Cronet_QuicHintPtr element); -// CRONET_EXPORT -// void Cronet_EngineParams_public_key_pins_add( -// Cronet_EngineParamsPtr self, -// const Cronet_PublicKeyPinsPtr element); -// CRONET_EXPORT -// void Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_set( -// Cronet_EngineParamsPtr self, -// const bool enable_public_key_pinning_bypass_for_local_trust_anchors); -// CRONET_EXPORT -// void Cronet_EngineParams_network_thread_priority_set( -// Cronet_EngineParamsPtr self, -// const double network_thread_priority); -// CRONET_EXPORT -// void Cronet_EngineParams_experimental_options_set( -// Cronet_EngineParamsPtr self, -// const Cronet_String experimental_options); -// // Cronet_EngineParams getters. -// CRONET_EXPORT -// bool Cronet_EngineParams_enable_check_result_get( -// const Cronet_EngineParamsPtr self); -// CRONET_EXPORT -// Cronet_String Cronet_EngineParams_user_agent_get( -// const Cronet_EngineParamsPtr self); -// CRONET_EXPORT -// Cronet_String Cronet_EngineParams_accept_language_get( -// const Cronet_EngineParamsPtr self); -// CRONET_EXPORT -// Cronet_String Cronet_EngineParams_storage_path_get( -// const Cronet_EngineParamsPtr self); -// CRONET_EXPORT -// bool Cronet_EngineParams_enable_quic_get(const Cronet_EngineParamsPtr self); -// CRONET_EXPORT -// bool Cronet_EngineParams_enable_http2_get(const Cronet_EngineParamsPtr self); -// CRONET_EXPORT -// bool Cronet_EngineParams_enable_brotli_get(const Cronet_EngineParamsPtr self); -// CRONET_EXPORT -// Cronet_EngineParams_HTTP_CACHE_MODE Cronet_EngineParams_http_cache_mode_get( -// const Cronet_EngineParamsPtr self); -// CRONET_EXPORT -// int64_t Cronet_EngineParams_http_cache_max_size_get( -// const Cronet_EngineParamsPtr self); -// CRONET_EXPORT -// uint32_t Cronet_EngineParams_quic_hints_size(const Cronet_EngineParamsPtr self); -// CRONET_EXPORT -// Cronet_QuicHintPtr Cronet_EngineParams_quic_hints_at( -// const Cronet_EngineParamsPtr self, -// uint32_t index); -// CRONET_EXPORT -// void Cronet_EngineParams_quic_hints_clear(Cronet_EngineParamsPtr self); -// CRONET_EXPORT -// uint32_t Cronet_EngineParams_public_key_pins_size( -// const Cronet_EngineParamsPtr self); -// CRONET_EXPORT -// Cronet_PublicKeyPinsPtr Cronet_EngineParams_public_key_pins_at( -// const Cronet_EngineParamsPtr self, -// uint32_t index); -// CRONET_EXPORT -// void Cronet_EngineParams_public_key_pins_clear(Cronet_EngineParamsPtr self); -// CRONET_EXPORT -// bool Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_get( -// const Cronet_EngineParamsPtr self); -// CRONET_EXPORT -// double Cronet_EngineParams_network_thread_priority_get( -// const Cronet_EngineParamsPtr self); -// CRONET_EXPORT -// Cronet_String Cronet_EngineParams_experimental_options_get( -// const Cronet_EngineParamsPtr self); +CRONET_EXPORT +void Cronet_EngineParams_public_key_pins_add( + Cronet_EngineParamsPtr self, + const Cronet_PublicKeyPinsPtr element); +CRONET_EXPORT +void Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_set( + Cronet_EngineParamsPtr self, + const bool enable_public_key_pinning_bypass_for_local_trust_anchors); +CRONET_EXPORT +void Cronet_EngineParams_network_thread_priority_set( + Cronet_EngineParamsPtr self, + const double network_thread_priority); +CRONET_EXPORT +void Cronet_EngineParams_experimental_options_set( + Cronet_EngineParamsPtr self, + const Cronet_String experimental_options); +// Cronet_EngineParams getters. +CRONET_EXPORT +bool Cronet_EngineParams_enable_check_result_get( + const Cronet_EngineParamsPtr self); +CRONET_EXPORT +Cronet_String Cronet_EngineParams_user_agent_get( + const Cronet_EngineParamsPtr self); +CRONET_EXPORT +Cronet_String Cronet_EngineParams_accept_language_get( + const Cronet_EngineParamsPtr self); +CRONET_EXPORT +Cronet_String Cronet_EngineParams_storage_path_get( + const Cronet_EngineParamsPtr self); +CRONET_EXPORT +bool Cronet_EngineParams_enable_quic_get(const Cronet_EngineParamsPtr self); +CRONET_EXPORT +bool Cronet_EngineParams_enable_http2_get(const Cronet_EngineParamsPtr self); +CRONET_EXPORT +bool Cronet_EngineParams_enable_brotli_get(const Cronet_EngineParamsPtr self); +CRONET_EXPORT +Cronet_EngineParams_HTTP_CACHE_MODE Cronet_EngineParams_http_cache_mode_get( + const Cronet_EngineParamsPtr self); +CRONET_EXPORT +int64_t Cronet_EngineParams_http_cache_max_size_get( + const Cronet_EngineParamsPtr self); +CRONET_EXPORT +uint32_t Cronet_EngineParams_quic_hints_size(const Cronet_EngineParamsPtr self); +CRONET_EXPORT +Cronet_QuicHintPtr Cronet_EngineParams_quic_hints_at( + const Cronet_EngineParamsPtr self, + uint32_t index); +CRONET_EXPORT +void Cronet_EngineParams_quic_hints_clear(Cronet_EngineParamsPtr self); +CRONET_EXPORT +uint32_t Cronet_EngineParams_public_key_pins_size( + const Cronet_EngineParamsPtr self); +CRONET_EXPORT +Cronet_PublicKeyPinsPtr Cronet_EngineParams_public_key_pins_at( + const Cronet_EngineParamsPtr self, + uint32_t index); +CRONET_EXPORT +void Cronet_EngineParams_public_key_pins_clear(Cronet_EngineParamsPtr self); +CRONET_EXPORT +bool Cronet_EngineParams_enable_public_key_pinning_bypass_for_local_trust_anchors_get( + const Cronet_EngineParamsPtr self); +CRONET_EXPORT +double Cronet_EngineParams_network_thread_priority_get( + const Cronet_EngineParamsPtr self); +CRONET_EXPORT +Cronet_String Cronet_EngineParams_experimental_options_get( + const Cronet_EngineParamsPtr self); /////////////////////// // Struct Cronet_HttpHeader. @@ -904,91 +902,91 @@ void Cronet_HttpHeader_name_set(Cronet_HttpHeaderPtr self, CRONET_EXPORT void Cronet_HttpHeader_value_set(Cronet_HttpHeaderPtr self, const Cronet_String value); -// // Cronet_HttpHeader getters. -// CRONET_EXPORT -// Cronet_String Cronet_HttpHeader_name_get(const Cronet_HttpHeaderPtr self); -// CRONET_EXPORT -// Cronet_String Cronet_HttpHeader_value_get(const Cronet_HttpHeaderPtr self); +// Cronet_HttpHeader getters. +CRONET_EXPORT +Cronet_String Cronet_HttpHeader_name_get(const Cronet_HttpHeaderPtr self); +CRONET_EXPORT +Cronet_String Cronet_HttpHeader_value_get(const Cronet_HttpHeaderPtr self); -// /////////////////////// -// // Struct Cronet_UrlResponseInfo. -// CRONET_EXPORT Cronet_UrlResponseInfoPtr Cronet_UrlResponseInfo_Create(void); -// CRONET_EXPORT void Cronet_UrlResponseInfo_Destroy( -// Cronet_UrlResponseInfoPtr self); -// // Cronet_UrlResponseInfo setters. -// CRONET_EXPORT -// void Cronet_UrlResponseInfo_url_set(Cronet_UrlResponseInfoPtr self, -// const Cronet_String url); -// CRONET_EXPORT -// void Cronet_UrlResponseInfo_url_chain_add(Cronet_UrlResponseInfoPtr self, -// const Cronet_String element); -// CRONET_EXPORT -// void Cronet_UrlResponseInfo_http_status_code_set( -// Cronet_UrlResponseInfoPtr self, -// const int32_t http_status_code); -// CRONET_EXPORT -// void Cronet_UrlResponseInfo_http_status_text_set( -// Cronet_UrlResponseInfoPtr self, -// const Cronet_String http_status_text); -// CRONET_EXPORT -// void Cronet_UrlResponseInfo_all_headers_list_add( -// Cronet_UrlResponseInfoPtr self, -// const Cronet_HttpHeaderPtr element); -// CRONET_EXPORT -// void Cronet_UrlResponseInfo_was_cached_set(Cronet_UrlResponseInfoPtr self, -// const bool was_cached); -// CRONET_EXPORT -// void Cronet_UrlResponseInfo_negotiated_protocol_set( -// Cronet_UrlResponseInfoPtr self, -// const Cronet_String negotiated_protocol); -// CRONET_EXPORT -// void Cronet_UrlResponseInfo_proxy_server_set(Cronet_UrlResponseInfoPtr self, -// const Cronet_String proxy_server); -// CRONET_EXPORT -// void Cronet_UrlResponseInfo_received_byte_count_set( -// Cronet_UrlResponseInfoPtr self, -// const int64_t received_byte_count); -// // Cronet_UrlResponseInfo getters. -// CRONET_EXPORT -// Cronet_String Cronet_UrlResponseInfo_url_get( -// const Cronet_UrlResponseInfoPtr self); -// CRONET_EXPORT -// uint32_t Cronet_UrlResponseInfo_url_chain_size( -// const Cronet_UrlResponseInfoPtr self); -// CRONET_EXPORT -// Cronet_String Cronet_UrlResponseInfo_url_chain_at( -// const Cronet_UrlResponseInfoPtr self, -// uint32_t index); -// CRONET_EXPORT -// void Cronet_UrlResponseInfo_url_chain_clear(Cronet_UrlResponseInfoPtr self); +/////////////////////// +// Struct Cronet_UrlResponseInfo. +CRONET_EXPORT Cronet_UrlResponseInfoPtr Cronet_UrlResponseInfo_Create(void); +CRONET_EXPORT void Cronet_UrlResponseInfo_Destroy( + Cronet_UrlResponseInfoPtr self); +// Cronet_UrlResponseInfo setters. +CRONET_EXPORT +void Cronet_UrlResponseInfo_url_set(Cronet_UrlResponseInfoPtr self, + const Cronet_String url); +CRONET_EXPORT +void Cronet_UrlResponseInfo_url_chain_add(Cronet_UrlResponseInfoPtr self, + const Cronet_String element); +CRONET_EXPORT +void Cronet_UrlResponseInfo_http_status_code_set( + Cronet_UrlResponseInfoPtr self, + const int32_t http_status_code); +CRONET_EXPORT +void Cronet_UrlResponseInfo_http_status_text_set( + Cronet_UrlResponseInfoPtr self, + const Cronet_String http_status_text); +CRONET_EXPORT +void Cronet_UrlResponseInfo_all_headers_list_add( + Cronet_UrlResponseInfoPtr self, + const Cronet_HttpHeaderPtr element); +CRONET_EXPORT +void Cronet_UrlResponseInfo_was_cached_set(Cronet_UrlResponseInfoPtr self, + const bool was_cached); +CRONET_EXPORT +void Cronet_UrlResponseInfo_negotiated_protocol_set( + Cronet_UrlResponseInfoPtr self, + const Cronet_String negotiated_protocol); +CRONET_EXPORT +void Cronet_UrlResponseInfo_proxy_server_set(Cronet_UrlResponseInfoPtr self, + const Cronet_String proxy_server); +CRONET_EXPORT +void Cronet_UrlResponseInfo_received_byte_count_set( + Cronet_UrlResponseInfoPtr self, + const int64_t received_byte_count); +// Cronet_UrlResponseInfo getters. +CRONET_EXPORT +Cronet_String Cronet_UrlResponseInfo_url_get( + const Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +uint32_t Cronet_UrlResponseInfo_url_chain_size( + const Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +Cronet_String Cronet_UrlResponseInfo_url_chain_at( + const Cronet_UrlResponseInfoPtr self, + uint32_t index); +CRONET_EXPORT +void Cronet_UrlResponseInfo_url_chain_clear(Cronet_UrlResponseInfoPtr self); CRONET_EXPORT int32_t Cronet_UrlResponseInfo_http_status_code_get( const Cronet_UrlResponseInfoPtr self); CRONET_EXPORT Cronet_String Cronet_UrlResponseInfo_http_status_text_get( const Cronet_UrlResponseInfoPtr self); -// CRONET_EXPORT -// uint32_t Cronet_UrlResponseInfo_all_headers_list_size( -// const Cronet_UrlResponseInfoPtr self); -// CRONET_EXPORT -// Cronet_HttpHeaderPtr Cronet_UrlResponseInfo_all_headers_list_at( -// const Cronet_UrlResponseInfoPtr self, -// uint32_t index); -// CRONET_EXPORT -// void Cronet_UrlResponseInfo_all_headers_list_clear( -// Cronet_UrlResponseInfoPtr self); -// CRONET_EXPORT -// bool Cronet_UrlResponseInfo_was_cached_get( -// const Cronet_UrlResponseInfoPtr self); -// CRONET_EXPORT -// Cronet_String Cronet_UrlResponseInfo_negotiated_protocol_get( -// const Cronet_UrlResponseInfoPtr self); -// CRONET_EXPORT -// Cronet_String Cronet_UrlResponseInfo_proxy_server_get( -// const Cronet_UrlResponseInfoPtr self); -// CRONET_EXPORT -// int64_t Cronet_UrlResponseInfo_received_byte_count_get( -// const Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +uint32_t Cronet_UrlResponseInfo_all_headers_list_size( + const Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +Cronet_HttpHeaderPtr Cronet_UrlResponseInfo_all_headers_list_at( + const Cronet_UrlResponseInfoPtr self, + uint32_t index); +CRONET_EXPORT +void Cronet_UrlResponseInfo_all_headers_list_clear( + Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +bool Cronet_UrlResponseInfo_was_cached_get( + const Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +Cronet_String Cronet_UrlResponseInfo_negotiated_protocol_get( + const Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +Cronet_String Cronet_UrlResponseInfo_proxy_server_get( + const Cronet_UrlResponseInfoPtr self); +CRONET_EXPORT +int64_t Cronet_UrlResponseInfo_received_byte_count_get( + const Cronet_UrlResponseInfoPtr self); /////////////////////// // Struct Cronet_UrlRequestParams. @@ -1003,283 +1001,283 @@ CRONET_EXPORT void Cronet_UrlRequestParams_request_headers_add( Cronet_UrlRequestParamsPtr self, const Cronet_HttpHeaderPtr element); -// CRONET_EXPORT -// void Cronet_UrlRequestParams_disable_cache_set(Cronet_UrlRequestParamsPtr self, -// const bool disable_cache); -// CRONET_EXPORT -// void Cronet_UrlRequestParams_priority_set( -// Cronet_UrlRequestParamsPtr self, -// const Cronet_UrlRequestParams_REQUEST_PRIORITY priority); -// CRONET_EXPORT -// void Cronet_UrlRequestParams_upload_data_provider_set( -// Cronet_UrlRequestParamsPtr self, -// const Cronet_UploadDataProviderPtr upload_data_provider); -// CRONET_EXPORT -// void Cronet_UrlRequestParams_upload_data_provider_executor_set( -// Cronet_UrlRequestParamsPtr self, -// const Cronet_ExecutorPtr upload_data_provider_executor); -// CRONET_EXPORT -// void Cronet_UrlRequestParams_allow_direct_executor_set( -// Cronet_UrlRequestParamsPtr self, -// const bool allow_direct_executor); -// CRONET_EXPORT -// void Cronet_UrlRequestParams_annotations_add(Cronet_UrlRequestParamsPtr self, -// const Cronet_RawDataPtr element); -// CRONET_EXPORT -// void Cronet_UrlRequestParams_request_finished_listener_set( -// Cronet_UrlRequestParamsPtr self, -// const Cronet_RequestFinishedInfoListenerPtr request_finished_listener); -// CRONET_EXPORT -// void Cronet_UrlRequestParams_request_finished_executor_set( -// Cronet_UrlRequestParamsPtr self, -// const Cronet_ExecutorPtr request_finished_executor); -// CRONET_EXPORT -// void Cronet_UrlRequestParams_idempotency_set( -// Cronet_UrlRequestParamsPtr self, -// const Cronet_UrlRequestParams_IDEMPOTENCY idempotency); -// // Cronet_UrlRequestParams getters. -// CRONET_EXPORT -// Cronet_String Cronet_UrlRequestParams_http_method_get( -// const Cronet_UrlRequestParamsPtr self); -// CRONET_EXPORT -// uint32_t Cronet_UrlRequestParams_request_headers_size( -// const Cronet_UrlRequestParamsPtr self); -// CRONET_EXPORT -// Cronet_HttpHeaderPtr Cronet_UrlRequestParams_request_headers_at( -// const Cronet_UrlRequestParamsPtr self, -// uint32_t index); -// CRONET_EXPORT -// void Cronet_UrlRequestParams_request_headers_clear( -// Cronet_UrlRequestParamsPtr self); -// CRONET_EXPORT -// bool Cronet_UrlRequestParams_disable_cache_get( -// const Cronet_UrlRequestParamsPtr self); -// CRONET_EXPORT -// Cronet_UrlRequestParams_REQUEST_PRIORITY Cronet_UrlRequestParams_priority_get( -// const Cronet_UrlRequestParamsPtr self); -// CRONET_EXPORT -// Cronet_UploadDataProviderPtr Cronet_UrlRequestParams_upload_data_provider_get( -// const Cronet_UrlRequestParamsPtr self); -// CRONET_EXPORT -// Cronet_ExecutorPtr Cronet_UrlRequestParams_upload_data_provider_executor_get( -// const Cronet_UrlRequestParamsPtr self); -// CRONET_EXPORT -// bool Cronet_UrlRequestParams_allow_direct_executor_get( -// const Cronet_UrlRequestParamsPtr self); -// CRONET_EXPORT -// uint32_t Cronet_UrlRequestParams_annotations_size( -// const Cronet_UrlRequestParamsPtr self); -// CRONET_EXPORT -// Cronet_RawDataPtr Cronet_UrlRequestParams_annotations_at( -// const Cronet_UrlRequestParamsPtr self, -// uint32_t index); -// CRONET_EXPORT -// void Cronet_UrlRequestParams_annotations_clear(Cronet_UrlRequestParamsPtr self); -// CRONET_EXPORT -// Cronet_RequestFinishedInfoListenerPtr -// Cronet_UrlRequestParams_request_finished_listener_get( -// const Cronet_UrlRequestParamsPtr self); -// CRONET_EXPORT -// Cronet_ExecutorPtr Cronet_UrlRequestParams_request_finished_executor_get( -// const Cronet_UrlRequestParamsPtr self); -// CRONET_EXPORT -// Cronet_UrlRequestParams_IDEMPOTENCY Cronet_UrlRequestParams_idempotency_get( -// const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +void Cronet_UrlRequestParams_disable_cache_set(Cronet_UrlRequestParamsPtr self, + const bool disable_cache); +CRONET_EXPORT +void Cronet_UrlRequestParams_priority_set( + Cronet_UrlRequestParamsPtr self, + const Cronet_UrlRequestParams_REQUEST_PRIORITY priority); +CRONET_EXPORT +void Cronet_UrlRequestParams_upload_data_provider_set( + Cronet_UrlRequestParamsPtr self, + const Cronet_UploadDataProviderPtr upload_data_provider); +CRONET_EXPORT +void Cronet_UrlRequestParams_upload_data_provider_executor_set( + Cronet_UrlRequestParamsPtr self, + const Cronet_ExecutorPtr upload_data_provider_executor); +CRONET_EXPORT +void Cronet_UrlRequestParams_allow_direct_executor_set( + Cronet_UrlRequestParamsPtr self, + const bool allow_direct_executor); +CRONET_EXPORT +void Cronet_UrlRequestParams_annotations_add(Cronet_UrlRequestParamsPtr self, + const Cronet_RawDataPtr element); +CRONET_EXPORT +void Cronet_UrlRequestParams_request_finished_listener_set( + Cronet_UrlRequestParamsPtr self, + const Cronet_RequestFinishedInfoListenerPtr request_finished_listener); +CRONET_EXPORT +void Cronet_UrlRequestParams_request_finished_executor_set( + Cronet_UrlRequestParamsPtr self, + const Cronet_ExecutorPtr request_finished_executor); +CRONET_EXPORT +void Cronet_UrlRequestParams_idempotency_set( + Cronet_UrlRequestParamsPtr self, + const Cronet_UrlRequestParams_IDEMPOTENCY idempotency); +// Cronet_UrlRequestParams getters. +CRONET_EXPORT +Cronet_String Cronet_UrlRequestParams_http_method_get( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +uint32_t Cronet_UrlRequestParams_request_headers_size( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +Cronet_HttpHeaderPtr Cronet_UrlRequestParams_request_headers_at( + const Cronet_UrlRequestParamsPtr self, + uint32_t index); +CRONET_EXPORT +void Cronet_UrlRequestParams_request_headers_clear( + Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +bool Cronet_UrlRequestParams_disable_cache_get( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +Cronet_UrlRequestParams_REQUEST_PRIORITY Cronet_UrlRequestParams_priority_get( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +Cronet_UploadDataProviderPtr Cronet_UrlRequestParams_upload_data_provider_get( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +Cronet_ExecutorPtr Cronet_UrlRequestParams_upload_data_provider_executor_get( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +bool Cronet_UrlRequestParams_allow_direct_executor_get( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +uint32_t Cronet_UrlRequestParams_annotations_size( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +Cronet_RawDataPtr Cronet_UrlRequestParams_annotations_at( + const Cronet_UrlRequestParamsPtr self, + uint32_t index); +CRONET_EXPORT +void Cronet_UrlRequestParams_annotations_clear(Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +Cronet_RequestFinishedInfoListenerPtr +Cronet_UrlRequestParams_request_finished_listener_get( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +Cronet_ExecutorPtr Cronet_UrlRequestParams_request_finished_executor_get( + const Cronet_UrlRequestParamsPtr self); +CRONET_EXPORT +Cronet_UrlRequestParams_IDEMPOTENCY Cronet_UrlRequestParams_idempotency_get( + const Cronet_UrlRequestParamsPtr self); -// /////////////////////// -// // Struct Cronet_DateTime. -// CRONET_EXPORT Cronet_DateTimePtr Cronet_DateTime_Create(void); -// CRONET_EXPORT void Cronet_DateTime_Destroy(Cronet_DateTimePtr self); -// // Cronet_DateTime setters. -// CRONET_EXPORT -// void Cronet_DateTime_value_set(Cronet_DateTimePtr self, const int64_t value); -// // Cronet_DateTime getters. -// CRONET_EXPORT -// int64_t Cronet_DateTime_value_get(const Cronet_DateTimePtr self); +/////////////////////// +// Struct Cronet_DateTime. +CRONET_EXPORT Cronet_DateTimePtr Cronet_DateTime_Create(void); +CRONET_EXPORT void Cronet_DateTime_Destroy(Cronet_DateTimePtr self); +// Cronet_DateTime setters. +CRONET_EXPORT +void Cronet_DateTime_value_set(Cronet_DateTimePtr self, const int64_t value); +// Cronet_DateTime getters. +CRONET_EXPORT +int64_t Cronet_DateTime_value_get(const Cronet_DateTimePtr self); -// /////////////////////// -// // Struct Cronet_Metrics. -// CRONET_EXPORT Cronet_MetricsPtr Cronet_Metrics_Create(void); -// CRONET_EXPORT void Cronet_Metrics_Destroy(Cronet_MetricsPtr self); -// // Cronet_Metrics setters. -// CRONET_EXPORT -// void Cronet_Metrics_request_start_set(Cronet_MetricsPtr self, -// const Cronet_DateTimePtr request_start); -// // Move data from |request_start|. The caller retains ownership of -// // |request_start| and must destroy it. -// void Cronet_Metrics_request_start_move(Cronet_MetricsPtr self, -// Cronet_DateTimePtr request_start); -// CRONET_EXPORT -// void Cronet_Metrics_dns_start_set(Cronet_MetricsPtr self, -// const Cronet_DateTimePtr dns_start); -// // Move data from |dns_start|. The caller retains ownership of |dns_start| and -// // must destroy it. -// void Cronet_Metrics_dns_start_move(Cronet_MetricsPtr self, -// Cronet_DateTimePtr dns_start); -// CRONET_EXPORT -// void Cronet_Metrics_dns_end_set(Cronet_MetricsPtr self, -// const Cronet_DateTimePtr dns_end); -// // Move data from |dns_end|. The caller retains ownership of |dns_end| and must -// // destroy it. -// void Cronet_Metrics_dns_end_move(Cronet_MetricsPtr self, -// Cronet_DateTimePtr dns_end); -// CRONET_EXPORT -// void Cronet_Metrics_connect_start_set(Cronet_MetricsPtr self, -// const Cronet_DateTimePtr connect_start); -// // Move data from |connect_start|. The caller retains ownership of -// // |connect_start| and must destroy it. -// void Cronet_Metrics_connect_start_move(Cronet_MetricsPtr self, -// Cronet_DateTimePtr connect_start); -// CRONET_EXPORT -// void Cronet_Metrics_connect_end_set(Cronet_MetricsPtr self, -// const Cronet_DateTimePtr connect_end); -// // Move data from |connect_end|. The caller retains ownership of |connect_end| -// // and must destroy it. -// void Cronet_Metrics_connect_end_move(Cronet_MetricsPtr self, -// Cronet_DateTimePtr connect_end); -// CRONET_EXPORT -// void Cronet_Metrics_ssl_start_set(Cronet_MetricsPtr self, -// const Cronet_DateTimePtr ssl_start); -// // Move data from |ssl_start|. The caller retains ownership of |ssl_start| and -// // must destroy it. -// void Cronet_Metrics_ssl_start_move(Cronet_MetricsPtr self, -// Cronet_DateTimePtr ssl_start); -// CRONET_EXPORT -// void Cronet_Metrics_ssl_end_set(Cronet_MetricsPtr self, -// const Cronet_DateTimePtr ssl_end); -// // Move data from |ssl_end|. The caller retains ownership of |ssl_end| and must -// // destroy it. -// void Cronet_Metrics_ssl_end_move(Cronet_MetricsPtr self, -// Cronet_DateTimePtr ssl_end); -// CRONET_EXPORT -// void Cronet_Metrics_sending_start_set(Cronet_MetricsPtr self, -// const Cronet_DateTimePtr sending_start); -// // Move data from |sending_start|. The caller retains ownership of -// // |sending_start| and must destroy it. -// void Cronet_Metrics_sending_start_move(Cronet_MetricsPtr self, -// Cronet_DateTimePtr sending_start); -// CRONET_EXPORT -// void Cronet_Metrics_sending_end_set(Cronet_MetricsPtr self, -// const Cronet_DateTimePtr sending_end); -// // Move data from |sending_end|. The caller retains ownership of |sending_end| -// // and must destroy it. -// void Cronet_Metrics_sending_end_move(Cronet_MetricsPtr self, -// Cronet_DateTimePtr sending_end); -// CRONET_EXPORT -// void Cronet_Metrics_push_start_set(Cronet_MetricsPtr self, -// const Cronet_DateTimePtr push_start); -// // Move data from |push_start|. The caller retains ownership of |push_start| and -// // must destroy it. -// void Cronet_Metrics_push_start_move(Cronet_MetricsPtr self, -// Cronet_DateTimePtr push_start); -// CRONET_EXPORT -// void Cronet_Metrics_push_end_set(Cronet_MetricsPtr self, -// const Cronet_DateTimePtr push_end); -// // Move data from |push_end|. The caller retains ownership of |push_end| and -// // must destroy it. -// void Cronet_Metrics_push_end_move(Cronet_MetricsPtr self, -// Cronet_DateTimePtr push_end); -// CRONET_EXPORT -// void Cronet_Metrics_response_start_set(Cronet_MetricsPtr self, -// const Cronet_DateTimePtr response_start); -// // Move data from |response_start|. The caller retains ownership of -// // |response_start| and must destroy it. -// void Cronet_Metrics_response_start_move(Cronet_MetricsPtr self, -// Cronet_DateTimePtr response_start); -// CRONET_EXPORT -// void Cronet_Metrics_request_end_set(Cronet_MetricsPtr self, -// const Cronet_DateTimePtr request_end); -// // Move data from |request_end|. The caller retains ownership of |request_end| -// // and must destroy it. -// void Cronet_Metrics_request_end_move(Cronet_MetricsPtr self, -// Cronet_DateTimePtr request_end); -// CRONET_EXPORT -// void Cronet_Metrics_socket_reused_set(Cronet_MetricsPtr self, -// const bool socket_reused); -// CRONET_EXPORT -// void Cronet_Metrics_sent_byte_count_set(Cronet_MetricsPtr self, -// const int64_t sent_byte_count); -// CRONET_EXPORT -// void Cronet_Metrics_received_byte_count_set(Cronet_MetricsPtr self, -// const int64_t received_byte_count); -// // Cronet_Metrics getters. -// CRONET_EXPORT -// Cronet_DateTimePtr Cronet_Metrics_request_start_get( -// const Cronet_MetricsPtr self); -// CRONET_EXPORT -// Cronet_DateTimePtr Cronet_Metrics_dns_start_get(const Cronet_MetricsPtr self); -// CRONET_EXPORT -// Cronet_DateTimePtr Cronet_Metrics_dns_end_get(const Cronet_MetricsPtr self); -// CRONET_EXPORT -// Cronet_DateTimePtr Cronet_Metrics_connect_start_get( -// const Cronet_MetricsPtr self); -// CRONET_EXPORT -// Cronet_DateTimePtr Cronet_Metrics_connect_end_get(const Cronet_MetricsPtr self); -// CRONET_EXPORT -// Cronet_DateTimePtr Cronet_Metrics_ssl_start_get(const Cronet_MetricsPtr self); -// CRONET_EXPORT -// Cronet_DateTimePtr Cronet_Metrics_ssl_end_get(const Cronet_MetricsPtr self); -// CRONET_EXPORT -// Cronet_DateTimePtr Cronet_Metrics_sending_start_get( -// const Cronet_MetricsPtr self); -// CRONET_EXPORT -// Cronet_DateTimePtr Cronet_Metrics_sending_end_get(const Cronet_MetricsPtr self); -// CRONET_EXPORT -// Cronet_DateTimePtr Cronet_Metrics_push_start_get(const Cronet_MetricsPtr self); -// CRONET_EXPORT -// Cronet_DateTimePtr Cronet_Metrics_push_end_get(const Cronet_MetricsPtr self); -// CRONET_EXPORT -// Cronet_DateTimePtr Cronet_Metrics_response_start_get( -// const Cronet_MetricsPtr self); -// CRONET_EXPORT -// Cronet_DateTimePtr Cronet_Metrics_request_end_get(const Cronet_MetricsPtr self); -// CRONET_EXPORT -// bool Cronet_Metrics_socket_reused_get(const Cronet_MetricsPtr self); -// CRONET_EXPORT -// int64_t Cronet_Metrics_sent_byte_count_get(const Cronet_MetricsPtr self); -// CRONET_EXPORT -// int64_t Cronet_Metrics_received_byte_count_get(const Cronet_MetricsPtr self); +/////////////////////// +// Struct Cronet_Metrics. +CRONET_EXPORT Cronet_MetricsPtr Cronet_Metrics_Create(void); +CRONET_EXPORT void Cronet_Metrics_Destroy(Cronet_MetricsPtr self); +// Cronet_Metrics setters. +CRONET_EXPORT +void Cronet_Metrics_request_start_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr request_start); +// Move data from |request_start|. The caller retains ownership of +// |request_start| and must destroy it. +void Cronet_Metrics_request_start_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr request_start); +CRONET_EXPORT +void Cronet_Metrics_dns_start_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr dns_start); +// Move data from |dns_start|. The caller retains ownership of |dns_start| and +// must destroy it. +void Cronet_Metrics_dns_start_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr dns_start); +CRONET_EXPORT +void Cronet_Metrics_dns_end_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr dns_end); +// Move data from |dns_end|. The caller retains ownership of |dns_end| and must +// destroy it. +void Cronet_Metrics_dns_end_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr dns_end); +CRONET_EXPORT +void Cronet_Metrics_connect_start_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr connect_start); +// Move data from |connect_start|. The caller retains ownership of +// |connect_start| and must destroy it. +void Cronet_Metrics_connect_start_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr connect_start); +CRONET_EXPORT +void Cronet_Metrics_connect_end_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr connect_end); +// Move data from |connect_end|. The caller retains ownership of |connect_end| +// and must destroy it. +void Cronet_Metrics_connect_end_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr connect_end); +CRONET_EXPORT +void Cronet_Metrics_ssl_start_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr ssl_start); +// Move data from |ssl_start|. The caller retains ownership of |ssl_start| and +// must destroy it. +void Cronet_Metrics_ssl_start_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr ssl_start); +CRONET_EXPORT +void Cronet_Metrics_ssl_end_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr ssl_end); +// Move data from |ssl_end|. The caller retains ownership of |ssl_end| and must +// destroy it. +void Cronet_Metrics_ssl_end_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr ssl_end); +CRONET_EXPORT +void Cronet_Metrics_sending_start_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr sending_start); +// Move data from |sending_start|. The caller retains ownership of +// |sending_start| and must destroy it. +void Cronet_Metrics_sending_start_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr sending_start); +CRONET_EXPORT +void Cronet_Metrics_sending_end_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr sending_end); +// Move data from |sending_end|. The caller retains ownership of |sending_end| +// and must destroy it. +void Cronet_Metrics_sending_end_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr sending_end); +CRONET_EXPORT +void Cronet_Metrics_push_start_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr push_start); +// Move data from |push_start|. The caller retains ownership of |push_start| and +// must destroy it. +void Cronet_Metrics_push_start_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr push_start); +CRONET_EXPORT +void Cronet_Metrics_push_end_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr push_end); +// Move data from |push_end|. The caller retains ownership of |push_end| and +// must destroy it. +void Cronet_Metrics_push_end_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr push_end); +CRONET_EXPORT +void Cronet_Metrics_response_start_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr response_start); +// Move data from |response_start|. The caller retains ownership of +// |response_start| and must destroy it. +void Cronet_Metrics_response_start_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr response_start); +CRONET_EXPORT +void Cronet_Metrics_request_end_set(Cronet_MetricsPtr self, + const Cronet_DateTimePtr request_end); +// Move data from |request_end|. The caller retains ownership of |request_end| +// and must destroy it. +void Cronet_Metrics_request_end_move(Cronet_MetricsPtr self, + Cronet_DateTimePtr request_end); +CRONET_EXPORT +void Cronet_Metrics_socket_reused_set(Cronet_MetricsPtr self, + const bool socket_reused); +CRONET_EXPORT +void Cronet_Metrics_sent_byte_count_set(Cronet_MetricsPtr self, + const int64_t sent_byte_count); +CRONET_EXPORT +void Cronet_Metrics_received_byte_count_set(Cronet_MetricsPtr self, + const int64_t received_byte_count); +// Cronet_Metrics getters. +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_request_start_get( + const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_dns_start_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_dns_end_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_connect_start_get( + const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_connect_end_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_ssl_start_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_ssl_end_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_sending_start_get( + const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_sending_end_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_push_start_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_push_end_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_response_start_get( + const Cronet_MetricsPtr self); +CRONET_EXPORT +Cronet_DateTimePtr Cronet_Metrics_request_end_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +bool Cronet_Metrics_socket_reused_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +int64_t Cronet_Metrics_sent_byte_count_get(const Cronet_MetricsPtr self); +CRONET_EXPORT +int64_t Cronet_Metrics_received_byte_count_get(const Cronet_MetricsPtr self); -// /////////////////////// -// // Struct Cronet_RequestFinishedInfo. -// CRONET_EXPORT Cronet_RequestFinishedInfoPtr -// Cronet_RequestFinishedInfo_Create(void); -// CRONET_EXPORT void Cronet_RequestFinishedInfo_Destroy( -// Cronet_RequestFinishedInfoPtr self); -// // Cronet_RequestFinishedInfo setters. -// CRONET_EXPORT -// void Cronet_RequestFinishedInfo_metrics_set(Cronet_RequestFinishedInfoPtr self, -// const Cronet_MetricsPtr metrics); -// // Move data from |metrics|. The caller retains ownership of |metrics| and must -// // destroy it. -// void Cronet_RequestFinishedInfo_metrics_move(Cronet_RequestFinishedInfoPtr self, -// Cronet_MetricsPtr metrics); -// CRONET_EXPORT -// void Cronet_RequestFinishedInfo_annotations_add( -// Cronet_RequestFinishedInfoPtr self, -// const Cronet_RawDataPtr element); -// CRONET_EXPORT -// void Cronet_RequestFinishedInfo_finished_reason_set( -// Cronet_RequestFinishedInfoPtr self, -// const Cronet_RequestFinishedInfo_FINISHED_REASON finished_reason); -// // Cronet_RequestFinishedInfo getters. -// CRONET_EXPORT -// Cronet_MetricsPtr Cronet_RequestFinishedInfo_metrics_get( -// const Cronet_RequestFinishedInfoPtr self); -// CRONET_EXPORT -// uint32_t Cronet_RequestFinishedInfo_annotations_size( -// const Cronet_RequestFinishedInfoPtr self); -// CRONET_EXPORT -// Cronet_RawDataPtr Cronet_RequestFinishedInfo_annotations_at( -// const Cronet_RequestFinishedInfoPtr self, -// uint32_t index); -// CRONET_EXPORT -// void Cronet_RequestFinishedInfo_annotations_clear( -// Cronet_RequestFinishedInfoPtr self); -// CRONET_EXPORT -// Cronet_RequestFinishedInfo_FINISHED_REASON -// Cronet_RequestFinishedInfo_finished_reason_get( -// const Cronet_RequestFinishedInfoPtr self); +/////////////////////// +// Struct Cronet_RequestFinishedInfo. +CRONET_EXPORT Cronet_RequestFinishedInfoPtr +Cronet_RequestFinishedInfo_Create(void); +CRONET_EXPORT void Cronet_RequestFinishedInfo_Destroy( + Cronet_RequestFinishedInfoPtr self); +// Cronet_RequestFinishedInfo setters. +CRONET_EXPORT +void Cronet_RequestFinishedInfo_metrics_set(Cronet_RequestFinishedInfoPtr self, + const Cronet_MetricsPtr metrics); +// Move data from |metrics|. The caller retains ownership of |metrics| and must +// destroy it. +void Cronet_RequestFinishedInfo_metrics_move(Cronet_RequestFinishedInfoPtr self, + Cronet_MetricsPtr metrics); +CRONET_EXPORT +void Cronet_RequestFinishedInfo_annotations_add( + Cronet_RequestFinishedInfoPtr self, + const Cronet_RawDataPtr element); +CRONET_EXPORT +void Cronet_RequestFinishedInfo_finished_reason_set( + Cronet_RequestFinishedInfoPtr self, + const Cronet_RequestFinishedInfo_FINISHED_REASON finished_reason); +// Cronet_RequestFinishedInfo getters. +CRONET_EXPORT +Cronet_MetricsPtr Cronet_RequestFinishedInfo_metrics_get( + const Cronet_RequestFinishedInfoPtr self); +CRONET_EXPORT +uint32_t Cronet_RequestFinishedInfo_annotations_size( + const Cronet_RequestFinishedInfoPtr self); +CRONET_EXPORT +Cronet_RawDataPtr Cronet_RequestFinishedInfo_annotations_at( + const Cronet_RequestFinishedInfoPtr self, + uint32_t index); +CRONET_EXPORT +void Cronet_RequestFinishedInfo_annotations_clear( + Cronet_RequestFinishedInfoPtr self); +CRONET_EXPORT +Cronet_RequestFinishedInfo_FINISHED_REASON +Cronet_RequestFinishedInfo_finished_reason_get( + const Cronet_RequestFinishedInfoPtr self); #ifdef __cplusplus } diff --git a/third_party/cronet_sample/BUILD.md b/third_party/cronet_sample/BUILD.md deleted file mode 100644 index 1fa31ce..0000000 --- a/third_party/cronet_sample/BUILD.md +++ /dev/null @@ -1,15 +0,0 @@ -# Build Cronet Sample - -Source: [Chromium Cronet Sample](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/components/cronet/native/sample). - -**Note:** Code here aren't used by the Dart code by any means. It is only to test if the downloaded/built cronet library is working and major apis are compatible with this package. - -## Compilation Instruction - -```bash -g++ -std=c++11 main.cc sample_executor.cc sample_url_request_callback.cc -o sample.out -ldl -lpthread -L. -l:libcronet.86.0.4240.198.so -Wl,-z,origin -Wl,-rpath,'$ORIGIN' -``` - -Put the compiled `sample.out` and `libcronet.86.0.4240.198.so` in the same folder and execute `./sample.out`. - -Replace `libcronet.86.0.4240.198.so` with your cronet dylib's name. diff --git a/third_party/cronet_sample/CMakeLists.txt b/third_party/cronet_sample/CMakeLists.txt new file mode 100644 index 0000000..30a6196 --- /dev/null +++ b/third_party/cronet_sample/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.15) +set(PROJECT_NAME "cronet_sample") +project(${PROJECT_NAME} LANGUAGES C CXX) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +add_executable(${PROJECT_NAME} + "main.cc" + "sample_executor.cc" + "sample_url_request_callback.cc" +) + +target_include_directories(${PROJECT_NAME} PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/../cronet/" + +) + +if (UNIX) + set(CRONET_DIR "$ENV{CURRENTDIR}/.dart_tool/cronet/linux64") + find_library(CRONET cronet.86.0.4240.198 ${CRONET_DIR}) + target_link_libraries(${PROJECT_NAME} pthread dl ${CRONET}) +endif (UNIX) + +if (WIN32) + set(CRONET_DIR "$ENV{CURRENTDIR}\\.dart_tool\\cronet\\windows64") + find_library(CRONET cronet.86.0.4240.198.dll ${CRONET_DIR}) + target_link_libraries(${PROJECT_NAME} ${CRONET}) +endif (WIN32) From 0beef32f9790d32516d7b788dfced453ec33362f Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Thu, 1 Jul 2021 15:04:16 +0530 Subject: [PATCH 36/42] C API for SampleExecutor --- analysis_options.yaml | 4 + bin/setup.dart | 8 +- lib/src/globals.dart | 28 +- lib/src/http_callback_handler.dart | 6 +- lib/src/http_client.dart | 39 +- lib/src/http_client_request.dart | 25 +- lib/src/http_client_response.dart | 6 +- lib/src/third_party/cronet/ffigen.yaml | 3 +- .../cronet/generated_bindings.dart | 15 +- lib/src/wrapper/ffigen.yaml | 11 + lib/src/wrapper/generated_bindings.dart | 498 ++++++++++++------ src/wrapper.cc | 75 +-- src/wrapper.h | 82 ++- src/wrapper_export.h | 4 +- tool/build_wrapper.dart | 5 +- 15 files changed, 495 insertions(+), 314 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 93c5024..3743f9b 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -8,3 +8,7 @@ analyzer: strong-mode: implicit-casts: false implicit-dynamic: false +linter: + rules: + - directives_ordering + - lines_longer_than_80_chars diff --git a/bin/setup.dart b/bin/setup.dart index 2ecf13a..978643e 100644 --- a/bin/setup.dart +++ b/bin/setup.dart @@ -38,7 +38,8 @@ void placeBinaries(String platform, String fileName) { File(fileName).deleteSync(); logger.stdout( - '${ansi.green}Done! Cronet support for $platform is now available!${ansi.none}'); + '${ansi.green}Done! Cronet support for $platform is now available!' + '${ansi.none}'); } /// Download `cronet` library from Github Releases. @@ -88,8 +89,9 @@ void buildWrapper() { logger.stdout("${ansi.red}Build failed.${ansi.none}"); if (Platform.isWindows) { logger.stdout( - 'Open ${ansi.yellow}x64 Native Tools Command Prompt for VS 2019.${ansi.none} Then run:\n'); - logger.stdout('cd ${pwd.path}\ndart run cronet:setup build'); + 'Open ${ansi.yellow}x64 Native Tools Command Prompt for VS 2019.' + '${ansi.none} Then run:\n' + 'cd ${pwd.path}\ndart run cronet:setup build'); } return; } diff --git a/lib/src/globals.dart b/lib/src/globals.dart index 17c11b2..64aa515 100644 --- a/lib/src/globals.dart +++ b/lib/src/globals.dart @@ -2,12 +2,38 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'dart:ffi'; + import 'dylib_handler.dart'; import 'third_party/cronet/generated_bindings.dart'; import 'wrapper/generated_bindings.dart'; +Wrapper loadAndInitWrapper() { + final wrapper = Wrapper(loadWrapper()); + // Initialize Dart Native API dynamically. + wrapper.InitDartApiDL(NativeApi.initializeApiDLData); + // Registers few cronet functions that are required by the wrapper. + // Casting because of https://github.com/dart-lang/ffigen/issues/22 + wrapper.InitCronetApi( + cronet.addresses.Cronet_Engine_Shutdown.cast(), + cronet.addresses.Cronet_Engine_Destroy.cast(), + cronet.addresses.Cronet_Buffer_Create.cast(), + cronet.addresses.Cronet_Buffer_InitWithAlloc.cast()); + // Registers few cronet functions that are required by the executor + // run from the wrapper for executing network requests. + // Casting because of https://github.com/dart-lang/ffigen/issues/22 + wrapper.InitCronetExecutorApi( + cronet.addresses.Cronet_Executor_CreateWith.cast(), + cronet.addresses.Cronet_Executor_SetClientContext.cast(), + cronet.addresses.Cronet_Executor_GetClientContext.cast(), + cronet.addresses.Cronet_Executor_Destroy.cast(), + cronet.addresses.Cronet_Runnable_Run.cast(), + cronet.addresses.Cronet_Runnable_Destroy.cast()); + return wrapper; +} + final _cronet = Cronet(loadCronet()); Cronet get cronet => _cronet; -final _wrapper = Wrapper(loadWrapper()); +final _wrapper = loadAndInitWrapper(); Wrapper get wrapper => _wrapper; diff --git a/lib/src/http_callback_handler.dart b/lib/src/http_callback_handler.dart index 32e7a1d..04c3657 100644 --- a/lib/src/http_callback_handler.dart +++ b/lib/src/http_callback_handler.dart @@ -13,6 +13,7 @@ import 'package:ffi/ffi.dart'; import 'exceptions.dart'; import 'globals.dart'; import 'third_party/cronet/generated_bindings.dart'; +import 'wrapper/generated_bindings.dart' as wrpr; /// Deserializes the message sent by cronet and it's wrapper. class _CallbackRequestMessage { @@ -35,7 +36,7 @@ class _CallbackRequestMessage { /// data that are sent by [NativePort] from native cronet library. class CallbackHandler { final ReceivePort receivePort; - final Pointer executor; + final Pointer executor; // These are a part of HttpClientRequest Public API. bool followRedirects = true; @@ -99,7 +100,8 @@ class CallbackHandler { switch (reqMessage.method) { case 'OnRedirectReceived': { - log('New Location: ${Pointer.fromAddress(args[0]).cast().toDartString()}'); + log('New Location: ' + '${Pointer.fromAddress(args[0]).cast().toDartString()}'); // If NOT a 3XX status code, throw Exception. statusChecker( Pointer.fromAddress(args[1]).cast(), diff --git a/lib/src/http_client.dart b/lib/src/http_client.dart index 0d1114a..98a9a65 100644 --- a/lib/src/http_client.dart +++ b/lib/src/http_client.dart @@ -64,28 +64,7 @@ class HttpClient { this.acceptLanguage = 'en_US', }) : _cronetEngine = cronet.Cronet_Engine_Create() { if (_cronetEngine == nullptr) throw Error(); - // Initialize Dart Native API dynamically. - wrapper.InitDartApiDL(NativeApi.initializeApiDLData); wrapper.RegisterHttpClient(this, _cronetEngine.cast()); - // Registers few cronet functions that are required by the wrapper. - // Casting because of https://github.com/dart-lang/ffigen/issues/22 - wrapper.InitCronetApi( - cronet.addresses.Cronet_Engine_Shutdown.cast(), - cronet.addresses.Cronet_Engine_Destroy.cast(), - cronet.addresses.Cronet_Buffer_Create.cast(), - cronet.addresses.Cronet_Buffer_InitWithAlloc.cast(), - cronet.addresses.Cronet_UrlRequestCallback_CreateWith.cast(), - cronet.addresses.Cronet_UrlRequest_InitWithParams.cast()); - // Registers few cronet functions that are required by the executor - // run from the wrapper for executing network requests. - // Casting because of https://github.com/dart-lang/ffigen/issues/22 - wrapper.InitCronetExecutorApi( - cronet.addresses.Cronet_Executor_CreateWith.cast(), - cronet.addresses.Cronet_Executor_SetClientContext.cast(), - cronet.addresses.Cronet_Executor_GetClientContext.cast(), - cronet.addresses.Cronet_Executor_Destroy.cast(), - cronet.addresses.Cronet_Runnable_Run.cast(), - cronet.addresses.Cronet_Runnable_Destroy.cast()); // Starting the engine with parameters. final engineParams = cronet.Cronet_EngineParams_Create(); if (engineParams == nullptr) throw Error(); @@ -188,7 +167,8 @@ class HttpClient { return openUrl('GET', url); } - /// Opens a request on the basis of [host], [port] and [path] using GET method. + /// Opens a request on the basis of [host], [port] and [path] using GET + /// method. /// /// Returns a [Future] of [HttpClientRequest]. Future get(String host, int port, String path) { @@ -202,7 +182,8 @@ class HttpClient { return openUrl('HEAD', url); } - /// Opens a request on the basis of [host], [port] and [path] using HEAD method. + /// Opens a request on the basis of [host], [port] and [path] using HEAD + /// method. /// /// Returns a [Future] of [HttpClientRequest]. Future head(String host, int port, String path) { @@ -216,7 +197,8 @@ class HttpClient { return openUrl('PUT', url); } - /// Opens a request on the basis of [host], [port] and [path] using PUT method. + /// Opens a request on the basis of [host], [port] and [path] using PUT + /// method. /// /// Returns a [Future] of [HttpClientRequest]. Future put(String host, int port, String path) { @@ -230,7 +212,8 @@ class HttpClient { return openUrl('POST', url); } - /// Opens a request on the basis of [host], [port] and [path] using POST method. + /// Opens a request on the basis of [host], [port] and [path] using POST + /// method. /// /// Returns a [Future] of [HttpClientRequest]. Future post(String host, int port, String path) { @@ -244,7 +227,8 @@ class HttpClient { return openUrl('PATCH', url); } - /// Opens a request on the basis of [host], [port] and [path] using PATCH method. + /// Opens a request on the basis of [host], [port] and [path] using PATCH + /// method. /// /// Returns a [Future] of [HttpClientRequest]. Future patch(String host, int port, String path) { @@ -258,7 +242,8 @@ class HttpClient { return openUrl('DELETE', url); } - /// Opens a request on the basis of [host], [port] and [path] using DELETE method. + /// Opens a request on the basis of [host], [port] and [path] using DELETE + /// method. /// /// Returns a [Future] of [HttpClientRequest]. Future delete(String host, int port, String path) { diff --git a/lib/src/http_client_request.dart b/lib/src/http_client_request.dart index 7bc8826..2ef627e 100644 --- a/lib/src/http_client_request.dart +++ b/lib/src/http_client_request.dart @@ -83,7 +83,7 @@ class HttpClientRequestImpl implements HttpClientRequest { this._uri, this._method, this._cronetEngine, this._clientCleanup, {this.encoding = utf8}) : _callbackHandler = - CallbackHandler(wrapper.Create_Executor(), ReceivePort()), + CallbackHandler(wrapper.SampleExecutorCreate(), ReceivePort()), _request = cronet.Cronet_UrlRequest_Create() { // Register the native port to C side. wrapper.RegisterCallbackHandler( @@ -96,13 +96,24 @@ class HttpClientRequestImpl implements HttpClientRequest { if (requestParams == nullptr) throw Error(); cronet.Cronet_UrlRequestParams_http_method_set( requestParams, _method.toNativeUtf8().cast()); - - final res = wrapper.Cronet_UrlRequest_Init( - _request.cast(), - _cronetEngine.cast(), + wrapper.InitSampleExecutor(_callbackHandler.executor); + + final cronetCallbacks = cronet.Cronet_UrlRequestCallback_CreateWith( + wrapper.addresses.OnRedirectReceived.cast(), + wrapper.addresses.OnResponseStarted.cast(), + wrapper.addresses.OnReadCompleted.cast(), + wrapper.addresses.OnSucceeded.cast(), + wrapper.addresses.OnFailed.cast(), + wrapper.addresses.OnCanceled.cast(), + ); + final res = cronet.Cronet_UrlRequest_InitWithParams( + _request, + _cronetEngine, _uri.toString().toNativeUtf8().cast(), - requestParams.cast(), - _callbackHandler.executor); + requestParams, + cronetCallbacks, + wrapper.SampleExecutor_Cronet_ExecutorPtr_get(_callbackHandler.executor) + .cast()); if (res != Cronet_RESULT.Cronet_RESULT_SUCCESS) { throw UrlRequestError(res); diff --git a/lib/src/http_client_response.dart b/lib/src/http_client_response.dart index 2465a25..f7deaa9 100644 --- a/lib/src/http_client_response.dart +++ b/lib/src/http_client_response.dart @@ -6,14 +6,16 @@ import 'dart:async'; /// Represents the server's response to a request. /// -/// The body of a [HttpClientResponse] object is a [Stream] of data from the server. +/// The body of a [HttpClientResponse] object is a [Stream] of data from the +/// server. /// Listen to the body to handle the data and be notified when the entire body /// is received. abstract class HttpClientResponse extends Stream> {} /// Implementation of [HttpClientResponse]. /// -/// Takes instance of callback handler and registers [listen] callbacks to the stream. +/// Takes instance of callback handler and registers [listen] callbacks to the +/// stream. class HttpClientResponseImpl extends HttpClientResponse { final Stream> cbhStream; HttpClientResponseImpl(this.cbhStream); diff --git a/lib/src/third_party/cronet/ffigen.yaml b/lib/src/third_party/cronet/ffigen.yaml index 525efb5..83cbc1b 100644 --- a/lib/src/third_party/cronet/ffigen.yaml +++ b/lib/src/third_party/cronet/ffigen.yaml @@ -17,8 +17,6 @@ functions: - 'Cronet_Engine_Destroy' - 'Cronet_Buffer_Create' - 'Cronet_Buffer_InitWithAlloc' - - 'Cronet_UrlRequestCallback_CreateWith' - - 'Cronet_UrlRequest_InitWithParams' # For executor. - 'Cronet_Executor_CreateWith' - 'Cronet_Executor_SetClientContext' @@ -33,4 +31,5 @@ preamble: | // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names + // ignore_for_file: lines_longer_than_80_chars // ignore_for_file: non_constant_identifier_names diff --git a/lib/src/third_party/cronet/generated_bindings.dart b/lib/src/third_party/cronet/generated_bindings.dart index 992958a..7670a4a 100644 --- a/lib/src/third_party/cronet/generated_bindings.dart +++ b/lib/src/third_party/cronet/generated_bindings.dart @@ -4,6 +4,7 @@ // ignore_for_file: camel_case_types // ignore_for_file: constant_identifier_names +// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: non_constant_identifier_names // AUTO GENERATED FILE, DO NOT EDIT. @@ -938,7 +939,7 @@ class Cronet { } late final _Cronet_UrlRequestCallback_CreateWith_ptr = - _lookup>( + _lookup>( 'Cronet_UrlRequestCallback_CreateWith'); late final _dart_Cronet_UrlRequestCallback_CreateWith _Cronet_UrlRequestCallback_CreateWith = @@ -1327,7 +1328,7 @@ class Cronet { } late final _Cronet_UrlRequest_InitWithParams_ptr = - _lookup>( + _lookup>( 'Cronet_UrlRequest_InitWithParams'); late final _dart_Cronet_UrlRequest_InitWithParams _Cronet_UrlRequest_InitWithParams = _Cronet_UrlRequest_InitWithParams_ptr @@ -4677,12 +4678,6 @@ class _SymbolAddresses { get Cronet_Engine_Destroy => _library._Cronet_Engine_Destroy_ptr; ffi.Pointer> get Cronet_Engine_Shutdown => _library._Cronet_Engine_Shutdown_ptr; - ffi.Pointer> - get Cronet_UrlRequestCallback_CreateWith => - _library._Cronet_UrlRequestCallback_CreateWith_ptr; - ffi.Pointer> - get Cronet_UrlRequest_InitWithParams => - _library._Cronet_UrlRequest_InitWithParams_ptr; } class Cronet_Buffer extends ffi.Opaque {} @@ -5487,7 +5482,7 @@ typedef Cronet_UrlRequestCallback_OnCanceledFunc = ffi.Void Function( ffi.Pointer, ); -typedef Native_Cronet_UrlRequestCallback_CreateWith +typedef _c_Cronet_UrlRequestCallback_CreateWith = ffi.Pointer Function( ffi.Pointer< ffi.NativeFunction> @@ -5780,7 +5775,7 @@ typedef _dart_Cronet_UrlRequest_GetClientContext = ffi.Pointer ffi.Pointer self, ); -typedef Native_Cronet_UrlRequest_InitWithParams = ffi.Int32 Function( +typedef _c_Cronet_UrlRequest_InitWithParams = ffi.Int32 Function( ffi.Pointer self, ffi.Pointer engine, ffi.Pointer url, diff --git a/lib/src/wrapper/ffigen.yaml b/lib/src/wrapper/ffigen.yaml index 528f26d..2b7a415 100644 --- a/lib/src/wrapper/ffigen.yaml +++ b/lib/src/wrapper/ffigen.yaml @@ -11,6 +11,17 @@ compiler-opts: - '-Isrc/' - '-Ithird_party/dart-sdk/' - '-DDART_SHARED_LIB' + +# Callbacks. ISSUE: https://github.com/dart-lang/sdk/issues/37022 +functions: + symbol-address: + include: + - 'OnRedirectReceived' + - 'OnResponseStarted' + - 'OnReadCompleted' + - 'OnSucceeded' + - 'OnFailed' + - 'OnCanceled' comments: style: any length: full diff --git a/lib/src/wrapper/generated_bindings.dart b/lib/src/wrapper/generated_bindings.dart index 91e1dda..d2e0388 100644 --- a/lib/src/wrapper/generated_bindings.dart +++ b/lib/src/wrapper/generated_bindings.dart @@ -44,18 +44,12 @@ class Wrapper { ffi.Pointer> Cronet_Engine_Destroy, ffi.Pointer> Cronet_Buffer_Create, ffi.Pointer> Cronet_Buffer_InitWithAlloc, - ffi.Pointer> - Cronet_UrlRequestCallback_CreateWith, - ffi.Pointer> - Cronet_UrlRequest_InitWithParams, ) { return _InitCronetApi( Cronet_Engine_Shutdown, Cronet_Engine_Destroy, Cronet_Buffer_Create, Cronet_Buffer_InitWithAlloc, - Cronet_UrlRequestCallback_CreateWith, - Cronet_UrlRequest_InitWithParams, ); } @@ -64,15 +58,16 @@ class Wrapper { late final _dart_InitCronetApi _InitCronetApi = _InitCronetApi_ptr.asFunction<_dart_InitCronetApi>(); + /// Forward declaration. Implementation on sample_executor.cc void InitCronetExecutorApi( - ffi.Pointer> Cronet_Executor_CreateWith, - ffi.Pointer> + ffi.Pointer> Cronet_Executor_CreateWith, + ffi.Pointer> Cronet_Executor_SetClientContext, - ffi.Pointer> + ffi.Pointer> Cronet_Executor_GetClientContext, - ffi.Pointer> Cronet_Executor_Destroy, - ffi.Pointer> Cronet_Runnable_Run, - ffi.Pointer> Cronet_Runnable_Destroy, + ffi.Pointer> Cronet_Executor_Destroy, + ffi.Pointer> Cronet_Runnable_Run, + ffi.Pointer> Cronet_Runnable_Destroy, ) { return _InitCronetExecutorApi( Cronet_Executor_CreateWith, @@ -90,28 +85,6 @@ class Wrapper { late final _dart_InitCronetExecutorApi _InitCronetExecutorApi = _InitCronetExecutorApi_ptr.asFunction<_dart_InitCronetExecutorApi>(); - ffi.Pointer Create_Executor() { - return _Create_Executor(); - } - - late final _Create_Executor_ptr = - _lookup>('Create_Executor'); - late final _dart_Create_Executor _Create_Executor = - _Create_Executor_ptr.asFunction<_dart_Create_Executor>(); - - void Destroy_Executor( - ffi.Pointer executor, - ) { - return _Destroy_Executor( - executor, - ); - } - - late final _Destroy_Executor_ptr = - _lookup>('Destroy_Executor'); - late final _dart_Destroy_Executor _Destroy_Executor = - _Destroy_Executor_ptr.asFunction<_dart_Destroy_Executor>(); - void RegisterHttpClient( Object h, ffi.Pointer ce, @@ -129,7 +102,7 @@ class Wrapper { void RegisterCallbackHandler( int nativePort, - ffi.Pointer rp, + ffi.Pointer rp, ) { return _RegisterCallbackHandler( nativePort, @@ -144,7 +117,7 @@ class Wrapper { _RegisterCallbackHandler_ptr.asFunction<_dart_RegisterCallbackHandler>(); void RemoveRequest( - ffi.Pointer rp, + ffi.Pointer rp, ) { return _RemoveRequest( rp, @@ -156,47 +129,211 @@ class Wrapper { late final _dart_RemoveRequest _RemoveRequest = _RemoveRequest_ptr.asFunction<_dart_RemoveRequest>(); - int Cronet_UrlRequest_Init( - ffi.Pointer self, - ffi.Pointer engine, - ffi.Pointer url, - ffi.Pointer params, - ffi.Pointer _executor, + /// Callbacks. ISSUE: https://github.com/dart-lang/sdk/issues/37022 + void OnRedirectReceived( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ffi.Pointer newLocationUrl, ) { - return _Cronet_UrlRequest_Init( + return _OnRedirectReceived( self, - engine, - url, - params, - _executor, + request, + info, + newLocationUrl, ); } - late final _Cronet_UrlRequest_Init_ptr = - _lookup>( - 'Cronet_UrlRequest_Init'); - late final _dart_Cronet_UrlRequest_Init _Cronet_UrlRequest_Init = - _Cronet_UrlRequest_Init_ptr.asFunction<_dart_Cronet_UrlRequest_Init>(); -} + late final _OnRedirectReceived_ptr = + _lookup>( + 'OnRedirectReceived'); + late final _dart_OnRedirectReceived _OnRedirectReceived = + _OnRedirectReceived_ptr.asFunction<_dart_OnRedirectReceived>(); -class Cronet_EnginePtr extends ffi.Opaque {} + void OnResponseStarted( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ) { + return _OnResponseStarted( + self, + request, + info, + ); + } -class Cronet_BufferPtr extends ffi.Opaque {} + late final _OnResponseStarted_ptr = + _lookup>( + 'OnResponseStarted'); + late final _dart_OnResponseStarted _OnResponseStarted = + _OnResponseStarted_ptr.asFunction<_dart_OnResponseStarted>(); + + void OnReadCompleted( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ffi.Pointer buffer, + int bytes_read, + ) { + return _OnReadCompleted( + self, + request, + info, + buffer, + bytes_read, + ); + } -class Cronet_UrlRequestCallbackPtr extends ffi.Opaque {} + late final _OnReadCompleted_ptr = + _lookup>('OnReadCompleted'); + late final _dart_OnReadCompleted _OnReadCompleted = + _OnReadCompleted_ptr.asFunction<_dart_OnReadCompleted>(); -class Cronet_UrlRequestPtr extends ffi.Opaque {} + void OnSucceeded( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ) { + return _OnSucceeded( + self, + request, + info, + ); + } -class Cronet_UrlResponseInfoPtr extends ffi.Opaque {} + late final _OnSucceeded_ptr = + _lookup>('OnSucceeded'); + late final _dart_OnSucceeded _OnSucceeded = + _OnSucceeded_ptr.asFunction<_dart_OnSucceeded>(); -class Cronet_ErrorPtr extends ffi.Opaque {} + void OnFailed( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ffi.Pointer error, + ) { + return _OnFailed( + self, + request, + info, + error, + ); + } + + late final _OnFailed_ptr = + _lookup>('OnFailed'); + late final _dart_OnFailed _OnFailed = + _OnFailed_ptr.asFunction<_dart_OnFailed>(); + + void OnCanceled( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ) { + return _OnCanceled( + self, + request, + info, + ); + } + + late final _OnCanceled_ptr = + _lookup>('OnCanceled'); + late final _dart_OnCanceled _OnCanceled = + _OnCanceled_ptr.asFunction<_dart_OnCanceled>(); + + /// Sample Executor C APIs + ffi.Pointer SampleExecutorCreate() { + return _SampleExecutorCreate(); + } + + late final _SampleExecutorCreate_ptr = + _lookup>( + 'SampleExecutorCreate'); + late final _dart_SampleExecutorCreate _SampleExecutorCreate = + _SampleExecutorCreate_ptr.asFunction<_dart_SampleExecutorCreate>(); + + void SampleExecutorDestroy( + ffi.Pointer executor, + ) { + return _SampleExecutorDestroy( + executor, + ); + } + + late final _SampleExecutorDestroy_ptr = + _lookup>( + 'SampleExecutorDestroy'); + late final _dart_SampleExecutorDestroy _SampleExecutorDestroy = + _SampleExecutorDestroy_ptr.asFunction<_dart_SampleExecutorDestroy>(); -class Cronet_UrlRequestParamsPtr extends ffi.Opaque {} + void InitSampleExecutor( + ffi.Pointer self, + ) { + return _InitSampleExecutor( + self, + ); + } + + late final _InitSampleExecutor_ptr = + _lookup>('InitSampleExecutor'); + late final _dart_InitSampleExecutor _InitSampleExecutor = + _InitSampleExecutor_ptr.asFunction<_dart_InitSampleExecutor>(); + + ffi.Pointer SampleExecutor_Cronet_ExecutorPtr_get( + ffi.Pointer self, + ) { + return _SampleExecutor_Cronet_ExecutorPtr_get( + self, + ); + } + + late final _SampleExecutor_Cronet_ExecutorPtr_get_ptr = + _lookup>( + 'SampleExecutor_Cronet_ExecutorPtr_get'); + late final _dart_SampleExecutor_Cronet_ExecutorPtr_get + _SampleExecutor_Cronet_ExecutorPtr_get = + _SampleExecutor_Cronet_ExecutorPtr_get_ptr.asFunction< + _dart_SampleExecutor_Cronet_ExecutorPtr_get>(); + + late final addresses = _SymbolAddresses(this); +} + +class _SymbolAddresses { + final Wrapper _library; + _SymbolAddresses(this._library); + ffi.Pointer> + get OnRedirectReceived => _library._OnRedirectReceived_ptr; + ffi.Pointer> + get OnResponseStarted => _library._OnResponseStarted_ptr; + ffi.Pointer> get OnReadCompleted => + _library._OnReadCompleted_ptr; + ffi.Pointer> get OnSucceeded => + _library._OnSucceeded_ptr; + ffi.Pointer> get OnFailed => + _library._OnFailed_ptr; + ffi.Pointer> get OnCanceled => + _library._OnCanceled_ptr; +} + +class SampleExecutor extends ffi.Opaque {} + +class Cronet_EnginePtr extends ffi.Opaque {} + +class Cronet_BufferPtr extends ffi.Opaque {} class Cronet_ExecutorPtr extends ffi.Opaque {} class Cronet_RunnablePtr extends ffi.Opaque {} +class Cronet_UrlRequest extends ffi.Opaque {} + +class Cronet_UrlRequestCallbackPtr extends ffi.Opaque {} + +class Cronet_UrlResponseInfoPtr extends ffi.Opaque {} + +class Cronet_ErrorPtr extends ffi.Opaque {} + typedef _c_InitDartApiDL = ffi.IntPtr Function( ffi.Pointer data, ); @@ -220,75 +357,11 @@ typedef _typedefC_4 = ffi.Void Function( ffi.Uint64, ); -typedef Cronet_UrlRequestCallback_OnRedirectReceivedFunc = ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, -); - -typedef Cronet_UrlRequestCallback_OnResponseStartedFunc = ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, -); - -typedef Cronet_UrlRequestCallback_OnReadCompletedFunc = ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Uint64, -); - -typedef Cronet_UrlRequestCallback_OnSucceededFunc = ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, -); - -typedef Cronet_UrlRequestCallback_OnFailedFunc = ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, -); - -typedef Cronet_UrlRequestCallback_OnCanceledFunc = ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, -); - -typedef _typedefC_5 = ffi.Pointer Function( - ffi.Pointer< - ffi.NativeFunction>, - ffi.Pointer< - ffi.NativeFunction>, - ffi.Pointer< - ffi.NativeFunction>, - ffi.Pointer>, - ffi.Pointer>, - ffi.Pointer>, -); - -typedef _typedefC_6 = ffi.Int32 Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, -); - typedef _c_InitCronetApi = ffi.Void Function( ffi.Pointer> Cronet_Engine_Shutdown, ffi.Pointer> Cronet_Engine_Destroy, ffi.Pointer> Cronet_Buffer_Create, ffi.Pointer> Cronet_Buffer_InitWithAlloc, - ffi.Pointer> - Cronet_UrlRequestCallback_CreateWith, - ffi.Pointer> Cronet_UrlRequest_InitWithParams, ); typedef _dart_InitCronetApi = void Function( @@ -296,9 +369,6 @@ typedef _dart_InitCronetApi = void Function( ffi.Pointer> Cronet_Engine_Destroy, ffi.Pointer> Cronet_Buffer_Create, ffi.Pointer> Cronet_Buffer_InitWithAlloc, - ffi.Pointer> - Cronet_UrlRequestCallback_CreateWith, - ffi.Pointer> Cronet_UrlRequest_InitWithParams, ); typedef Cronet_Executor_ExecuteFunc = ffi.Void Function( @@ -306,59 +376,47 @@ typedef Cronet_Executor_ExecuteFunc = ffi.Void Function( ffi.Pointer, ); -typedef _typedefC_7 = ffi.Pointer Function( +typedef _typedefC_5 = ffi.Pointer Function( ffi.Pointer>, ); -typedef _typedefC_8 = ffi.Void Function( +typedef _typedefC_6 = ffi.Void Function( ffi.Pointer, ffi.Pointer, ); -typedef _typedefC_9 = ffi.Pointer Function( +typedef _typedefC_7 = ffi.Pointer Function( ffi.Pointer, ); -typedef _typedefC_10 = ffi.Void Function( +typedef _typedefC_8 = ffi.Void Function( ffi.Pointer, ); -typedef _typedefC_11 = ffi.Void Function( +typedef _typedefC_9 = ffi.Void Function( ffi.Pointer, ); -typedef _typedefC_12 = ffi.Void Function( +typedef _typedefC_10 = ffi.Void Function( ffi.Pointer, ); typedef _c_InitCronetExecutorApi = ffi.Void Function( - ffi.Pointer> Cronet_Executor_CreateWith, - ffi.Pointer> Cronet_Executor_SetClientContext, - ffi.Pointer> Cronet_Executor_GetClientContext, - ffi.Pointer> Cronet_Executor_Destroy, - ffi.Pointer> Cronet_Runnable_Run, - ffi.Pointer> Cronet_Runnable_Destroy, + ffi.Pointer> Cronet_Executor_CreateWith, + ffi.Pointer> Cronet_Executor_SetClientContext, + ffi.Pointer> Cronet_Executor_GetClientContext, + ffi.Pointer> Cronet_Executor_Destroy, + ffi.Pointer> Cronet_Runnable_Run, + ffi.Pointer> Cronet_Runnable_Destroy, ); typedef _dart_InitCronetExecutorApi = void Function( - ffi.Pointer> Cronet_Executor_CreateWith, - ffi.Pointer> Cronet_Executor_SetClientContext, - ffi.Pointer> Cronet_Executor_GetClientContext, - ffi.Pointer> Cronet_Executor_Destroy, - ffi.Pointer> Cronet_Runnable_Run, - ffi.Pointer> Cronet_Runnable_Destroy, -); - -typedef _c_Create_Executor = ffi.Pointer Function(); - -typedef _dart_Create_Executor = ffi.Pointer Function(); - -typedef _c_Destroy_Executor = ffi.Void Function( - ffi.Pointer executor, -); - -typedef _dart_Destroy_Executor = void Function( - ffi.Pointer executor, + ffi.Pointer> Cronet_Executor_CreateWith, + ffi.Pointer> Cronet_Executor_SetClientContext, + ffi.Pointer> Cronet_Executor_GetClientContext, + ffi.Pointer> Cronet_Executor_Destroy, + ffi.Pointer> Cronet_Runnable_Run, + ffi.Pointer> Cronet_Runnable_Destroy, ); typedef _c_RegisterHttpClient = ffi.Void Function( @@ -373,34 +431,128 @@ typedef _dart_RegisterHttpClient = void Function( typedef _c_RegisterCallbackHandler = ffi.Void Function( ffi.Int64 nativePort, - ffi.Pointer rp, + ffi.Pointer rp, ); typedef _dart_RegisterCallbackHandler = void Function( int nativePort, - ffi.Pointer rp, + ffi.Pointer rp, ); typedef _c_RemoveRequest = ffi.Void Function( - ffi.Pointer rp, + ffi.Pointer rp, ); typedef _dart_RemoveRequest = void Function( - ffi.Pointer rp, + ffi.Pointer rp, +); + +typedef Native_OnRedirectReceived = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ffi.Pointer newLocationUrl, +); + +typedef _dart_OnRedirectReceived = void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ffi.Pointer newLocationUrl, +); + +typedef Native_OnResponseStarted = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, +); + +typedef _dart_OnResponseStarted = void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, +); + +typedef Native_OnReadCompleted = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ffi.Pointer buffer, + ffi.Uint64 bytes_read, +); + +typedef _dart_OnReadCompleted = void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ffi.Pointer buffer, + int bytes_read, +); + +typedef Native_OnSucceeded = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, +); + +typedef _dart_OnSucceeded = void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, +); + +typedef Native_OnFailed = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ffi.Pointer error, +); + +typedef _dart_OnFailed = void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, + ffi.Pointer error, +); + +typedef Native_OnCanceled = ffi.Void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, +); + +typedef _dart_OnCanceled = void Function( + ffi.Pointer self, + ffi.Pointer request, + ffi.Pointer info, +); + +typedef _c_SampleExecutorCreate = ffi.Pointer Function(); + +typedef _dart_SampleExecutorCreate = ffi.Pointer Function(); + +typedef _c_SampleExecutorDestroy = ffi.Void Function( + ffi.Pointer executor, +); + +typedef _dart_SampleExecutorDestroy = void Function( + ffi.Pointer executor, +); + +typedef _c_InitSampleExecutor = ffi.Void Function( + ffi.Pointer self, +); + +typedef _dart_InitSampleExecutor = void Function( + ffi.Pointer self, ); -typedef _c_Cronet_UrlRequest_Init = ffi.Int32 Function( - ffi.Pointer self, - ffi.Pointer engine, - ffi.Pointer url, - ffi.Pointer params, - ffi.Pointer _executor, +typedef _c_SampleExecutor_Cronet_ExecutorPtr_get + = ffi.Pointer Function( + ffi.Pointer self, ); -typedef _dart_Cronet_UrlRequest_Init = int Function( - ffi.Pointer self, - ffi.Pointer engine, - ffi.Pointer url, - ffi.Pointer params, - ffi.Pointer _executor, +typedef _dart_SampleExecutor_Cronet_ExecutorPtr_get + = ffi.Pointer Function( + ffi.Pointer self, ); diff --git a/src/wrapper.cc b/src/wrapper.cc index 2409e6b..8bd1a51 100644 --- a/src/wrapper.cc +++ b/src/wrapper.cc @@ -20,17 +20,6 @@ Cronet_RESULT (*_Cronet_Engine_Shutdown)(Cronet_EnginePtr self); void (*_Cronet_Engine_Destroy)(Cronet_EnginePtr self); Cronet_BufferPtr (*_Cronet_Buffer_Create)(void); void (*_Cronet_Buffer_InitWithAlloc)(Cronet_BufferPtr self, uint64_t size); -Cronet_UrlRequestCallbackPtr (*_Cronet_UrlRequestCallback_CreateWith)( - Cronet_UrlRequestCallback_OnRedirectReceivedFunc OnRedirectReceivedFunc, - Cronet_UrlRequestCallback_OnResponseStartedFunc OnResponseStartedFunc, - Cronet_UrlRequestCallback_OnReadCompletedFunc OnReadCompletedFunc, - Cronet_UrlRequestCallback_OnSucceededFunc OnSucceededFunc, - Cronet_UrlRequestCallback_OnFailedFunc OnFailedFunc, - Cronet_UrlRequestCallback_OnCanceledFunc OnCanceledFunc); -Cronet_RESULT (*_Cronet_UrlRequest_InitWithParams)( - Cronet_UrlRequestPtr self, Cronet_EnginePtr engine, Cronet_String url, - Cronet_UrlRequestParamsPtr params, Cronet_UrlRequestCallbackPtr callback, - Cronet_ExecutorPtr executor); //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// @@ -41,26 +30,13 @@ intptr_t InitDartApiDL(void *data) { return Dart_InitializeApiDL(data); } //////////////////////////////////////////////////////////////////////////////// // Initialize required cronet functions -void InitCronetApi( - Cronet_RESULT (*Cronet_Engine_Shutdown)(Cronet_EnginePtr), - void (*Cronet_Engine_Destroy)(Cronet_EnginePtr), - Cronet_BufferPtr (*Cronet_Buffer_Create)(void), - void (*Cronet_Buffer_InitWithAlloc)(Cronet_BufferPtr, uint64_t), - Cronet_UrlRequestCallbackPtr (*Cronet_UrlRequestCallback_CreateWith)( - Cronet_UrlRequestCallback_OnRedirectReceivedFunc, - Cronet_UrlRequestCallback_OnResponseStartedFunc, - Cronet_UrlRequestCallback_OnReadCompletedFunc, - Cronet_UrlRequestCallback_OnSucceededFunc, - Cronet_UrlRequestCallback_OnFailedFunc, - Cronet_UrlRequestCallback_OnCanceledFunc), - Cronet_RESULT (*Cronet_UrlRequest_InitWithParams)( - Cronet_UrlRequestPtr, Cronet_EnginePtr, Cronet_String, - Cronet_UrlRequestParamsPtr, Cronet_UrlRequestCallbackPtr, - Cronet_ExecutorPtr)) { +void InitCronetApi(Cronet_RESULT (*Cronet_Engine_Shutdown)(Cronet_EnginePtr), + void (*Cronet_Engine_Destroy)(Cronet_EnginePtr), + Cronet_BufferPtr (*Cronet_Buffer_Create)(void), + void (*Cronet_Buffer_InitWithAlloc)(Cronet_BufferPtr, + uint64_t)) { if (!(Cronet_Engine_Shutdown && Cronet_Engine_Destroy && - Cronet_Buffer_Create && Cronet_Buffer_InitWithAlloc && - Cronet_UrlRequestCallback_CreateWith && - Cronet_UrlRequest_InitWithParams)) { + Cronet_Buffer_Create && Cronet_Buffer_InitWithAlloc)) { std::cerr << "Invalid pointer(s): null" << std::endl; return; } @@ -68,8 +44,6 @@ void InitCronetApi( _Cronet_Engine_Destroy = Cronet_Engine_Destroy; _Cronet_Buffer_Create = Cronet_Buffer_Create; _Cronet_Buffer_InitWithAlloc = Cronet_Buffer_InitWithAlloc; - _Cronet_UrlRequestCallback_CreateWith = Cronet_UrlRequestCallback_CreateWith; - _Cronet_UrlRequest_InitWithParams = Cronet_UrlRequest_InitWithParams; } //////////////////////////////////////////////////////////////////////////////// @@ -158,7 +132,9 @@ void RegisterHttpClient(Dart_Handle h, Cronet_Engine *ce) { Dart_NewFinalizableHandle_DL(h, peer, size, HttpClientDestroy); } -/* URL Callbacks Implementations */ +/* URL Callbacks Implementations +ISSUE: https://github.com/dart-lang/sdk/issues/37022 +*/ void OnRedirectReceived(Cronet_UrlRequestCallbackPtr self, Cronet_UrlRequestPtr request, @@ -203,32 +179,23 @@ void OnCanceled(Cronet_UrlRequestCallbackPtr self, Cronet_UrlRequestPtr request, DispatchCallback("OnCanceled", request, CallbackArgBuilder(0)); } -ExecutorPtr Create_Executor() { return new SampleExecutor(); } +// Creates a SampleExecutor Object. +SampleExecutorPtr SampleExecutorCreate() { return new SampleExecutor(); } -void Destroy_Executor(ExecutorPtr executor) { +// Destroys a SampleExecutor Object. +void SampleExecutorDestroy(SampleExecutorPtr executor) { if (executor == nullptr) { std::cerr << "Invalid executor pointer: null." << std::endl; return; } - delete reinterpret_cast(executor); + delete executor; } -// NOTE: Changed from original cronet's api. executor & callback params aren't -// needed. -Cronet_RESULT Cronet_UrlRequest_Init(Cronet_UrlRequestPtr self, - Cronet_EnginePtr engine, Cronet_String url, - Cronet_UrlRequestParamsPtr params, - ExecutorPtr _executor) { - SampleExecutor *executor = reinterpret_cast(_executor); - if (executor == nullptr) { - std::cerr << "Invalid executor pointer: null." << std::endl; - return Cronet_RESULT_NULL_POINTER_EXECUTOR; - } - executor->Init(); - Cronet_UrlRequestCallbackPtr urCallback = - _Cronet_UrlRequestCallback_CreateWith(OnRedirectReceived, - OnResponseStarted, OnReadCompleted, - OnSucceeded, OnFailed, OnCanceled); - return _Cronet_UrlRequest_InitWithParams(self, engine, url, params, - urCallback, executor->GetExecutor()); +// Initializes a SampleExecutor. +void InitSampleExecutor(SampleExecutorPtr self) { return self->Init(); } + +// Cronet_ExecutorPtr of the provided SampleExecutor. +Cronet_ExecutorPtr +SampleExecutor_Cronet_ExecutorPtr_get(SampleExecutorPtr self) { + return self->GetExecutor(); } diff --git a/src/wrapper.h b/src/wrapper.h index c6a6a4d..789bba3 100644 --- a/src/wrapper.h +++ b/src/wrapper.h @@ -19,25 +19,17 @@ extern "C" { #include -DART_EXPORT intptr_t InitDartApiDL(void *data); -DART_EXPORT void InitCronetApi( - Cronet_RESULT (*Cronet_Engine_Shutdown)(Cronet_EnginePtr), - void (*Cronet_Engine_Destroy)(Cronet_EnginePtr), - Cronet_BufferPtr (*Cronet_Buffer_Create)(void), - void (*Cronet_Buffer_InitWithAlloc)(Cronet_BufferPtr, uint64_t), - Cronet_UrlRequestCallbackPtr (*Cronet_UrlRequestCallback_CreateWith)( - Cronet_UrlRequestCallback_OnRedirectReceivedFunc, - Cronet_UrlRequestCallback_OnResponseStartedFunc, - Cronet_UrlRequestCallback_OnReadCompletedFunc, - Cronet_UrlRequestCallback_OnSucceededFunc, - Cronet_UrlRequestCallback_OnFailedFunc, - Cronet_UrlRequestCallback_OnCanceledFunc), - Cronet_RESULT (*Cronet_UrlRequest_InitWithParams)( - Cronet_UrlRequestPtr, Cronet_EnginePtr, Cronet_String, - Cronet_UrlRequestParamsPtr, Cronet_UrlRequestCallbackPtr, - Cronet_ExecutorPtr)); - -DART_EXPORT void InitCronetExecutorApi( +typedef struct SampleExecutor *SampleExecutorPtr; + +WRAPPER_EXPORT intptr_t InitDartApiDL(void *data); +WRAPPER_EXPORT void +InitCronetApi(Cronet_RESULT (*Cronet_Engine_Shutdown)(Cronet_EnginePtr), + void (*Cronet_Engine_Destroy)(Cronet_EnginePtr), + Cronet_BufferPtr (*Cronet_Buffer_Create)(void), + void (*Cronet_Buffer_InitWithAlloc)(Cronet_BufferPtr, uint64_t)); + +/* Forward declaration. Implementation on sample_executor.cc */ +WRAPPER_EXPORT void InitCronetExecutorApi( Cronet_ExecutorPtr (*Cronet_Executor_CreateWith)( Cronet_Executor_ExecuteFunc), void (*Cronet_Executor_SetClientContext)(Cronet_ExecutorPtr, @@ -48,18 +40,50 @@ DART_EXPORT void InitCronetExecutorApi( void (*Cronet_Runnable_Run)(Cronet_RunnablePtr), void (*Cronet_Runnable_Destroy)(Cronet_RunnablePtr)); -typedef void *ExecutorPtr; +WRAPPER_EXPORT void RegisterHttpClient(Dart_Handle h, Cronet_Engine *ce); +WRAPPER_EXPORT void RegisterCallbackHandler(Dart_Port nativePort, + Cronet_UrlRequest *rp); +WRAPPER_EXPORT void RemoveRequest(Cronet_UrlRequest *rp); + +/* Callbacks. ISSUE: https://github.com/dart-lang/sdk/issues/37022 */ + +WRAPPER_EXPORT void OnRedirectReceived(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_String newLocationUrl); + +WRAPPER_EXPORT void OnResponseStarted(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); + +WRAPPER_EXPORT void OnReadCompleted(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_BufferPtr buffer, + uint64_t bytes_read); + +WRAPPER_EXPORT void OnSucceeded(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); + +WRAPPER_EXPORT void OnFailed(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info, + Cronet_ErrorPtr error); + +WRAPPER_EXPORT void OnCanceled(Cronet_UrlRequestCallbackPtr self, + Cronet_UrlRequestPtr request, + Cronet_UrlResponseInfoPtr info); + +/* Sample Executor C APIs */ + +WRAPPER_EXPORT SampleExecutorPtr SampleExecutorCreate(); +WRAPPER_EXPORT void SampleExecutorDestroy(SampleExecutorPtr executor); -DART_EXPORT ExecutorPtr Create_Executor(); -DART_EXPORT void Destroy_Executor(ExecutorPtr executor); +WRAPPER_EXPORT void InitSampleExecutor(SampleExecutorPtr self); +WRAPPER_EXPORT Cronet_ExecutorPtr +SampleExecutor_Cronet_ExecutorPtr_get(SampleExecutorPtr self); -DART_EXPORT void RegisterHttpClient(Dart_Handle h, Cronet_Engine *ce); -DART_EXPORT void RegisterCallbackHandler(Dart_Port nativePort, - Cronet_UrlRequest *rp); -DART_EXPORT void RemoveRequest(Cronet_UrlRequest *rp); -DART_EXPORT Cronet_RESULT Cronet_UrlRequest_Init( - Cronet_UrlRequest *self, Cronet_Engine *engine, Cronet_String url, - Cronet_UrlRequestParams *params, ExecutorPtr _executor); #ifdef __cplusplus } #endif diff --git a/src/wrapper_export.h b/src/wrapper_export.h index 3b8686a..82bf62f 100644 --- a/src/wrapper_export.h +++ b/src/wrapper_export.h @@ -6,9 +6,9 @@ #define WRAPPER_EXPORT_H_ #if defined(WIN32) -#define CRONET_EXPORT __declspec(dllexport) +#define WRAPPER_EXPORT __declspec(dllexport) #else -#define CRONET_EXPORT __attribute__((visibility("default"))) +#define WRAPPER_EXPORT __attribute__((visibility("default"))) #endif #endif // WRAPPER_EXPORT_H_ diff --git a/tool/build_wrapper.dart b/tool/build_wrapper.dart index ec06bb8..5f920eb 100644 --- a/tool/build_wrapper.dart +++ b/tool/build_wrapper.dart @@ -17,8 +17,9 @@ void main() { final cronetName = getDylibName('cronet.$cronetVersion'); if (!isCronetAvailable(Platform.isLinux ? 'linux64' : 'windows64')) { logger.stderr('${ansi.yellow}Make sure that your cronet shared library' - ' is named as $cronetName and either placed in ${Directory.current.path}' - ' or, available in your system\'s shared library search path.${ansi.none}'); + ' is named as $cronetName and either placed in ' + '${Directory.current.path} or, available in your system\'s shared' + ' library search path.${ansi.none}'); logger.stdout('For more info and build instructions, go to: ' 'https://github.com/google/cronet.dart/#building-your-own'); From 4452dbe068a9b56bb618bd74f6e444b19f39cc51 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Thu, 1 Jul 2021 18:05:30 +0530 Subject: [PATCH 37/42] tool: update tarballs. setup verify: delete verifier after done. --- bin/setup.dart | 51 ++++++++++++++++++++----------------------- tool/update_tars.dart | 23 +++++++++++++++++++ 2 files changed, 47 insertions(+), 27 deletions(-) create mode 100644 tool/update_tars.dart diff --git a/bin/setup.dart b/bin/setup.dart index 978643e..950803f 100644 --- a/bin/setup.dart +++ b/bin/setup.dart @@ -126,42 +126,39 @@ void verifyCronetBinary() { logger.stdout('Get the cronet binaries by running: dart run cronet:setup'); return; } - // If the sample is NOT built. - if (!File( - '${pwd.path}/.dart_tool/cronet/${Platform.operatingSystem}64/$buildName') - .existsSync()) { - logger.stdout('Building Sample...'); - var result = Process.runSync('cmake', [ - '$sampleSource/CMakeLists.txt', - '-B', - '$sampleSource/out/${Platform.operatingSystem}' - ], environment: { - 'CURRENTDIR': pwd.path - }); - print(result.stdout); - print(result.stderr); - result = Process.runSync( - 'cmake', ['--build', '$sampleSource/out/${Platform.operatingSystem}'], - environment: {'CURRENTDIR': pwd.path}); - print(result.stdout); - print(result.stderr); - final buildOutputPath = Platform.isLinux - ? '$sampleSource/out/${Platform.operatingSystem}/$buildName' - : '$sampleSource\\out\\${Platform.operatingSystem}\\Debug\\$buildName'; - logger.stdout('Copying...'); - File(buildOutputPath) - .copySync('.dart_tool/cronet/${Platform.operatingSystem}64/$buildName'); - } + logger.stdout('Building Sample...'); + var result = Process.runSync('cmake', [ + '$sampleSource/CMakeLists.txt', + '-B', + '$sampleSource/out/${Platform.operatingSystem}' + ], environment: { + 'CURRENTDIR': pwd.path + }); + print(result.stdout); + print(result.stderr); + result = Process.runSync( + 'cmake', ['--build', '$sampleSource/out/${Platform.operatingSystem}'], + environment: {'CURRENTDIR': pwd.path}); + print(result.stdout); + print(result.stderr); + final buildOutputPath = Platform.isLinux + ? '$sampleSource/out/${Platform.operatingSystem}/$buildName' + : '$sampleSource\\out\\${Platform.operatingSystem}\\Debug\\$buildName'; + + logger.stdout('Copying...'); + final sample = File(buildOutputPath) + .copySync('.dart_tool/cronet/${Platform.operatingSystem}64/$buildName'); logger.stdout('Verifying...'); - final result = Process.runSync( + result = Process.runSync( '.dart_tool/cronet/${Platform.operatingSystem}64/$buildName', []); if (result.exitCode == 0) { logger.stdout('${ansi.green}Verified! Cronet is working fine.${ansi.none}'); } else { logger.stderr('${ansi.red}Verification failed!${ansi.none}'); } + sample.deleteSync(); } Future main(List args) async { diff --git a/tool/update_tars.dart b/tool/update_tars.dart new file mode 100644 index 0000000..cee886d --- /dev/null +++ b/tool/update_tars.dart @@ -0,0 +1,23 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Update github releases tarballs. +import 'dart:io'; + +import 'package:cronet/src/constants.dart'; + +void main() { + Directory.current = Directory.current.uri.resolve('.dart_tool/cronet').path; + for (final platform in validPlatforms) { + if (File('$platform/${getCronetName(platform)}').existsSync()) { + final result = + Process.runSync('tar', ['-czvf', '$platform.tar.gz', platform]); + print(result.stdout); + print(result.stderr); + } else { + print( + '${getCronetName(platform)} not found in .dart_tool/cronet/$platform'); + } + } +} From 1dcb37018e97532c0a9c9153ac5bb22241372245 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Fri, 2 Jul 2021 17:27:22 +0530 Subject: [PATCH 38/42] readme: setup command, add: ffigen issue reference --- README.md | 2 +- lib/src/http_client_request.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 192ea7f..d0a0fef 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ dart run ```bash dart pub get -dart run cronet # Downloads the cronet binaries. +dart run cronet:setup # Downloads the cronet binaries. dart test --platform vm ``` diff --git a/lib/src/http_client_request.dart b/lib/src/http_client_request.dart index 2ef627e..74563da 100644 --- a/lib/src/http_client_request.dart +++ b/lib/src/http_client_request.dart @@ -94,10 +94,10 @@ class HttpClientRequestImpl implements HttpClientRequest { void _startRequest() { final requestParams = cronet.Cronet_UrlRequestParams_Create(); if (requestParams == nullptr) throw Error(); + // TODO: ISSUE https://github.com/dart-lang/ffigen/issues/22 cronet.Cronet_UrlRequestParams_http_method_set( requestParams, _method.toNativeUtf8().cast()); wrapper.InitSampleExecutor(_callbackHandler.executor); - final cronetCallbacks = cronet.Cronet_UrlRequestCallback_CreateWith( wrapper.addresses.OnRedirectReceived.cast(), wrapper.addresses.OnResponseStarted.cast(), From c50d7b32dd13f7e3012d4692ea65a5f4620b6def Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Fri, 2 Jul 2021 17:30:16 +0530 Subject: [PATCH 39/42] readme: typo fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d0a0fef..c736a58 100644 --- a/README.md +++ b/README.md @@ -69,4 +69,4 @@ Make sure to have `cmake 3.15`. 2. Run `dart run cronet:setup build` from the root of your project. -**Note for Windows:** Run `step 3` from `x64 Native Tools Command Prompt for VS 2019` shell. +**Note for Windows:** Run `step 2` from `x64 Native Tools Command Prompt for VS 2019` shell. From f222aa490249852a0e8a70637ed3c9d50f3c09fd Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Fri, 2 Jul 2021 17:38:52 +0530 Subject: [PATCH 40/42] readme: supported platforms --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index c736a58..7dddf41 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ This is a [GSoC 2021 project](https://summerofcode.withgoogle.com/projects/#4757 ## Usage +### Supported Platforms + +Currently, 64 bit Linux and Windows systems are supported. + 1. Add package as a dependency in your `pubspec.yaml`. 2. Run this from the `root` of your project. From 3de33746f86da711554202f250c40f11915a8602 Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Fri, 2 Jul 2021 17:43:04 +0530 Subject: [PATCH 41/42] readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7dddf41..d7419a4 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,12 @@ This package binds to Cronet's [native API](https://chromium.googlesource.com/ch This is a [GSoC 2021 project](https://summerofcode.withgoogle.com/projects/#4757095741652992). -## Usage - -### Supported Platforms +## Supported Platforms Currently, 64 bit Linux and Windows systems are supported. +## Usage + 1. Add package as a dependency in your `pubspec.yaml`. 2. Run this from the `root` of your project. From ec2efb0f610f953c1a5d5375e34394c79c5bde2d Mon Sep 17 00:00:00 2001 From: Soumyadip Mondal Date: Fri, 2 Jul 2021 17:55:21 +0530 Subject: [PATCH 42/42] update: binary download url --- lib/src/constants.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/src/constants.dart b/lib/src/constants.dart index b0d6168..e2db8f0 100644 --- a/lib/src/constants.dart +++ b/lib/src/constants.dart @@ -5,10 +5,9 @@ import 'dart:io' show Platform; const validPlatforms = ['linux64', 'windows64']; -const release = '0.0.1'; -// TODO: Change URL and Version +const tag = 'binaries-v0.0.1'; const cronetBinaryUrl = - 'https://github.com/unsuitable001/cronet.dart/releases/download/$release/'; + 'https://github.com/google/cronet.dart/releases/download/$tag/'; const cronetVersion = "86.0.4240.198"; const binaryStorageDir = '.dart_tool/cronet/';