Commit 86068833 authored by ppi's avatar ppi Committed by Commit bot

Hook-up OnJNIOnLoadRegisterJNI for JNI registration in mojo network service.

This patch uses the unified JNI_OnLoad mechanism introduced in
http://crbug.com/447393 in mojo network service.

BUG=447393

Review URL: https://codereview.chromium.org/977843003

Cr-Commit-Position: refs/heads/master@{#319152}
parent e5afa237
......@@ -2,19 +2,41 @@
// 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_registrar.h"
#include <vector>
#include "base/android/base_jni_onload.h"
#include "base/android/jni_android.h"
#include "base/android/library_loader/library_loader_hooks.h"
#include "base/bind.h"
#include "net/android/net_jni_registrar.h"
namespace {
bool RegisterJNI(JNIEnv* env) {
return net::android::RegisterJni(env);
}
bool Init() {
return true;
}
} // namespace
// 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();
std::vector<base::android::RegisterCallback> register_callbacks;
register_callbacks.push_back(base::Bind(&RegisterJNI));
if (!base::android::RegisterJni(env))
return -1;
std::vector<base::android::InitCallback> init_callbacks;
init_callbacks.push_back(base::Bind(&Init));
if (!net::android::RegisterJni(env))
if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) ||
!base::android::OnJNIOnLoadInit(init_callbacks)) {
return -1;
}
// There cannot be two AtExitManagers at the same time. Remove the one from
// LibraryLoader as ApplicationRunnerChromium also uses one.
base::android::LibraryLoaderExitHook();
return JNI_VERSION_1_4;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment