summaryrefslogtreecommitdiffstats
path: root/chromecast
diff options
context:
space:
mode:
authormichaelbai <michaelbai@chromium.org>2015-02-13 17:24:26 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-14 01:25:10 +0000
commit5d4a4c5f9e60cdf954f23fa9de5a669adda475ed (patch)
treec73eff44bd83def16bc9a2e202f879c0e8d38da7 /chromecast
parentde0ab472b7b7d497a0d7facda6a7f6a17b791658 (diff)
downloadchromium_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')
-rw-r--r--chromecast/app/android/cast_jni_loader.cc46
-rw-r--r--chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastBrowserHelper.java7
2 files changed, 31 insertions, 22 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;
}
diff --git a/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastBrowserHelper.java b/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastBrowserHelper.java
index f9e5932..2010e03 100644
--- a/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastBrowserHelper.java
+++ b/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastBrowserHelper.java
@@ -13,6 +13,7 @@ import android.util.Log;
import org.chromium.base.BaseSwitches;
import org.chromium.base.CommandLine;
import org.chromium.base.library_loader.LibraryLoader;
+import org.chromium.base.library_loader.LibraryProcessType;
import org.chromium.base.library_loader.ProcessInitException;
import org.chromium.content.app.ContentApplication;
import org.chromium.content.browser.BrowserStartupController;
@@ -62,11 +63,11 @@ public class CastBrowserHelper {
DeviceUtils.addDeviceSpecificUserAgentSwitch(context);
try {
- LibraryLoader.ensureInitialized();
+ LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized();
Log.d(TAG, "Loading BrowserStartupController...");
- BrowserStartupController.get(context).startBrowserProcessesSync(false);
-
+ BrowserStartupController.get(context, LibraryProcessType.PROCESS_BROWSER)
+ .startBrowserProcessesSync(false);
sIsBrowserInitialized = true;
return true;
} catch (ProcessInitException e) {