| OLD | NEW |
| 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 #include "content/browser/android/child_process_launcher_android.h" | 5 #include "content/browser/android/child_process_launcher_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 return gfx::ScopedJavaSurface::AcquireExternalSurface( | 223 return gfx::ScopedJavaSurface::AcquireExternalSurface( |
| 224 Java_ChildProcessLauncher_getSurfaceTextureSurface( | 224 Java_ChildProcessLauncher_getSurfaceTextureSurface( |
| 225 env, surface_texture_id, client_id).obj()); | 225 env, surface_texture_id, client_id).obj()); |
| 226 } | 226 } |
| 227 | 227 |
| 228 jboolean IsSingleProcess(JNIEnv* env, const JavaParamRef<jclass>& clazz) { | 228 jboolean IsSingleProcess(JNIEnv* env, const JavaParamRef<jclass>& clazz) { |
| 229 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 229 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 230 switches::kSingleProcess); | 230 switches::kSingleProcess); |
| 231 } | 231 } |
| 232 | 232 |
| 233 static void ExecuteOnLauncherThread( |
| 234 const base::android::JavaRef<jobject>& runnable) { |
| 235 JNIEnv* env = AttachCurrentThread(); |
| 236 DCHECK(env); |
| 237 Java_ChildProcessLauncher_executeOnLauncherThread(env, runnable.obj()); |
| 238 } |
| 239 |
| 240 jboolean RunOnLauncherThread(JNIEnv* env, |
| 241 const JavaParamRef<jclass>& clazz, |
| 242 const JavaParamRef<jobject>& jrunnable, |
| 243 jlong delayInMS) { |
| 244 if (!BrowserThread::IsThreadInitialized(BrowserThread::PROCESS_LAUNCHER)) |
| 245 return false; |
| 246 |
| 247 if (delayInMS > 0) { |
| 248 ScopedJavaGlobalRef<jobject> scoped_runnable; |
| 249 scoped_runnable.Reset(env, jrunnable.obj()); |
| 250 BrowserThread::PostDelayedTask( |
| 251 BrowserThread::PROCESS_LAUNCHER, FROM_HERE, |
| 252 base::Bind(&ExecuteOnLauncherThread, scoped_runnable), |
| 253 base::TimeDelta::FromMilliseconds(delayInMS)); |
| 254 } else if (BrowserThread::CurrentlyOn(BrowserThread::PROCESS_LAUNCHER)) { |
| 255 ExecuteOnLauncherThread(jrunnable); |
| 256 } else { |
| 257 ScopedJavaGlobalRef<jobject> scoped_runnable; |
| 258 scoped_runnable.Reset(env, jrunnable.obj()); |
| 259 BrowserThread::PostTask( |
| 260 BrowserThread::PROCESS_LAUNCHER, FROM_HERE, |
| 261 base::Bind(&ExecuteOnLauncherThread, scoped_runnable)); |
| 262 } |
| 263 return true; |
| 264 } |
| 265 |
| 233 bool RegisterChildProcessLauncher(JNIEnv* env) { | 266 bool RegisterChildProcessLauncher(JNIEnv* env) { |
| 234 return RegisterNativesImpl(env); | 267 return RegisterNativesImpl(env); |
| 235 } | 268 } |
| 236 | 269 |
| 237 } // namespace content | 270 } // namespace content |
| OLD | NEW |