Chromium Code Reviews| Index: content/shell/android/shell_library_loader.cc |
| diff --git a/content/shell/android/shell_library_loader.cc b/content/shell/android/shell_library_loader.cc |
| index e447d7e729bbbd013f31bac1ab5a41bda22ba14b..4c645e948146cab95186c1f09a4a2d34030221c8 100644 |
| --- a/content/shell/android/shell_library_loader.cc |
| +++ b/content/shell/android/shell_library_loader.cc |
| @@ -3,8 +3,11 @@ |
| // found in the LICENSE file. |
| #include "base/basictypes.h" |
| +#include "base/debug/debugger.h" |
| +#include "base/logging.h" |
| #include "base/android/jni_android.h" |
| #include "base/android/jni_registrar.h" |
| +#include "content/public/app/content_main_runner.h" |
| #include "content/public/browser/android_library_loader_hooks.h" |
| #include "content/shell/shell_main_delegate.h" |
| #include "content/shell/android/shell_manager.h" |
| @@ -15,8 +18,30 @@ static base::android::RegistrationMethod kRegistrationMethods[] = { |
| { "ShellView", content::ShellView::Register }, |
| }; |
| +namespace { |
| + content::ContentMainRunner* gContentMainRunner = NULL; |
|
Yaron
2012/05/09 01:01:42
Shouldn't this be g_content_main_runner?
|
| +} |
| + |
| // This is called by the VM when the shared library is first loaded. |
| JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { |
| + |
| + // Don't call anything in base without initializing it. |
| + // ContentMainRunner will do what we need. |
| + gContentMainRunner = content::ContentMainRunner::Create(); |
| + |
| + // TODO(tedchoc): Set this to the main delegate once the Android specific |
| + // browser process initialization gets checked in. |
| + ShellMainDelegate* delegate = new ShellMainDelegate(); |
| + |
| + // We use a ShellContentClient, created as a member of |
| + // ShellMainDelegate and set with a call to |
| + // content::SetContentClient() in PreSandboxStartup(). |
| + // That must be done before ContentMainRunner::Initialize(). |
|
Yaron
2012/05/09 01:01:42
This pairs with the "return 0" early-out in conten
John Grabowski
2012/05/09 17:18:15
That isn't clear. If we don't PreSandboxStartup()
Yaron
2012/05/09 17:31:47
Well, downstream we don't need to do this. Also, i
John Grabowski
2012/05/09 17:44:35
TODO added
|
| + delegate->PreSandboxStartup(); |
| + |
| + // TODO(jrg): find command line info from java; pass down in here. |
| + gContentMainRunner->Initialize(0, NULL, NULL); |
| + |
| base::android::InitVM(vm); |
| JNIEnv* env = base::android::AttachCurrentThread(); |
| if (!RegisterLibraryLoaderEntryHook(env)) { |
| @@ -29,9 +54,12 @@ JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { |
| arraysize(kRegistrationMethods))) |
| return -1; |
| - // TODO(tedchoc): Set this to the main delegate once the Android specific |
| - // browser process initialization gets checked in. |
| - new ShellMainDelegate(); |
| - |
| return JNI_VERSION_1_4; |
| } |
| + |
| + |
| +JNI_EXPORT void JNI_OnUnload(JavaVM* vm, void* reserved) { |
| + delete gContentMainRunner; |
| + gContentMainRunner = NULL; |
| +} |
| + |