Commit 0363215d authored by Eric Stevenson's avatar Eric Stevenson Committed by Commit Bot

JNI refactor: @NativeMethods conversion (//net).

This CL was generated by
//base/android/jni_generator/jni_refactorer.py.

//net/android/java/src/org/chromium/net/HttpNegotiateAuthenticator.java
was omitted from this CL as it requires additional test refactoring
before being converted to use @NativeMethods.

Bug: 929661
Change-Id: I9bb82694017f792e59a488eb400173da515c3374
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1809397Reviewed-by: default avatarPaul Jensen <pauljensen@chromium.org>
Commit-Queue: Eric Stevenson <estevenson@chromium.org>
Auto-Submit: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700350}
parent d84b95f4
......@@ -31,9 +31,11 @@ android_library("net_java") {
deps = [
":net_thread_stats_uid_java",
"//base:base_java",
"//base:jni_java",
"//third_party/android_deps:androidx_annotation_annotation_java",
"//third_party/jsr-305:jsr_305_javalib",
]
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
srcjar_deps = [
":net_errors_java",
":net_android_java_enums_srcjar",
......
......@@ -5,6 +5,7 @@
package org.chromium.net;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
/**
* Class to access the GURL library from java.
......@@ -20,7 +21,7 @@ public final class GURLUtils {
* @return The origin of the url
*/
public static String getOrigin(String url) {
return nativeGetOrigin(url);
return GURLUtilsJni.get().getOrigin(url);
}
/**
......@@ -30,9 +31,12 @@ public final class GURLUtils {
* @return The scheme of the url.
*/
public static String getScheme(String url) {
return nativeGetScheme(url);
return GURLUtilsJni.get().getScheme(url);
}
private static native String nativeGetOrigin(String url);
private static native String nativeGetScheme(String url);
@NativeMethods
interface Natives {
String getOrigin(String url);
String getScheme(String url);
}
}
......@@ -5,6 +5,7 @@
package org.chromium.net;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
/**
* Class to access HttpUtil library from Java.
......@@ -20,7 +21,11 @@ public final class HttpUtil {
* - |headerValue| is validly formed (see HttpUtil::IsValidHeaderValue).
*/
public static boolean isAllowedHeader(String headerName, String headerValue) {
return nativeIsAllowedHeader(headerName, headerValue);
return HttpUtilJni.get().isAllowedHeader(headerName, headerValue);
}
@NativeMethods
interface Natives {
boolean isAllowedHeader(String headerName, String headerValue);
}
private static native boolean nativeIsAllowedHeader(String headerName, String headerValue);
}
......@@ -15,6 +15,7 @@ import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeClassQualifiedName;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.compat.ApiHelperForM;
import java.util.ArrayList;
......@@ -309,8 +310,8 @@ public class NetworkChangeNotifier {
private void notifyObserversOfConnectionTypeChange(int newConnectionType, long defaultNetId) {
for (Long nativeChangeNotifier : mNativeChangeNotifiers) {
nativeNotifyConnectionTypeChanged(
nativeChangeNotifier, newConnectionType, defaultNetId);
NetworkChangeNotifierJni.get().notifyConnectionTypeChanged(nativeChangeNotifier,
NetworkChangeNotifier.this, newConnectionType, defaultNetId);
}
for (ConnectionTypeObserver observer : mConnectionTypeObservers) {
observer.onConnectionTypeChanged(newConnectionType);
......@@ -322,7 +323,8 @@ public class NetworkChangeNotifier {
*/
void notifyObserversOfConnectionSubtypeChange(int connectionSubtype) {
for (Long nativeChangeNotifier : mNativeChangeNotifiers) {
nativeNotifyMaxBandwidthChanged(nativeChangeNotifier, connectionSubtype);
NetworkChangeNotifierJni.get().notifyMaxBandwidthChanged(
nativeChangeNotifier, NetworkChangeNotifier.this, connectionSubtype);
}
}
......@@ -331,7 +333,8 @@ public class NetworkChangeNotifier {
*/
void notifyObserversOfNetworkConnect(long netId, int connectionType) {
for (Long nativeChangeNotifier : mNativeChangeNotifiers) {
nativeNotifyOfNetworkConnect(nativeChangeNotifier, netId, connectionType);
NetworkChangeNotifierJni.get().notifyOfNetworkConnect(
nativeChangeNotifier, NetworkChangeNotifier.this, netId, connectionType);
}
}
......@@ -340,7 +343,8 @@ public class NetworkChangeNotifier {
*/
void notifyObserversOfNetworkSoonToDisconnect(long netId) {
for (Long nativeChangeNotifier : mNativeChangeNotifiers) {
nativeNotifyOfNetworkSoonToDisconnect(nativeChangeNotifier, netId);
NetworkChangeNotifierJni.get().notifyOfNetworkSoonToDisconnect(
nativeChangeNotifier, NetworkChangeNotifier.this, netId);
}
}
......@@ -349,7 +353,8 @@ public class NetworkChangeNotifier {
*/
void notifyObserversOfNetworkDisconnect(long netId) {
for (Long nativeChangeNotifier : mNativeChangeNotifiers) {
nativeNotifyOfNetworkDisconnect(nativeChangeNotifier, netId);
NetworkChangeNotifierJni.get().notifyOfNetworkDisconnect(
nativeChangeNotifier, NetworkChangeNotifier.this, netId);
}
}
......@@ -361,7 +366,8 @@ public class NetworkChangeNotifier {
*/
void notifyObserversToPurgeActiveNetworkList(long[] activeNetIds) {
for (Long nativeChangeNotifier : mNativeChangeNotifiers) {
nativeNotifyPurgeActiveNetworkList(nativeChangeNotifier, activeNetIds);
NetworkChangeNotifierJni.get().notifyPurgeActiveNetworkList(
nativeChangeNotifier, NetworkChangeNotifier.this, activeNetIds);
}
}
......@@ -410,26 +416,6 @@ public class NetworkChangeNotifier {
return getInstance().isProcessBoundToNetworkInternal();
}
@NativeClassQualifiedName("NetworkChangeNotifierDelegateAndroid")
private native void nativeNotifyConnectionTypeChanged(
long nativePtr, int newConnectionType, long defaultNetId);
@NativeClassQualifiedName("NetworkChangeNotifierDelegateAndroid")
private native void nativeNotifyMaxBandwidthChanged(long nativePtr, int subType);
@NativeClassQualifiedName("NetworkChangeNotifierDelegateAndroid")
private native void nativeNotifyOfNetworkConnect(
long nativePtr, long netId, int connectionType);
@NativeClassQualifiedName("NetworkChangeNotifierDelegateAndroid")
private native void nativeNotifyOfNetworkSoonToDisconnect(long nativePtr, long netId);
@NativeClassQualifiedName("NetworkChangeNotifierDelegateAndroid")
private native void nativeNotifyOfNetworkDisconnect(long nativePtr, long netId);
@NativeClassQualifiedName("NetworkChangeNotifierDelegateAndroid")
private native void nativeNotifyPurgeActiveNetworkList(long nativePtr, long[] activeNetIds);
// For testing only.
public static NetworkChangeNotifierAutoDetect getAutoDetectorForTest() {
return getInstance().mAutoDetector;
......@@ -442,4 +428,29 @@ public class NetworkChangeNotifier {
int connectionType = getInstance().getCurrentConnectionType();
return connectionType != ConnectionType.CONNECTION_NONE;
}
@NativeMethods
interface Natives {
@NativeClassQualifiedName("NetworkChangeNotifierDelegateAndroid")
void notifyConnectionTypeChanged(long nativePtr, NetworkChangeNotifier caller,
int newConnectionType, long defaultNetId);
@NativeClassQualifiedName("NetworkChangeNotifierDelegateAndroid")
void notifyMaxBandwidthChanged(long nativePtr, NetworkChangeNotifier caller, int subType);
@NativeClassQualifiedName("NetworkChangeNotifierDelegateAndroid")
void notifyOfNetworkConnect(
long nativePtr, NetworkChangeNotifier caller, long netId, int connectionType);
@NativeClassQualifiedName("NetworkChangeNotifierDelegateAndroid")
void notifyOfNetworkSoonToDisconnect(
long nativePtr, NetworkChangeNotifier caller, long netId);
@NativeClassQualifiedName("NetworkChangeNotifierDelegateAndroid")
void notifyOfNetworkDisconnect(long nativePtr, NetworkChangeNotifier caller, long netId);
@NativeClassQualifiedName("NetworkChangeNotifierDelegateAndroid")
void notifyPurgeActiveNetworkList(
long nativePtr, NetworkChangeNotifier caller, long[] activeNetIds);
}
}
......@@ -25,6 +25,7 @@ import org.chromium.base.ContextUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeClassQualifiedName;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.annotations.UsedByReflection;
import java.lang.reflect.InvocationTargetException;
......@@ -214,10 +215,11 @@ public class ProxyChangeListener {
}
if (cfg != null) {
nativeProxySettingsChangedTo(
mNativePtr, cfg.mHost, cfg.mPort, cfg.mPacUrl, cfg.mExclusionList);
ProxyChangeListenerJni.get().proxySettingsChangedTo(mNativePtr,
ProxyChangeListener.this, cfg.mHost, cfg.mPort, cfg.mPacUrl,
cfg.mExclusionList);
} else {
nativeProxySettingsChanged(mNativePtr);
ProxyChangeListenerJni.get().proxySettingsChanged(mNativePtr, ProxyChangeListener.this);
}
}
......@@ -293,9 +295,14 @@ public class ProxyChangeListener {
/**
* See net/proxy_resolution/proxy_config_service_android.cc
*/
@NativeClassQualifiedName("ProxyConfigServiceAndroid::JNIDelegate")
private native void nativeProxySettingsChangedTo(
long nativePtr, String host, int port, String pacUrl, String[] exclusionList);
@NativeClassQualifiedName("ProxyConfigServiceAndroid::JNIDelegate")
private native void nativeProxySettingsChanged(long nativePtr);
@NativeMethods
interface Natives {
@NativeClassQualifiedName("ProxyConfigServiceAndroid::JNIDelegate")
void proxySettingsChangedTo(long nativePtr, ProxyChangeListener caller, String host,
int port, String pacUrl, String[] exclusionList);
@NativeClassQualifiedName("ProxyConfigServiceAndroid::JNIDelegate")
void proxySettingsChanged(long nativePtr, ProxyChangeListener caller);
}
}
......@@ -18,6 +18,7 @@ import android.util.Pair;
import org.chromium.base.ContextUtils;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.MainDex;
import org.chromium.base.annotations.NativeMethods;
import java.io.ByteArrayInputStream;
import java.io.File;
......@@ -326,7 +327,7 @@ public class X509Util {
sSystemTrustAnchorCache = null;
ensureInitializedLocked();
}
nativeNotifyKeyChainChanged();
X509UtilJni.get().notifyKeyChainChanged();
}
/**
......@@ -557,8 +558,12 @@ public class X509Util {
public static void setDisableNativeCodeForTest(boolean disabled) {
sDisableNativeCodeForTest = disabled;
}
/**
* Notify the native net::CertDatabase instance that the system database has been updated.
*/
private static native void nativeNotifyKeyChainChanged();
@NativeMethods
interface Natives {
/**
* Notify the native net::CertDatabase instance that the system database has been updated.
*/
void notifyKeyChainChanged();
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment