Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mobile: Rewrite Java/JNI stream callbacks #34234

Merged
merged 2 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions mobile/library/common/types/c_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ typedef struct {
int64_t response_start_ms;
// The time when the stream reached a final state: Error, Cancel, Success.
int64_t stream_end_ms;
// TODO(fredyw): This should be a bool instead.
// True if the upstream socket had been used previously.
uint64_t socket_reused;
// The number of bytes sent upstream.
Expand Down
3 changes: 0 additions & 3 deletions mobile/library/java/io/envoyproxy/envoymobile/engine/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,15 @@ java_library(
"EnvoyConfiguration.java",
"EnvoyEngine.java",
"EnvoyEngineImpl.java",
"EnvoyFinalStreamIntelImpl.java",
"EnvoyHTTPFilterCallbacksImpl.java",
"EnvoyHTTPStream.java",
"EnvoyNativeFilterConfig.java",
"EnvoyNativeResourceRegistry.java",
"EnvoyNativeResourceReleaser.java",
"EnvoyNativeResourceWrapper.java",
"EnvoyStreamIntelImpl.java",
"HeaderMatchConfig.java",
"JniBridgeUtility.java",
"JniLibrary.java",
"JvmCallbackContext.java",
"JvmFilterContext.java",
"JvmFilterFactoryContext.java",
"JvmKeyValueStoreContext.java",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ public class EnvoyHTTPStream {
private final long engineHandle;
private final long streamHandle;
private final boolean explicitFlowControl;
private final JvmCallbackContext callbacksContext;
private final EnvoyHTTPCallbacks callbacks;

/**
* Start the stream via the JNI library.
*/
void start() {
JniLibrary.startStream(engineHandle, streamHandle, callbacksContext, explicitFlowControl);
JniLibrary.startStream(engineHandle, streamHandle, callbacks, explicitFlowControl);
}

/**
Expand All @@ -31,7 +31,7 @@ public EnvoyHTTPStream(long engineHandle, long streamHandle, EnvoyHTTPCallbacks
this.engineHandle = engineHandle;
this.streamHandle = streamHandle;
this.explicitFlowControl = explicitFlowControl;
callbacksContext = new JvmCallbackContext(callbacks);
this.callbacks = callbacks;
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.envoyproxy.envoymobile.engine;

import io.envoyproxy.envoymobile.engine.types.EnvoyEventTracker;
import io.envoyproxy.envoymobile.engine.types.EnvoyHTTPCallbacks;
import io.envoyproxy.envoymobile.engine.types.EnvoyLogger;
import io.envoyproxy.envoymobile.engine.types.EnvoyOnEngineRunning;
import java.nio.ByteBuffer;
Expand Down Expand Up @@ -58,16 +59,13 @@ private static class JavaLoader {
* Open an underlying HTTP stream. Note: Streams must be started before other
* other interaction can can occur.
*
* @param engine, handle to the stream's associated engine.
* @param stream, handle to the stream to be started.
* @param context, context that contains dispatch logic to fire callbacks
* callbacks.
* @param explicitFlowControl, whether explicit flow control should be enabled
* for the stream.
* @return envoy_stream, with a stream handle and a success status, or a failure
* status.
* @param engine handle to the stream's associated engine.
* @param stream handle to the stream to be started.
* @param callbacks context that contains dispatch logic to fire callbacks.
* @param explicitFlowControl whether explicit flow control should be enabled for the stream.
* @return a stream handle and a success status, or a failure status.
*/
protected static native int startStream(long engine, long stream, JvmCallbackContext context,
protected static native int startStream(long engine, long stream, EnvoyHTTPCallbacks callbacks,
boolean explicitFlowControl);

/**
Expand Down Expand Up @@ -263,7 +261,7 @@ public static native Object callCertificateVerificationFromNative(byte[][] certC
* Mimic a call to AndroidNetworkLibrary#addTestRootCertificate from native code.
* To be used for testing only.
*
* @param rootCert DER encoded bytes of the certificate.
* @param cert DER encoded bytes of the certificate.
*/
public static native void callAddTestRootCertificateFromNative(byte[] cert);

Expand All @@ -274,7 +272,7 @@ public static native Object callCertificateVerificationFromNative(byte[][] certC
*/
public static native void callClearTestRootCertificateFromNative();

/*
/**
* Given a filter name, create the proto config for adding the native filter
*
* @param filterName the name of the native filter
Expand Down