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

The following examples show how to use org.chromium.base.metrics.RecordHistogram#recordLinearCountHistogram() . 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: ChromeActivity.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Records UMA histograms for the current screen width. Should only be called when the activity
 * is in Android N multi-window mode.
 */
protected void recordMultiWindowModeScreenWidth() {
    if (!DeviceFormFactor.isTablet(this)) return;

    RecordHistogram.recordBooleanHistogram(
            "Android.MultiWindowMode.IsTabletScreenWidthBelow600",
            mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP);

    if (mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP) {
        RecordHistogram.recordLinearCountHistogram(
                "Android.MultiWindowMode.TabletScreenWidth", mScreenWidthDp, 1,
                DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP, 50);
    }
}
 
Example 2
Source File: DownloadUtils.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private static void recordShareHistograms(int count, int filterType) {
    RecordHistogram.recordEnumeratedHistogram("Android.DownloadManager.Share.FileTypes",
            filterType, DownloadFilter.FILTER_BOUNDARY);

    RecordHistogram.recordLinearCountHistogram("Android.DownloadManager.Share.Count",
            count, 1, 20, 20);
}
 
Example 3
Source File: ClearBrowsingDataPreferences.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onImportantRegisterableDomainsReady(
        String[] domains, String[] exampleOrigins, int[] importantReasons) {
    if (domains == null) return;
    // mMaxImportantSites is a constant on the C++ side. While 0 is valid, use 1 as the minimum
    // because histogram code assumes a min >= 1; the underflow bucket will record the 0s.
    RecordHistogram.recordLinearCountHistogram("History.ClearBrowsingData.NumImportant",
            domains.length, 1, mMaxImportantSites + 1, mMaxImportantSites + 1);
    mSortedImportantDomains = Arrays.copyOf(domains, domains.length);
    mSortedImportantDomainReasons = Arrays.copyOf(importantReasons, importantReasons.length);
    mSortedExampleOrigins = Arrays.copyOf(exampleOrigins, exampleOrigins.length);
}
 
Example 4
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Records UMA histograms for the current screen width. Should only be called when the activity
 * is in Android N multi-window mode.
 */
protected void recordMultiWindowModeScreenWidth() {
    if (!DeviceFormFactor.isTablet(this)) return;

    RecordHistogram.recordBooleanHistogram(
            "Android.MultiWindowMode.IsTabletScreenWidthBelow600",
            mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP);

    if (mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP) {
        RecordHistogram.recordLinearCountHistogram(
                "Android.MultiWindowMode.TabletScreenWidth", mScreenWidthDp, 1,
                DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP, 50);
    }
}
 
Example 5
Source File: DownloadUtils.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private static void recordShareHistograms(int count, int filterType) {
    RecordHistogram.recordEnumeratedHistogram("Android.DownloadManager.Share.FileTypes",
            filterType, DownloadFilter.FILTER_BOUNDARY);

    RecordHistogram.recordLinearCountHistogram("Android.DownloadManager.Share.Count",
            count, 1, 20, 20);
}
 
Example 6
Source File: ClearBrowsingDataPreferences.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onImportantRegisterableDomainsReady(String[] domains, String[] exampleOrigins,
        int[] importantReasons, boolean dialogDisabled) {
    if (domains == null || dialogDisabled) return;
    // mMaxImportantSites is a constant on the C++ side. While 0 is valid, use 1 as the minimum
    // because histogram code assumes a min >= 1; the underflow bucket will record the 0s.
    RecordHistogram.recordLinearCountHistogram("History.ClearBrowsingData.NumImportant",
            domains.length, 1, mMaxImportantSites + 1, mMaxImportantSites + 1);
    mSortedImportantDomains = Arrays.copyOf(domains, domains.length);
    mSortedImportantDomainReasons = Arrays.copyOf(importantReasons, importantReasons.length);
    mSortedExampleOrigins = Arrays.copyOf(exampleOrigins, exampleOrigins.length);
}
 
Example 7
Source File: ChromeActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Records UMA histograms for the current screen width. Should only be called when the activity
 * is in Android N multi-window mode.
 */
protected void recordMultiWindowModeScreenWidth() {
    if (!DeviceFormFactor.isTablet()) return;

    RecordHistogram.recordBooleanHistogram(
            "Android.MultiWindowMode.IsTabletScreenWidthBelow600",
            mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP);

    if (mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP) {
        RecordHistogram.recordLinearCountHistogram(
                "Android.MultiWindowMode.TabletScreenWidth", mScreenWidthDp, 1,
                DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP, 50);
    }
}
 
