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/app/android/child_process_service.h" | 5 #include "content/app/android/child_process_service.h" |
6 | 6 |
7 #include <android/native_window_jni.h> | 7 #include <android/native_window_jni.h> |
8 #include <cpu-features.h> | 8 #include <cpu-features.h> |
9 | 9 |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 124 |
125 private: | 125 private: |
126 // The instance of org.chromium.content.app.ChildProcessService. | 126 // The instance of org.chromium.content.app.ChildProcessService. |
127 base::android::ScopedJavaGlobalRef<jobject> service_; | 127 base::android::ScopedJavaGlobalRef<jobject> service_; |
128 | 128 |
129 DISALLOW_COPY_AND_ASSIGN(SurfaceTextureManagerImpl); | 129 DISALLOW_COPY_AND_ASSIGN(SurfaceTextureManagerImpl); |
130 }; | 130 }; |
131 | 131 |
132 // Chrome actually uses the renderer code path for all of its child | 132 // Chrome actually uses the renderer code path for all of its child |
133 // processes such as renderers, plugins, etc. | 133 // processes such as renderers, plugins, etc. |
134 void InternalInitChildProcess(const std::vector<int>& file_ids, | 134 void InternalInitChildProcess(JNIEnv* env, |
135 const std::vector<int>& file_fds, | |
136 JNIEnv* env, | |
137 jclass clazz, | 135 jclass clazz, |
138 jobject context, | 136 jobject context, |
139 jobject service_in, | 137 jobject service_in, |
140 jint cpu_count, | 138 jint cpu_count, |
141 jlong cpu_features) { | 139 jlong cpu_features) { |
142 base::android::ScopedJavaLocalRef<jobject> service(env, service_in); | 140 base::android::ScopedJavaLocalRef<jobject> service(env, service_in); |
143 | 141 |
144 // Set the CPU properties. | 142 // Set the CPU properties. |
145 android_setCpu(cpu_count, cpu_features); | 143 android_setCpu(cpu_count, cpu_features); |
146 // Register the file descriptors. | |
147 // This includes the IPC channel, the crash dump signals and resource related | |
148 // files. | |
149 DCHECK(file_fds.size() == file_ids.size()); | |
150 for (size_t i = 0; i < file_ids.size(); ++i) | |
151 base::GlobalDescriptors::GetInstance()->Set(file_ids[i], file_fds[i]); | |
152 | |
153 SurfaceTextureManager::SetInstance(new SurfaceTextureManagerImpl(service)); | 144 SurfaceTextureManager::SetInstance(new SurfaceTextureManagerImpl(service)); |
154 | 145 |
155 base::android::MemoryPressureListenerAndroid::RegisterSystemCallback(env); | 146 base::android::MemoryPressureListenerAndroid::RegisterSystemCallback(env); |
156 } | 147 } |
157 | 148 |
158 } // namespace <anonymous> | 149 } // namespace <anonymous> |
159 | 150 |
| 151 void RegisterGlobalFileDescriptor(JNIEnv* env, |
| 152 jclass clazz, |
| 153 jint id, |
| 154 jint fd, |
| 155 jlong offset, |
| 156 jlong size) { |
| 157 base::MemoryMappedFile::Region region(offset, size); |
| 158 base::GlobalDescriptors::GetInstance()->Set(id, fd, region); |
| 159 } |
| 160 |
160 void InitChildProcess(JNIEnv* env, | 161 void InitChildProcess(JNIEnv* env, |
161 jclass clazz, | 162 jclass clazz, |
162 jobject context, | 163 jobject context, |
163 jobject service, | 164 jobject service, |
164 jintArray j_file_ids, | |
165 jintArray j_file_fds, | |
166 jint cpu_count, | 165 jint cpu_count, |
167 jlong cpu_features) { | 166 jlong cpu_features) { |
168 std::vector<int> file_ids; | 167 InternalInitChildProcess(env, clazz, context, service, cpu_count, |
169 std::vector<int> file_fds; | 168 cpu_features); |
170 JavaIntArrayToIntVector(env, j_file_ids, &file_ids); | |
171 JavaIntArrayToIntVector(env, j_file_fds, &file_fds); | |
172 | |
173 InternalInitChildProcess( | |
174 file_ids, file_fds, env, clazz, context, service, | |
175 cpu_count, cpu_features); | |
176 } | 169 } |
177 | 170 |
178 void ExitChildProcess(JNIEnv* env, jclass clazz) { | 171 void ExitChildProcess(JNIEnv* env, jclass clazz) { |
179 VLOG(0) << "ChildProcessService: Exiting child process."; | 172 VLOG(0) << "ChildProcessService: Exiting child process."; |
180 base::android::LibraryLoaderExitHook(); | 173 base::android::LibraryLoaderExitHook(); |
181 _exit(0); | 174 _exit(0); |
182 } | 175 } |
183 | 176 |
184 bool RegisterChildProcessService(JNIEnv* env) { | 177 bool RegisterChildProcessService(JNIEnv* env) { |
185 return RegisterNativesImpl(env); | 178 return RegisterNativesImpl(env); |
186 } | 179 } |
187 | 180 |
188 void ShutdownMainThread(JNIEnv* env, jobject obj) { | 181 void ShutdownMainThread(JNIEnv* env, jobject obj) { |
189 ChildThreadImpl::ShutdownThread(); | 182 ChildThreadImpl::ShutdownThread(); |
190 } | 183 } |
191 | 184 |
192 } // namespace content | 185 } // namespace content |
OLD | NEW |