summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjnd@chromium.org <jnd@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-17 06:15:10 +0000
committerjnd@chromium.org <jnd@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-17 06:15:10 +0000
commit995a3ff438014715589891ce1a51662ada55dcf0 (patch)
treec01a05f5c5bdd86c4d5a08383c055f679983f630
parent0c9f326176095aacc0de142746bc485d62082407 (diff)
downloadchromium_src-995a3ff438014715589891ce1a51662ada55dcf0.zip
chromium_src-995a3ff438014715589891ce1a51662ada55dcf0.tar.gz
chromium_src-995a3ff438014715589891ce1a51662ada55dcf0.tar.bz2
Chromium's key generation is running on a non-joinable worker thread, which requirs us to use leakable Singleton/LazyInstance object since.
See crbug.com/134118 for details BUG=134118 TEST=None Review URL: https://chromiumcodereview.appspot.com/10580038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157083 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/android/jni_android.cc23
-rw-r--r--net/base/openssl_private_key_store_android.cc11
2 files changed, 21 insertions, 13 deletions
diff --git a/base/android/jni_android.cc b/base/android/jni_android.cc
index 2a01063..d3b4e79 100644
--- a/base/android/jni_android.cc
+++ b/base/android/jni_android.cc
@@ -18,11 +18,6 @@ using base::android::GetClass;
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 @@ struct MethodIdentifier {
};
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 @@ jmethodID GetMethodID(JNIEnv* env,
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 @@ bool ClearException(JNIEnv* env) {
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.
diff --git a/net/base/openssl_private_key_store_android.cc b/net/base/openssl_private_key_store_android.cc
index 5940555..3adc222 100644
--- a/net/base/openssl_private_key_store_android.cc
+++ b/net/base/openssl_private_key_store_android.cc
@@ -47,12 +47,19 @@ class OpenSSLKeyStoreAndroid : public OpenSSLPrivateKeyStore {
}
static OpenSSLKeyStoreAndroid* GetInstance() {
- return Singleton<OpenSSLKeyStoreAndroid>::get();
+ // Leak the OpenSSL key store as it is used from a non-joinable worker
+ // thread that may still be running at shutdown.
+ return Singleton<
+ OpenSSLKeyStoreAndroid,
+ OpenSSLKeyStoreAndroidLeakyTraits>::get();
}
private:
- OpenSSLKeyStoreAndroid() {}
friend struct DefaultSingletonTraits<OpenSSLKeyStoreAndroid>;
+ typedef LeakySingletonTraits<OpenSSLKeyStoreAndroid>
+ OpenSSLKeyStoreAndroidLeakyTraits;
+
+ OpenSSLKeyStoreAndroid() {}
DISALLOW_COPY_AND_ASSIGN(OpenSSLKeyStoreAndroid);
};