org.chromium.base.TraceEvent Java Examples

The following examples show how to use org.chromium.base.TraceEvent. 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: CompositorViewHolder.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onSwapBuffersCompleted(int pendingSwapBuffersCount) {
    TraceEvent.instant("onSwapBuffersCompleted");

    // Wait until the second frame to turn off the placeholder background on
    // tablets so the tab strip has time to start drawing.
    final ViewGroup controlContainer = (ViewGroup) mControlContainer;
    if (controlContainer != null && controlContainer.getBackground() != null && mHasDrawnOnce) {
        post(new Runnable() {
            @Override
            public void run() {
                controlContainer.setBackgroundResource(0);
            }
        });
    }

    mHasDrawnOnce = true;

    mPendingSwapBuffersCount = pendingSwapBuffersCount;

    if (!mSkipInvalidation || pendingSwapBuffersCount == 0) flushInvalidation();
    mSkipInvalidation = !mSkipInvalidation;
}
 
Example #4
Source File: TaskRunnerImpl.java    From cronet with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void run() {
    TraceEvent te = null;
    try {
        te = TraceEvent.scoped("TaskRunnerImpl.PreNativeTask.run");
        synchronized (mLock) {
            if (mPreNativeTasks == null) return;

            mPreNativeTasks.remove(this);
        }

        mTask.run();
    } finally {
        if (te != null) {
            try {
                te.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
 
Example #5
Source File: Tab.java    From 365browser with Apache License 2.0 6 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);
        }

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

        mTabRedirectHandler.clear();

        // 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 #6
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 #7
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 #8
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 #9
Source File: CompositorViewHolder.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onSwapBuffersCompleted(int pendingSwapBuffersCount) {
    TraceEvent.instant("onSwapBuffersCompleted");

    // Wait until the second frame to turn off the placeholder background on
    // tablets so the tab strip has time to start drawing.
    final ViewGroup controlContainer = (ViewGroup) mControlContainer;
    if (controlContainer != null && controlContainer.getBackground() != null && mHasDrawnOnce) {
        post(new Runnable() {
            @Override
            public void run() {
                controlContainer.setBackgroundResource(0);
            }
        });
    }

    mHasDrawnOnce = true;

    mPendingSwapBuffersCount = pendingSwapBuffersCount;

    if (!mSkipInvalidation || pendingSwapBuffersCount == 0) flushInvalidation();
    mSkipInvalidation = !mSkipInvalidation;
}
 
Example #10
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 #11
Source File: NewTabPageView.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void initializeVoiceSearchButton() {
    TraceEvent.begin(TAG + ".initializeVoiceSearchButton()");
    mVoiceSearchButton = (ImageView) mNewTabPageLayout.findViewById(R.id.voice_search_button);
    mVoiceSearchButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mManager.focusSearchBox(true, null);
        }
    });
    TraceEvent.end(TAG + ".initializeVoiceSearchButton()");
}
 
Example #12
Source File: ChromeLauncherActivity.java    From AndroidChromium 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");
    TraceEvent.begin("ChromeLauncherActivity.onCreate");
    try {
        super.onCreate(savedInstanceState);
        doOnCreate(savedInstanceState);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
        TraceEvent.end("ChromeLauncherActivity.onCreate");
    }
}
 
Example #13
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 #14
Source File: LibraryLoader.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/** Prefetches the native libraries in a background thread.
 *
 * Launches an AsyncTask that, through a short-lived forked process, reads a
 * part of each page of the native library.  This is done to warm up the
 * page cache, turning hard page faults into soft ones.
 *
 * This is done this way, as testing shows that fadvise(FADV_WILLNEED) is
 * detrimental to the startup time.
 */
