Index: base/android/jni_android.cc |
diff --git a/base/android/jni_android.cc b/base/android/jni_android.cc |
index 59f25e2e817dbe6ea258d16b65b7d71e5bedb9ec..b112530060d38b08a3d4f2ec9f7177045304b49d 100644 |
--- a/base/android/jni_android.cc |
+++ b/base/android/jni_android.cc |
@@ -81,6 +81,18 @@ JNIEnv* AttachCurrentThread() { |
return env; |
} |
+JNIEnv* AttachCurrentThreadWithName(const std::string& thread_name) { |
+ DCHECK(g_jvm); |
+ JavaVMAttachArgs args; |
+ args.version = JNI_VERSION_1_2; |
+ args.name = thread_name.c_str(); |
+ args.group = NULL; |
+ JNIEnv* env = NULL; |
+ jint ret = g_jvm->AttachCurrentThread(&env, &args); |
+ DCHECK_EQ(JNI_OK, ret); |
+ return env; |
+} |
+ |
void DetachFromVM() { |
// Ignore the return value, if the thread is not attached, DetachCurrentThread |
// will fail. But it is ok as the native thread may never be attached. |