Java Code Examples for org.chromium.base.TraceEvent#end()

The following examples show how to use org.chromium.base.TraceEvent#end() . 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: ChromeBrowserInitializer.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void startChromeBrowserProcessesSync() throws ProcessInitException {
    try {
        TraceEvent.begin("ChromeBrowserInitializer.startChromeBrowserProcessesSync");
        ThreadUtils.assertOnUiThread();
        mApplication.initCommandLine();
        LibraryLoader libraryLoader = LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER);
        StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
        libraryLoader.ensureInitialized();
        StrictMode.setThreadPolicy(oldPolicy);
        libraryLoader.asyncPrefetchLibrariesToMemory();
        BrowserStartupController.get(mApplication, LibraryProcessType.PROCESS_BROWSER)
                .startBrowserProcessesSync(false);
        GoogleServicesManager.get(mApplication);
    } finally {
        TraceEvent.end("ChromeBrowserInitializer.startChromeBrowserProcessesSync");
    }
}
 
Example 2
Source File: Tab.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Loads a tab that was already loaded but since then was lost. This happens either when we
 * unfreeze the tab from serialized state or when we reload a tab that crashed. In both cases
 * the load codepath is the same (run in loadIfNecessary()) and the same caching policies of
 * history load are used.
 */
private final void restoreIfNeeded() {
    try {
        TraceEvent.begin("Tab.restoreIfNeeded");
        if (isFrozen() && mFrozenContentsState != null) {
            // Restore is needed for a tab that is loaded for the first time. WebContents will
            // be restored from a saved state.
            unfreezeContents();
        } else if (mNeedsReload) {
            // Restore is needed for a tab that was previously loaded, but its renderer was
            // killed by the oom killer.
            mNeedsReload = false;
            requestRestoreLoad();
        } else {
            // No restore needed.
            return;
        }

        loadIfNecessary();
        mIsBeingRestored = true;
        if (mTabUma != null) mTabUma.onRestoreStarted();
    } finally {
        TraceEvent.end("Tab.restoreIfNeeded");
    }
}
 
Example 3
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void initializeCompositor() {
    TraceEvent.begin("ChromeActivity:CompositorInitialization");
    super.initializeCompositor();

    setTabContentManager(new TabContentManager(this, getContentOffsetProvider(),
            DeviceClassManager.enableSnapshots()));
    mCompositorViewHolder.onNativeLibraryReady(mWindowAndroid, getTabContentManager());

    if (isContextualSearchAllowed() && ContextualSearchFieldTrial.isEnabled()) {
        mContextualSearchManager = new ContextualSearchManager(this, mWindowAndroid, this);
    }

    if (ReaderModeManager.isEnabled(this)) {
        mReaderModeManager = new ReaderModeManager(getTabModelSelector(), this);
        if (mToolbarManager != null) {
            mToolbarManager.addFindToolbarObserver(
                    mReaderModeManager.getFindToolbarObserver());
        }
    }

    TraceEvent.end("ChromeActivity:CompositorInitialization");
}
 
Example 4
Source File: Tab.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Loads a tab that was already loaded but since then was lost. This happens either when we
 * unfreeze the tab from serialized state or when we reload a tab that crashed. In both cases
 * the load codepath is the same (run in loadIfNecessary()) and the same caching policies of
 * history load are used.
 */
private final void restoreIfNeeded() {
    try {
        TraceEvent.begin("Tab.restoreIfNeeded");
        if (isFrozen() && mFrozenContentsState != null) {
            // Restore is needed for a tab that is loaded for the first time. WebContents will
            // be restored from a saved state.
            unfreezeContents();
        } else if (mNeedsReload) {
            // Restore is needed for a tab that was previously loaded, but its renderer was
            // killed by the oom killer.
            mNeedsReload = false;
            requestRestoreLoad();
        } else {
            // No restore needed.
            return;
        }

        loadIfNecessary();
        mIsBeingRestored = true;
        if (mTabUma != null) mTabUma.onRestoreStarted();
    } finally {
        TraceEvent.end("Tab.restoreIfNeeded");
    }
}
 
