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

Unified Diff: base/android/jni_android.cc

Issue 330823004: Set chrome thread name in JVM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Define AttachCurrentThreadWithName and call it for all browser threads. Created 6 years, 6 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
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.

Powered by Google App Engine
This is Rietveld 408576698