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

The following examples show how to use org.chromium.base.TraceEvent#begin() . 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: ContentViewCore.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Sets a new container view for this {@link ContentViewCore}.
 *
 * <p>WARNING: This method can also be used to replace the existing container view,
 * but you should only do it if you have a very good reason to. Replacing the
 * container view has been designed to support fullscreen in the Webview so it
 * might not be appropriate for other use cases.
 *
 * <p>This method only performs a small part of replacing the container view and
 * embedders are responsible for:
 * <ul>
 *     <li>Disconnecting the old container view from this ContentViewCore</li>
 *     <li>Updating the InternalAccessDelegate</li>
 *     <li>Reconciling the state of this ContentViewCore with the new container view</li>
 *     <li>Tearing down and recreating the native GL rendering where appropriate</li>
 *     <li>etc.</li>
 * </ul>
 */
public void setContainerView(ViewGroup containerView) {
    try {
        TraceEvent.begin("ContentViewCore.setContainerView");
        if (mContainerView != null) {
            hideSelectPopupWithCancelMessage();
            mPopupZoomer.hide(false);
            mImeAdapter.setContainerView(containerView);
        }

        mContainerView = containerView;
        mContainerView.setClickable(true);
        if (mSelectionPopupController != null) {
            mSelectionPopupController.setContainerView(containerView);
        }
    } finally {
        TraceEvent.end("ContentViewCore.setContainerView");
    }
}
 
Example 2
Source File: ContentViewCore.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * @see View#onHoverEvent(MotionEvent)
 * Mouse move events are sent on hover move.
 */
public boolean onHoverEvent(MotionEvent event) {
    TraceEvent.begin("onHoverEvent");

    MotionEvent offset = createOffsetMotionEvent(event);
    try {
        if (mBrowserAccessibilityManager != null && !mIsObscuredByAnotherView
                && mBrowserAccessibilityManager.onHoverEvent(offset)) {
            return true;
        }

        return getEventForwarder().onMouseEvent(event);
    } finally {
        offset.recycle();
        TraceEvent.end("onHoverEvent");
    }
}
 
Example 3
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 4
Source File: AsyncPreloadResourceLoader.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private Resource createResource(int resId) {
    try {
        TraceEvent.begin("AsyncPreloadResourceLoader.createResource");
        return mCreator.create(resId);
    } finally {
        TraceEvent.end("AsyncPreloadResourceLoader.createResource");
    }
}
 
Example 5
Source File: ChromeGoogleApiClientImpl.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public boolean connectWithTimeout(long timeout) {
    TraceEvent.begin("ChromeGoogleApiClientImpl:connectWithTimeout");
    try {
        ConnectionResult result = mClient.blockingConnect(timeout, TimeUnit.MILLISECONDS);
        if (!result.isSuccess()) {
            Log.e(TAG, "Connection to GmsCore unsuccessful. Error %d", result.getErrorCode());
        } else {
            Log.d(TAG, "Connection to GmsCore successful.");
        }
        return result.isSuccess();
    } finally {
        TraceEvent.end("ChromeGoogleApiClientImpl:connectWithTimeout");
    }
}
 
Example 6
Source File: GoogleServicesManager.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Called once during initialization and then again for every start (warm-start).
 * Responsible for checking if configuration has changed since Chrome was last launched
 * and updates state accordingly.
 */
public void onMainActivityStart() {
    try {
        TraceEvent.begin("GoogleServicesManager.onMainActivityStart");
        boolean accountsChanged = SigninHelper.checkAndClearAccountsChangedPref(mContext);
        mSigninHelper.validateAccountSettings(accountsChanged);
    } finally {
        TraceEvent.end("GoogleServicesManager.onMainActivityStart");
    }
}
 
Example 7
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 8
Source File: TabModelImpl.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void setIndex(int i, final TabSelectionType type) {
    try {
        TraceEvent.begin("TabModelImpl.setIndex");
        int lastId = getLastId(type);

        if (!isCurrentModel()) {
            mModelDelegate.selectModel(isIncognito());
        }

        if (!hasValidTab()) {
            mIndex = INVALID_TAB_INDEX;
        } else {
            mIndex = MathUtils.clamp(i, 0, mTabs.size() - 1);
        }

        Tab tab = TabModelUtils.getCurrentTab(this);

        mModelDelegate.requestToShowTab(tab, type);

        if (tab != null) {
            for (TabModelObserver obs : mObservers) obs.didSelectTab(tab, type, lastId);

            boolean wasAlreadySelected = tab.getId() == lastId;
            if (!wasAlreadySelected && type == TabSelectionType.FROM_USER && mUma != null) {
                // We only want to record when the user actively switches to a different tab.
                mUma.userSwitchedToTab();
            }
        }

    } finally {
        TraceEvent.end("TabModelImpl.setIndex");
    }
}
 
