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

Unified Diff: base/android/jni_android.cc

Issue 10580038: Allow OpenSSLPrivateKeyStore and Android global app context leaking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | « no previous file | net/base/openssl_private_key_store_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/jni_android.cc
===================================================================
--- base/android/jni_android.cc (revision 154951)
+++ base/android/jni_android.cc (working copy)
@@ -18,11 +18,6 @@
using base::android::GetMethodID;
using base::android::ScopedJavaLocalRef;
-JavaVM* g_jvm = NULL;
-
-base::LazyInstance<base::android::ScopedJavaGlobalRef<jobject> >
- g_application_context = LAZY_INSTANCE_INITIALIZER;
-
struct MethodIdentifier {
const char* class_name;
const char* method;
@@ -48,11 +43,17 @@
};
typedef std::map<MethodIdentifier, jmethodID> MethodIDMap;
-base::LazyInstance<MethodIDMap>::Leaky
- g_method_id_map = LAZY_INSTANCE_INITIALIZER;
+
const base::subtle::AtomicWord kUnlocked = 0;
const base::subtle::AtomicWord kLocked = 1;
base::subtle::AtomicWord g_method_id_map_lock = kUnlocked;
+JavaVM* g_jvm = NULL;
+// Leak the global app context, as it is used from a non-joinable worker thread
+// that may still be running at shutdown. There is no harm in doing this.
+base::LazyInstance<base::android::ScopedJavaGlobalRef<jobject> >::Leaky
+ g_application_context = LAZY_INSTANCE_INITIALIZER;
+base::LazyInstance<MethodIDMap>::Leaky
+ g_method_id_map = LAZY_INSTANCE_INITIALIZER;
std::string GetJavaExceptionInfo(JNIEnv* env, jthrowable java_throwable) {
ScopedJavaLocalRef<jclass> throwable_clazz =
@@ -156,7 +157,7 @@
const JavaRef<jclass>& clazz,
const char* method_name,
const char* jni_signature) {
- // We can't use clazz.env() as that may be from a different thread.
+ // clazz.env() can not be used as that may be from a different thread.
return GetMethodID(env, clazz.obj(), method_name, jni_signature);
}
@@ -304,14 +305,14 @@
void CheckException(JNIEnv* env) {
if (!HasException(env)) return;
- // Ugh, we are going to die, might as well tell breakpad about it.
+ // Exception has been found, might as well tell breakpad about it.
jthrowable java_throwable = env->ExceptionOccurred();
if (!java_throwable) {
- // Nothing we can do.
+ // Do nothing but return false.
CHECK(false);
}
- // Clear the pending exception, we do have a reference to it.
+ // Clear the pending exception, since a local reference is now held.
env->ExceptionClear();
// Set the exception_string in BuildInfo so that breakpad can read it.
« no previous file with comments | « no previous file | net/base/openssl_private_key_store_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698