OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/child_process_launcher_helper_android.h" | 5 #include "content/browser/child_process_launcher_helper_android.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/android/apk_assets.h" | 9 #include "base/android/apk_assets.h" |
10 #include "base/android/context_utils.h" | 10 #include "base/android/context_utils.h" |
11 #include "base/android/jni_array.h" | 11 #include "base/android/jni_array.h" |
12 #include "base/android/unguessable_token_android.h" | |
13 #include "base/i18n/icu_util.h" | 12 #include "base/i18n/icu_util.h" |
14 #include "base/logging.h" | 13 #include "base/logging.h" |
15 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
16 #include "content/browser/android/scoped_surface_request_manager.h" | |
17 #include "content/browser/child_process_launcher_helper.h" | 15 #include "content/browser/child_process_launcher_helper.h" |
18 #include "content/browser/child_process_launcher_helper_posix.h" | 16 #include "content/browser/child_process_launcher_helper_posix.h" |
19 #include "content/browser/file_descriptor_info_impl.h" | 17 #include "content/browser/file_descriptor_info_impl.h" |
20 #include "content/browser/web_contents/web_contents_impl.h" | 18 #include "content/browser/web_contents/web_contents_impl.h" |
21 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
23 #include "content/public/common/content_descriptors.h" | 21 #include "content/public/common/content_descriptors.h" |
24 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
25 #include "gin/v8_initializer.h" | 23 #include "gin/v8_initializer.h" |
26 #include "gpu/ipc/common/gpu_surface_tracker.h" | |
27 #include "jni/ChildProcessLauncher_jni.h" | 24 #include "jni/ChildProcessLauncher_jni.h" |
28 | 25 |
29 using base::android::AttachCurrentThread; | 26 using base::android::AttachCurrentThread; |
30 using base::android::JavaParamRef; | 27 using base::android::JavaParamRef; |
31 using base::android::ScopedJavaGlobalRef; | 28 using base::android::ScopedJavaGlobalRef; |
32 using base::android::ScopedJavaLocalRef; | 29 using base::android::ScopedJavaLocalRef; |
33 using base::android::ToJavaArrayOfStrings; | 30 using base::android::ToJavaArrayOfStrings; |
34 | 31 |
35 namespace content { | 32 namespace content { |
36 | 33 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 jint handle) { | 274 jint handle) { |
278 StartChildProcessCallback* callback = | 275 StartChildProcessCallback* callback = |
279 reinterpret_cast<StartChildProcessCallback*>(client_context); | 276 reinterpret_cast<StartChildProcessCallback*>(client_context); |
280 int launch_result = (handle == base::kNullProcessHandle) | 277 int launch_result = (handle == base::kNullProcessHandle) |
281 ? LAUNCH_RESULT_FAILURE | 278 ? LAUNCH_RESULT_FAILURE |
282 : LAUNCH_RESULT_SUCCESS; | 279 : LAUNCH_RESULT_SUCCESS; |
283 callback->Run(static_cast<base::ProcessHandle>(handle), launch_result); | 280 callback->Run(static_cast<base::ProcessHandle>(handle), launch_result); |
284 delete callback; | 281 delete callback; |
285 } | 282 } |
286 | 283 |
287 void CompleteScopedSurfaceRequest(JNIEnv* env, | |
288 const JavaParamRef<jclass>& clazz, | |
289 const JavaParamRef<jobject>& token, | |
290 const JavaParamRef<jobject>& surface) { | |
291 base::UnguessableToken requestToken = | |
292 base::android::UnguessableTokenAndroid::FromJavaUnguessableToken(env, | |
293 token); | |
294 if (!requestToken) { | |
295 DLOG(ERROR) << "Received invalid surface request token."; | |
296 return; | |
297 } | |
298 | |
299 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
300 | |
301 ScopedJavaGlobalRef<jobject> jsurface; | |
302 jsurface.Reset(env, surface); | |
303 ScopedSurfaceRequestManager::GetInstance()->FulfillScopedSurfaceRequest( | |
304 requestToken, gl::ScopedJavaSurface(jsurface)); | |
305 } | |
306 | |
307 jboolean IsSingleProcess(JNIEnv* env, const JavaParamRef<jclass>& clazz) { | 284 jboolean IsSingleProcess(JNIEnv* env, const JavaParamRef<jclass>& clazz) { |
308 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 285 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
309 switches::kSingleProcess); | 286 switches::kSingleProcess); |
310 } | 287 } |
311 | 288 |
312 base::android::ScopedJavaLocalRef<jobject> GetViewSurface( | |
313 JNIEnv* env, | |
314 const base::android::JavaParamRef<jclass>& jcaller, | |
315 jint surface_id) { | |
316 gl::ScopedJavaSurface surface_view = | |
317 gpu::GpuSurfaceTracker::GetInstance()->AcquireJavaSurface(surface_id); | |
318 return base::android::ScopedJavaLocalRef<jobject>(surface_view.j_surface()); | |
319 } | |
320 | |
321 bool RegisterChildProcessLauncher(JNIEnv* env) { | 289 bool RegisterChildProcessLauncher(JNIEnv* env) { |
322 return RegisterNativesImpl(env); | 290 return RegisterNativesImpl(env); |
323 } | 291 } |
324 | 292 |
325 } // namespace content | 293 } // namespace content |
OLD | NEW |