Java Code Examples for org.chromium.base.metrics.RecordHistogram#recordCustomCountHistogram()

The following examples show how to use org.chromium.base.metrics.RecordHistogram#recordCustomCountHistogram() . 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: ClearBrowsingDataPreferences.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * This is the callback for the important domain dialog. We should only clear if we get the
 * positive button response.
 */
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == IMPORTANT_SITES_DIALOG_CODE && resultCode == Activity.RESULT_OK) {
        // Deselected means that the user is excluding the domain from being cleared.
        String[] deselectedDomains = data.getStringArrayExtra(
                ConfirmImportantSitesDialogFragment.DESELECTED_DOMAINS_TAG);
        if (deselectedDomains != null && mSortedImportantDomains != null) {
            // mMaxImportantSites is a constant on the C++ side.
            RecordHistogram.recordCustomCountHistogram(
                    "History.ClearBrowsingData.ImportantDeselectedNum",
                    deselectedDomains.length, 0, mMaxImportantSites + 1,
                    mMaxImportantSites + 1);
            // We put our max at 20 instead of 100 to reduce the number of empty buckets (as
            // our maximum denominator is 5).
            RecordHistogram.recordEnumeratedHistogram(
                    "History.ClearBrowsingData.ImportantDeselectedPercent",
                    deselectedDomains.length * IMPORTANT_SITES_PERCENTAGE_BUCKET_COUNT
                            / mSortedImportantDomains.length,
                    IMPORTANT_SITES_PERCENTAGE_BUCKET_COUNT + 1);
        }
        clearBrowsingData(getSelectedOptions(), deselectedDomains);
    }
}
 
Example 2
Source File: PrecacheController.java    From delion with Apache License 2.0 5 votes vote down vote up
private static void recordPeriodicTaskIntervalHistogram() {
    SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
    long previous_start_time_ms = prefs.getLong(PREF_PRECACHE_PERIODIC_TASK_START_TIME_MS, 0);
    long current_start_time_ms = System.currentTimeMillis();
    if (previous_start_time_ms > 0 && current_start_time_ms > previous_start_time_ms) {
        int interval_mins =
                (int) ((current_start_time_ms - previous_start_time_ms) / (1000 * 60));
        RecordHistogram.recordCustomCountHistogram(
                "Precache.PeriodicTaskInterval", interval_mins, 1, 10000, 50);
    }
    prefs.edit()
            .putLong(PREF_PRECACHE_PERIODIC_TASK_START_TIME_MS, current_start_time_ms)
            .apply();
}
 
Example 3
Source File: ClearBrowsingDataPreferences.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * This is the callback for the important domain dialog. We should only clear if we get the
 * positive button response.
 */
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == IMPORTANT_SITES_DIALOG_CODE && resultCode == Activity.RESULT_OK) {
        // Deselected means that the user is excluding the domain from being cleared.
        String[] deselectedDomains = data.getStringArrayExtra(
                ConfirmImportantSitesDialogFragment.DESELECTED_DOMAINS_TAG);
        int[] deselectedDomainReasons = data.getIntArrayExtra(
                ConfirmImportantSitesDialogFragment.DESELECTED_DOMAIN_REASONS_TAG);
        String[] ignoredDomains = data.getStringArrayExtra(
                ConfirmImportantSitesDialogFragment.IGNORED_DOMAINS_TAG);
        int[] ignoredDomainReasons = data.getIntArrayExtra(
                ConfirmImportantSitesDialogFragment.IGNORED_DOMAIN_REASONS_TAG);
        if (deselectedDomains != null && mSortedImportantDomains != null) {
            // mMaxImportantSites is a constant on the C++ side.
            RecordHistogram.recordCustomCountHistogram(
                    "History.ClearBrowsingData.ImportantDeselectedNum",
                    deselectedDomains.length, 1, mMaxImportantSites + 1,
                    mMaxImportantSites + 1);
            RecordHistogram.recordCustomCountHistogram(
                    "History.ClearBrowsingData.ImportantIgnoredNum", ignoredDomains.length, 1,
                    mMaxImportantSites + 1, mMaxImportantSites + 1);
            // We put our max at 20 instead of 100 to reduce the number of empty buckets (as
            // our maximum denominator is 5).
            RecordHistogram.recordEnumeratedHistogram(
                    "History.ClearBrowsingData.ImportantDeselectedPercent",
                    deselectedDomains.length * IMPORTANT_SITES_PERCENTAGE_BUCKET_COUNT
                            / mSortedImportantDomains.length,
                    IMPORTANT_SITES_PERCENTAGE_BUCKET_COUNT + 1);
            RecordHistogram.recordEnumeratedHistogram(
                    "History.ClearBrowsingData.ImportantIgnoredPercent",
                    ignoredDomains.length * IMPORTANT_SITES_PERCENTAGE_BUCKET_COUNT
                            / mSortedImportantDomains.length,
                    IMPORTANT_SITES_PERCENTAGE_BUCKET_COUNT + 1);
        }
        clearBrowsingData(getSelectedOptions(), deselectedDomains, deselectedDomainReasons,
                ignoredDomains, ignoredDomainReasons);
    }
}
 