Example 9
Source File: TabCreatorManager.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new tab and loads the NTP.
 */
public final void launchNTP() {
    try {
        TraceEvent.begin("TabCreator.launchNTP");
        launchUrl(UrlConstants.NTP_URL, TabModel.TabLaunchType.FROM_CHROME_UI);
    } finally {
        TraceEvent.end("TabCreator.launchNTP");
    }
}
 
Example 10
Source File: AsyncInitializationActivity.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void maybePreconnect() {
    TraceEvent.begin("maybePreconnect");
    Intent intent = getIntent();
    if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) {
        final String url = intent.getDataString();
        WarmupManager.getInstance()
            .maybePreconnectUrlAndSubResources(Profile.getLastUsedProfile(), url);
    }
    TraceEvent.end("maybePreconnect");
}
 
Example 11
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 12
Source File: NewTabPageView.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Adds listeners to scrolling to take care of snap scrolling and updating the search box on
 * scroll.
 */
private void setupScrollHandling() {
    TraceEvent.begin(TAG + ".setupScrollHandling()");
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            mLastScrollY = mRecyclerView.computeVerticalScrollOffset();
            handleScroll();
        }
    });

    mRecyclerView.setOnTouchListener(new OnTouchListener() {
        @Override
        @SuppressLint("ClickableViewAccessibility")
        public boolean onTouch(View v, MotionEvent event) {
            mRecyclerView.removeCallbacks(mSnapScrollRunnable);

            if (event.getActionMasked() == MotionEvent.ACTION_CANCEL
                    || event.getActionMasked() == MotionEvent.ACTION_UP) {
                mPendingSnapScroll = true;
                mRecyclerView.postDelayed(mSnapScrollRunnable, SNAP_SCROLL_DELAY_MS);
            } else {
                mPendingSnapScroll = false;
            }
            return false;
        }
    });
    TraceEvent.end(TAG + ".setupScrollHandling()");
}
 
Example 13
Source File: GoogleServicesManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Called once during initialization and then again for every start (warm-start).
 * Responsible for checking if configuration has changed since Chrome was last launched
 * and updates state accordingly.
 */
public void onMainActivityStart() {
    try {
        TraceEvent.begin("GoogleServicesManager.onMainActivityStart");
        boolean accountsChanged = SigninHelper.checkAndClearAccountsChangedPref(mContext);
        mSigninHelper.validateAccountSettings(accountsChanged);
    } finally {
        TraceEvent.end("GoogleServicesManager.onMainActivityStart");
    }
}
 
Example 14
Source File: AsyncInitializationActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void maybePreconnect() {
    TraceEvent.begin("maybePreconnect");
    Intent intent = getIntent();
    if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) {
        final String url = intent.getDataString();
        WarmupManager.getInstance()
            .maybePreconnectUrlAndSubResources(Profile.getLastUsedProfile(), url);
    }
    TraceEvent.end("maybePreconnect");
}
 
Example 15
Source File: GoogleServicesManager.java    From 365browser 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();
        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 16
Source File: Tab.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Triggers the hiding logic for the view backing the tab.
 */
public final void hide() {
    try {
        TraceEvent.begin("Tab.hide");
        if (isHidden()) return;
        mIsHidden = true;

        if (mContentViewCore != null) mContentViewCore.onHide();

        // Clean up any fullscreen state that might impact other tabs.
        if (mFullscreenManager != null) {
            mFullscreenManager.setPersistentFullscreenMode(false);
            mFullscreenManager.hideControlsPersistent(mFullscreenHungRendererToken);
            mFullscreenHungRendererToken = FullscreenManager.INVALID_TOKEN;
        }

        if (mTabUma != null) mTabUma.onHide();

        mTabRedirectHandler.clear();

        cancelEnableFullscreenLoadDelay();

        // Allow this tab's NativePage to be frozen if it stays hidden for a while.
        NativePageAssassin.getInstance().tabHidden(this);

        for (TabObserver observer : mObservers) observer.onHidden(this);
    } finally {
        TraceEvent.end("Tab.hide");
    }
}
 