public void asyncPrefetchLibrariesToMemory() {
    final boolean coldStart = mPrefetchLibraryHasBeenCalled.compareAndSet(false, true);
    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            TraceEvent.begin("LibraryLoader.asyncPrefetchLibrariesToMemory");
            int percentage = nativePercentageOfResidentNativeLibraryCode();
            boolean success = false;
            // Arbitrary percentage threshold. If most of the native library is already
            // resident (likely with monochrome), don't bother creating a prefetch process.
            boolean prefetch = coldStart && percentage < 90;
            if (prefetch) {
                success = nativeForkAndPrefetchNativeLibrary();
                if (!success) {
                    Log.w(TAG, "Forking a process to prefetch the native library failed.");
                }
            }
            // As this runs in a background thread, it can be called before histograms are
            // initialized. In this instance, histograms are dropped.
            RecordHistogram.initialize();
            if (prefetch) {
                RecordHistogram.recordBooleanHistogram("LibraryLoader.PrefetchStatus", success);
            }
            if (percentage != -1) {
                String histogram = "LibraryLoader.PercentageOfResidentCodeBeforePrefetch"
                        + (coldStart ? ".ColdStartup" : ".WarmStartup");
                RecordHistogram.recordPercentageHistogram(histogram, percentage);
            }
            TraceEvent.end("LibraryLoader.asyncPrefetchLibrariesToMemory");
            return null;
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example #15
Source File: GoogleServicesManager.java    From AndroidChromium 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 #16
Source File: GoogleServicesManager.java    From AndroidChromium 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 #17
Source File: AsyncInitializationActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Extending classes should override {@link AsyncInitializationActivity#preInflationStartup()},
 * {@link AsyncInitializationActivity#setContentView()} and
 * {@link AsyncInitializationActivity#postInflationStartup()} instead of this call which will
 * be called on that order.
 */
@Override
@SuppressLint("MissingSuperCall")  // Called in onCreateInternal.
protected final void onCreate(Bundle savedInstanceState) {
    TraceEvent.begin("AsyncInitializationActivity.onCreate()");
    onCreateInternal(savedInstanceState);
    TraceEvent.end("AsyncInitializationActivity.onCreate()");
}
 
Example #18
Source File: TabCreatorManager.java    From AndroidChromium 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 #19
Source File: VSyncMonitor.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a VSyncMonitor
 * @param context The application context.
 * @param listener The listener receiving VSync notifications.
 */
public VSyncMonitor(Context context, VSyncMonitor.Listener listener) {
    mListener = listener;
    float refreshRate = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE))
            .getDefaultDisplay().getRefreshRate();
    final boolean useEstimatedRefreshPeriod = refreshRate < 30;

    if (refreshRate <= 0) refreshRate = 60;
    mRefreshPeriodNano = (long) (NANOSECONDS_PER_SECOND / refreshRate);

    mChoreographer = Choreographer.getInstance();
    mVSyncFrameCallback = new Choreographer.FrameCallback() {
        @Override
        public void doFrame(long frameTimeNanos) {
            TraceEvent.begin("VSync");
            if (useEstimatedRefreshPeriod && mConsecutiveVSync) {
                // Display.getRefreshRate() is unreliable on some platforms.
                // Adjust refresh period- initial value is based on Display.getRefreshRate()
                // after that it asymptotically approaches the real value.
                long lastRefreshDurationNano = frameTimeNanos - mGoodStartingPointNano;
                float lastRefreshDurationWeight = 0.1f;
                mRefreshPeriodNano += (long) (lastRefreshDurationWeight
                        * (lastRefreshDurationNano - mRefreshPeriodNano));
            }
            mGoodStartingPointNano = frameTimeNanos;
            onVSyncCallback(frameTimeNanos, getCurrentNanoTime());
            TraceEvent.end("VSync");
        }
    };
    mGoodStartingPointNano = getCurrentNanoTime();
}
 
Example #20
Source File: ChromeFullscreenManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void applyTranslationToTopChildViews(ViewGroup contentView, float translation) {
    for (int i = 0; i < contentView.getChildCount(); i++) {
        View child = contentView.getChildAt(i);
        if (!(child.getLayoutParams() instanceof FrameLayout.LayoutParams)) continue;

        FrameLayout.LayoutParams layoutParams =
                (FrameLayout.LayoutParams) child.getLayoutParams();
        if (Gravity.TOP == (layoutParams.gravity & Gravity.FILL_VERTICAL)) {
            child.setTranslationY(translation);
            TraceEvent.instant("FullscreenManager:child.setTranslationY()");
        }
    }
}
 
Example #21
Source File: ChromeGoogleApiClientImpl.java    From 365browser 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 #22
Source File: AsyncInitializationActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Extending classes should override {@link AsyncInitializationActivity#preInflationStartup()},
 * {@link AsyncInitializationActivity#setContentView()} and
 * {@link AsyncInitializationActivity#postInflationStartup()} instead of this call which will
 * be called on that order.
 */
@Override
@SuppressLint("MissingSuperCall")  // Called in onCreateInternal.
protected final void onCreate(Bundle savedInstanceState) {
    TraceEvent.begin("AsyncInitializationActivity.onCreate()");
    onCreateInternal(savedInstanceState);
    TraceEvent.end("AsyncInitializationActivity.onCreate()");
}
 
Example #23
Source File: CustomTabsConnection.java    From 365browser with Apache License 2.0 5 votes vote down vote up
public boolean warmup(long flags) {
    try {
        TraceEvent.begin("CustomTabsConnection.warmup");
        boolean success = warmupInternal(true);
        logCall("warmup()", success);
        return success;
    } finally {
        TraceEvent.end("CustomTabsConnection.warmup");
    }
}
 
Example #24
Source File: ChromeBrowserInitializer.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
public static void initNetworkChangeNotifier(Context context) {
    ThreadUtils.assertOnUiThread();
    TraceEvent.begin("NetworkChangeNotifier.init");
    // Enable auto-detection of network connectivity state changes.
    NetworkChangeNotifier.init(context);
    NetworkChangeNotifier.setAutoDetectConnectivityState(true);
    TraceEvent.end("NetworkChangeNotifier.init");
}
 
Example #25
Source File: AsyncTask.java    From cronet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Waits if necessary for the computation to complete, and then
 * retrieves its result.
 *
 * @return The computed result.
 *
 * @throws CancellationException If the computation was cancelled.
 * @throws ExecutionException If the computation threw an exception.
 * @throws InterruptedException If the current thread was interrupted
 *         while waiting.
 */
@DoNotInline
public final Result get() throws InterruptedException, ExecutionException {
    Result r;
    if (getStatus() != Status.FINISHED && ThreadUtils.runningOnUiThread()) {
        StackTraceElement[] stackTrace = new Exception().getStackTrace();
        String caller = "";
        if (stackTrace.length > 1) {
            caller = stackTrace[1].getClassName() + '.' + stackTrace[1].getMethodName() + '.';
        }
        TraceEvent te = null;
        try  {
            te = TraceEvent.scoped(caller + "AsyncTask.get");
            r = mFuture.get();
        } finally {
            if (te != null) {
                try {
                    te.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    } else {
        r = mFuture.get();
    }
    return r;
}
 
Example #26
Source File: ChromeBrowserInitializer.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void startChromeBrowserProcessesAsync(
        boolean startGpuProcess,
        BrowserStartupController.StartupCallback callback) throws ProcessInitException {
    try {
        TraceEvent.begin("ChromeBrowserInitializer.startChromeBrowserProcessesAsync");
        BrowserStartupController.get(mApplication, LibraryProcessType.PROCESS_BROWSER)
                .startBrowserProcessesAsync(startGpuProcess, callback);
    } finally {
        TraceEvent.end("ChromeBrowserInitializer.startChromeBrowserProcessesAsync");
    }
}
 
Example #27
Source File: CompositorView.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Converts the layout into compositor layers. This is to be called on every frame the layout
 * is changing.
 * @param provider               Provides the layout to be rendered.
 * @param forRotation            Whether or not this is a special draw during a rotation.
 */
public void finalizeLayers(final LayoutProvider provider, boolean forRotation,
        final DrawingInfo progressBarDrawingInfo) {
    TraceEvent.begin("CompositorView:finalizeLayers");
    Layout layout = provider.getActiveLayout();
    if (layout == null || mNativeCompositorView == 0) {
        TraceEvent.end("CompositorView:finalizeLayers");
        return;
    }

    if (!mPreloadedResources) {
        // Attempt to prefetch any necessary resources
        mResourceManager.preloadResources(AndroidResourceType.STATIC,
                StaticResourcePreloads.getSynchronousResources(getContext()),
                StaticResourcePreloads.getAsynchronousResources(getContext()));
        mPreloadedResources = true;
    }

    // IMPORTANT: Do not do anything that impacts the compositor layer tree before this line.
    // If you do, you could inadvertently trigger follow up renders.  For further information
    // see dtrainor@, tedchoc@, or klobag@.

    provider.getViewportPixel(mCacheViewport);

    nativeSetLayoutBounds(mNativeCompositorView);

    SceneLayer sceneLayer =
            provider.getUpdatedActiveSceneLayer(mCacheViewport, mLayerTitleCache,
                    mTabContentManager, mResourceManager, provider.getFullscreenManager());

    nativeSetSceneLayer(mNativeCompositorView, sceneLayer);

    final LayoutTab[] tabs = layout.getLayoutTabsToRender();
    final int tabsCount = tabs != null ? tabs.length : 0;
    mLastLayerCount = tabsCount;
    TabModelImpl.flushActualTabSwitchLatencyMetric();
    nativeFinalizeLayers(mNativeCompositorView);
    TraceEvent.end("CompositorView:finalizeLayers");
}
 
Example #28
Source File: CompositorViewHolder.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void flushInvalidation() {
    if (mPendingInvalidations.isEmpty()) return;
    TraceEvent.instant("CompositorViewHolder.flushInvalidation");
    for (int i = 0; i < mPendingInvalidations.size(); i++) {
        mPendingInvalidations.get(i).doInvalidate();
    }
    mPendingInvalidations.clear();
}
 
Example #29
Source File: ContentView.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
    try {
        TraceEvent.begin("ContentView.onFocusChanged");
        super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
        mContentViewCore.onFocusChanged(gainFocus, true /* hideKeyboardOnBlur */);
    } finally {
        TraceEvent.end("ContentView.onFocusChanged");
    }
}
 
Example #30
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Causes this tab to navigate to the specified URL.
 * @param params parameters describing the url load. Note that it is important to set correct
 *               page transition as it is used for ranking URLs in the history so the omnibox
 *               can report suggestions correctly.
 * @return FULL_PRERENDERED_PAGE_LOAD or PARTIAL_PRERENDERED_PAGE_LOAD if the page has been
 *         prerendered. DEFAULT_PAGE_LOAD if it had not.
 */
public int loadUrl(LoadUrlParams params) {
    try {
        TraceEvent.begin("Tab.loadUrl");
        // TODO(tedchoc): When showing the android NTP, delay the call to nativeLoadUrl until
        //                the android view has entirely rendered.
        if (!mIsNativePageCommitPending) {
            mIsNativePageCommitPending = maybeShowNativePage(params.getUrl(), false);
        }

        removeSadTabIfPresent();

        // Clear the app association if the user navigated to a different page from the omnibox.
        if ((params.getTransitionType() & PageTransition.FROM_ADDRESS_BAR)
                == PageTransition.FROM_ADDRESS_BAR) {
            mAppAssociatedWith = null;
            setIsAllowedToReturnToExternalApp(false);
        }

        // We load the URL from the tab rather than directly from the ContentView so the tab has
        // a chance of using a prerenderer page is any.
        int loadType = nativeLoadUrl(mNativeTabAndroid, params.getUrl(),
                params.getVerbatimHeaders(), params.getPostData(), params.getTransitionType(),
                params.getReferrer() != null ? params.getReferrer().getUrl() : null,
                // Policy will be ignored for null referrer url, 0 is just a placeholder.
                // TODO(ppi): Should we pass Referrer jobject and add JNI methods to read it
                //            from the native?
                params.getReferrer() != null ? params.getReferrer().getPolicy() : 0,
                params.getIsRendererInitiated(), params.getShouldReplaceCurrentEntry(),
                params.getIntentReceivedTimestamp(), params.getHasUserGesture());

        for (TabObserver observer : mObservers) {
            observer.onLoadUrl(this, params, loadType);
        }
        return loadType;
    } finally {
        TraceEvent.end("Tab.loadUrl");
    }
}