Example 4
Source File: ContextualSearchUma.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Logs the duration between the panel being triggered due to a tap and the panel being
 * dismissed due to a scroll.
 * @param durationSincePanelTriggerMs The amount of time between the panel getting triggered and
 *                                    the panel being dismissed due to a scroll.
 * @param wasSearchContentViewSeen If the panel was opened.
 */
public static void logDurationBetweenTriggerAndScroll(
        long durationSincePanelTriggerMs, boolean wasSearchContentViewSeen) {
    String histogram = wasSearchContentViewSeen
            ? "Search.ContextualSearchDurationBetweenTriggerAndScrollSeen"
            : "Search.ContextualSearchDurationBetweenTriggerAndScrollNotSeen";
    if (durationSincePanelTriggerMs < 2000) {
        RecordHistogram.recordCustomCountHistogram(
                histogram, (int) durationSincePanelTriggerMs, 1, 2000, 200);
    }
}
 
Example 5
Source File: ContextualSearchUma.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Logs the location of a Tap and whether the panel was seen and the type of the
 * trigger.
 * @param wasPanelSeen Whether the panel was seen.
 * @param wasTap Whether the gesture was a Tap or not.
 * @param triggerLocationDps The trigger location from the top of the screen.
 */
public static void logScreenTopTapLocation(
        boolean wasPanelSeen, boolean wasTap, int triggerLocationDps) {
    // We only log Tap locations for the screen top.
    if (!wasTap) return;
    String histogram = wasPanelSeen ? "Search.ContextualSearchTopLocationSeen"
                                    : "Search.ContextualSearchTopLocationNotSeen";
    int min = 1;
    int max = 250;
    int numBuckets = 50;
    RecordHistogram.recordCustomCountHistogram(
            histogram, triggerLocationDps, min, max, numBuckets);
}
 
Example 6
Source File: PrecacheController.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private static void recordPeriodicTaskIntervalHistogram() {
    SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
    long previous_start_time_ms = prefs.getLong(PREF_PRECACHE_PERIODIC_TASK_START_TIME_MS, 0);
    long current_start_time_ms = System.currentTimeMillis();
    if (previous_start_time_ms > 0 && current_start_time_ms > previous_start_time_ms) {
        int interval_mins =
                (int) ((current_start_time_ms - previous_start_time_ms) / (1000 * 60));
        RecordHistogram.recordCustomCountHistogram(
                "Precache.PeriodicTaskInterval", interval_mins, 1, 10000, 50);
    }
    prefs.edit()
            .putLong(PREF_PRECACHE_PERIODIC_TASK_START_TIME_MS, current_start_time_ms)
            .apply();
}
 
Example 7
Source File: StartupMetrics.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/** Records the startup data in a histogram. Should only be called after native is loaded. */
public void recordHistogram(boolean onStop) {
    if (!mShouldRecordHistogram) return;
    if (!isShortlyAfterChromeStarted() || mFirstActionTaken != NO_ACTIVITY || onStop) {
        String histogramName = mIsMainIntent ? "MobileStartup.MainIntentAction" :
                "MobileStartup.NonMainIntentAction";
        RecordHistogram.recordEnumeratedHistogram(histogramName, mFirstActionTaken, MAX_INDEX);
        mShouldRecordHistogram = false;
        long lastUsedTimeMilli = ContextUtils.getAppSharedPreferences().getLong(
                UmaSessionStats.LAST_USED_TIME_PREF, 0);
        if (mIsMainIntent && (lastUsedTimeMilli > 0) && (mStartTimeMilli > lastUsedTimeMilli)
                && (mStartTimeMilli - lastUsedTimeMilli > Integer.MAX_VALUE)) {
            // Measured in minutes and capped at a day with a bucket precision of 6 minutes.
            RecordHistogram.recordCustomCountHistogram("MobileStartup.TimeSinceLastUse",
                    (int) (mStartTimeMilli - lastUsedTimeMilli) / MILLI_SEC_PER_MINUTE, 1,
                    MINUTES_PER_30DAYS, NUM_BUCKETS);
        }
    } else {
        // Call back later to record the histogram after 10s have elapsed.
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                recordHistogram(false);
            }
        }, (RECORDING_THRESHOLD_NS - (System.nanoTime() - mStartTimeNanoMonotonic)) / 1000000);
    }
}
 
