Java Code Examples for org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings#getInstance()

The following examples show how to use org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings#getInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataReductionPreferences.java    From delion with Apache License 2.0 6 votes vote down vote up
private static NetworkStatsHistory getNetworkStatsHistory(long[] history, int days) {
    if (days > history.length) days = history.length;
    NetworkStatsHistory networkStatsHistory =
            new NetworkStatsHistory(
                    DateUtils.DAY_IN_MILLIS, days, NetworkStatsHistory.FIELD_RX_BYTES);

    DataReductionProxySettings config = DataReductionProxySettings.getInstance();
    long time = config.getDataReductionLastUpdateTime() - days * DateUtils.DAY_IN_MILLIS;
    for (int i = history.length - days, bucket = 0; i < history.length; i++, bucket++) {
        NetworkStats.Entry entry = new NetworkStats.Entry();
        entry.rxBytes = history[i];
        long startTime = time + (DateUtils.DAY_IN_MILLIS * bucket);
        // Spread each day's record over the first hour of the day.
        networkStatsHistory.recordData(
                startTime, startTime + DateUtils.HOUR_IN_MILLIS, entry);
    }
    return networkStatsHistory;
}
 
Example 2
Source File: DataReductionPreferences.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private static NetworkStatsHistory getNetworkStatsHistory(long[] history, int days) {
    if (days > history.length) days = history.length;
    NetworkStatsHistory networkStatsHistory =
            new NetworkStatsHistory(
                    DateUtils.DAY_IN_MILLIS, days, NetworkStatsHistory.FIELD_RX_BYTES);

    DataReductionProxySettings config = DataReductionProxySettings.getInstance();
    long time = config.getDataReductionLastUpdateTime() - days * DateUtils.DAY_IN_MILLIS;
    for (int i = history.length - days, bucket = 0; i < history.length; i++, bucket++) {
        NetworkStats.Entry entry = new NetworkStats.Entry();
        entry.rxBytes = history[i];
        long startTime = time + (DateUtils.DAY_IN_MILLIS * bucket);
        // Spread each day's record over the first hour of the day.
        networkStatsHistory.recordData(
                startTime, startTime + DateUtils.HOUR_IN_MILLIS, entry);
    }
    return networkStatsHistory;
}
 
Example 3
Source File: DataReductionStatsPreference.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private static NetworkStatsHistory getNetworkStatsHistory(long[] history, int days) {
    if (days > history.length) days = history.length;
    NetworkStatsHistory networkStatsHistory = new NetworkStatsHistory(
            DateUtils.DAY_IN_MILLIS, days, NetworkStatsHistory.FIELD_RX_BYTES);

    DataReductionProxySettings config = DataReductionProxySettings.getInstance();
    long time = config.getDataReductionLastUpdateTime() - days * DateUtils.DAY_IN_MILLIS;
    for (int i = history.length - days, bucket = 0; i < history.length; i++, bucket++) {
        NetworkStats.Entry entry = new NetworkStats.Entry();
        entry.rxBytes = history[i];
        long startTime = time + (DateUtils.DAY_IN_MILLIS * bucket);
        // Spread each day's record over the first hour of the day.
        networkStatsHistory.recordData(startTime, startTime + DateUtils.HOUR_IN_MILLIS, entry);
    }
    return networkStatsHistory;
}
 
Example 4
Source File: DataReductionPreferences.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the preference screen to convey current statistics on data reduction.
 */
public void updateReductionStatistics() {
    DataReductionProxySettings config = DataReductionProxySettings.getInstance();

    DataReductionStatsPreference statsPref = (DataReductionStatsPreference)
            getPreferenceScreen().findPreference(PREF_DATA_REDUCTION_STATS);
    long original[] = config.getOriginalNetworkStatsHistory();
    long received[] = config.getReceivedNetworkStatsHistory();
    statsPref.setReductionStats(
            config.getDataReductionLastUpdateTime(),
            getNetworkStatsHistory(original, DAYS_IN_CHART),
            getNetworkStatsHistory(received, DAYS_IN_CHART));
}
 
Example 5
Source File: DataReductionPreferences.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the preference screen to convey current statistics on data reduction.
 */
public void updateReductionStatistics() {
    DataReductionProxySettings config = DataReductionProxySettings.getInstance();

    DataReductionStatsPreference statsPref = (DataReductionStatsPreference)
            getPreferenceScreen().findPreference(PREF_DATA_REDUCTION_STATS);
    long original[] = config.getOriginalNetworkStatsHistory();
    long received[] = config.getReceivedNetworkStatsHistory();
    statsPref.setReductionStats(
            config.getDataReductionLastUpdateTime(),
            getNetworkStatsHistory(original, DAYS_IN_CHART),
            getNetworkStatsHistory(received, DAYS_IN_CHART));
}