Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1013)

Side by Side Diff: content/app/android/child_process_service.cc

Issue 1156873002: Load v8 snapshots directly from APK (and store them uncompressed) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8initializer
Patch Set: Pass FDs & Regions through to child process (Still has formatting errors) Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 LOG(WARNING) << "REG NATIVE " << id << " " << fd;
158 base::MemoryMappedFile::Region region(offset, size);
159 base::GlobalDescriptors::GetInstance()->Set(id, fd, region);
160 }
161
160 void InitChildProcess(JNIEnv* env, 162 void InitChildProcess(JNIEnv* env,
161 jclass clazz, 163 jclass clazz,
162 jobject context, 164 jobject context,
163 jobject service, 165 jobject service,
164 jintArray j_file_ids,
165 jintArray j_file_fds,
166 jint cpu_count, 166 jint cpu_count,
167 jlong cpu_features) { 167 jlong cpu_features) {
168 std::vector<int> file_ids; 168 InternalInitChildProcess(env, clazz, context, service,
169 std::vector<int> file_fds;
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); 169 cpu_count, cpu_features);
176 } 170 }
177 171
178 void ExitChildProcess(JNIEnv* env, jclass clazz) { 172 void ExitChildProcess(JNIEnv* env, jclass clazz) {
179 VLOG(0) << "ChildProcessService: Exiting child process."; 173 VLOG(0) << "ChildProcessService: Exiting child process.";
180 base::android::LibraryLoaderExitHook(); 174 base::android::LibraryLoaderExitHook();
181 _exit(0); 175 _exit(0);
182 } 176 }
183 177
184 bool RegisterChildProcessService(JNIEnv* env) { 178 bool RegisterChildProcessService(JNIEnv* env) {
185 return RegisterNativesImpl(env); 179 return RegisterNativesImpl(env);
186 } 180 }
187 181
188 void ShutdownMainThread(JNIEnv* env, jobject obj) { 182 void ShutdownMainThread(JNIEnv* env, jobject obj) {
189 ChildThreadImpl::ShutdownThread(); 183 ChildThreadImpl::ShutdownThread();
190 } 184 }
191 185
192 } // namespace content 186 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698