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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 } // anonymous namespace | 83 } // anonymous namespace |
84 | 84 |
85 // Called from ChildProcessLauncher.java when the ChildProcess was | 85 // Called from ChildProcessLauncher.java when the ChildProcess was |
86 // started. | 86 // started. |
87 // |client_context| is the pointer to StartChildProcessCallback which was | 87 // |client_context| is the pointer to StartChildProcessCallback which was |
88 // passed in from StartChildProcess. | 88 // passed in from StartChildProcess. |
89 // |handle| is the processID of the child process as originated in Java, 0 if | 89 // |handle| is the processID of the child process as originated in Java, 0 if |
90 // the ChildProcess could not be created. | 90 // the ChildProcess could not be created. |
91 static void OnChildProcessStarted(JNIEnv*, | 91 static void OnChildProcessStarted(JNIEnv*, |
92 jclass, | 92 const JavaParamRef<jclass>&, |
93 jlong client_context, | 93 jlong client_context, |
94 jint handle) { | 94 jint handle) { |
95 StartChildProcessCallback* callback = | 95 StartChildProcessCallback* callback = |
96 reinterpret_cast<StartChildProcessCallback*>(client_context); | 96 reinterpret_cast<StartChildProcessCallback*>(client_context); |
97 if (handle) | 97 if (handle) |
98 callback->Run(static_cast<base::ProcessHandle>(handle)); | 98 callback->Run(static_cast<base::ProcessHandle>(handle)); |
99 delete callback; | 99 delete callback; |
100 } | 100 } |
101 | 101 |
102 void StartChildProcess( | 102 void StartChildProcess( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 162 } |
163 | 163 |
164 void SetChildProcessInForeground(base::ProcessHandle handle, | 164 void SetChildProcessInForeground(base::ProcessHandle handle, |
165 bool in_foreground) { | 165 bool in_foreground) { |
166 JNIEnv* env = AttachCurrentThread(); | 166 JNIEnv* env = AttachCurrentThread(); |
167 DCHECK(env); | 167 DCHECK(env); |
168 return Java_ChildProcessLauncher_setInForeground(env, | 168 return Java_ChildProcessLauncher_setInForeground(env, |
169 static_cast<jint>(handle), static_cast<jboolean>(in_foreground)); | 169 static_cast<jint>(handle), static_cast<jboolean>(in_foreground)); |
170 } | 170 } |
171 | 171 |
172 void EstablishSurfacePeer( | 172 void EstablishSurfacePeer(JNIEnv* env, |
173 JNIEnv* env, jclass clazz, | 173 const JavaParamRef<jclass>& clazz, |
174 jint pid, jobject surface, jint primary_id, jint secondary_id) { | 174 jint pid, |
| 175 const JavaParamRef<jobject>& surface, |
| 176 jint primary_id, |
| 177 jint secondary_id) { |
175 ScopedJavaGlobalRef<jobject> jsurface; | 178 ScopedJavaGlobalRef<jobject> jsurface; |
176 jsurface.Reset(env, surface); | 179 jsurface.Reset(env, surface); |
177 if (jsurface.is_null()) | 180 if (jsurface.is_null()) |
178 return; | 181 return; |
179 | 182 |
180 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | 183 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); |
181 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 184 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( |
182 &SetSurfacePeer, jsurface, pid, primary_id, secondary_id)); | 185 &SetSurfacePeer, jsurface, pid, primary_id, secondary_id)); |
183 } | 186 } |
184 | 187 |
(...skipping 30 matching lines...) Expand all Loading... |
215 | 218 |
216 gfx::ScopedJavaSurface GetSurfaceTextureSurface(int surface_texture_id, | 219 gfx::ScopedJavaSurface GetSurfaceTextureSurface(int surface_texture_id, |
217 int client_id) { | 220 int client_id) { |
218 JNIEnv* env = AttachCurrentThread(); | 221 JNIEnv* env = AttachCurrentThread(); |
219 DCHECK(env); | 222 DCHECK(env); |
220 return gfx::ScopedJavaSurface::AcquireExternalSurface( | 223 return gfx::ScopedJavaSurface::AcquireExternalSurface( |
221 Java_ChildProcessLauncher_getSurfaceTextureSurface( | 224 Java_ChildProcessLauncher_getSurfaceTextureSurface( |
222 env, surface_texture_id, client_id).obj()); | 225 env, surface_texture_id, client_id).obj()); |
223 } | 226 } |
224 | 227 |
225 jboolean IsSingleProcess(JNIEnv* env, jclass clazz) { | 228 jboolean IsSingleProcess(JNIEnv* env, const JavaParamRef<jclass>& clazz) { |
226 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 229 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
227 switches::kSingleProcess); | 230 switches::kSingleProcess); |
228 } | 231 } |
229 | 232 |
230 bool RegisterChildProcessLauncher(JNIEnv* env) { | 233 bool RegisterChildProcessLauncher(JNIEnv* env) { |
231 return RegisterNativesImpl(env); | 234 return RegisterNativesImpl(env); |
232 } | 235 } |
233 | 236 |
234 } // namespace content | 237 } // namespace content |
OLD | NEW |