org.chromium.chrome.browser.metrics.UmaUtils Java Examples

The following examples show how to use org.chromium.chrome.browser.metrics.UmaUtils. 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 365browser with Apache License 2.0 6 votes vote down vote up
protected final void postDeferredStartupIfNeeded() {
    if (!mNativeInitialized) {
        // Native hasn't loaded yet.  Queue it up for later.
        mDeferredStartupQueued = true;
        return;
    }
    mDeferredStartupQueued = false;

    if (!mDeferredStartupPosted) {
        mDeferredStartupPosted = true;
        RecordHistogram.recordLongTimesHistogram(
                "UMA.Debug.EnableCrashUpload.PostDeferredStartUptime2",
                SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime(),
                TimeUnit.MILLISECONDS);
        onDeferredStartup();
    }
}
 
Example #2
Source File: ChromeActivity.java    From delion with Apache License 2.0 6 votes vote down vote up
protected final void postDeferredStartupIfNeeded() {
    if (!mDeferredStartupNotified) {
        RecordHistogram.recordLongTimesHistogram(
                "UMA.Debug.EnableCrashUpload.PostDeferredStartUptime",
                SystemClock.uptimeMillis() - UmaUtils.getMainEntryPointTime(),
                TimeUnit.MILLISECONDS);

        // We want to perform deferred startup tasks a short time after the first page
        // load completes, but only when the main thread Looper has become idle.
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (!mDeferredStartupNotified && !isActivityDestroyed()) {
                    mDeferredStartupNotified = true;
                    Looper.myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
                        @Override
                        public boolean queueIdle() {
                            onDeferredStartup();
                            return false;  // Remove this idle handler.
                        }
                    });
                }
            }
        }, DEFERRED_STARTUP_DELAY_MS);
    }
}
 
Example #3
Source File: FirstRunActivity.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onStart() {
    super.onStart();
    // Since the FRE may be shown before any tab is shown, mark that this is the point at
    // which Chrome went to foreground. This is needed as otherwise an assert will be hit
    // in UmaUtils.getForegroundStartTime() when recording the time taken to load the first
    // page (which happens after native has been initialized possibly while FRE is still
    // active).
    UmaUtils.recordForegroundStartTime();
    stopProgressionIfNotAcceptedTermsOfService();
    if (!mFreProperties.getBoolean(EXTRA_USE_FRE_FLOW_SEQUENCER)) {
        if (FirstRunStatus.getFirstRunFlowComplete()) {
            // This is a parallel flow that needs to be refreshed/re-fired.
            // Signal the FRE flow completion and re-launch the original intent.
            completeFirstRunExperience();
        }
    }
}
 
Example #4
Source File: ChromeActivitySessionTracker.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Called when last of Chrome activities is stopped, ending the foreground session. This will
 * not be called when a Chrome activity is stopped because another Chrome activity takes over.
 * This is ensured by ActivityStatus, which switches to track new activity when its started and
 * will not report the old one being stopped (see createStateListener() below).
 */
private void onForegroundSessionEnd() {
    if (!mIsStarted) return;
    UmaUtils.recordBackgroundTime();
    ChromeApplication.flushPersistentData();
    mIsStarted = false;
    mPowerBroadcastReceiver.onForegroundSessionEnd();

    ChildProcessLauncher.onSentToBackground();
    IntentHandler.clearPendingReferrer();
    IntentHandler.clearPendingIncognitoUrl();

    int totalTabCount = 0;
    for (WeakReference<Activity> reference : ApplicationStatus.getRunningActivities()) {
        Activity activity = reference.get();
        if (activity instanceof ChromeActivity) {
            TabModelSelector tabModelSelector =
                    ((ChromeActivity) activity).getTabModelSelector();
            if (tabModelSelector != null) {
                totalTabCount += tabModelSelector.getTotalTabCount();
            }
        }
    }
    RecordHistogram.recordCountHistogram(
            "Tab.TotalTabCount.BeforeLeavingApp", totalTabCount);
}
 
Example #5
Source File: ChromeActivitySessionTracker.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Called when a top-level Chrome activity (ChromeTabbedActivity, FullscreenActivity) is
 * started in foreground. It will not be called again when other Chrome activities take over
 * (see onStart()), that is, when correct activity calls startActivity() for another Chrome
 * activity.
 */
private void onForegroundSessionStart() {
    UmaUtils.recordForegroundStartTime();
    ChildProcessLauncher.onBroughtToForeground();
    updatePasswordEchoState();
    FontSizePrefs.getInstance(mApplication).onSystemFontScaleChanged();
    updateAcceptLanguages();
    mVariationsSession.start(mApplication);
    mPowerBroadcastReceiver.onForegroundSessionStart();

    // Track the ratio of Chrome startups that are caused by notification clicks.
    // TODO(johnme): Add other reasons (and switch to recordEnumeratedHistogram).
    RecordHistogram.recordBooleanHistogram(
            "Startup.BringToForegroundReason",
            NotificationPlatformBridge.wasNotificationRecentlyClicked());
}
 
