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

Unified Diff: content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellActivity.java

Issue 22272006: Add support for multiple asynchronous browser startups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merged BrowserStartupConfig and BrowserStartupController. Rebased. Updated ContentShellActivity to … Created 7 years, 4 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
Index: content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellActivity.java
diff --git a/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellActivity.java b/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellActivity.java
index 3f7ceb08898a87f109ba0f546502d1c0da4841bc..13bf0db250d933fbca42c06a2ac589a038487f8e 100644
--- a/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellActivity.java
+++ b/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ContentShellActivity.java
@@ -17,8 +17,7 @@ import org.chromium.base.ChromiumActivity;
import org.chromium.base.MemoryPressureListener;
import org.chromium.content.app.LibraryLoader;
import org.chromium.content.browser.ActivityContentVideoViewClient;
-import org.chromium.content.browser.AndroidBrowserProcess;
-import org.chromium.content.browser.BrowserStartupConfig;
+import org.chromium.content.browser.BrowserStartupController;
import org.chromium.content.browser.ContentVideoViewClient;
import org.chromium.content.browser.ContentView;
import org.chromium.content.browser.ContentViewClient;
@@ -65,7 +64,7 @@ public class ContentShellActivity extends ChromiumActivity {
private BroadcastReceiver mReceiver;
@Override
- protected void onCreate(Bundle savedInstanceState) {
+ protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initializing the command line must occur before loading the library.
@@ -81,45 +80,60 @@ public class ContentShellActivity extends ChromiumActivity {
DeviceUtils.addDeviceSpecificUserAgentSwitch(this);
try {
LibraryLoader.ensureInitialized();
+ } catch (ProcessInitException e) {
+ Log.e(TAG, "ContentView initialization failed.", e);
+ finish();
+ return;
+ }
- setContentView(R.layout.content_shell_activity);
- mShellManager = (ShellManager) findViewById(R.id.shell_container);
- mWindowAndroid = new WindowAndroid(this);
- mWindowAndroid.restoreInstanceState(savedInstanceState);
- mShellManager.setWindow(mWindowAndroid);
+ setContentView(R.layout.content_shell_activity);
+ mShellManager = (ShellManager) findViewById(R.id.shell_container);
+ mWindowAndroid = new WindowAndroid(this);
+ mWindowAndroid.restoreInstanceState(savedInstanceState);
+ mShellManager.setWindow(mWindowAndroid);
- String startupUrl = getUrlFromIntent(getIntent());
- if (!TextUtils.isEmpty(startupUrl)) {
- mShellManager.setStartupUrl(Shell.sanitizeUrl(startupUrl));
- }
+ String startupUrl = getUrlFromIntent(getIntent());
+ if (!TextUtils.isEmpty(startupUrl)) {
+ mShellManager.setStartupUrl(Shell.sanitizeUrl(startupUrl));
+ }
- if (!CommandLine.getInstance().hasSwitch(CommandLine.DUMP_RENDER_TREE)) {
- BrowserStartupConfig.setAsync(new BrowserStartupConfig.StartupCallback() {
-
- @Override
- public void run(int startupResult) {
- if (startupResult > 0) {
- // TODO: Show error message.
- Log.e(TAG, "ContentView initialization failed.");
- finish();
- } else {
- finishInitialization();
+ BrowserStartupController.StartupCallback callback;
+ if (CommandLine.getInstance().hasSwitch(CommandLine.DUMP_RENDER_TREE)) {
+ callback = new BrowserStartupController.StartupCallback() {
+ @Override
+ public void run(int startupResult) {
+ if (startupResult > 0) {
+ // TODO: Show error message.
+ Log.e(TAG, "ContentView initialization failed.");
+ finish();
+ } else {
+ String shellUrl = ShellManager.DEFAULT_SHELL_URL;
+ if (savedInstanceState != null
+ && savedInstanceState.containsKey(ACTIVE_SHELL_URL_KEY)) {
+ shellUrl = savedInstanceState.getString(ACTIVE_SHELL_URL_KEY);
}
+ mShellManager.launchShell(shellUrl);
+ finishInitialization();
}
- });
- }
-
- if (!AndroidBrowserProcess.init(this, AndroidBrowserProcess.MAX_RENDERERS_LIMIT)) {
- String shellUrl = ShellManager.DEFAULT_SHELL_URL;
- if (savedInstanceState != null
- && savedInstanceState.containsKey(ACTIVE_SHELL_URL_KEY)) {
- shellUrl = savedInstanceState.getString(ACTIVE_SHELL_URL_KEY);
}
- mShellManager.launchShell(shellUrl);
- finishInitialization();
- }
- } catch (ProcessInitException e) {
- Log.e(TAG, "ContentView initialization failed.", e);
+ };
+ } else {
+ callback = new BrowserStartupController.StartupCallback() {
+ @Override
+ public void run(int startupResult) {
+ if (startupResult > 0) {
+ // TODO: Show error message.
+ Log.e(TAG, "ContentView initialization failed.");
+ finish();
+ } else {
+ finishInitialization();
+ }
+ }
+ };
+ }
+
+ if (!BrowserStartupController.get(this).startBrowserProcessesAsync(callback)) {
+ Log.e(TAG, "ContentView initialization failed.");
finish();
}
}

Powered by Google App Engine
This is Rietveld 408576698