This source file includes following definitions.
- CalledByNative
- create
- getOriginal
- getReceived
- getInstance
- initDataReductionProxySettings
- bypassHostPattern
- bypassURLPattern
- isDataReductionProxyAllowed
- isDataReductionProxyPromoAllowed
- getDataReductionProxyOrigin
- setDataReductionProxyEnabled
- isDataReductionProxyEnabled
- isDataReductionProxyManaged
- getDataReductionLastUpdateTime
- getContentLengths
- isAcceptableAuthChallenge
- getTokenForAuthChallenge
- getOriginalNetworkStatsHistory
- getReceivedNetworkStatsHistory
- getContentLengthPercentSavings
- nativeInit
- nativeInitDataReductionProxySettings
- nativeBypassHostPattern
- nativeBypassURLPattern
- nativeIsDataReductionProxyAllowed
- nativeIsDataReductionProxyPromoAllowed
- nativeGetDataReductionProxyOrigin
- nativeIsDataReductionProxyEnabled
- nativeIsDataReductionProxyManaged
- nativeSetDataReductionProxyEnabled
- nativeGetDataReductionLastUpdateTime
- nativeGetContentLengths
- nativeIsAcceptableAuthChallenge
- nativeGetTokenForAuthChallenge
- nativeGetDailyOriginalContentLengths
- nativeGetDailyReceivedContentLengths
package org.chromium.chrome.browser.net.spdyproxy;
import org.chromium.base.CalledByNative;
import org.chromium.base.ThreadUtils;
import java.text.NumberFormat;
import java.util.Locale;
public class DataReductionProxySettings {
public static class ContentLengths {
private final long mOriginal;
private final long mReceived;
@CalledByNative("ContentLengths")
public static ContentLengths create(long original, long received) {
return new ContentLengths(original, received);
}
private ContentLengths(long original, long received) {
mOriginal = original;
mReceived = received;
}
public long getOriginal() {
return mOriginal;
}
public long getReceived() {
return mReceived;
}
}
private static DataReductionProxySettings sSettings;
public static DataReductionProxySettings getInstance() {
ThreadUtils.assertOnUiThread();
if (sSettings == null) {
sSettings = new DataReductionProxySettings();
}
return sSettings;
}
private final long mNativeDataReductionProxySettings;
private DataReductionProxySettings() {
mNativeDataReductionProxySettings = nativeInit();
initDataReductionProxySettings();
}
public void initDataReductionProxySettings() {
nativeInitDataReductionProxySettings(mNativeDataReductionProxySettings);
}
public void bypassHostPattern(String pattern) {
nativeBypassHostPattern(mNativeDataReductionProxySettings, pattern);
}
public void bypassURLPattern(String pattern) {
nativeBypassURLPattern(mNativeDataReductionProxySettings, pattern);
}
public boolean isDataReductionProxyAllowed() {
return nativeIsDataReductionProxyAllowed(mNativeDataReductionProxySettings);
}
public boolean isDataReductionProxyPromoAllowed() {
return nativeIsDataReductionProxyPromoAllowed(mNativeDataReductionProxySettings);
}
public String getDataReductionProxyOrigin() {
return nativeGetDataReductionProxyOrigin(mNativeDataReductionProxySettings);
}
public void setDataReductionProxyEnabled(boolean enabled) {
nativeSetDataReductionProxyEnabled(mNativeDataReductionProxySettings, enabled);
}
public boolean isDataReductionProxyEnabled() {
return nativeIsDataReductionProxyEnabled(mNativeDataReductionProxySettings);
}
public boolean isDataReductionProxyManaged() {
return nativeIsDataReductionProxyManaged(mNativeDataReductionProxySettings);
}
public long getDataReductionLastUpdateTime() {
return nativeGetDataReductionLastUpdateTime(mNativeDataReductionProxySettings);
}
public ContentLengths getContentLengths() {
return nativeGetContentLengths(mNativeDataReductionProxySettings);
}
public boolean isAcceptableAuthChallenge(String host, String realm) {
return nativeIsAcceptableAuthChallenge(mNativeDataReductionProxySettings, host, realm);
}
public String getTokenForAuthChallenge(String host, String realm) {
return nativeGetTokenForAuthChallenge(mNativeDataReductionProxySettings, host, realm);
}
public long[] getOriginalNetworkStatsHistory() {
return nativeGetDailyOriginalContentLengths(mNativeDataReductionProxySettings);
}
public long[] getReceivedNetworkStatsHistory() {
return nativeGetDailyReceivedContentLengths(mNativeDataReductionProxySettings);
}
public String getContentLengthPercentSavings() {
ContentLengths length = getContentLengths();
double savings = 0;
if (length.getOriginal() > 0L && length.getOriginal() > length.getReceived()) {
savings = (length.getOriginal() - length.getReceived()) / (double) length.getOriginal();
}
NumberFormat percentageFormatter = NumberFormat.getPercentInstance(Locale.getDefault());
return percentageFormatter.format(savings);
}
private native long nativeInit();
private native void nativeInitDataReductionProxySettings(
long nativeDataReductionProxySettingsAndroid);
private native void nativeBypassHostPattern(
long nativeDataReductionProxySettingsAndroid, String pattern);
private native void nativeBypassURLPattern(
long nativeDataReductionProxySettingsAndroid, String pattern);
private native boolean nativeIsDataReductionProxyAllowed(
long nativeDataReductionProxySettingsAndroid);
private native boolean nativeIsDataReductionProxyPromoAllowed(
long nativeDataReductionProxySettingsAndroid);
private native String nativeGetDataReductionProxyOrigin(
long nativeDataReductionProxySettingsAndroid);
private native boolean nativeIsDataReductionProxyEnabled(
long nativeDataReductionProxySettingsAndroid);
private native boolean nativeIsDataReductionProxyManaged(
long nativeDataReductionProxySettingsAndroid);
private native void nativeSetDataReductionProxyEnabled(
long nativeDataReductionProxySettingsAndroid, boolean enabled);
private native long nativeGetDataReductionLastUpdateTime(
long nativeDataReductionProxySettingsAndroid);
private native ContentLengths nativeGetContentLengths(
long nativeDataReductionProxySettingsAndroid);
private native boolean nativeIsAcceptableAuthChallenge(
long nativeDataReductionProxySettingsAndroid, String host, String realm);
private native String nativeGetTokenForAuthChallenge(
long nativeDataReductionProxySettingsAndroid, String host, String realm);
private native long[] nativeGetDailyOriginalContentLengths(
long nativeDataReductionProxySettingsAndroid);
private native long[] nativeGetDailyReceivedContentLengths(
long nativeDataReductionProxySettingsAndroid);
}