Example #6
Source File: ChromeActivitySessionTracker.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Called when a top-level Chrome activity (ChromeTabbedActivity, FullscreenActivity) is
 * started in foreground. It will not be called again when other Chrome activities take over
 * (see onStart()), that is, when correct activity calls startActivity() for another Chrome
 * activity.
 */
private void onForegroundSessionStart() {
    UmaUtils.recordForegroundStartTime();
    ChildProcessLauncher.onBroughtToForeground();
    updatePasswordEchoState();
    FontSizePrefs.getInstance(mApplication).onSystemFontScaleChanged();
    updateAcceptLanguages();
    mVariationsSession.start(mApplication);
    mPowerBroadcastReceiver.onForegroundSessionStart();

    // Track the ratio of Chrome startups that are caused by notification clicks.
    // TODO(johnme): Add other reasons (and switch to recordEnumeratedHistogram).
    RecordHistogram.recordBooleanHistogram(
            "Startup.BringToForegroundReason",
            NotificationPlatformBridge.wasNotificationRecentlyClicked());
}
 
Example #7
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
protected final void postDeferredStartupIfNeeded() {
    if (!mDeferredStartupPosted) {
        mDeferredStartupPosted = true;
        RecordHistogram.recordLongTimesHistogram(
                "UMA.Debug.EnableCrashUpload.PostDeferredStartUptime2",
                SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime(),
                TimeUnit.MILLISECONDS);
        onDeferredStartup();
    }
}
 
Example #8
Source File: FirstRunActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void acceptTermsOfService(boolean allowCrashUpload) {
    // If default is true then it corresponds to opt-out and false corresponds to opt-in.
    UmaUtils.recordMetricsReportingDefaultOptIn(!DEFAULT_METRICS_AND_CRASH_REPORTING);
    sGlue.acceptTermsOfService(allowCrashUpload);
    FirstRunStatus.setSkipWelcomePage(true);
    flushPersistentData();
    stopProgressionIfNotAcceptedTermsOfService();
    jumpToPage(mPager.getCurrentItem() + 1);
}
 
Example #9
Source File: ChromeApplication.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * This is called once per ChromeApplication instance, which get created per process
 * (browser OR renderer).  Don't stick anything in here that shouldn't be called multiple times
 * during Chrome's lifetime.
 */
@Override
public void onCreate() {
    UmaUtils.recordMainEntryPointTime();
    initCommandLine();
    TraceEvent.maybeEnableEarlyTracing();
    TraceEvent.begin("ChromeApplication.onCreate");

    super.onCreate();

    TraceEvent.end("ChromeApplication.onCreate");
}
 
Example #10
Source File: DeferredStartupHandler.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void recordDeferredStartupStats() {
    RecordHistogram.recordLongTimesHistogram(
            "UMA.Debug.EnableCrashUpload.DeferredStartUpDuration", mDeferredStartupDuration,
            TimeUnit.MILLISECONDS);
    RecordHistogram.recordLongTimesHistogram(
            "UMA.Debug.EnableCrashUpload.DeferredStartUpMaxTaskDuration", mMaxTaskDuration,
            TimeUnit.MILLISECONDS);
    RecordHistogram.recordLongTimesHistogram(
            "UMA.Debug.EnableCrashUpload.DeferredStartUpCompleteTime",
            SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime(),
            TimeUnit.MILLISECONDS);
}
 
Example #11
Source File: ProcessInitializationHandler.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Handle application level deferred startup tasks that can be lazily done after all
 * the necessary initialization has been completed. Should only be triggered once per browser
 * process lifetime. Any calls requiring network access should probably go here.
 *
 * Keep these tasks short and break up long tasks into multiple smaller tasks, as they run on
 * the UI thread and are blocking. Remember to follow RAIL guidelines, as much as possible, and
 * that most devices are quite slow, so leave enough buffer.
 */
public final void initializeDeferredStartupTasks() {
    ThreadUtils.checkUiThread();
    if (mInitializedDeferredStartupTasks) return;
    mInitializedDeferredStartupTasks = true;

    RecordHistogram.recordLongTimesHistogram("UMA.Debug.EnableCrashUpload.DeferredStartUptime2",
            SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime(),
            TimeUnit.MILLISECONDS);

    handleDeferredStartupTasksInitialization();
}
 
Example #12
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 #13
Source File: FirstRunActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void acceptTermsOfService(boolean allowCrashUpload) {
    // If default is true then it corresponds to opt-out and false corresponds to opt-in.
    UmaUtils.recordMetricsReportingDefaultOptIn(!DEFAULT_METRICS_AND_CRASH_REPORTING);
    sGlue.acceptTermsOfService(allowCrashUpload);
    FirstRunStatus.setSkipWelcomePage(true);
    flushPersistentData();
    stopProgressionIfNotAcceptedTermsOfService();
    jumpToPage(mPager.getCurrentItem() + 1);
}
 
