Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java

Issue 2855043002: Defer deferred startup if native isn't loaded (Closed)
Patch Set: Defer deferred startup if native isn't loaded Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
index ec1daa3068c4a4acfe2126a851efdfd8d20c8e3c..7245b062251dcadd5509365fab8e369e490baa72 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
@@ -226,7 +226,12 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
protected IntentHandler mIntentHandler;
+ /** Set if {@link #postDeferredStartupIfNeeded()} is called before native has loaded. */
+ private boolean mDeferredStartupQueued;
+
+ /** Whether or not {@link #postDeferredStartupIfNeeded()} has already successfully run. */
private boolean mDeferredStartupPosted;
+
private boolean mTabModelsInitialized;
private boolean mNativeInitialized;
private boolean mRemoveWindowBackgroundDone;
@@ -764,6 +769,8 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
@Override
public void onStartWithNative() {
+ assert mNativeInitialized : "onStartWithNative was called before native was initialized.";
+
super.onStartWithNative();
UpdateMenuItemHelper.getInstance().onStart();
ChromeActivitySessionTracker.getInstance().onStartWithNative();
@@ -779,7 +786,7 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
// #onPageLoadFinished() and #onCrash(). If we are not actively loading a tab (e.g.
// in Android N multi-instance, which is created by re-parenting an existing tab),
// ensure onDeferredStartup() gets called by calling postDeferredStartupIfNeeded() here.
- if (getActivityTab() == null || !getActivityTab().isLoading()) {
+ if (mDeferredStartupQueued || getActivityTab() == null || !getActivityTab().isLoading()) {
postDeferredStartupIfNeeded();
}
}
@@ -2010,6 +2017,13 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
}
protected final void postDeferredStartupIfNeeded() {
+ if (!mNativeInitialized) {
+ // Native hasn't loaded yet. Queue it up for later.
+ mDeferredStartupQueued = true;
+ return;
+ }
+ mDeferredStartupQueued = false;
+
if (!mDeferredStartupPosted) {
mDeferredStartupPosted = true;
RecordHistogram.recordLongTimesHistogram(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698