Example 5
Source File: ChromeBrowserInitializer.java    From delion with Apache License 2.0 6 votes vote down vote up
private void startChromeBrowserProcessesSync() throws ProcessInitException {
    try {
        TraceEvent.begin("ChromeBrowserInitializer.startChromeBrowserProcessesSync");
        ThreadUtils.assertOnUiThread();
        mApplication.initCommandLine();
        LibraryLoader libraryLoader = LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER);
        StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
        libraryLoader.ensureInitialized(mApplication);
        StrictMode.setThreadPolicy(oldPolicy);
        libraryLoader.asyncPrefetchLibrariesToMemory();
        // The policies are used by browser startup, so we need to register the policy providers
        // before starting the browser process.
        mApplication.registerPolicyProviders(CombinedPolicyProvider.get());
        BrowserStartupController.get(mApplication, LibraryProcessType.PROCESS_BROWSER)
                .startBrowserProcessesSync(false);
        GoogleServicesManager.get(mApplication);
    } finally {
        TraceEvent.end("ChromeBrowserInitializer.startChromeBrowserProcessesSync");
    }
}
 
Example 6
Source File: ChromeBrowserInitializer.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private void startChromeBrowserProcessesSync() throws ProcessInitException {
    try {
        TraceEvent.begin("ChromeBrowserInitializer.startChromeBrowserProcessesSync");
        ThreadUtils.assertOnUiThread();
        mApplication.initCommandLine();
        LibraryLoader libraryLoader = LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER);
        StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
        libraryLoader.ensureInitialized();
        StrictMode.setThreadPolicy(oldPolicy);
        libraryLoader.asyncPrefetchLibrariesToMemory();
        BrowserStartupController.get(LibraryProcessType.PROCESS_BROWSER)
                .startBrowserProcessesSync(false);
        GoogleServicesManager.get(mApplication);
    } finally {
        TraceEvent.end("ChromeBrowserInitializer.startChromeBrowserProcessesSync");
    }
}
 
Example 7
Source File: ConnectedTask.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
@VisibleForTesting
public final void run() {
    TraceEvent.begin("GCore:" + mLogPrefix + ":run");
    try {
        Log.d(TAG, "%s:%s started", mLogPrefix, getName());
        if (mClient.connectWithTimeout(CONNECTION_TIMEOUT_MS)) {
            try {
                Log.d(TAG, "%s:%s connected", mLogPrefix, getName());
                doWhenConnected(mClient);
                Log.d(TAG, "%s:%s finished", mLogPrefix, getName());
            } finally {
                mClient.disconnect();
                Log.d(TAG, "%s:%s disconnected", mLogPrefix, getName());
                cleanUp();
                Log.d(TAG, "%s:%s cleaned up", mLogPrefix, getName());
            }
        } else {
            mRetryNumber++;
            if (mRetryNumber < RETRY_NUMBER_LIMIT && mClient.isGooglePlayServicesAvailable()) {
                Log.d(TAG, "%s:%s calling retry", mLogPrefix, getName());
                retry(this, CONNECTION_RETRY_TIME_MS);
            } else {
                connectionFailed();
                Log.d(TAG, "%s:%s number of retries exceeded", mLogPrefix, getName());
                cleanUp();
                Log.d(TAG, "%s:%s cleaned up", mLogPrefix, getName());
            }
        }
    } catch (RuntimeException e) {
        Log.e(TAG, "%s:%s runtime exception %s: %s", mLogPrefix, getName(),
                e.getClass().getName(), e.getMessage());
        throw e;
    } finally {
        TraceEvent.end("GCore:" + mLogPrefix + ":run");
    }
}
 
Example 8
Source File: GoogleServicesManager.java    From delion with Apache License 2.0 5 votes vote down vote up
private GoogleServicesManager(Context context) {
    try {
        TraceEvent.begin("GoogleServicesManager.GoogleServicesManager");
        ThreadUtils.assertOnUiThread();
        // We should store the application context, as we outlive any activity which may create
        // us.
        mContext = context.getApplicationContext();

        mChromeSigninController = ChromeSigninController.get(mContext);
        mSigninHelper = SigninHelper.get(mContext);

        // The sign out flow starts by clearing the signed in user in the ChromeSigninController
        // on the Java side, and then performs a sign out on the native side. If there is a
        // crash on the native side then the signin state may get out of sync. Make sure that
        // the native side is signed out if the Java side doesn't have a currently signed in
        // user.
        SigninManager signinManager = SigninManager.get(mContext);
        if (!mChromeSigninController.isSignedIn() && signinManager.isSignedInOnNative()) {
            Log.w(TAG, "Signed in state got out of sync, forcing native sign out");
            signinManager.signOut();
        }

        // Initialize sync.
        SyncController.get(context);

        ApplicationStatus.registerApplicationStateListener(this);
    } finally {
        TraceEvent.end("GoogleServicesManager.GoogleServicesManager");
    }
}
 