Example #14
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 #15
Source File: ChromeApplication.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * This is called once per ChromeApplication instance, which get created per process
 * (browser OR renderer).  Don't stick anything in here that shouldn't be called multiple times
 * during Chrome's lifetime.
 */
@Override
public void onCreate() {
    UmaUtils.recordMainEntryPointTime();
    initCommandLine();
    TraceEvent.maybeEnableEarlyTracing();
    TraceEvent.begin("ChromeApplication.onCreate");

    super.onCreate();

    TraceEvent.end("ChromeApplication.onCreate");
}
 
Example #16
Source File: DeferredStartupHandler.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void recordDeferredStartupStats() {
    RecordHistogram.recordLongTimesHistogram(
            "UMA.Debug.EnableCrashUpload.DeferredStartUpDuration",
            mDeferredStartupDuration,
            TimeUnit.MILLISECONDS);
    RecordHistogram.recordLongTimesHistogram(
            "UMA.Debug.EnableCrashUpload.DeferredStartUpMaxTaskDuration",
            mMaxTaskDuration,
            TimeUnit.MILLISECONDS);
    RecordHistogram.recordLongTimesHistogram(
            "UMA.Debug.EnableCrashUpload.DeferredStartUpCompleteTime",
            SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime(),
            TimeUnit.MILLISECONDS);
    LocaleManager.getInstance().recordStartupMetrics();
}
 
Example #17
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 #18
Source File: FirstRunActivity.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void acceptTermsOfService(boolean allowCrashUpload) {
    UmaUtils.recordMetricsReportingDefaultOptIn(isMetricsReportingOptIn());
    sGlue.acceptTermsOfService(getApplicationContext(), allowCrashUpload);
    FirstRunStatus.setSkipWelcomePage(FirstRunActivity.this, true);
    flushPersistentData();
    stopProgressionIfNotAcceptedTermsOfService();
    jumpToPage(mPager.getCurrentItem() + 1, true);
}
 
Example #19
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 #20
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 #21
Source File: DeferredStartupHandler.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Handle application level deferred startup tasks that can be lazily done after all
 * the necessary initialization has been completed. Any calls requiring network access should
 * probably go here.
 *
 * Keep these tasks short and break up long tasks into multiple smaller tasks, as they run on
 * the UI thread and are blocking. Remember to follow RAIL guidelines, as much as possible, and
 * that most devices are quite slow, so leave enough buffer.
 */
@UiThread
public void initDeferredStartupForApp() {
    if (mDeferredStartupInitializedForApp) return;
    mDeferredStartupInitializedForApp = true;
    ThreadUtils.assertOnUiThread();

    RecordHistogram.recordLongTimesHistogram(
            "UMA.Debug.EnableCrashUpload.DeferredStartUptime2",
            SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime(),
            TimeUnit.MILLISECONDS);

    mDeferredTasks.add(new Runnable() {
        @Override
        public void run() {
            // Punt all tasks that may block on disk off onto a background thread.
            initAsyncDiskTask();

            AfterStartupTaskUtils.setStartupComplete();

            PartnerBrowserCustomizations.setOnInitializeAsyncFinished(new Runnable() {
                @Override
                public void run() {
                    String homepageUrl = HomepageManager.getHomepageUri(mAppContext);
                    LaunchMetrics.recordHomePageLaunchMetrics(
                            HomepageManager.isHomepageEnabled(mAppContext),
                            NewTabPage.isNTPUrl(homepageUrl), homepageUrl);
                }
            });

            PartnerBookmarksShim.kickOffReading(mAppContext);

            PowerMonitor.create(mAppContext);

            ShareHelper.clearSharedImages();

            OfflinePageUtils.clearSharedOfflineFiles(mAppContext);
        }
    });

    mDeferredTasks.add(new Runnable() {
        @Override
        public void run() {
            // Clear any media notifications that existed when Chrome was last killed.
            MediaCaptureNotificationService.clearMediaNotifications(mAppContext);

            startModerateBindingManagementIfNeeded();

            recordKeyboardLocaleUma();
        }
    });

    mDeferredTasks.add(new Runnable() {
        @Override
        public void run() {
            // Start or stop Physical Web
            PhysicalWeb.onChromeStart();
        }
    });

    final ChromeApplication application = (ChromeApplication) mAppContext;

    mDeferredTasks.add(new Runnable() {
        @Override
        public void run() {
            // Starts syncing with GSA.
            application.createGsaHelper().startSync();
        }
    });

    ProcessInitializationHandler.getInstance().initializeDeferredStartupTasks();
}
 
Example #22
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();
    }
}