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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 jint handle) { | 49 jint handle) { |
50 StartChildProcessCallback* callback = | 50 StartChildProcessCallback* callback = |
51 reinterpret_cast<StartChildProcessCallback*>(client_context); | 51 reinterpret_cast<StartChildProcessCallback*>(client_context); |
52 int launch_result = (handle == base::kNullProcessHandle) | 52 int launch_result = (handle == base::kNullProcessHandle) |
53 ? LAUNCH_RESULT_FAILURE | 53 ? LAUNCH_RESULT_FAILURE |
54 : LAUNCH_RESULT_SUCCESS; | 54 : LAUNCH_RESULT_SUCCESS; |
55 callback->Run(static_cast<base::ProcessHandle>(handle), launch_result); | 55 callback->Run(static_cast<base::ProcessHandle>(handle), launch_result); |
56 delete callback; | 56 delete callback; |
57 } | 57 } |
58 | 58 |
59 void StartChildProcess( | 59 void StartChildProcess(const base::CommandLine::StringVector& argv, |
60 const base::CommandLine::StringVector& argv, | 60 int child_process_id, |
61 int child_process_id, | 61 content::FileDescriptorInfo* files_to_register, |
62 content::FileDescriptorInfo* files_to_register, | 62 int child_process_param_id, |
63 const StartChildProcessCallback& callback) { | 63 const StartChildProcessCallback& callback) { |
64 JNIEnv* env = AttachCurrentThread(); | 64 JNIEnv* env = AttachCurrentThread(); |
65 DCHECK(env); | 65 DCHECK(env); |
66 | 66 |
67 // Create the Command line String[] | 67 // Create the Command line String[] |
68 ScopedJavaLocalRef<jobjectArray> j_argv = ToJavaArrayOfStrings(env, argv); | 68 ScopedJavaLocalRef<jobjectArray> j_argv = ToJavaArrayOfStrings(env, argv); |
69 | 69 |
70 size_t file_count = files_to_register->GetMappingSize(); | 70 size_t file_count = files_to_register->GetMappingSize(); |
71 DCHECK(file_count > 0); | 71 DCHECK(file_count > 0); |
72 | 72 |
73 ScopedJavaLocalRef<jclass> j_file_info_class = base::android::GetClass( | 73 ScopedJavaLocalRef<jclass> j_file_info_class = base::android::GetClass( |
(...skipping 11 matching lines...) Expand all Loading... |
85 ScopedJavaLocalRef<jobject> j_file_info = | 85 ScopedJavaLocalRef<jobject> j_file_info = |
86 Java_ChildProcessLauncher_makeFdInfo(env, id, fd, auto_close, | 86 Java_ChildProcessLauncher_makeFdInfo(env, id, fd, auto_close, |
87 region.offset, region.size); | 87 region.offset, region.size); |
88 PCHECK(j_file_info.obj()); | 88 PCHECK(j_file_info.obj()); |
89 env->SetObjectArrayElement(j_file_infos.obj(), i, j_file_info.obj()); | 89 env->SetObjectArrayElement(j_file_infos.obj(), i, j_file_info.obj()); |
90 if (auto_close) { | 90 if (auto_close) { |
91 ignore_result(files_to_register->ReleaseFD(fd).release()); | 91 ignore_result(files_to_register->ReleaseFD(fd).release()); |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 constexpr int param_key = 0; // TODO(boliu): Use this. | |
96 Java_ChildProcessLauncher_start( | 95 Java_ChildProcessLauncher_start( |
97 env, base::android::GetApplicationContext(), param_key, j_argv, | 96 env, base::android::GetApplicationContext(), child_process_param_id, |
98 child_process_id, j_file_infos, | 97 j_argv, child_process_id, j_file_infos, |
99 reinterpret_cast<intptr_t>(new StartChildProcessCallback(callback))); | 98 reinterpret_cast<intptr_t>(new StartChildProcessCallback(callback))); |
100 } | 99 } |
101 | 100 |
102 void StopChildProcess(base::ProcessHandle handle) { | 101 void StopChildProcess(base::ProcessHandle handle) { |
103 JNIEnv* env = AttachCurrentThread(); | 102 JNIEnv* env = AttachCurrentThread(); |
104 DCHECK(env); | 103 DCHECK(env); |
105 Java_ChildProcessLauncher_stop(env, static_cast<jint>(handle)); | 104 Java_ChildProcessLauncher_stop(env, static_cast<jint>(handle)); |
106 } | 105 } |
107 | 106 |
108 bool IsChildProcessOomProtected(base::ProcessHandle handle) { | 107 bool IsChildProcessOomProtected(base::ProcessHandle handle) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 gl::ScopedJavaSurface surface_view = | 150 gl::ScopedJavaSurface surface_view = |
152 gpu::GpuSurfaceTracker::GetInstance()->AcquireJavaSurface(surface_id); | 151 gpu::GpuSurfaceTracker::GetInstance()->AcquireJavaSurface(surface_id); |
153 return base::android::ScopedJavaLocalRef<jobject>(surface_view.j_surface()); | 152 return base::android::ScopedJavaLocalRef<jobject>(surface_view.j_surface()); |
154 } | 153 } |
155 | 154 |
156 bool RegisterChildProcessLauncher(JNIEnv* env) { | 155 bool RegisterChildProcessLauncher(JNIEnv* env) { |
157 return RegisterNativesImpl(env); | 156 return RegisterNativesImpl(env); |
158 } | 157 } |
159 | 158 |
160 } // namespace content | 159 } // namespace content |
OLD | NEW |