Chromium Code Reviews| 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 44e1bd38f6dd2ae8a0ce7faac3d3b0b17f31b373..1456a9ad1af33ab77ea0b623ac3d4a7821cf7520 100644 |
| --- a/content/browser/android/child_process_launcher_android.cc |
| +++ b/content/browser/android/child_process_launcher_android.cc |
| @@ -230,6 +230,42 @@ jboolean IsSingleProcess(JNIEnv* env, const JavaParamRef<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, |
| + const JavaParamRef<jclass>& clazz, |
| + const JavaParamRef<jobject>& jrunnable, |
| + jlong delayInMS) { |
| + if (jrunnable.is_null()) |
|
Yaron
2015/09/09 01:00:20
Does this actually happen?
Jaekyun Seok (inactive)
2015/09/09 02:02:41
No. I will remove this.
|
| + return false; |
| + |
| + if (!BrowserThread::IsThreadInitialized(BrowserThread::PROCESS_LAUNCHER)) |
|
Yaron
2015/09/09 01:00:20
Is this also because of tests? Or can this actuall
Jaekyun Seok (inactive)
2015/09/09 02:02:41
This happens actually when ChildProcessLauncher.wa
|
| + return false; |
| + |
| + if (delayInMS > 0) { |
| + ScopedJavaGlobalRef<jobject> scoped_runnable; |
| + scoped_runnable.Reset(env, jrunnable.obj()); |
| + BrowserThread::PostDelayedTask( |
| + BrowserThread::PROCESS_LAUNCHER, FROM_HERE, |
| + base::Bind(&ExecuteOnLauncherThread, scoped_runnable), |
| + base::TimeDelta::FromMilliseconds(delayInMS)); |
| + } else if (BrowserThread::CurrentlyOn(BrowserThread::PROCESS_LAUNCHER)) { |
| + ExecuteOnLauncherThread(jrunnable); |
| + } else { |
| + ScopedJavaGlobalRef<jobject> scoped_runnable; |
| + scoped_runnable.Reset(env, jrunnable.obj()); |
| + BrowserThread::PostTask( |
| + BrowserThread::PROCESS_LAUNCHER, FROM_HERE, |
| + base::Bind(&ExecuteOnLauncherThread, scoped_runnable)); |
| + } |
| + return true; |
| +} |
| + |
| bool RegisterChildProcessLauncher(JNIEnv* env) { |
| return RegisterNativesImpl(env); |
| } |