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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(JNIEnv* env, | 134 void InternalInitChildProcess(JNIEnv* env, |
135 jclass clazz, | 135 jclass clazz, |
136 jobject context, | |
137 jobject service_in, | 136 jobject service_in, |
138 jint cpu_count, | 137 jint cpu_count, |
139 jlong cpu_features) { | 138 jlong cpu_features) { |
140 base::android::ScopedJavaLocalRef<jobject> service(env, service_in); | 139 base::android::ScopedJavaLocalRef<jobject> service( |
| 140 env, env->NewLocalRef(service_in)); |
141 | 141 |
142 // Set the CPU properties. | 142 // Set the CPU properties. |
143 android_setCpu(cpu_count, cpu_features); | 143 android_setCpu(cpu_count, cpu_features); |
144 SurfaceTextureManager::SetInstance(new SurfaceTextureManagerImpl(service)); | 144 SurfaceTextureManager::SetInstance(new SurfaceTextureManagerImpl(service)); |
145 | 145 |
146 base::android::MemoryPressureListenerAndroid::RegisterSystemCallback(env); | 146 base::android::MemoryPressureListenerAndroid::RegisterSystemCallback(env); |
147 } | 147 } |
148 | 148 |
149 } // namespace <anonymous> | 149 } // namespace <anonymous> |
150 | 150 |
151 void RegisterGlobalFileDescriptor(JNIEnv* env, | 151 void RegisterGlobalFileDescriptor(JNIEnv* env, |
152 jclass clazz, | 152 jclass clazz, |
153 jint id, | 153 jint id, |
154 jint fd, | 154 jint fd, |
155 jlong offset, | 155 jlong offset, |
156 jlong size) { | 156 jlong size) { |
157 base::MemoryMappedFile::Region region = {offset, size}; | 157 base::MemoryMappedFile::Region region = {offset, size}; |
158 base::GlobalDescriptors::GetInstance()->Set(id, fd, region); | 158 base::GlobalDescriptors::GetInstance()->Set(id, fd, region); |
159 } | 159 } |
160 | 160 |
161 void InitChildProcess(JNIEnv* env, | 161 void InitChildProcess(JNIEnv* env, |
162 jclass clazz, | 162 jclass clazz, |
163 jobject context, | |
164 jobject service, | 163 jobject service, |
165 jint cpu_count, | 164 jint cpu_count, |
166 jlong cpu_features) { | 165 jlong cpu_features) { |
167 InternalInitChildProcess(env, clazz, context, service, cpu_count, | 166 InternalInitChildProcess(env, clazz, service, cpu_count, cpu_features); |
168 cpu_features); | |
169 } | 167 } |
170 | 168 |
171 void ExitChildProcess(JNIEnv* env, jclass clazz) { | 169 void ExitChildProcess(JNIEnv* env, jclass clazz) { |
172 VLOG(0) << "ChildProcessService: Exiting child process."; | 170 VLOG(0) << "ChildProcessService: Exiting child process."; |
173 base::android::LibraryLoaderExitHook(); | 171 base::android::LibraryLoaderExitHook(); |
174 _exit(0); | 172 _exit(0); |
175 } | 173 } |
176 | 174 |
177 bool RegisterChildProcessService(JNIEnv* env) { | 175 bool RegisterChildProcessService(JNIEnv* env) { |
178 return RegisterNativesImpl(env); | 176 return RegisterNativesImpl(env); |
179 } | 177 } |
180 | 178 |
181 void ShutdownMainThread(JNIEnv* env, jobject obj) { | 179 void ShutdownMainThread(JNIEnv* env, jobject obj) { |
182 ChildThreadImpl::ShutdownThread(); | 180 ChildThreadImpl::ShutdownThread(); |
183 } | 181 } |
184 | 182 |
185 } // namespace content | 183 } // namespace content |
OLD | NEW |