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

Side by Side Diff: base/android/jni_android.h

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 unified diff | Download patch
« no previous file with comments | « no previous file | base/android/jni_android.cc » ('j') | content/browser/browser_thread_impl.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_ANDROID_JNI_ANDROID_H_ 5 #ifndef BASE_ANDROID_JNI_ANDROID_H_
6 #define BASE_ANDROID_JNI_ANDROID_H_ 6 #define BASE_ANDROID_JNI_ANDROID_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 10
11 #include <string>
12
11 #include "base/android/scoped_java_ref.h" 13 #include "base/android/scoped_java_ref.h"
12 #include "base/atomicops.h" 14 #include "base/atomicops.h"
13 #include "base/base_export.h" 15 #include "base/base_export.h"
14 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
15 17
16 namespace base { 18 namespace base {
17 namespace android { 19 namespace android {
18 20
19 // Used to mark symbols to be exported in a shared library's symbol table. 21 // Used to mark symbols to be exported in a shared library's symbol table.
20 #define JNI_EXPORT __attribute__ ((visibility("default"))) 22 #define JNI_EXPORT __attribute__ ((visibility("default")))
21 23
22 // Contains the registration method information for initializing JNI bindings. 24 // Contains the registration method information for initializing JNI bindings.
23 struct RegistrationMethod { 25 struct RegistrationMethod {
24 const char* name; 26 const char* name;
25 bool (*func)(JNIEnv* env); 27 bool (*func)(JNIEnv* env);
26 }; 28 };
27 29
28 // Attach the current thread to the VM (if necessary) and return the JNIEnv*. 30 // Attaches the current thread to the VM (if necessary) and return the JNIEnv*.
29 BASE_EXPORT JNIEnv* AttachCurrentThread(); 31 BASE_EXPORT JNIEnv* AttachCurrentThread();
30 32
31 // Detach the current thread from VM if it is attached. 33 // Same to AttachCurrentThread except that thread name will be set to
34 // |thread_name| if it is the first call. Otherwise, thread_name won't be
35 // changed. AttachCurrentThread() doesn't regard underlying platform thread
36 // name, but just resets it to "Thread-???". This function should be called
37 // right after new thread is created if it is important to keep thread name.
38 BASE_EXPORT JNIEnv* AttachCurrentThreadWithName(const std::string& thread_name);
39
40 // Detaches the current thread from VM if it is attached.
32 BASE_EXPORT void DetachFromVM(); 41 BASE_EXPORT void DetachFromVM();
33 42
34 // Initializes the global JVM. It is not necessarily called before 43 // Initializes the global JVM. It is not necessarily called before
35 // InitApplicationContext(). 44 // InitApplicationContext().
36 BASE_EXPORT void InitVM(JavaVM* vm); 45 BASE_EXPORT void InitVM(JavaVM* vm);
37 46
38 // Returns true if the global JVM has been initialized. 47 // Returns true if the global JVM has been initialized.
39 BASE_EXPORT bool IsVMInitialized(); 48 BASE_EXPORT bool IsVMInitialized();
40 49
41 // Initializes the global application context object. The |context| can be any 50 // Initializes the global application context object. The |context| can be any
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // and returns true. 100 // and returns true.
92 BASE_EXPORT bool ClearException(JNIEnv* env); 101 BASE_EXPORT bool ClearException(JNIEnv* env);
93 102
94 // This function will call CHECK() macro if there's any pending exception. 103 // This function will call CHECK() macro if there's any pending exception.
95 BASE_EXPORT void CheckException(JNIEnv* env); 104 BASE_EXPORT void CheckException(JNIEnv* env);
96 105
97 } // namespace android 106 } // namespace android
98 } // namespace base 107 } // namespace base
99 108
100 #endif // BASE_ANDROID_JNI_ANDROID_H_ 109 #endif // BASE_ANDROID_JNI_ANDROID_H_
OLDNEW
« no previous file with comments | « no previous file | base/android/jni_android.cc » ('j') | content/browser/browser_thread_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698