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

Side by Side 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: Apply Yaron's comments Created 5 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 unified diff | Download patch
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 #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
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 (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.
245 return false;
246
247 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
248 return false;
249
250 if (delayInMS > 0) {
251 ScopedJavaGlobalRef<jobject> scoped_runnable;
252 scoped_runnable.Reset(env, jrunnable.obj());
253 BrowserThread::PostDelayedTask(
254 BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
255 base::Bind(&ExecuteOnLauncherThread, scoped_runnable),
256 base::TimeDelta::FromMilliseconds(delayInMS));
257 } else if (BrowserThread::CurrentlyOn(BrowserThread::PROCESS_LAUNCHER)) {
258 ExecuteOnLauncherThread(jrunnable);
259 } else {
260 ScopedJavaGlobalRef<jobject> scoped_runnable;
261 scoped_runnable.Reset(env, jrunnable.obj());
262 BrowserThread::PostTask(
263 BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
264 base::Bind(&ExecuteOnLauncherThread, scoped_runnable));
265 }
266 return true;
267 }
268
233 bool RegisterChildProcessLauncher(JNIEnv* env) { 269 bool RegisterChildProcessLauncher(JNIEnv* env) {
234 return RegisterNativesImpl(env); 270 return RegisterNativesImpl(env);
235 } 271 }
236 272
237 } // namespace content 273 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698