Java Code Examples for org.chromium.chrome.browser.metrics.UmaUtils#setRunningApplicationStart()

The following examples show how to use org.chromium.chrome.browser.metrics.UmaUtils#setRunningApplicationStart() . 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: ChromeTabbedActivity.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void preInflationStartup() {
    super.preInflationStartup();

    // Decide whether to record startup UMA histograms. This is done  early in the main
    // Activity.onCreate() to avoid recording navigation delays when they require user input to
    // proceed. For example, FRE (First Run Experience) happens before the activity is created,
    // and triggers initialization of the native library. At the moment it seems safe to assume
    // that uninitialized native library is an indication of an application start that is
    // followed by navigation immediately without user input.
    if (!LibraryLoader.isInitialized()) {
        UmaUtils.setRunningApplicationStart(true);
    }

    CommandLine commandLine = CommandLine.getInstance();
    if (commandLine.hasSwitch(ContentSwitches.ENABLE_TEST_INTENTS)
            && getIntent() != null
            && getIntent().hasExtra(
                    ChromeTabbedActivity.INTENT_EXTRA_TEST_RENDER_PROCESS_LIMIT)) {
        int value = getIntent().getIntExtra(
                ChromeTabbedActivity.INTENT_EXTRA_TEST_RENDER_PROCESS_LIMIT, -1);
        if (value != -1) {
            String[] args = new String[1];
            args[0] = "--" + ContentSwitches.RENDER_PROCESS_LIMIT
                    + "=" + Integer.toString(value);
            commandLine.appendSwitchesAndArguments(args);
        }
    }

    supportRequestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);

    // We are starting from history with a URL after data has been cleared. On Samsung this
    // can happen after user clears data and clicks on a recents item on pre-L devices.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP
            && getIntent().getData() != null
            && (getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0
            && OmahaClient.isFreshInstallOrDataHasBeenCleared(getApplicationContext())) {
        getIntent().setData(null);
    }
}
 
Example 2
Source File: TabWebContentsObserver.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void didCommitProvisionalLoadForFrame(long frameId, boolean isMainFrame, String url,
        int transitionType) {
    if (isMainFrame && UmaUtils.isRunningApplicationStart()) {
        // Currently it takes about 2000ms to commit a navigation if the measurement
        // begins very early in the browser start. How many buckets (b) are needed to
        // explore the _typical_ values with granularity 100ms and a maximum duration
        // of 1 minute?
        //   s^{n+1} / s^{n} = 2100 / 2000
        //   s = 1.05
        //   s^b = 60000
        //   b = ln(60000) / ln(1.05) ~= 225
        RecordHistogram.recordCustomTimesHistogram("Startup.FirstCommitNavigationTime",
                SystemClock.uptimeMillis() - UmaUtils.getMainEntryPointTime(),
                1, 60000 /* 1 minute */, TimeUnit.MILLISECONDS, 225);
        UmaUtils.setRunningApplicationStart(false);
    }

    if (isMainFrame) {
        mTab.setIsTabStateDirty(true);
        mTab.updateTitle();
    }

    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().onDidCommitProvisionalLoadForFrame(
                mTab, frameId, isMainFrame, url, transitionType);
    }

    observers.rewind();
    while (observers.hasNext()) {
        observers.next().onUrlUpdated(mTab);
    }

    if (!isMainFrame) return;
    mTab.handleDidCommitProvisonalLoadForFrame(url, transitionType);
}
 
Example 3
Source File: ChromeTabbedActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void preInflationStartup() {
    super.preInflationStartup();

    // Decide whether to record startup UMA histograms. This is done  early in the main
    // Activity.onCreate() to avoid recording navigation delays when they require user input to
    // proceed. For example, FRE (First Run Experience) happens before the activity is created,
    // and triggers initialization of the native library. At the moment it seems safe to assume
    // that uninitialized native library is an indication of an application start that is
    // followed by navigation immediately without user input.
    if (!LibraryLoader.isInitialized()) {
        UmaUtils.setRunningApplicationStart(true);
    }

    CommandLine commandLine = CommandLine.getInstance();
    if (commandLine.hasSwitch(ContentSwitches.ENABLE_TEST_INTENTS)
            && getIntent() != null
            && getIntent().hasExtra(
                    ChromeTabbedActivity.INTENT_EXTRA_TEST_RENDER_PROCESS_LIMIT)) {
        int value = getIntent().getIntExtra(
                ChromeTabbedActivity.INTENT_EXTRA_TEST_RENDER_PROCESS_LIMIT, -1);
        if (value != -1) {
            String[] args = new String[1];
            args[0] = "--" + ContentSwitches.RENDER_PROCESS_LIMIT
                    + "=" + Integer.toString(value);
            commandLine.appendSwitchesAndArguments(args);
        }
    }

    supportRequestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);

    // We are starting from history with a URL after data has been cleared. On Samsung this
    // can happen after user clears data and clicks on a recents item on pre-L devices.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP
            && getIntent().getData() != null
            && (getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0
            && OmahaClient.isFreshInstallOrDataHasBeenCleared(getApplicationContext())) {
        getIntent().setData(null);
    }
}
 
