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

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

Issue 2431833002: customtabs: Re-Create a spare renderer on Tab close. (Closed)
Patch Set: Make FindBugs happy. Created 4 years, 2 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 | chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java » ('j') | 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/customtabs/CustomTabActivity.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java
index 26afef05a009f0f6f22c70b89660459d387f5f2f..635703b6f49f645a760e25198b7411d33edbf8ad 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java
@@ -157,7 +157,7 @@ public class CustomTabActivity extends ChromeActivity {
public void didCloseTab(int tabId, boolean incognito) {
PageLoadMetrics.removeObserver(mMetricsObserver);
// Finish the activity after we intent out.
- if (getTabModelSelector().getCurrentModel().getCount() == 0) finish();
+ if (getTabModelSelector().getCurrentModel().getCount() == 0) finishAndClose(false);
}
};
@@ -363,7 +363,7 @@ public class CustomTabActivity extends ChromeActivity {
@Override
public void onClick(View v) {
RecordUserAction.record("CustomTabs.CloseButtonClicked");
- finishAndClose();
+ finishAndClose(false);
}
});
@@ -644,9 +644,25 @@ public class CustomTabActivity extends ChromeActivity {
/**
* Finishes the activity and removes the reference from the Android recents.
+ *
+ * @param reparenting true iff the activity finishes due to tab reparenting.
*/
- public final void finishAndClose() {
+ public final void finishAndClose(boolean reparenting) {
mIsClosing = true;
+ if (!reparenting) {
+ // Closing the activity destroys the renderer as well. Re-create a spare renderer some
+ // time after, so that we have one ready for the next tab open. This does not increase
+ // memory consumption, as the current renderer goes away. We create a renderer as a lot
+ // of users open several Custom Tabs in a row. The delay is there to avoid jank in the
+ // transition animation when closing the tab.
+ ThreadUtils.postOnUiThreadDelayed(new Runnable() {
+ @Override
+ public void run() {
+ WarmupManager.getInstance().createSpareWebContents();
+ }
+ }, 500);
+ }
+
handleFinishAndClose();
}
@@ -671,7 +687,7 @@ public class CustomTabActivity extends ChromeActivity {
if (getCurrentTabModel().getCount() > 1) {
getCurrentTabModel().closeTab(getActivityTab(), false, false, false);
} else {
- finishAndClose();
+ finishAndClose(false);
}
}
return true;
@@ -823,7 +839,7 @@ public class CustomTabActivity extends ChromeActivity {
Runnable finalizeCallback = new Runnable() {
@Override
public void run() {
- finishAndClose();
+ finishAndClose(true);
}
};
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698