Example 8
Source File: ClearBrowsingDataPreferences.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * This is the callback for the important domain dialog. We should only clear if we get the
 * positive button response.
 */
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == IMPORTANT_SITES_DIALOG_CODE && resultCode == Activity.RESULT_OK) {
        // Deselected means that the user is excluding the domain from being cleared.
        String[] deselectedDomains = data.getStringArrayExtra(
                ConfirmImportantSitesDialogFragment.DESELECTED_DOMAINS_TAG);
        int[] deselectedDomainReasons = data.getIntArrayExtra(
                ConfirmImportantSitesDialogFragment.DESELECTED_DOMAIN_REASONS_TAG);
        String[] ignoredDomains = data.getStringArrayExtra(
                ConfirmImportantSitesDialogFragment.IGNORED_DOMAINS_TAG);
        int[] ignoredDomainReasons = data.getIntArrayExtra(
                ConfirmImportantSitesDialogFragment.IGNORED_DOMAIN_REASONS_TAG);
        if (deselectedDomains != null && mSortedImportantDomains != null) {
            // mMaxImportantSites is a constant on the C++ side.
            RecordHistogram.recordCustomCountHistogram(
                    "History.ClearBrowsingData.ImportantDeselectedNum",
                    deselectedDomains.length, 1, mMaxImportantSites + 1,
                    mMaxImportantSites + 1);
            RecordHistogram.recordCustomCountHistogram(
                    "History.ClearBrowsingData.ImportantIgnoredNum", ignoredDomains.length, 1,
                    mMaxImportantSites + 1, mMaxImportantSites + 1);
            // We put our max at 20 instead of 100 to reduce the number of empty buckets (as
            // our maximum denominator is 5).
            RecordHistogram.recordEnumeratedHistogram(
                    "History.ClearBrowsingData.ImportantDeselectedPercent",
                    deselectedDomains.length * IMPORTANT_SITES_PERCENTAGE_BUCKET_COUNT
                            / mSortedImportantDomains.length,
                    IMPORTANT_SITES_PERCENTAGE_BUCKET_COUNT + 1);
            RecordHistogram.recordEnumeratedHistogram(
                    "History.ClearBrowsingData.ImportantIgnoredPercent",
                    ignoredDomains.length * IMPORTANT_SITES_PERCENTAGE_BUCKET_COUNT
                            / mSortedImportantDomains.length,
                    IMPORTANT_SITES_PERCENTAGE_BUCKET_COUNT + 1);
        }
        clearBrowsingData(getSelectedOptions(), deselectedDomains, deselectedDomainReasons,
                ignoredDomains, ignoredDomainReasons);
    }
}
 
Example 9
Source File: ContextualSearchUma.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Logs the duration between the panel being triggered due to a tap or long-press and the
 * panel being dismissed due to a scroll.
 * @param durationSincePanelTriggerMs The amount of time between the panel getting triggered and
 *                                    the panel being dismissed due to a scroll.
 * @param wasSearchContentViewSeen If the panel was opened.
 */
public static void logDurationBetweenTriggerAndScroll(
        long durationSincePanelTriggerMs, boolean wasSearchContentViewSeen) {
    String histogram = wasSearchContentViewSeen
            ? "Search.ContextualSearchDurationBetweenTriggerAndScrollSeen"
            : "Search.ContextualSearchDurationBetweenTriggerAndScrollNotSeen";
    if (durationSincePanelTriggerMs < 2000) {
        RecordHistogram.recordCustomCountHistogram(
                histogram, (int) durationSincePanelTriggerMs, 1, 2000, 200);
    }
}
 
Example 10
Source File: ContextualSearchUma.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Logs the location of a Tap and whether the panel was seen and the type of the
 * trigger.
 * @param wasPanelSeen Whether the panel was seen.
 * @param wasTap Whether the gesture was a Tap or not.
 * @param triggerLocationDps The trigger location from the top of the screen.
 */
