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

Unified Diff: base/android/java_handler_thread.cc

Issue 551183002: Microbenchmark for the cost of posting tasks to different pump types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
Index: base/android/java_handler_thread.cc
diff --git a/base/android/java_handler_thread.cc b/base/android/java_handler_thread.cc
index 18e1440ee5cdfc33429ae5515be88164d55de3ec..117971eda5d0674468e96325d8da9286c9f20088 100644
--- a/base/android/java_handler_thread.cc
+++ b/base/android/java_handler_thread.cc
@@ -44,6 +44,15 @@ void JavaHandlerThread::Start() {
}
void JavaHandlerThread::Stop() {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ base::WaitableEvent shutdown_event(false, false);
+ Java_JavaHandlerThread_stop(env,
+ java_thread_.obj(),
+ reinterpret_cast<intptr_t>(this),
+ reinterpret_cast<intptr_t>(&shutdown_event));
+ // Wait for thread to shut down before returning.
+ base::ThreadRestrictions::ScopedAllowWait wait_allowed;
+ shutdown_event.Wait();
}
void JavaHandlerThread::InitializeThread(JNIEnv* env, jobject obj,
@@ -54,6 +63,11 @@ void JavaHandlerThread::InitializeThread(JNIEnv* env, jobject obj,
reinterpret_cast<base::WaitableEvent*>(event)->Signal();
}
+void JavaHandlerThread::StopThread(JNIEnv* env, jobject obj, jlong event) {
+ static_cast<MessageLoopForUI*>(message_loop_.get())->Quit();
+ reinterpret_cast<base::WaitableEvent*>(event)->Signal();
+}
+
// static
bool JavaHandlerThread::RegisterBindings(JNIEnv* env) {
return RegisterNativesImpl(env);

Powered by Google App Engine
This is Rietveld 408576698