Example 9
Source File: ChromeApplication.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * The host activity should call this during its onPause() handler to ensure
 * all state is saved when the app is suspended.  Calling ChromiumApplication.onStop() does
 * this for you.
 */
public static void flushPersistentData() {
    try {
        TraceEvent.begin("ChromiumApplication.flushPersistentData");
        nativeFlushPersistentData();
    } finally {
        TraceEvent.end("ChromiumApplication.flushPersistentData");
    }
}
 
Example 10
Source File: ChromeLauncherActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Figure out how to route the Intent.  Because this is on the critical path to startup, please
 * avoid making the pathway any more complicated than it already is.  Make sure that anything
 * you add _absolutely has_ to be here.
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    // Third-party code adds disk access to Activity.onCreate. http://crbug.com/619824
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    TraceEvent.begin("ChromeLauncherActivity.onCreate");
    try {
        super.onCreate(savedInstanceState);
        doOnCreate(savedInstanceState);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
        TraceEvent.end("ChromeLauncherActivity.onCreate");
    }
}
 
Example 11
Source File: ContentViewCore.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @see View#onConfigurationChanged(Configuration)
 */
@SuppressWarnings("javadoc")
public void onConfigurationChanged(Configuration newConfig) {
    try {
        TraceEvent.begin("ContentViewCore.onConfigurationChanged");
        mImeAdapter.onKeyboardConfigurationChanged(newConfig);
        mContainerViewInternals.super_onConfigurationChanged(newConfig);
        // To request layout has side effect, but it seems OK as it only happen in
        // onConfigurationChange and layout has to be changed in most case.
        mContainerView.requestLayout();
    } finally {
        TraceEvent.end("ContentViewCore.onConfigurationChanged");
    }
}
 
Example 12
Source File: ChromeGoogleApiClientImpl.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isGooglePlayServicesAvailable() {
    TraceEvent.begin("ChromeGoogleApiClientImpl:isGooglePlayServicesAvailable");
    try {
        return ExternalAuthUtils.getInstance().canUseGooglePlayServices(
                mApplicationContext, new UserRecoverableErrorHandler.Silent());
    } finally {
        TraceEvent.end("ChromeGoogleApiClientImpl:isGooglePlayServicesAvailable");
    }
}
 
Example 13
Source File: SwipeRefreshHandler.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public void release(boolean allowRefresh) {
    TraceEvent.begin("SwipeRefreshHandler.release");
    mSwipeRefreshLayout.release(allowRefresh);
    TraceEvent.end("SwipeRefreshHandler.release");
}
 