public static void logScreenTopTapLocation(
        boolean wasPanelSeen, boolean wasTap, int triggerLocationDps) {
    // We only log Tap locations for the screen top.
    if (!wasTap) return;
    String histogram = wasPanelSeen ? "Search.ContextualSearchTopLocationSeen"
                                    : "Search.ContextualSearchTopLocationNotSeen";
    int min = 1;
    int max = 250;
    int numBuckets = 50;
    RecordHistogram.recordCustomCountHistogram(
            histogram, triggerLocationDps, min, max, numBuckets);
}
 
Example 11
Source File: DataReductionProxyUma.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Record UMA on data savings displayed to the user. Called when the user views the data
 * savings in the UI.
 * @param compressedTotalBytes The total data used as shown to the user.
 * @param originalTotalBytes Original total size as shown to the user.
 * @param percentage Percentage savings as shown to the user.
 */
public static void dataReductionProxyUserViewedSavings(
        long compressedTotalBytes, long originalTotalBytes, double percentage) {
    // The byte counts are stored in KB. The largest histogram bucket is set to ~1 TB.
    RecordHistogram.recordCustomCountHistogram(USER_VIEWED_ORIGINAL_SIZE_HISTOGRAM_NAME,
            (int) (originalTotalBytes / 1024), 1, 1000 * 1000 * 1000, 100);
    RecordHistogram.recordCustomCountHistogram(USER_VIEWED_SAVINGS_SIZE_HISTOGRAM_NAME,
            (int) ((originalTotalBytes - compressedTotalBytes) / 1024), 1, 1000 * 1000 * 1000,
            100);

    RecordHistogram.recordPercentageHistogram(
            USER_VIEWED_SAVINGS_PERCENT_HISTOGRAM_NAME, (int) percentage);
}
 
Example 12
Source File: StartupMetrics.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/** Records the startup data in a histogram. Should only be called after native is loaded. */
public void recordHistogram(boolean onStop) {
    if (!mShouldRecordHistogram) return;
    if (!isShortlyAfterChromeStarted() || mFirstActionTaken != NO_ACTIVITY || onStop) {
        String histogramName = mIsMainIntent ? "MobileStartup.MainIntentAction" :
                "MobileStartup.NonMainIntentAction";
        RecordHistogram.recordEnumeratedHistogram(histogramName, mFirstActionTaken, MAX_INDEX);
        mShouldRecordHistogram = false;
        long lastUsedTimeMilli = ContextUtils.getAppSharedPreferences().getLong(
                UmaSessionStats.LAST_USED_TIME_PREF, 0);
        if (mIsMainIntent && (lastUsedTimeMilli > 0) && (mStartTimeMilli > lastUsedTimeMilli)
                && (mStartTimeMilli - lastUsedTimeMilli > Integer.MAX_VALUE)) {
            // Measured in minutes and capped at a day with a bucket precision of 6 minutes.
            RecordHistogram.recordCustomCountHistogram("MobileStartup.TimeSinceLastUse",
                    (int) (mStartTimeMilli - lastUsedTimeMilli) / MILLI_SEC_PER_MINUTE, 1,
                    MINUTES_PER_30DAYS, NUM_BUCKETS);
        }
    } else {
        // Call back later to record the histogram after 10s have elapsed.
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                recordHistogram(false);
            }
        }, (RECORDING_THRESHOLD_NS - (System.nanoTime() - mStartTimeNanoMonotonic)) / 1000000);
    }
}
 
Example 13
Source File: ClearBrowsingDataPreferences.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onImportantRegisterableDomainsReady(String[] domains, String[] exampleOrigins) {
    if (domains == null) return;
    // mMaxImportantSites is a constant on the C++ side.
    RecordHistogram.recordCustomCountHistogram("History.ClearBrowsingData.NumImportant",
            domains.length, 0, mMaxImportantSites + 1, mMaxImportantSites + 1);
    mSortedImportantDomains = Arrays.copyOf(domains, domains.length);
    mSortedExampleOrigins = Arrays.copyOf(exampleOrigins, exampleOrigins.length);
}
 
Example 14
Source File: SnippetArticle.java    From delion with Apache License 2.0 5 votes vote down vote up
private static void recordAge(String histogramName, int ageInMinutes) {
    // Negative values (when the time of the device is set inappropriately) provide no value.
    if (ageInMinutes >= 0) {
        // If the max value below (72 hours) were to be changed, the histogram should be renamed
        // since it will change the shape of buckets.
        RecordHistogram.recordCustomCountHistogram(histogramName, ageInMinutes, 1, 72 * 60, 50);
    }
}
 
