Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 2
0
  /**
   * 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.
   *
   * <p>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();
  }
  /**
   * 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.
   */
  @UiThread
  public void onDeferredStartupForApp() {
    if (mDeferredStartupComplete) return;
    ThreadUtils.assertOnUiThread();

    long startDeferredStartupTime = SystemClock.uptimeMillis();

    RecordHistogram.recordLongTimesHistogram(
        "UMA.Debug.EnableCrashUpload.DeferredStartUptime",
        startDeferredStartupTime - UmaUtils.getMainEntryPointTime(),
        TimeUnit.MILLISECONDS);
    mLocaleManager.recordStartupMetrics();

    // Punt all tasks that may block the UI thread off onto a background thread.
    new AsyncTask<Void, Void, Void>() {
      @Override
      protected Void doInBackground(Void... params) {
        try {
          TraceEvent.begin("ChromeBrowserInitializer.onDeferredStartup.doInBackground");
          long asyncTaskStartTime = SystemClock.uptimeMillis();
          boolean crashDumpDisabled =
              CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_CRASH_DUMP_UPLOAD);
          if (!crashDumpDisabled) {
            RecordHistogram.recordLongTimesHistogram(
                "UMA.Debug.EnableCrashUpload.Uptime2",
                asyncTaskStartTime - UmaUtils.getMainEntryPointTime(),
                TimeUnit.MILLISECONDS);
            PrivacyPreferencesManager.getInstance().enablePotentialCrashUploading();
            MinidumpUploadService.tryUploadAllCrashDumps(mAppContext);
          }
          CrashFileManager crashFileManager = new CrashFileManager(mAppContext.getCacheDir());
          crashFileManager.cleanOutAllNonFreshMinidumpFiles();

          MinidumpUploadService.storeBreakpadUploadStatsInUma(
              ChromePreferenceManager.getInstance(mAppContext));

          // Force a widget refresh in order to wake up any possible zombie widgets.
          // This is needed to ensure the right behavior when the process is suddenly
          // killed.
          BookmarkWidgetProvider.refreshAllWidgets(mAppContext);

          // Initialize whether or not precaching is enabled.
          PrecacheLauncher.updatePrecachingEnabled(mAppContext);

          if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_WEBAPK)) {
            WebApkVersionManager.updateWebApksIfNeeded();
          }

          removeSnapshotDatabase();

          cacheIsChromeDefaultBrowser();

          RecordHistogram.recordLongTimesHistogram(
              "UMA.Debug.EnableCrashUpload.DeferredStartUpDurationAsync",
              SystemClock.uptimeMillis() - asyncTaskStartTime,
              TimeUnit.MILLISECONDS);

          return null;
        } finally {
          TraceEvent.end("ChromeBrowserInitializer.onDeferredStartup.doInBackground");
        }
      }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

    AfterStartupTaskUtils.setStartupComplete();

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

    // TODO(aruslan): http://b/6397072 This will be moved elsewhere
    PartnerBookmarksShim.kickOffReading(mAppContext);

    PowerMonitor.create(mAppContext);

    ShareHelper.clearSharedImages(mAppContext);

    // Clear any media notifications that existed when Chrome was last killed.
    MediaCaptureNotificationService.clearMediaNotifications(mAppContext);

    startModerateBindingManagementIfNeeded();

    recordKeyboardLocaleUma();

    ChromeApplication application = (ChromeApplication) mAppContext;
    // Starts syncing with GSA.
    application.createGsaHelper().startSync();

    application.initializeSharedClasses();

    // Start or stop Physical Web
    PhysicalWeb.onChromeStart(application);

    mDeferredStartupComplete = true;

    RecordHistogram.recordLongTimesHistogram(
        "UMA.Debug.EnableCrashUpload.DeferredStartUpDuration",
        SystemClock.uptimeMillis() - startDeferredStartupTime,
        TimeUnit.MILLISECONDS);
  }