diff options
author | michaelbai <michaelbai@chromium.org> | 2015-02-13 17:24:26 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-14 01:25:10 +0000 |
commit | 5d4a4c5f9e60cdf954f23fa9de5a669adda475ed (patch) | |
tree | c73eff44bd83def16bc9a2e202f879c0e8d38da7 /chromecast/app | |
parent | de0ab472b7b7d497a0d7facda6a7f6a17b791658 (diff) | |
download | chromium_src-5d4a4c5f9e60cdf954f23fa9de5a669adda475ed.zip chromium_src-5d4a4c5f9e60cdf954f23fa9de5a669adda475ed.tar.gz chromium_src-5d4a4c5f9e60cdf954f23fa9de5a669adda475ed.tar.bz2 |
Migrate cast to use JNIOnLoadDelegate
BUG=447393
Review URL: https://codereview.chromium.org/923953005
Cr-Commit-Position: refs/heads/master@{#316351}
Diffstat (limited to 'chromecast/app')
-rw-r--r-- | chromecast/app/android/cast_jni_loader.cc | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/chromecast/app/android/cast_jni_loader.cc b/chromecast/app/android/cast_jni_loader.cc index ed7f6ee..d2cc9c7 100644 --- a/chromecast/app/android/cast_jni_loader.cc +++ b/chromecast/app/android/cast_jni_loader.cc @@ -3,34 +3,42 @@ // found in the LICENSE file. #include "base/android/jni_android.h" -#include "base/android/jni_registrar.h" -#include "base/android/library_loader/library_loader_hooks.h" -#include "base/basictypes.h" -#include "base/debug/debugger.h" -#include "base/logging.h" +#include "base/android/jni_onload_delegate.h" #include "chromecast/android/cast_jni_registrar.h" #include "chromecast/android/platform_jni_loader.h" #include "chromecast/app/cast_main_delegate.h" -#include "content/public/app/android_library_loader_hooks.h" +#include "content/public/app/content_jni_onload.h" #include "content/public/app/content_main.h" #include "content/public/browser/android/compositor.h" -// This is called by the VM when the shared library is first loaded. -JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { - base::android::SetLibraryLoadedHook(&content::LibraryLoaded); - base::android::InitVM(vm); - JNIEnv* env = base::android::AttachCurrentThread(); +namespace { - if (!base::android::RegisterLibraryLoaderEntryHook(env)) return -1; +class CastJNIOnLoadDelegate : public base::android::JNIOnLoadDelegate { + public: + bool RegisterJNI(JNIEnv* env) override { + // To be called only from the UI thread. If loading the library is done on + // a separate thread, this should be moved elsewhere. + if (!chromecast::android::RegisterJni(env)) + return false; + // Allow platform-specific implementations to perform more JNI registration. + if (!chromecast::android::PlatformRegisterJni(env)) + return false; + return true; + } - // To be called only from the UI thread. If loading the library is done on - // a separate thread, this should be moved elsewhere. - if (!chromecast::android::RegisterJni(env)) return -1; - // Allow platform-specific implementations to perform more JNI registration. - if (!chromecast::android::PlatformRegisterJni(env)) return -1; + bool Init() override { + content::Compositor::Initialize(); + content::SetContentMainDelegate(new chromecast::shell::CastMainDelegate); + return true; + } +}; - content::Compositor::Initialize(); - content::SetContentMainDelegate(new chromecast::shell::CastMainDelegate); +} // namespace +// This is called by the VM when the shared library is first loaded. +JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + CastJNIOnLoadDelegate delegate; + if (!content::android::OnJNIOnLoad(vm, &delegate)) + return -1; return JNI_VERSION_1_4; } |