Example 15
Source File: ContextualSearchUma.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Logs the location of a Tap and whether the panel was seen and the type of the
 * trigger.
 * @param wasPanelSeen Whether the panel was seen.
 * @param wasTap Whether the gesture was a Tap or not.
 * @param triggerLocationDps The trigger location from the top of the screen.
 */
public static void logScreenTopTapLocation(
        boolean wasPanelSeen, boolean wasTap, int triggerLocationDps) {
    // We only log Tap locations for the screen top.
    if (!wasTap) return;
    String histogram = wasPanelSeen ? "Search.ContextualSearchTopLocationSeen"
                                    : "Search.ContextualSearchTopLocationNotSeen";
    int min = 1;
    int max = 250;
    int numBuckets = 50;
    RecordHistogram.recordCustomCountHistogram(
            histogram, triggerLocationDps, min, max, numBuckets);
}
 
Example 16
Source File: StartupMetrics.java    From delion with Apache License 2.0 5 votes vote down vote up
/** Records the startup data in a histogram. Should only be called after native is loaded. */
public void recordHistogram(boolean onStop) {
    if (!mShouldRecordHistogram) return;
    if (!isShortlyAfterChromeStarted() || mFirstActionTaken != NO_ACTIVITY || onStop) {
        String histogramName = mIsMainIntent ? "MobileStartup.MainIntentAction" :
                "MobileStartup.NonMainIntentAction";
        RecordHistogram.recordEnumeratedHistogram(histogramName, mFirstActionTaken, MAX_INDEX);
        mShouldRecordHistogram = false;
        long lastUsedTimeMilli = ContextUtils.getAppSharedPreferences().getLong(
                UmaSessionStats.LAST_USED_TIME_PREF, 0);
        if (mIsMainIntent && (lastUsedTimeMilli > 0) && (mStartTimeMilli > lastUsedTimeMilli)
                && (mStartTimeMilli - lastUsedTimeMilli > Integer.MAX_VALUE)) {
            // Measured in minutes and capped at a day with a bucket precision of 6 minutes.
            RecordHistogram.recordCustomCountHistogram("MobileStartup.TimeSinceLastUse",
                    (int) (mStartTimeMilli - lastUsedTimeMilli) / MILLI_SEC_PER_MINUTE, 1,
                    MINUTES_PER_30DAYS, NUM_BUCKETS);
        }
    } else {
        // Call back later to record the histogram after 10s have elapsed.
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                recordHistogram(false);
            }
        }, (RECORDING_THRESHOLD_NS - (System.nanoTime() - mStartTimeNanoMonotonic)) / 1000000);
    }
}
 
Example 17
Source File: DataReductionProxyUma.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Record the DataReductionProxy.SnackbarPromo.DataSavings histogram.
 * @param promoDataSavingsMB The data savings in MB of the promo that was shown.
 */
public static void dataReductionProxySnackbarPromo(int promoDataSavingsMB) {
    RecordHistogram.recordCustomCountHistogram(
            SNACKBAR_HISTOGRAM_NAME, promoDataSavingsMB, 1, 10000, 200);
}
 
Example 18
Source File: SnippetArticle.java    From delion with Apache License 2.0 4 votes vote down vote up
private static void recordScore(String histogramName, float score) {
    int recordedScore = Math.min((int) Math.ceil(score), 100000);
    RecordHistogram.recordCustomCountHistogram(histogramName, recordedScore, 1, 100000, 50);
}
 
Example 19
Source File: DataReductionProxyUma.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Record the DataReductionProxy.SnackbarPromo.DataSavings histogram.
 * @param promoDataSavingsMB The data savings in MB of the promo that was shown.
 */
public static void dataReductionProxySnackbarPromo(int promoDataSavingsMB) {
    RecordHistogram.recordCustomCountHistogram(
            SNACKBAR_HISTOGRAM_NAME, promoDataSavingsMB, 1, 10000, 200);
}
 
Example 20
Source File: DownloadManagerService.java    From 365browser with Apache License 2.0 2 votes vote down vote up
/**
 * Helper method to record the bytes wasted metrics when a download completes.
 * @param name Histogram name
 * @param bytesWasted Bytes wasted during download.
 */
private void recordBytesWasted(String name, long bytesWasted) {
    RecordHistogram.recordCustomCountHistogram(
            name, (int) (bytesWasted / 1024), 1, GB_IN_KILO_BYTES, 50);
}