Example 4
Source File: TabWebContentsObserver.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void didCommitProvisionalLoadForFrame(long frameId, boolean isMainFrame, String url,
        int transitionType) {
    if (isMainFrame && UmaUtils.isRunningApplicationStart()) {
        // Currently it takes about 2000ms to commit a navigation if the measurement
        // begins very early in the browser start. How many buckets (b) are needed to
        // explore the _typical_ values with granularity 100ms and a maximum duration
        // of 1 minute?
        //   s^{n+1} / s^{n} = 2100 / 2000
        //   s = 1.05
        //   s^b = 60000
        //   b = ln(60000) / ln(1.05) ~= 225
        RecordHistogram.recordCustomTimesHistogram("Startup.FirstCommitNavigationTime2",
                SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime(),
                1, 60000 /* 1 minute */, TimeUnit.MILLISECONDS, 225);
        UmaUtils.setRunningApplicationStart(false);
    }

    if (isMainFrame) {
        mTab.setIsTabStateDirty(true);
        mTab.updateTitle();
    }

    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().onDidCommitProvisionalLoadForFrame(
                mTab, frameId, isMainFrame, url, transitionType);
    }

    observers.rewind();
    while (observers.hasNext()) {
        observers.next().onUrlUpdated(mTab);
    }

    if (!isMainFrame) return;
    mTab.handleDidCommitProvisonalLoadForFrame(url, transitionType);
}
 
Example 5
Source File: ChromeTabbedActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public void preInflationStartup() {
    super.preInflationStartup();

    // Decide whether to record startup UMA histograms. This is done  early in the main
    // Activity.onCreate() to avoid recording navigation delays when they require user input to
    // proceed. For example, FRE (First Run Experience) happens before the activity is created,
    // and triggers initialization of the native library. At the moment it seems safe to assume
    // that uninitialized native library is an indication of an application start that is
    // followed by navigation immediately without user input.
    if (!LibraryLoader.isInitialized()) {
        UmaUtils.setRunningApplicationStart(true);
    }

    CommandLine commandLine = CommandLine.getInstance();
    if (commandLine.hasSwitch(ContentSwitches.ENABLE_TEST_INTENTS)
            && getIntent() != null
            && getIntent().hasExtra(
                    ChromeTabbedActivity.INTENT_EXTRA_TEST_RENDER_PROCESS_LIMIT)) {
        int value = getIntent().getIntExtra(
                ChromeTabbedActivity.INTENT_EXTRA_TEST_RENDER_PROCESS_LIMIT, -1);
        if (value != -1) {
            String[] args = new String[1];
            args[0] = "--" + ContentSwitches.RENDER_PROCESS_LIMIT
                    + "=" + Integer.toString(value);
            commandLine.appendSwitchesAndArguments(args);
        }
    }

    supportRequestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);

    // We are starting from history with a URL after data has been cleared. On Samsung this
    // can happen after user clears data and clicks on a recents item on pre-L devices.
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP
            && getIntent().getData() != null
            && (getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0
            && OmahaBase.isProbablyFreshInstall(this)) {
        getIntent().setData(null);
    }

    launchFirstRunExperience();
}
 
Example 6
Source File: TabWebContentsObserver.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public void didFinishNavigation(String url, boolean isInMainFrame, boolean isErrorPage,
        boolean hasCommitted, boolean isSameDocument, boolean isFragmentNavigation,
        Integer pageTransition, int errorCode, String errorDescription, int httpStatusCode) {
    RewindableIterator<TabObserver> observers = mTab.getTabObservers();
    while (observers.hasNext()) {
        observers.next().onDidFinishNavigation(mTab, url, isInMainFrame, isErrorPage,
                hasCommitted, isSameDocument, isFragmentNavigation, pageTransition, errorCode,
                httpStatusCode);
    }

    if (errorCode != 0) {
        mTab.updateThemeColorIfNeeded(true);
        if (isInMainFrame) mTab.didFailPageLoad(errorCode);

        recordErrorInPolicyAuditor(url, errorDescription, errorCode);
    }

    if (!hasCommitted) return;
    if (isInMainFrame && UmaUtils.isRunningApplicationStart()) {
        // Current median is 550ms, and long tail is very long. ZoomedIn gives good view of the
        // median and ZoomedOut gives a good overview.
        RecordHistogram.recordCustomTimesHistogram(
                "Startup.FirstCommitNavigationTime2.ZoomedIn",
                SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime(),
                200, 1000, TimeUnit.MILLISECONDS, 100);
        // For ZoomedOut very rarely is it under 50ms and this range matches
        // CustomTabs.IntentToFirstCommitNavigationTime2.ZoomedOut.
        RecordHistogram.recordCustomTimesHistogram(
                "Startup.FirstCommitNavigationTime2.ZoomedOut",
                SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime(),
                50, TimeUnit.MINUTES.toMillis(10), TimeUnit.MILLISECONDS, 50);
        UmaUtils.setRunningApplicationStart(false);
    }

    if (isInMainFrame) {
        mTab.setIsTabStateDirty(true);
        mTab.updateTitle();
        mTab.handleDidFinishNavigation(url, pageTransition);
        mTab.setIsShowingErrorPage(isErrorPage);
    }

    observers.rewind();
    while (observers.hasNext()) {
        observers.next().onUrlUpdated(mTab);
    }

    FullscreenManager fullscreenManager = mTab.getFullscreenManager();
    if (isInMainFrame && !isSameDocument && fullscreenManager != null) {
        fullscreenManager.setPersistentFullscreenMode(false);
    }

    if (isInMainFrame) {
        mTab.stopSwipeRefreshHandler();
    }
}