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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 jint handle) { | 74 jint handle) { |
75 StartChildProcessCallback* callback = | 75 StartChildProcessCallback* callback = |
76 reinterpret_cast<StartChildProcessCallback*>(client_context); | 76 reinterpret_cast<StartChildProcessCallback*>(client_context); |
77 if (handle) | 77 if (handle) |
78 callback->Run(static_cast<base::ProcessHandle>(handle)); | 78 callback->Run(static_cast<base::ProcessHandle>(handle)); |
79 delete callback; | 79 delete callback; |
80 } | 80 } |
81 | 81 |
82 void StartChildProcess( | 82 void StartChildProcess( |
83 const CommandLine::StringVector& argv, | 83 const CommandLine::StringVector& argv, |
84 int child_process_id, | |
84 const std::vector<content::FileDescriptorInfo>& files_to_register, | 85 const std::vector<content::FileDescriptorInfo>& files_to_register, |
85 const StartChildProcessCallback& callback) { | 86 const StartChildProcessCallback& callback) { |
86 JNIEnv* env = AttachCurrentThread(); | 87 JNIEnv* env = AttachCurrentThread(); |
87 DCHECK(env); | 88 DCHECK(env); |
88 | 89 |
89 // Create the Command line String[] | 90 // Create the Command line String[] |
90 ScopedJavaLocalRef<jobjectArray> j_argv = ToJavaArrayOfStrings(env, argv); | 91 ScopedJavaLocalRef<jobjectArray> j_argv = ToJavaArrayOfStrings(env, argv); |
91 | 92 |
92 size_t file_count = files_to_register.size(); | 93 size_t file_count = files_to_register.size(); |
93 DCHECK(file_count > 0); | 94 DCHECK(file_count > 0); |
(...skipping 18 matching lines...) Expand all Loading... | |
112 file_fds[i] = fd_info.fd.fd; | 113 file_fds[i] = fd_info.fd.fd; |
113 file_auto_close[i] = fd_info.fd.auto_close; | 114 file_auto_close[i] = fd_info.fd.auto_close; |
114 } | 115 } |
115 env->ReleaseIntArrayElements(j_file_ids.obj(), file_ids, 0); | 116 env->ReleaseIntArrayElements(j_file_ids.obj(), file_ids, 0); |
116 env->ReleaseIntArrayElements(j_file_fds.obj(), file_fds, 0); | 117 env->ReleaseIntArrayElements(j_file_fds.obj(), file_fds, 0); |
117 env->ReleaseBooleanArrayElements(j_file_auto_close.obj(), file_auto_close, 0); | 118 env->ReleaseBooleanArrayElements(j_file_auto_close.obj(), file_auto_close, 0); |
118 | 119 |
119 Java_ChildProcessLauncher_start(env, | 120 Java_ChildProcessLauncher_start(env, |
120 base::android::GetApplicationContext(), | 121 base::android::GetApplicationContext(), |
121 j_argv.obj(), | 122 j_argv.obj(), |
123 child_process_id, | |
122 j_file_ids.obj(), | 124 j_file_ids.obj(), |
123 j_file_fds.obj(), | 125 j_file_fds.obj(), |
124 j_file_auto_close.obj(), | 126 j_file_auto_close.obj(), |
125 reinterpret_cast<intptr_t>(new StartChildProcessCallback(callback))); | 127 reinterpret_cast<intptr_t>(new StartChildProcessCallback(callback))); |
126 } | 128 } |
127 | 129 |
128 void StopChildProcess(base::ProcessHandle handle) { | 130 void StopChildProcess(base::ProcessHandle handle) { |
129 JNIEnv* env = AttachCurrentThread(); | 131 JNIEnv* env = AttachCurrentThread(); |
130 DCHECK(env); | 132 DCHECK(env); |
131 Java_ChildProcessLauncher_stop(env, static_cast<jint>(handle)); | 133 Java_ChildProcessLauncher_stop(env, static_cast<jint>(handle)); |
(...skipping 20 matching lines...) Expand all Loading... | |
152 } | 154 } |
153 | 155 |
154 jobject GetViewSurface(JNIEnv* env, jclass clazz, jint surface_id) { | 156 jobject GetViewSurface(JNIEnv* env, jclass clazz, jint surface_id) { |
155 // This is a synchronous call from the GPU process and is expected to be | 157 // This is a synchronous call from the GPU process and is expected to be |
156 // handled on a binder thread. Handling this on the UI thread will lead | 158 // handled on a binder thread. Handling this on the UI thread will lead |
157 // to deadlocks. | 159 // to deadlocks. |
158 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | 160 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); |
159 return CompositorImpl::GetSurface(surface_id); | 161 return CompositorImpl::GetSurface(surface_id); |
160 } | 162 } |
161 | 163 |
164 jobject GetSurfaceTextureSurface(JNIEnv* env, | |
165 jclass clazz, | |
166 jint surface_texture_id, | |
167 jint pid) { | |
168 // This is a synchronous call from a renderer process and is expected to be | |
169 // handled on a binder thread. Handling this on the UI thread will lead | |
170 // to deadlocks. | |
171 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
172 return CompositorImpl::GetSurfaceTextureSurface(surface_texture_id, pid); | |
piman
2014/03/27 01:07:25
Should there be a check somewhere to ensure a rend
reveman
2014/03/27 14:48:11
This is done in the Java code. See line 436 in Chi
| |
173 } | |
174 | |
162 jboolean IsSingleProcess(JNIEnv* env, jclass clazz) { | 175 jboolean IsSingleProcess(JNIEnv* env, jclass clazz) { |
163 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); | 176 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); |
164 } | 177 } |
165 | 178 |
166 bool RegisterChildProcessLauncher(JNIEnv* env) { | 179 bool RegisterChildProcessLauncher(JNIEnv* env) { |
167 return RegisterNativesImpl(env); | 180 return RegisterNativesImpl(env); |
168 } | 181 } |
169 | 182 |
170 } // namespace content | 183 } // namespace content |
OLD | NEW |