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

Unified Diff: content/browser/android/child_process_launcher_android.cc

Issue 1307793003: Execute operations of ChildProcessLauncher on launcher thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix PrerenderServiceTest and ChildProcessLauncherTest Created 5 years, 4 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: content/browser/android/child_process_launcher_android.cc
diff --git a/content/browser/android/child_process_launcher_android.cc b/content/browser/android/child_process_launcher_android.cc
index 3b0473a9294ece42c21c18f4cfdcee3122bf8ce8..7265ae0c5636cb23dffb634900a6903ba1cc888c 100644
--- a/content/browser/android/child_process_launcher_android.cc
+++ b/content/browser/android/child_process_launcher_android.cc
@@ -227,6 +227,31 @@ jboolean IsSingleProcess(JNIEnv* env, jclass clazz) {
switches::kSingleProcess);
}
+static void ExecuteOnLauncherThread(
+ const base::android::JavaRef<jobject>& runnable) {
+ JNIEnv* env = AttachCurrentThread();
+ DCHECK(env);
+ Java_ChildProcessLauncher_executeOnLauncherThread(env, runnable.obj());
+}
+
+jboolean RunOnLauncherThread(JNIEnv* env, jclass clazz, jobject runnable) {
Yaron 2015/09/04 16:04:03 I think you're going to have to rebase on torne's
Jaekyun Seok (inactive) 2015/09/08 09:45:11 Done.
+ ScopedJavaGlobalRef<jobject> jrunnable;
+ jrunnable.Reset(env, runnable);
+ if (jrunnable.is_null())
+ return false;
+
+ if (!BrowserThread::IsThreadInitialized(BrowserThread::PROCESS_LAUNCHER))
+ return false;
+
+ if (BrowserThread::CurrentlyOn(BrowserThread::PROCESS_LAUNCHER)) {
+ ExecuteOnLauncherThread(jrunnable);
+ } else {
+ BrowserThread::PostTask(BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
+ base::Bind(&ExecuteOnLauncherThread, jrunnable));
+ }
+ return true;
+}
+
bool RegisterChildProcessLauncher(JNIEnv* env) {
return RegisterNativesImpl(env);
}

Powered by Google App Engine
This is Rietveld 408576698