| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 reinterpret_cast<StartChildProcessCallback*>(client_context); | 106 reinterpret_cast<StartChildProcessCallback*>(client_context); |
| 107 if (handle) | 107 if (handle) |
| 108 callback->Run(static_cast<base::ProcessHandle>(handle)); | 108 callback->Run(static_cast<base::ProcessHandle>(handle)); |
| 109 delete callback; | 109 delete callback; |
| 110 } | 110 } |
| 111 | 111 |
| 112 void StartChildProcess( | 112 void StartChildProcess( |
| 113 const base::CommandLine::StringVector& argv, | 113 const base::CommandLine::StringVector& argv, |
| 114 int child_process_id, | 114 int child_process_id, |
| 115 std::unique_ptr<content::FileDescriptorInfo> files_to_register, | 115 std::unique_ptr<content::FileDescriptorInfo> files_to_register, |
| 116 const std::map<int, base::MemoryMappedFile::Region>& regions, | |
| 117 const StartChildProcessCallback& callback) { | 116 const StartChildProcessCallback& callback) { |
| 118 JNIEnv* env = AttachCurrentThread(); | 117 JNIEnv* env = AttachCurrentThread(); |
| 119 DCHECK(env); | 118 DCHECK(env); |
| 120 | 119 |
| 121 // Create the Command line String[] | 120 // Create the Command line String[] |
| 122 ScopedJavaLocalRef<jobjectArray> j_argv = ToJavaArrayOfStrings(env, argv); | 121 ScopedJavaLocalRef<jobjectArray> j_argv = ToJavaArrayOfStrings(env, argv); |
| 123 | 122 |
| 124 size_t file_count = files_to_register->GetMappingSize(); | 123 size_t file_count = files_to_register->GetMappingSize(); |
| 125 DCHECK(file_count > 0); | 124 DCHECK(file_count > 0); |
| 126 | 125 |
| 127 ScopedJavaLocalRef<jclass> j_file_info_class = base::android::GetClass( | 126 ScopedJavaLocalRef<jclass> j_file_info_class = base::android::GetClass( |
| 128 env, "org/chromium/content/common/FileDescriptorInfo"); | 127 env, "org/chromium/content/common/FileDescriptorInfo"); |
| 129 ScopedJavaLocalRef<jobjectArray> j_file_infos( | 128 ScopedJavaLocalRef<jobjectArray> j_file_infos( |
| 130 env, env->NewObjectArray(file_count, j_file_info_class.obj(), NULL)); | 129 env, env->NewObjectArray(file_count, j_file_info_class.obj(), NULL)); |
| 131 base::android::CheckException(env); | 130 base::android::CheckException(env); |
| 132 | 131 |
| 133 for (size_t i = 0; i < file_count; ++i) { | 132 for (size_t i = 0; i < file_count; ++i) { |
| 134 int fd = files_to_register->GetFDAt(i); | 133 int fd = files_to_register->GetFDAt(i); |
| 135 PCHECK(0 <= fd); | 134 PCHECK(0 <= fd); |
| 136 int id = files_to_register->GetIDAt(i); | 135 int id = files_to_register->GetIDAt(i); |
| 137 bool auto_close = files_to_register->OwnsFD(fd); | 136 bool auto_close = files_to_register->OwnsFD(fd); |
| 138 int64_t offset = 0L; | 137 const base::MemoryMappedFile::Region& region = |
| 139 int64_t size = 0L; | 138 files_to_register->GetRegionAt(i); |
| 140 auto found_region_iter = regions.find(id); | 139 int64_t offset = region.offset; |
| 141 if (found_region_iter != regions.end()) { | 140 int64_t size = region.size; |
| 142 offset = found_region_iter->second.offset; | |
| 143 size = found_region_iter->second.size; | |
| 144 } | |
| 145 ScopedJavaLocalRef<jobject> j_file_info = | 141 ScopedJavaLocalRef<jobject> j_file_info = |
| 146 Java_ChildProcessLauncher_makeFdInfo(env, id, fd, auto_close, offset, | 142 Java_ChildProcessLauncher_makeFdInfo(env, id, fd, auto_close, offset, |
| 147 size); | 143 size); |
| 148 PCHECK(j_file_info.obj()); | 144 PCHECK(j_file_info.obj()); |
| 149 env->SetObjectArrayElement(j_file_infos.obj(), i, j_file_info.obj()); | 145 env->SetObjectArrayElement(j_file_infos.obj(), i, j_file_info.obj()); |
| 150 if (auto_close) { | 146 if (auto_close) { |
| 151 ignore_result(files_to_register->ReleaseFD(fd).release()); | 147 ignore_result(files_to_register->ReleaseFD(fd).release()); |
| 152 } | 148 } |
| 153 } | 149 } |
| 154 | 150 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 gl::ScopedJavaSurface surface_view = | 222 gl::ScopedJavaSurface surface_view = |
| 227 gpu::GpuSurfaceTracker::GetInstance()->AcquireJavaSurface(surface_id); | 223 gpu::GpuSurfaceTracker::GetInstance()->AcquireJavaSurface(surface_id); |
| 228 return base::android::ScopedJavaLocalRef<jobject>(surface_view.j_surface()); | 224 return base::android::ScopedJavaLocalRef<jobject>(surface_view.j_surface()); |
| 229 } | 225 } |
| 230 | 226 |
| 231 bool RegisterChildProcessLauncher(JNIEnv* env) { | 227 bool RegisterChildProcessLauncher(JNIEnv* env) { |
| 232 return RegisterNativesImpl(env); | 228 return RegisterNativesImpl(env); |
| 233 } | 229 } |
| 234 | 230 |
| 235 } // namespace content | 231 } // namespace content |
| OLD | NEW |