SkyShell DCHECKs on startup

We need to update how we initialize JNI to make sure we get an AtExitManager.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1003813004
This commit is contained in:
Adam Barth
2015-03-13 10:48:41 -07:00
parent 0bde9320f4
commit 06f46a22c1

View File

@@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/android/base_jni_onload.h"
#include "base/android/base_jni_registrar.h"
#include "base/android/jni_android.h"
#include "base/android/jni_registrar.h"
#include "base/android/library_loader/library_loader_hooks.h"
#include "base/bind.h"
#include "base/logging.h"
#include "mojo/android/system/core_impl.h"
#include "sky/shell/java_service_provider.h"
@@ -21,7 +23,10 @@ base::android::RegistrationMethod kSkyRegisteredMethods[] = {
{"PlatformView", sky::shell::PlatformView::Register},
};
bool RegisterSkyJni(JNIEnv* env) {
bool RegisterJNI(JNIEnv* env) {
if (!base::android::RegisterJni(env))
return false;
return RegisterNativeMethods(env, kSkyRegisteredMethods,
arraysize(kSkyRegisteredMethods));
}
@@ -30,17 +35,13 @@ bool RegisterSkyJni(JNIEnv* env) {
// This is called by the VM when the shared library is first loaded.
JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
base::android::InitVM(vm);
JNIEnv* env = base::android::AttachCurrentThread();
if (!base::android::RegisterLibraryLoaderEntryHook(env))
return -1;
if (!base::android::RegisterJni(env))
return -1;
if (!RegisterSkyJni(env))
std::vector<base::android::RegisterCallback> register_callbacks;
register_callbacks.push_back(base::Bind(&RegisterJNI));
if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) ||
!base::android::OnJNIOnLoadInit(
std::vector<base::android::InitCallback>())) {
return -1;
}
return JNI_VERSION_1_4;
}