-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch
cronet_http
to use jnigen (#1016)
- Loading branch information
1 parent
de19214
commit 2cbb703
Showing
16 changed files
with
4,292 additions
and
541 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
# pigeon generated code | ||
lib/src/messages.dart linguist-generated | ||
android/src/main/java/io/flutter/plugins/cronet_http/Messages.java linguist-generated | ||
|
||
# jnigen generated code | ||
lib/src/jni/jni_bindings.dart linguist-generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
239 changes: 0 additions & 239 deletions
239
pkgs/cronet_http/android/src/main/kotlin/io/flutter/plugins/cronet_http/CronetHttpPlugin.kt
This file was deleted.
Oops, something went wrong.
77 changes: 77 additions & 0 deletions
77
...et_http/android/src/main/kotlin/io/flutter/plugins/cronet_http/UrlRequestCallbackProxy.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright (c) 2023, 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. | ||
|
||
// Cronet allows developers to manage HTTP requests by subclassing the | ||
// the abstract class `UrlRequest.Callback`. | ||
// | ||
// `package:jnigen` does not support the ability to subclass abstract Java | ||
// classes in Dart (see https://github.com/dart-lang/jnigen/issues/348). | ||
// | ||
// This file provides an interface `UrlRequestCallbackInterface`, which can | ||
// be implemented in Dart and a wrapper class `UrlRequestCallbackProxy`, which | ||
// can be passed to the Cronet API. | ||
|
||
package io.flutter.plugins.cronet_http | ||
|
||
import org.chromium.net.CronetException | ||
import org.chromium.net.UrlRequest | ||
import org.chromium.net.UrlResponseInfo | ||
import java.nio.ByteBuffer | ||
|
||
|
||
class UrlRequestCallbackProxy(val callback: UrlRequestCallbackInterface) : UrlRequest.Callback() { | ||
public interface UrlRequestCallbackInterface { | ||
fun onRedirectReceived( | ||
request: UrlRequest, | ||
info: UrlResponseInfo, | ||
newLocationUrl: String | ||
) | ||
|
||
fun onResponseStarted(request: UrlRequest?, info: UrlResponseInfo) | ||
fun onReadCompleted( | ||
request: UrlRequest, | ||
info: UrlResponseInfo, | ||
byteBuffer: ByteBuffer | ||
) | ||
|
||
fun onSucceeded(request: UrlRequest, info: UrlResponseInfo?) | ||
fun onFailed( | ||
request: UrlRequest, | ||
info: UrlResponseInfo?, | ||
error: CronetException | ||
) | ||
} | ||
|
||
override fun onRedirectReceived( | ||
request: UrlRequest, | ||
info: UrlResponseInfo, | ||
newLocationUrl: String | ||
) { | ||
callback.onRedirectReceived(request, info, newLocationUrl); | ||
} | ||
|
||
override fun onResponseStarted(request: UrlRequest?, info: UrlResponseInfo) { | ||
callback.onResponseStarted(request, info); | ||
} | ||
|
||
override fun onReadCompleted( | ||
request: UrlRequest, | ||
info: UrlResponseInfo, | ||
byteBuffer: ByteBuffer | ||
) { | ||
callback.onReadCompleted(request, info, byteBuffer); | ||
} | ||
|
||
override fun onSucceeded(request: UrlRequest, info: UrlResponseInfo?) { | ||
callback.onSucceeded(request, info); | ||
} | ||
|
||
override fun onFailed( | ||
request: UrlRequest, | ||
info: UrlResponseInfo?, | ||
error: CronetException | ||
) { | ||
callback.onFailed(request, info, error); | ||
} | ||
} |
Oops, something went wrong.