Example 14
Source File: ChromeTabbedActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public void initializeCompositor() {
    try {
        TraceEvent.begin("ChromeTabbedActivity.initializeCompositor");
        super.initializeCompositor();

        mTabModelSelectorImpl.onNativeLibraryReady(getTabContentManager());
        mVrShellDelegate.onNativeLibraryReady();

        mTabModelObserver = new TabModelSelectorTabModelObserver(mTabModelSelectorImpl) {
            @Override
            public void didCloseTab(int tabId, boolean incognito) {
                closeIfNoTabsAndHomepageEnabled(false);
            }

            @Override
            public void tabPendingClosure(Tab tab) {
                closeIfNoTabsAndHomepageEnabled(true);
            }

            @Override
            public void tabRemoved(Tab tab) {
                closeIfNoTabsAndHomepageEnabled(false);
            }

            private void closeIfNoTabsAndHomepageEnabled(boolean isPendingClosure) {
                if (getTabModelSelector().getTotalTabCount() == 0) {
                    // If the last tab is closed, and homepage is enabled, then exit Chrome.
                    if (HomepageManager.isHomepageEnabled(getApplicationContext())) {
                        finish();
                    } else if (isPendingClosure) {
                        NewTabPageUma.recordNTPImpression(
                                NewTabPageUma.NTP_IMPESSION_POTENTIAL_NOTAB);
                    }
                }
            }

            @Override
            public void didAddTab(Tab tab, TabLaunchType type) {
                if (type == TabLaunchType.FROM_LONGPRESS_BACKGROUND
                        && !DeviceClassManager.enableAnimations(getApplicationContext())) {
                    Toast.makeText(ChromeTabbedActivity.this,
                            R.string.open_in_new_tab_toast,
                            Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void allTabsPendingClosure(List<Integer> tabIds) {
                NewTabPageUma.recordNTPImpression(
                        NewTabPageUma.NTP_IMPESSION_POTENTIAL_NOTAB);
            }
        };

        Bundle state = getSavedInstanceState();
        if (state != null && state.containsKey(FRE_RUNNING)) {
            mIsOnFirstRun = state.getBoolean(FRE_RUNNING);
        }
    } finally {
        TraceEvent.end("ChromeTabbedActivity.initializeCompositor");
    }
}
 
Example 15
Source File: ChromeActivity.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * This function builds the {@link CompositorViewHolder}.  Subclasses *must* call
 * super.setContentView() before using {@link #getTabModelSelector()} or
 * {@link #getCompositorViewHolder()}.
 */
@Override
protected final void setContentView() {
    final long begin = SystemClock.elapsedRealtime();
    TraceEvent.begin("onCreate->setContentView()");

    enableHardwareAcceleration();
    setLowEndTheme();
    int controlContainerLayoutId = getControlContainerLayoutId();
    WarmupManager warmupManager = WarmupManager.getInstance();
    if (warmupManager.hasBuiltOrClearViewHierarchyWithToolbar(controlContainerLayoutId)) {
        View placeHolderView = new View(this);
        setContentView(placeHolderView);
        ViewGroup contentParent = (ViewGroup) placeHolderView.getParent();
        WarmupManager.getInstance().transferViewHierarchyTo(contentParent);
        contentParent.removeView(placeHolderView);
    } else {
        setContentView(R.layout.main);
        if (controlContainerLayoutId != NO_CONTROL_CONTAINER) {
            ViewStub toolbarContainerStub =
                    ((ViewStub) findViewById(R.id.control_container_stub));
            toolbarContainerStub.setLayoutResource(controlContainerLayoutId);
            toolbarContainerStub.inflate();
        }
    }
    TraceEvent.end("onCreate->setContentView()");
    mInflateInitialLayoutDurationMs = SystemClock.elapsedRealtime() - begin;

    // Set the status bar color to black by default. This is an optimization for
    // Chrome not to draw under status and navigation bars when we use the default
    // black status bar
    ApiCompatibilityUtils.setStatusBarColor(getWindow(), Color.BLACK);

    ViewGroup rootView = (ViewGroup) getWindow().getDecorView().getRootView();
    mCompositorViewHolder = (CompositorViewHolder) findViewById(R.id.compositor_view_holder);
    mCompositorViewHolder.setRootView(rootView);

    // Setting fitsSystemWindows to false ensures that the root view doesn't consume the insets.
    rootView.setFitsSystemWindows(false);

    // Add a custom view right after the root view that stores the insets to access later.
    // ContentViewCore needs the insets to determine the portion of the screen obscured by
    // non-content displaying things such as the OSK.
    mInsetObserverView = InsetObserverView.create(this);
    rootView.addView(mInsetObserverView, 0);
}
 
Example 16
Source File: ChromeTabbedActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public void initializeState() {
    // This method goes through 3 steps:
    // 1. Load the saved tab state (but don't start restoring the tabs yet).
    // 2. Process the Intent that this activity received and if that should result in any
    //    new tabs, create them.  This is done after step 1 so that the new tab gets
    //    created after previous tab state was restored.
    // 3. If no tabs were created in any of the above steps, create an NTP, otherwise
    //    start asynchronous tab restore (loading the previously active tab synchronously
    //    if no new tabs created in step 2).

    // Only look at the original intent if this is not a "restoration" and we are allowed to
    // process intents. Any subsequent intents are carried through onNewIntent.
    try {
        TraceEvent.begin("ChromeTabbedActivity.initializeState");

        super.initializeState();

        Intent intent = getIntent();

        boolean hadCipherData =
                CipherFactory.getInstance().restoreFromBundle(getSavedInstanceState());

        boolean noRestoreState =
                CommandLine.getInstance().hasSwitch(ChromeSwitches.NO_RESTORE_STATE);
        if (noRestoreState) {
            // Clear the state files because they are inconsistent and useless from now on.
            mTabModelSelectorImpl.clearState();
        } else if (!mIsOnFirstRun) {
            // State should be clear when we start first run and hence we do not need to load
            // a previous state. This may change the current Model, watch out for initialization
            // based on the model.
            // Never attempt to restore incognito tabs when this activity was previously swiped
            // away in Recents. http://crbug.com/626629
            boolean ignoreIncognitoFiles = !hadCipherData;
            mTabModelSelectorImpl.loadState(ignoreIncognitoFiles);
        }

        mIntentWithEffect = false;
        if ((mIsOnFirstRun || getSavedInstanceState() == null) && intent != null) {
            if (mVrShellDelegate.isVrIntent(intent)) {
                // TODO(mthiesse): Improve startup when started from a VR intent. Right now
                // we launch out of VR, partially load out of VR, then switch into VR.
                mVrShellDelegate.enterVRIfNecessary();
            } else if (!mIntentHandler.shouldIgnoreIntent(ChromeTabbedActivity.this, intent)) {
                mIntentWithEffect = mIntentHandler.onNewIntent(ChromeTabbedActivity.this,
                        intent);
            }
        }

        mCreatedTabOnStartup = getCurrentTabModel().getCount() > 0
                || mTabModelSelectorImpl.getRestoredTabCount() > 0
                || mIntentWithEffect;

        // We always need to try to restore tabs. The set of tabs might be empty, but at least
        // it will trigger the notification that tab restore is complete which is needed by
        // other parts of Chrome such as sync.
        boolean activeTabBeingRestored = !mIntentWithEffect;
        mTabModelSelectorImpl.restoreTabs(activeTabBeingRestored);

        // Only create an initial tab if no tabs were restored and no intent was handled.
        // Also, check whether the active tab was supposed to be restored and that the total
        // tab count is now non zero.  If this is not the case, tab restore failed and we need
        // to create a new tab as well.
        if (!mCreatedTabOnStartup
                || (activeTabBeingRestored && getTabModelSelector().getTotalTabCount() == 0)) {
            // If homepage URI is not determined, due to PartnerBrowserCustomizations provider
            // async reading, then create a tab at the async reading finished. If it takes
            // too long, just create NTP.
            PartnerBrowserCustomizations.setOnInitializeAsyncFinished(
                    new Runnable() {
                        @Override
                        public void run() {
                            createInitialTab();
                        }
                    }, INITIAL_TAB_CREATION_TIMEOUT_MS);
        }

        RecordHistogram.recordBooleanHistogram(
                "MobileStartup.ColdStartupIntent", mIntentWithEffect);
    } finally {
        TraceEvent.end("ChromeTabbedActivity.initializeState");
    }
}
 
Example 17
Source File: SwipeRefreshHandler.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public void release(boolean allowRefresh) {
    TraceEvent.begin("SwipeRefreshHandler.release");
    mSwipeRefreshLayout.release(allowRefresh);
    TraceEvent.end("SwipeRefreshHandler.release");
}
 
Example 18
Source File: LayoutManager.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Updates the state of the active {@link Layout} if needed.  This updates the animations and
 * cascades the changes to the tabs.
 */
public void onUpdate() {
    TraceEvent.begin("LayoutDriver:onUpdate");
    onUpdate(time(), FRAME_DELTA_TIME_MS);
    TraceEvent.end("LayoutDriver:onUpdate");
}
 
Example 19
Source File: ChromeTabbedActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public void finishNativeInitialization() {
    try {
        TraceEvent.begin("ChromeTabbedActivity.finishNativeInitialization");

        refreshSignIn();

        initializeUI();

        // The dataset has already been created, we need to initialize our state.
        mTabModelSelectorImpl.notifyChanged();

        ApiCompatibilityUtils.setWindowIndeterminateProgress(getWindow());

        // Check for incognito tabs to handle the case where Chrome was swiped away in the
        // background.
        if (TabWindowManager.getInstance().canDestroyIncognitoProfile()) {
            IncognitoNotificationManager.dismissIncognitoNotification();
        }

        // LocaleManager can only function after the native library is loaded.
        mLocaleManager = LocaleManager.getInstance();
        boolean searchEnginePromoShown =
                mLocaleManager.showSearchEnginePromoIfNeeded(this, null);

        ChromePreferenceManager preferenceManager = ChromePreferenceManager.getInstance();
        // Promos can only be shown when we start with ACTION_MAIN intent and
        // after FRE is complete. Native initialization can finish before the FRE flow is
        // complete, and this will only show promos on the second opportunity. This is
        // because the FRE is shown on the first opportunity, and we don't want to show such
        // content back to back.
        if (!searchEnginePromoShown && !mIntentWithEffect
                && FirstRunStatus.getFirstRunFlowComplete()
                && preferenceManager.getPromosSkippedOnFirstStart()) {
            // Data reduction promo should be temporarily suppressed if the sign in promo is
            // shown to avoid nagging users too much.
            if (!SigninPromoUtil.launchSigninPromoIfNeeded(this)) {
                DataReductionPromoScreen.launchDataReductionPromo(this);
            }
        } else {
            preferenceManager.setPromosSkippedOnFirstStart(true);
        }

        super.finishNativeInitialization();
    } finally {
        TraceEvent.end("ChromeTabbedActivity.finishNativeInitialization");
    }
}
 
Example 20
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * This function builds the {@link CompositorViewHolder}.  Subclasses *must* call
 * super.setContentView() before using {@link #getTabModelSelector()} or
 * {@link #getCompositorViewHolder()}.
 */
@Override
protected final void setContentView() {
    final long begin = SystemClock.elapsedRealtime();
    TraceEvent.begin("onCreate->setContentView()");

    enableHardwareAcceleration();
    setLowEndTheme();
    int controlContainerLayoutId = getControlContainerLayoutId();
    WarmupManager warmupManager = WarmupManager.getInstance();
    if (warmupManager.hasViewHierarchyWithToolbar(controlContainerLayoutId)) {
        View placeHolderView = new View(this);
        setContentView(placeHolderView);
        ViewGroup contentParent = (ViewGroup) placeHolderView.getParent();
        warmupManager.transferViewHierarchyTo(contentParent);
        contentParent.removeView(placeHolderView);
    } else {
        warmupManager.clearViewHierarchy();

        // Allow disk access for the content view and toolbar container setup.
        // On certain android devices this setup sequence results in disk writes outside
        // of our control, so we have to disable StrictMode to work. See crbug.com/639352.
        StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
        try {
            setContentView(R.layout.main);
            if (controlContainerLayoutId != NO_CONTROL_CONTAINER) {
                ViewStub toolbarContainerStub =
                        ((ViewStub) findViewById(R.id.control_container_stub));
                toolbarContainerStub.setLayoutResource(controlContainerLayoutId);
                toolbarContainerStub.inflate();
            }

            // It cannot be assumed that the result of toolbarContainerStub.inflate() will be
            // the control container since it may be wrapped in another view.
            ControlContainer controlContainer =
                    (ControlContainer) findViewById(R.id.control_container);

            // Inflate the correct toolbar layout for the device.
            int toolbarLayoutId = getToolbarLayoutId();
            if (toolbarLayoutId != NO_TOOLBAR_LAYOUT && controlContainer != null) {
                controlContainer.initWithToolbar(toolbarLayoutId);
            }
        } finally {
            StrictMode.setThreadPolicy(oldPolicy);
        }
    }
    TraceEvent.end("onCreate->setContentView()");
    mInflateInitialLayoutDurationMs = SystemClock.elapsedRealtime() - begin;

    // Set the status bar color to black by default. This is an optimization for
    // Chrome not to draw under status and navigation bars when we use the default
    // black status bar
    ApiCompatibilityUtils.setStatusBarColor(getWindow(), Color.BLACK);

    ViewGroup rootView = (ViewGroup) getWindow().getDecorView().getRootView();
    mCompositorViewHolder = (CompositorViewHolder) findViewById(R.id.compositor_view_holder);
    mCompositorViewHolder.setRootView(rootView);

    // Setting fitsSystemWindows to false ensures that the root view doesn't consume the insets.
    rootView.setFitsSystemWindows(false);

    // Add a custom view right after the root view that stores the insets to access later.
    // ContentViewCore needs the insets to determine the portion of the screen obscured by
    // non-content displaying things such as the OSK.
    mInsetObserverView = InsetObserverView.create(this);
    rootView.addView(mInsetObserverView, 0);
}