Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Unified Diff: webrtc/modules/utility/source/jvm_android.cc

Issue 2894593002: Revert of Removes usage of native base::android::GetApplicationContext() (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/utility/include/jvm_android.h ('k') | webrtc/pc/test/androidtestinitializer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/utility/source/jvm_android.cc
diff --git a/webrtc/modules/utility/source/jvm_android.cc b/webrtc/modules/utility/source/jvm_android.cc
index 2228d3ad255db605dfaf5ce5387fa2c2513826b8..9d08688700748b0fce3f0defbd3e9b7810448e60 100644
--- a/webrtc/modules/utility/source/jvm_android.cc
+++ b/webrtc/modules/utility/source/jvm_android.cc
@@ -217,10 +217,10 @@
}
// static
-void JVM::Initialize(JavaVM* jvm) {
+void JVM::Initialize(JavaVM* jvm, jobject context) {
ALOGD("JVM::Initialize%s", GetThreadInfo().c_str());
RTC_CHECK(!g_jvm);
- g_jvm = new JVM(jvm);
+ g_jvm = new JVM(jvm, context);
}
// static
@@ -237,9 +237,11 @@
return g_jvm;
}
-JVM::JVM(JavaVM* jvm) : jvm_(jvm) {
+JVM::JVM(JavaVM* jvm, jobject context)
+ : jvm_(jvm) {
ALOGD("JVM::JVM%s", GetThreadInfo().c_str());
RTC_CHECK(jni()) << "AttachCurrentThread() must be called on this thread.";
+ context_ = NewGlobalRef(jni(), context);
LoadClasses(jni());
}
@@ -247,6 +249,7 @@
ALOGD("JVM::~JVM%s", GetThreadInfo().c_str());
RTC_DCHECK(thread_checker_.CalledOnValidThread());
FreeClassReferences(jni());
+ DeleteGlobalRef(jni(), context_);
}
std::unique_ptr<JNIEnvironment> JVM::environment() {
« no previous file with comments | « webrtc/modules/utility/include/jvm_android.h ('k') | webrtc/pc/test/androidtestinitializer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698