summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwBrowserProcess.java11
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/AndroidWebViewTestBase.java9
-rw-r--r--chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java10
-rw-r--r--chrome/app/android/chrome_main_delegate_android.cc7
-rw-r--r--content/app/android/library_loader_hooks.cc21
-rw-r--r--content/public/android/java/src/org/chromium/content/app/LibraryLoader.java31
-rw-r--r--content/public/android/java/src/org/chromium/content/app/SandboxedProcessService.java3
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/AndroidBrowserProcess.java12
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentView.java7
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java13
-rw-r--r--content/public/android/java/src/org/chromium/content/common/ProcessInitException.java37
-rw-r--r--content/public/android/javatests/src/org/chromium/content/browser/CommandLineTest.java7
-rw-r--r--content/public/common/result_codes.h7
-rw-r--r--content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java46
-rw-r--r--testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java47
15 files changed, 160 insertions, 108 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwBrowserProcess.java b/android_webview/java/src/org/chromium/android_webview/AwBrowserProcess.java
index 682706a..3e465d6 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwBrowserProcess.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwBrowserProcess.java
@@ -11,6 +11,7 @@ import org.chromium.base.ThreadUtils;
import org.chromium.content.app.LibraryLoader;
import org.chromium.content.browser.AndroidBrowserProcess;
import org.chromium.content.browser.ResourceExtractor;
+import org.chromium.content.common.ProcessInitException;
/**
* Wrapper for the steps needed to initialize the java and native sides of webview chromium.
@@ -46,9 +47,13 @@ public abstract class AwBrowserProcess {
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
- LibraryLoader.ensureInitialized();
- AndroidBrowserProcess.initContentViewProcess(context,
- AndroidBrowserProcess.MAX_RENDERERS_SINGLE_PROCESS);
+ try {
+ LibraryLoader.ensureInitialized();
+ AndroidBrowserProcess.initContentViewProcess(context,
+ AndroidBrowserProcess.MAX_RENDERERS_SINGLE_PROCESS);
+ } catch (ProcessInitException e) {
+ throw new RuntimeException("Cannot initialize WebView", e);
+ }
}
});
}
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AndroidWebViewTestBase.java b/android_webview/javatests/src/org/chromium/android_webview/test/AndroidWebViewTestBase.java
index 3c8af55..26295b6 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AndroidWebViewTestBase.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AndroidWebViewTestBase.java
@@ -22,6 +22,7 @@ import org.chromium.content.browser.test.util.CallbackHelper;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
+import org.chromium.content.common.ProcessInitException;
import org.chromium.ui.gfx.ActivityNativeWindow;
import java.util.concurrent.atomic.AtomicInteger;
@@ -51,8 +52,12 @@ public class AndroidWebViewTestBase
@Override
public void run() {
AwTestResourceProvider.registerResources(context);
- ContentViewCore.initChromiumBrowserProcess(
- context, ContentView.MAX_RENDERERS_SINGLE_PROCESS);
+ try {
+ ContentViewCore.initChromiumBrowserProcess(
+ context, ContentView.MAX_RENDERERS_SINGLE_PROCESS);
+ } catch (ProcessInitException e) {
+ throw new Error("Failed to initialize browser process", e);
+ }
}
});
}
diff --git a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java
index b8cb09f..4d9e6b7 100644
--- a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java
+++ b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/ChromiumTestShellActivity.java
@@ -18,6 +18,7 @@ import org.chromium.content.app.LibraryLoader;
import org.chromium.content.browser.ContentView;
import org.chromium.content.browser.DeviceUtils;
import org.chromium.content.common.CommandLine;
+import org.chromium.content.common.ProcessInitException;
import org.chromium.ui.gfx.ActivityNativeWindow;
/**
@@ -40,9 +41,12 @@ public class ChromiumTestShellActivity extends ChromiumActivity {
waitForDebuggerIfNeeded();
DeviceUtils.addDeviceSpecificUserAgentSwitch(this);
-
- ContentView.initChromiumBrowserProcess(this, ContentView.MAX_RENDERERS_AUTOMATIC);
-
+ try {
+ ContentView.initChromiumBrowserProcess(this, ContentView.MAX_RENDERERS_AUTOMATIC);
+ } catch (ProcessInitException e) {
+ Log.e(TAG, "Chromium browser process initialization failed", e);
+ finish();
+ }
setContentView(R.layout.testshell_activity);
mTabManager = (TabManager) findViewById(R.id.tab_manager);
String startupUrl = getUrlFromIntent(getIntent());
diff --git a/chrome/app/android/chrome_main_delegate_android.cc b/chrome/app/android/chrome_main_delegate_android.cc
index bf28f4a..2d82ba9 100644
--- a/chrome/app/android/chrome_main_delegate_android.cc
+++ b/chrome/app/android/chrome_main_delegate_android.cc
@@ -40,12 +40,7 @@ int ChromeMainDelegateAndroid::RunProcess(
RegisterApplicationNativeMethods(env);
browser_runner_.reset(content::BrowserMainRunner::Create());
- int exit_code = browser_runner_->Initialize(main_function_params);
- DCHECK(exit_code < 0);
-
- // Return 0 so that we do NOT trigger the default behavior. On Android, the
- // UI message loop is managed by the Java application.
- return 0;
+ return browser_runner_->Initialize(main_function_params);
}
return ChromeMainDelegate::RunProcess(process_type, main_function_params);
diff --git a/content/app/android/library_loader_hooks.cc b/content/app/android/library_loader_hooks.cc
index 346a0ed..80026b8 100644
--- a/content/app/android/library_loader_hooks.cc
+++ b/content/app/android/library_loader_hooks.cc
@@ -23,6 +23,7 @@
#include "content/common/android/common_jni_registrar.h"
#include "content/common/android/command_line.h"
#include "content/public/common/content_switches.h"
+#include "content/public/common/result_codes.h"
#include "media/base/android/media_jni_registrar.h"
#include "net/android/net_jni_registrar.h"
#include "ui/android/ui_jni_registrar.h"
@@ -35,7 +36,7 @@ base::AtExitManager* g_at_exit_manager = NULL;
namespace content {
-static jboolean LibraryLoadedOnMainThread(JNIEnv* env, jclass clazz,
+static jint LibraryLoadedOnMainThread(JNIEnv* env, jclass clazz,
jobjectArray init_command_line) {
InitNativeCommandLineFromJavaArray(env, init_command_line);
@@ -70,30 +71,30 @@ static jboolean LibraryLoadedOnMainThread(JNIEnv* env, jclass clazz,
<< ", default verbosity = " << logging::GetVlogVerbosity();
if (!base::android::RegisterJni(env))
- return JNI_FALSE;
+ return RESULT_CODE_FAILED_TO_REGISTER_JNI;
if (!net::android::RegisterJni(env))
- return JNI_FALSE;
+ return RESULT_CODE_FAILED_TO_REGISTER_JNI;
if (!ui::RegisterJni(env))
- return JNI_FALSE;
+ return RESULT_CODE_FAILED_TO_REGISTER_JNI;
if (!content::android::RegisterCommonJni(env))
- return JNI_FALSE;
+ return RESULT_CODE_FAILED_TO_REGISTER_JNI;
if (!content::android::RegisterBrowserJni(env))
- return JNI_FALSE;
+ return RESULT_CODE_FAILED_TO_REGISTER_JNI;
if (!content::android::RegisterAppJni(env))
- return JNI_FALSE;
+ return RESULT_CODE_FAILED_TO_REGISTER_JNI;
if (!media::RegisterJni(env))
- return JNI_FALSE;
+ return RESULT_CODE_FAILED_TO_REGISTER_JNI;
if (!gfx::RegisterJni(env))
- return JNI_FALSE;
+ return RESULT_CODE_FAILED_TO_REGISTER_JNI;
- return JNI_TRUE;
+ return 0;
}
void LibraryLoaderExitHook() {
diff --git a/content/public/android/java/src/org/chromium/content/app/LibraryLoader.java b/content/public/android/java/src/org/chromium/content/app/LibraryLoader.java
index 75e40c0..91e3234 100644
--- a/content/public/android/java/src/org/chromium/content/app/LibraryLoader.java
+++ b/content/public/android/java/src/org/chromium/content/app/LibraryLoader.java
@@ -11,6 +11,7 @@ import android.util.Log;
import org.chromium.base.JNINamespace;
import org.chromium.content.common.CommandLine;
+import org.chromium.content.common.ProcessInitException;
import org.chromium.content.common.TraceEvent;
/**
@@ -56,17 +57,11 @@ public class LibraryLoader {
return sLibrary;
}
- @Deprecated
- public static void loadAndInitSync() {
- // TODO(joth): remove in next patch.
- ensureInitialized();
- }
-
/**
* This method blocks until the library is fully loaded and initialized;
* must be called on the thread that the native will call its "main" thread.
*/
- public static void ensureInitialized() {
+ public static void ensureInitialized() throws ProcessInitException {
checkThreadUsage();
if (sInitialized) {
// Already initialized, nothing to do.
@@ -77,15 +72,6 @@ public class LibraryLoader {
}
/**
- * @throws UnsatisfiedLinkError if the library is not yet initialized.
- */
- public static void checkIsReady() {
- if (!sInitialized) {
- throw new UnsatisfiedLinkError(sLibrary + " is not initialized");
- }
- }
-
- /**
* Loads the library and blocks until the load completes. The caller is responsible
* for subsequently calling ensureInitialized().
* May be called on any thread, but should only be called once. Note the thread
@@ -116,14 +102,15 @@ public class LibraryLoader {
* @param initCommandLine The command line arguments that native command line will
* be initialized with.
*/
- static void initializeOnMainThread(String[] initCommandLine) {
+ static void initializeOnMainThread(String[] initCommandLine) throws ProcessInitException {
checkThreadUsage();
if (sInitialized) {
return;
}
- if (!nativeLibraryLoadedOnMainThread(initCommandLine)) {
+ int resultCode = nativeLibraryLoadedOnMainThread(initCommandLine);
+ if (resultCode != 0) {
Log.e(TAG, "error calling nativeLibraryLoadedOnMainThread");
- throw new UnsatisfiedLinkError();
+ throw new ProcessInitException(resultCode);
}
// From this point on, native code is ready to use and checkIsReady()
// shouldn't complain from now on (and in fact, it's used by the
@@ -133,7 +120,7 @@ public class LibraryLoader {
TraceEvent.setEnabledToMatchNative();
}
- static private void initializeOnMainThread() {
+ static private void initializeOnMainThread() throws ProcessInitException {
checkThreadUsage();
if (!sInitialized) {
initializeOnMainThread(CommandLine.getJavaSwitchesOrNull());
@@ -166,5 +153,7 @@ public class LibraryLoader {
// This is the only method that is registered during System.loadLibrary, as it
// may happen on a different thread. We then call it on the main thread to register
// everything else.
- private static native boolean nativeLibraryLoadedOnMainThread(String[] initCommandLine);
+ // Return 0 on success, otherwise return the error code from
+ // content/public/common/result_codes.h.
+ private static native int nativeLibraryLoadedOnMainThread(String[] initCommandLine);
}
diff --git a/content/public/android/java/src/org/chromium/content/app/SandboxedProcessService.java b/content/public/android/java/src/org/chromium/content/app/SandboxedProcessService.java
index 4253deb..d89cce1 100644
--- a/content/public/android/java/src/org/chromium/content/app/SandboxedProcessService.java
+++ b/content/public/android/java/src/org/chromium/content/app/SandboxedProcessService.java
@@ -24,6 +24,7 @@ import org.chromium.content.app.ContentMain;
import org.chromium.content.browser.SandboxedProcessConnection;
import org.chromium.content.common.ISandboxedProcessCallback;
import org.chromium.content.common.ISandboxedProcessService;
+import org.chromium.content.common.ProcessInitException;
import org.chromium.content.common.SurfaceCallback;
/**
@@ -153,6 +154,8 @@ public class SandboxedProcessService extends Service {
nativeExitSandboxedProcess();
} catch (InterruptedException e) {
Log.w(TAG, MAIN_THREAD_NAME + " startup failed: " + e);
+ } catch (ProcessInitException e) {
+ Log.w(TAG, MAIN_THREAD_NAME + " startup failed: " + e);
}
}
}, MAIN_THREAD_NAME);
diff --git a/content/public/android/java/src/org/chromium/content/browser/AndroidBrowserProcess.java b/content/public/android/java/src/org/chromium/content/browser/AndroidBrowserProcess.java
index 6f62a71..5c4aad7 100644
--- a/content/public/android/java/src/org/chromium/content/browser/AndroidBrowserProcess.java
+++ b/content/public/android/java/src/org/chromium/content/browser/AndroidBrowserProcess.java
@@ -16,6 +16,7 @@ import org.chromium.base.JNINamespace;
import org.chromium.content.app.ContentMain;
import org.chromium.content.app.LibraryLoader;
import org.chromium.content.common.CommandLine;
+import org.chromium.content.common.ProcessInitException;
import org.chromium.content.R;
// NOTE: This file hasn't been fully upstreamed, please don't merge to downstream.
@@ -69,7 +70,8 @@ public class AndroidBrowserProcess {
* @param maxRendererProcesses See ContentView.enableMultiProcess().
* @return Whether the process actually needed to be initialized (false if already running).
*/
- public static boolean initContentViewProcess(Context context, int maxRendererProcesses) {
+ public static boolean initContentViewProcess(Context context, int maxRendererProcesses)
+ throws ProcessInitException {
return genericChromiumProcessInit(context, maxRendererProcesses, false);
}
@@ -81,7 +83,8 @@ public class AndroidBrowserProcess {
* @param maxRendererProcesses See ContentView.enableMultiProcess().
* @return Whether the process actually needed to be initialized (false if already running).
*/
- public static boolean initChromiumBrowserProcess(Context context, int maxRendererProcesses) {
+ public static boolean initChromiumBrowserProcess(Context context, int maxRendererProcesses)
+ throws ProcessInitException {
return genericChromiumProcessInit(context, maxRendererProcesses, true);
}
@@ -93,7 +96,7 @@ public class AndroidBrowserProcess {
* @return Whether the process actually needed to be initialized (false if already running).
*/
private static boolean genericChromiumProcessInit(Context context, int maxRendererProcesses,
- boolean hostIsChrome) {
+ boolean hostIsChrome) throws ProcessInitException {
if (sInitialized) return false;
sInitialized = true;
@@ -156,7 +159,8 @@ public class AndroidBrowserProcess {
nativeSetCommandLineFlags(maxRenderers);
ContentMain.initApplicationContext(appContext);
- ContentMain.start();
+ int result = ContentMain.start();
+ if (result > 0) throw new ProcessInitException(result);
return true;
}
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentView.java b/content/public/android/java/src/org/chromium/content/browser/ContentView.java
index eebd79b..e0639b7 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentView.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentView.java
@@ -23,6 +23,7 @@ import android.widget.FrameLayout;
import com.google.common.annotations.VisibleForTesting;
+import org.chromium.content.common.ProcessInitException;
import org.chromium.content.common.TraceEvent;
import org.chromium.ui.gfx.NativeWindow;
@@ -71,7 +72,8 @@ public class ContentView extends FrameLayout implements ContentViewCore.Internal
* maximum number of allowed renderers is capped by MAX_RENDERERS_LIMIT.
* @return Whether the process actually needed to be initialized (false if already running).
*/
- public static boolean enableMultiProcess(Context context, int maxRendererProcesses) {
+ public static boolean enableMultiProcess(Context context, int maxRendererProcesses)
+ throws ProcessInitException {
return ContentViewCore.enableMultiProcess(context, maxRendererProcesses);
}
@@ -83,7 +85,8 @@ public class ContentView extends FrameLayout implements ContentViewCore.Internal
* @param maxRendererProcesses Same as ContentView.enableMultiProcess()
* @return Whether the process actually needed to be initialized (false if already running).
*/
- public static boolean initChromiumBrowserProcess(Context context, int maxRendererProcesses) {
+ public static boolean initChromiumBrowserProcess(Context context, int maxRendererProcesses)
+ throws ProcessInitException {
return ContentViewCore.initChromiumBrowserProcess(context, maxRendererProcesses);
}
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index a97a69c..42f25ff 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -45,6 +45,7 @@ import org.chromium.base.WeakContext;
import org.chromium.content.R;
import org.chromium.content.browser.ContentViewGestureHandler.MotionEventDelegate;
import org.chromium.content.browser.accessibility.AccessibilityInjector;
+import org.chromium.content.common.ProcessInitException;
import org.chromium.content.common.TraceEvent;
import org.chromium.ui.gfx.NativeWindow;
@@ -266,7 +267,8 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
* maximum number of allowed renderers is capped by MAX_RENDERERS_LIMIT.
* @return Whether the process actually needed to be initialized (false if already running).
*/
- public static boolean enableMultiProcess(Context context, int maxRendererProcesses) {
+ public static boolean enableMultiProcess(Context context, int maxRendererProcesses)
+ throws ProcessInitException {
return AndroidBrowserProcess.initContentViewProcess(context, maxRendererProcesses);
}
@@ -278,7 +280,8 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
* @param maxRendererProcesses Same as ContentView.enableMultiProcess()
* @return Whether the process actually needed to be initialized (false if already running).
*/
- public static boolean initChromiumBrowserProcess(Context context, int maxRendererProcesses) {
+ public static boolean initChromiumBrowserProcess(Context context, int maxRendererProcesses)
+ throws ProcessInitException {
return AndroidBrowserProcess.initChromiumBrowserProcess(context, maxRendererProcesses);
}
@@ -293,12 +296,6 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient {
mContext = context;
WeakContext.initializeWeakContext(context);
- // By default, ContentView will initialize single process mode. The call to
- // initContentViewProcess below is ignored if either the ContentView host called
- // enableMultiProcess() or the platform browser called initChromiumBrowserProcess().
- AndroidBrowserProcess.initContentViewProcess(
- context, AndroidBrowserProcess.MAX_RENDERERS_SINGLE_PROCESS);
-
mPersonality = personality;
HeapStatsLogger.init(mContext.getApplicationContext());
diff --git a/content/public/android/java/src/org/chromium/content/common/ProcessInitException.java b/content/public/android/java/src/org/chromium/content/common/ProcessInitException.java
new file mode 100644
index 0000000..cd6d54e
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/common/ProcessInitException.java
@@ -0,0 +1,37 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content.common;
+
+/**
+ * The exception that is thrown when the intialization of a process was failed.
+ */
+public class ProcessInitException extends Exception {
+ private int mErrorCode = 0;
+
+ /**
+ * @param errorCode The error code could be one from content/public/common/result_codes.h
+ * or embedder.
+ */
+ public ProcessInitException(int errorCode) {
+ mErrorCode = errorCode;
+ }
+
+ /**
+ * @param errorCode The error code could be one from content/public/common/result_codes.h
+ * or embedder.
+ * @param throwable The wrapped throwable obj.
+ */
+ public ProcessInitException(int errorCode, Throwable throwable) {
+ super(null, throwable);
+ mErrorCode = errorCode;
+ }
+
+ /**
+ * Return the error code.
+ */
+ public int getErrorCode() {
+ return mErrorCode;
+ }
+}
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/CommandLineTest.java b/content/public/android/javatests/src/org/chromium/content/browser/CommandLineTest.java
index ad41cd6b..b84f7b8 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/CommandLineTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/CommandLineTest.java
@@ -11,6 +11,7 @@ import android.test.suitebuilder.annotation.SmallTest;
import org.chromium.base.test.util.Feature;
import org.chromium.content.app.LibraryLoader;
import org.chromium.content.common.CommandLine;
+import org.chromium.content.common.ProcessInitException;
import org.chromium.content_shell.ContentShellActivity;
import org.chromium.content_shell.ContentShellApplication;
@@ -43,7 +44,11 @@ public class CommandLineTest extends InstrumentationTestCase {
@Override
public void run() {
ContentShellApplication.initializeApplicationParameters();
- LibraryLoader.ensureInitialized();
+ try {
+ LibraryLoader.ensureInitialized();
+ } catch (ProcessInitException e) {
+ throw new Error(e);
+ }
}
});
assertTrue(CommandLine.getInstance().isNativeImplementation());
diff --git a/content/public/common/result_codes.h b/content/public/common/result_codes.h
index 20cfbb8..b3c4a6b 100644
--- a/content/public/common/result_codes.h
+++ b/content/public/common/result_codes.h
@@ -28,7 +28,12 @@ enum ResultCode {
RESULT_CODE_HUNG = 2,
// A bad message caused the process termination.
- RESULT_CODE_KILLED_BAD_MESSAGE,
+ RESULT_CODE_KILLED_BAD_MESSAGE = 3,
+
+#if defined(OS_ANDROID)
+ // Failed to register JNI methods.
+ RESULT_CODE_FAILED_TO_REGISTER_JNI = 4,
+#endif
// Last return code (keep this last).
RESULT_CODE_LAST_CODE
diff --git a/content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java b/content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java
index a0d1682..cd3e546 100644
--- a/content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java
+++ b/content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java
@@ -22,6 +22,7 @@ import org.chromium.content.browser.ContentView;
import org.chromium.content.browser.DeviceUtils;
import org.chromium.content.browser.TracingIntentHandler;
import org.chromium.content.common.CommandLine;
+import org.chromium.content.common.ProcessInitException;
import org.chromium.ui.gfx.ActivityNativeWindow;
/**
@@ -59,29 +60,32 @@ public class ContentShellActivity extends ChromiumActivity {
waitForDebuggerIfNeeded();
DeviceUtils.addDeviceSpecificUserAgentSwitch(this);
-
- LibraryLoader.ensureInitialized();
-
- setContentView(R.layout.content_shell_activity);
- mShellManager = (ShellManager) findViewById(R.id.shell_container);
- mActivityNativeWindow = new ActivityNativeWindow(this);
- mActivityNativeWindow.restoreInstanceState(savedInstanceState);
- mShellManager.setWindow(mActivityNativeWindow);
- ContentVideoView.registerContentVideoViewContextDelegate(
- new ActivityContentVideoViewDelegate(this));
-
- String startupUrl = getUrlFromIntent(getIntent());
- if (!TextUtils.isEmpty(startupUrl)) {
- mShellManager.setStartupUrl(Shell.sanitizeUrl(startupUrl));
- }
-
- if (!ContentView.enableMultiProcess(this, ContentView.MAX_RENDERERS_AUTOMATIC)) {
- String shellUrl = DEFAULT_SHELL_URL;
- if (savedInstanceState != null
+ try {
+ LibraryLoader.ensureInitialized();
+
+ setContentView(R.layout.content_shell_activity);
+ mShellManager = (ShellManager) findViewById(R.id.shell_container);
+ mActivityNativeWindow = new ActivityNativeWindow(this);
+ mActivityNativeWindow.restoreInstanceState(savedInstanceState);
+ mShellManager.setWindow(mActivityNativeWindow);
+ ContentVideoView.registerContentVideoViewContextDelegate(
+ new ActivityContentVideoViewDelegate(this));
+
+ String startupUrl = getUrlFromIntent(getIntent());
+ if (!TextUtils.isEmpty(startupUrl)) {
+ mShellManager.setStartupUrl(Shell.sanitizeUrl(startupUrl));
+ }
+ if (!ContentView.enableMultiProcess(this, ContentView.MAX_RENDERERS_AUTOMATIC)) {
+ String shellUrl = DEFAULT_SHELL_URL;
+ if (savedInstanceState != null
&& savedInstanceState.containsKey(ACTIVE_SHELL_URL_KEY)) {
- shellUrl = savedInstanceState.getString(ACTIVE_SHELL_URL_KEY);
+ shellUrl = savedInstanceState.getString(ACTIVE_SHELL_URL_KEY);
+ }
+ mShellManager.launchShell(shellUrl);
}
- mShellManager.launchShell(shellUrl);
+ } catch (ProcessInitException e) {
+ Log.e(TAG, "ContentView initialization failed.", e);
+ finish();
}
}
diff --git a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
index 490ed14..21b0f85 100644
--- a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
+++ b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
@@ -45,31 +45,26 @@ public class ChromeNativeTestActivity extends ChromiumActivity {
// Needed by system_monitor_unittest.cc
SystemMonitor.createForTests(this);
- try {
- loadLibrary();
- Bundle extras = this.getIntent().getExtras();
- if (extras != null && extras.containsKey(EXTRA_RUN_IN_SUB_THREAD)) {
- // Create a new thread and run tests on it.
- new Thread() {
- @Override
- public void run() {
- runTests();
- }
- }.start();
- } else {
- // Post a task to run the tests. This allows us to not block
- // onCreate and still run tests on the main thread.
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- runTests();
- }
- }, RUN_TESTS_DELAY_IN_MS);
- }
- } catch (UnsatisfiedLinkError e) {
- Log.e(TAG, "Unable to load lib" + mLibrary + ".so: " + e);
- nativeTestFailed();
- throw e;
+
+ loadLibrary();
+ Bundle extras = this.getIntent().getExtras();
+ if (extras != null && extras.containsKey(EXTRA_RUN_IN_SUB_THREAD)) {
+ // Create a new thread and run tests on it.
+ new Thread() {
+ @Override
+ public void run() {
+ runTests();
+ }
+ }.start();
+ } else {
+ // Post a task to run the tests. This allows us to not block
+ // onCreate and still run tests on the main thread.
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ runTests();
+ }
+ }, RUN_TESTS_DELAY_IN_MS);
}
}
@@ -85,7 +80,7 @@ public class ChromeNativeTestActivity extends ChromiumActivity {
Log.e(TAG, "[ RUNNER_FAILED ] could not load native library");
}
- private void loadLibrary() throws UnsatisfiedLinkError {
+ private void loadLibrary() {
Log.i(TAG, "loading: " + mLibrary);
System.loadLibrary(mLibrary);
Log.i(TAG, "loaded: " + mLibrary);