Example 8
Source File: TabPersistentStore.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Extracts the tab information from a given tab state stream.
 *
 * @param stream   The stream pointing to the tab state file to be parsed.
 * @param callback A callback to be streamed updates about the tab state information being read.
 * @param tabIds   A mapping of tab ID to whether the tab is an off the record tab.
 * @param forMerge Whether this state file was read as part of a merge.
 * @return The next available tab ID based on the maximum ID referenced in this state file.
 */
public static int readSavedStateFile(
        DataInputStream stream, @Nullable OnTabStateReadCallback callback,
        @Nullable SparseBooleanArray tabIds, boolean forMerge) throws IOException {
    if (stream == null) return 0;
    long time = SystemClock.uptimeMillis();
    int nextId = 0;
    boolean skipUrlRead = false;
    boolean skipIncognitoCount = false;
    final int version = stream.readInt();
    if (version != SAVED_STATE_VERSION) {
        // We don't support restoring Tab data from before M18.
        if (version < 3) return 0;
        // Older versions are missing newer data.
        if (version < 5) skipIncognitoCount = true;
        if (version < 4) skipUrlRead = true;
    }

    final int count = stream.readInt();
    final int incognitoCount = skipIncognitoCount ? -1 : stream.readInt();
    final int incognitoActiveIndex = stream.readInt();
    final int standardActiveIndex = stream.readInt();
    if (count < 0 || incognitoActiveIndex >= count || standardActiveIndex >= count) {
        throw new IOException();
    }

    for (int i = 0; i < count; i++) {
        int id = stream.readInt();
        String tabUrl = skipUrlRead ? "" : stream.readUTF();
        if (id >= nextId) nextId = id + 1;
        if (tabIds != null) tabIds.append(id, true);

        Boolean isIncognito = (incognitoCount < 0) ? null : i < incognitoCount;
        if (callback != null) {
            callback.onDetailsRead(i, id, tabUrl, isIncognito,
                    i == standardActiveIndex, i == incognitoActiveIndex);
        }
    }

    if (forMerge) {
        logExecutionTime("ReadMergedStateTime", time);
        int tabCount = count + ((incognitoCount > 0) ? incognitoCount : 0);
        RecordHistogram.recordLinearCountHistogram(
                "Android.TabPersistentStore.MergeStateTabCount",
                tabCount, 1, 200, 200);
    }

    logExecutionTime("ReadSavedStateTime", time);

    return nextId;
}
 
Example 9
Source File: TabPersistentStore.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Extracts the tab information from a given tab state stream.
 *
 * @param stream   The stream pointing to the tab state file to be parsed.
 * @param callback A callback to be streamed updates about the tab state information being read.
 * @param tabIds   A mapping of tab ID to whether the tab is an off the record tab.
 * @param forMerge Whether this state file was read as part of a merge.
 * @return The next available tab ID based on the maximum ID referenced in this state file.
 */
public static int readSavedStateFile(
        DataInputStream stream, @Nullable OnTabStateReadCallback callback,
        @Nullable SparseBooleanArray tabIds, boolean forMerge) throws IOException {
    if (stream == null) return 0;
    long time = SystemClock.uptimeMillis();
    int nextId = 0;
    boolean skipUrlRead = false;
    boolean skipIncognitoCount = false;
    final int version = stream.readInt();
    if (version != SAVED_STATE_VERSION) {
        // We don't support restoring Tab data from before M18.
        if (version < 3) return 0;
        // Older versions are missing newer data.
        if (version < 5) skipIncognitoCount = true;
        if (version < 4) skipUrlRead = true;
    }

    final int count = stream.readInt();
    final int incognitoCount = skipIncognitoCount ? -1 : stream.readInt();
    final int incognitoActiveIndex = stream.readInt();
    final int standardActiveIndex = stream.readInt();
    if (count < 0 || incognitoActiveIndex >= count || standardActiveIndex >= count) {
        throw new IOException();
    }

    for (int i = 0; i < count; i++) {
        int id = stream.readInt();
        String tabUrl = skipUrlRead ? "" : stream.readUTF();
        if (id >= nextId) nextId = id + 1;
        if (tabIds != null) tabIds.append(id, true);

        Boolean isIncognito = (incognitoCount < 0) ? null : i < incognitoCount;
        if (callback != null) {
            callback.onDetailsRead(i, id, tabUrl, isIncognito,
                    i == standardActiveIndex, i == incognitoActiveIndex);
        }
    }

    if (forMerge) {
        logExecutionTime("ReadMergedStateTime", time);
        int tabCount = count + ((incognitoCount > 0) ? incognitoCount : 0);
        RecordHistogram.recordLinearCountHistogram(
                "Android.TabPersistentStore.MergeStateTabCount",
                tabCount, 1, 200, 200);
    }

    logExecutionTime("ReadSavedStateTime", time);

    return nextId;
}