Example 17
Source File: ChromeTabbedActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public void finishNativeInitialization() {
    try {
        TraceEvent.begin("ChromeTabbedActivity.finishNativeInitialization");

        launchFirstRunExperience();

        refreshSignIn();

        ChromePreferenceManager preferenceManager = ChromePreferenceManager.getInstance(this);
        // Promos can only be shown when we start with ACTION_MAIN intent and
        // after FRE is complete.
        if (!mIntentWithEffect && FirstRunStatus.getFirstRunFlowComplete()) {
            // Only show promos on the second oppurtunity. This is because we show FRE on the
            // first oppurtunity, and we don't want to show such content back to back.
            if (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);
            }

            // Notify users experimenting with WebAPKs if they need to do extra steps to enable
            // WebAPKs.
            ChromeWebApkHost.launchWebApkRequirementsDialogIfNeeded(this);
        }

        initializeUI();

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

        getWindow().setFeatureInt(Window.FEATURE_INDETERMINATE_PROGRESS,
                Window.PROGRESS_VISIBILITY_OFF);

        // Check for incognito tabs to handle the case where Chrome was swiped away in the
        // background.
        int incognitoCount = TabWindowManager.getInstance().getIncognitoTabCount();
        if (incognitoCount == 0) IncognitoNotificationManager.dismissIncognitoNotification();

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

        super.finishNativeInitialization();
    } finally {
        TraceEvent.end("ChromeTabbedActivity.finishNativeInitialization");
    }
}
 
Example 18
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 19
Source File: ContentViewCore.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unused")
@CalledByNative
private void updateFrameInfo(float scrollOffsetX, float scrollOffsetY, float pageScaleFactor,
        float minPageScaleFactor, float maxPageScaleFactor, float contentWidth,
        float contentHeight, float viewportWidth, float viewportHeight, float topBarShownPix,
        boolean topBarChanged, boolean isMobileOptimizedHint) {
    TraceEvent.begin("ContentViewCore:updateFrameInfo");
    mIsMobileOptimizedHint = isMobileOptimizedHint;
    // Adjust contentWidth/Height to be always at least as big as
    // the actual viewport (as set by onSizeChanged).
    final float deviceScale = mRenderCoordinates.getDeviceScaleFactor();
    contentWidth = Math.max(contentWidth,
            mViewportWidthPix / (deviceScale * pageScaleFactor));
    contentHeight = Math.max(contentHeight,
            mViewportHeightPix / (deviceScale * pageScaleFactor));

    final boolean contentSizeChanged =
            contentWidth != mRenderCoordinates.getContentWidthCss()
            || contentHeight != mRenderCoordinates.getContentHeightCss();
    final boolean scaleLimitsChanged =
            minPageScaleFactor != mRenderCoordinates.getMinPageScaleFactor()
            || maxPageScaleFactor != mRenderCoordinates.getMaxPageScaleFactor();
    final boolean pageScaleChanged =
            pageScaleFactor != mRenderCoordinates.getPageScaleFactor();
    final boolean scrollChanged =
            pageScaleChanged
            || scrollOffsetX != mRenderCoordinates.getScrollX()
            || scrollOffsetY != mRenderCoordinates.getScrollY();

    final boolean needHidePopupZoomer = contentSizeChanged || scrollChanged;

    if (needHidePopupZoomer) mPopupZoomer.hide(true);

    if (scrollChanged) {
        mContainerViewInternals.onScrollChanged(
                (int) mRenderCoordinates.fromLocalCssToPix(scrollOffsetX),
                (int) mRenderCoordinates.fromLocalCssToPix(scrollOffsetY),
                (int) mRenderCoordinates.getScrollXPix(),
                (int) mRenderCoordinates.getScrollYPix());
    }

    mRenderCoordinates.updateFrameInfo(scrollOffsetX, scrollOffsetY, contentWidth,
            contentHeight, viewportWidth, viewportHeight, pageScaleFactor, minPageScaleFactor,
            maxPageScaleFactor, topBarShownPix);

    if (scrollChanged || topBarChanged) {
        for (mGestureStateListenersIterator.rewind();
                mGestureStateListenersIterator.hasNext();) {
            mGestureStateListenersIterator.next().onScrollOffsetOrExtentChanged(
                    computeVerticalScrollOffset(),
                    computeVerticalScrollExtent());
        }
    }

    if (scaleLimitsChanged) {
        for (mGestureStateListenersIterator.rewind();
                mGestureStateListenersIterator.hasNext();) {
            mGestureStateListenersIterator.next().onScaleLimitsChanged(
                    minPageScaleFactor, maxPageScaleFactor);
        }
    }

    if (mBrowserAccessibilityManager != null) {
        mBrowserAccessibilityManager.notifyFrameInfoInitialized();
    }

    TraceEvent.end("ContentViewCore:updateFrameInfo");
}
 
Example 20
Source File: ChromeTabbedActivity.java    From 365browser 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());

        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()) {
                    Toast.makeText(ChromeTabbedActivity.this,
                            R.string.open_in_new_tab_toast,
                            Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void allTabsPendingClosure(List<Tab> tabs) {
                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");
    }
}