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

Side by Side Diff: content/browser/child_process_launcher_helper_android.cc

Issue 2950153002: Improve process launch handle sharing API. (Closed)
Patch Set: Fix Mojo launcher, review comments Created 3 years, 5 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/child_process_launcher_helper_android.h" 5 #include "content/browser/child_process_launcher_helper_android.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/android/apk_assets.h" 9 #include "base/android/apk_assets.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
11 #include "base/i18n/icu_util.h" 11 #include "base/i18n/icu_util.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/metrics/field_trial.h" 13 #include "base/metrics/field_trial.h"
14 #include "content/browser/child_process_launcher_helper.h" 14 #include "content/browser/child_process_launcher_helper.h"
15 #include "content/browser/child_process_launcher_helper_posix.h" 15 #include "content/browser/child_process_launcher_helper_posix.h"
16 #include "content/browser/file_descriptor_info_impl.h" 16 #include "content/browser/posix_file_descriptor_info_impl.h"
17 #include "content/browser/web_contents/web_contents_impl.h" 17 #include "content/browser/web_contents/web_contents_impl.h"
18 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/render_process_host.h" 19 #include "content/public/browser/render_process_host.h"
20 #include "content/public/common/content_descriptors.h" 20 #include "content/public/common/content_descriptors.h"
21 #include "content/public/common/content_switches.h" 21 #include "content/public/common/content_switches.h"
22 #include "jni/ChildProcessLauncherHelper_jni.h" 22 #include "jni/ChildProcessLauncherHelper_jni.h"
23 23
24 using base::android::AttachCurrentThread; 24 using base::android::AttachCurrentThread;
25 using base::android::JavaParamRef; 25 using base::android::JavaParamRef;
26 using base::android::ScopedJavaGlobalRef; 26 using base::android::ScopedJavaGlobalRef;
(...skipping 29 matching lines...) Expand all
56 // Non-sandboxed utility or renderer process are currently not supported. 56 // Non-sandboxed utility or renderer process are currently not supported.
57 DCHECK(process_type == switches::kGpuProcess || 57 DCHECK(process_type == switches::kGpuProcess ||
58 !command_line()->HasSwitch(switches::kNoSandbox)); 58 !command_line()->HasSwitch(switches::kNoSandbox));
59 } 59 }
60 60
61 mojo::edk::ScopedPlatformHandle 61 mojo::edk::ScopedPlatformHandle
62 ChildProcessLauncherHelper::PrepareMojoPipeHandlesOnClientThread() { 62 ChildProcessLauncherHelper::PrepareMojoPipeHandlesOnClientThread() {
63 return mojo::edk::ScopedPlatformHandle(); 63 return mojo::edk::ScopedPlatformHandle();
64 } 64 }
65 65
66 std::unique_ptr<FileDescriptorInfo> 66 std::unique_ptr<PosixFileDescriptorInfo>
67 ChildProcessLauncherHelper::GetFilesToMap() { 67 ChildProcessLauncherHelper::GetFilesToMap() {
68 DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER); 68 DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER);
69 69
70 // Android WebView runs in single process, ensure that we never get here when 70 // Android WebView runs in single process, ensure that we never get here when
71 // running in single process mode. 71 // running in single process mode.
72 CHECK(!command_line()->HasSwitch(switches::kSingleProcess)); 72 CHECK(!command_line()->HasSwitch(switches::kSingleProcess));
73 73
74 std::unique_ptr<FileDescriptorInfo> files_to_register = 74 std::unique_ptr<PosixFileDescriptorInfo> files_to_register =
75 CreateDefaultPosixFilesToMap(child_process_id(), mojo_client_handle(), 75 CreateDefaultPosixFilesToMap(child_process_id(), mojo_client_handle(),
76 true /* include_service_required_files */, 76 true /* include_service_required_files */,
77 GetProcessType(), command_line()); 77 GetProcessType(), command_line());
78 78
79 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE 79 #if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
80 base::MemoryMappedFile::Region icu_region; 80 base::MemoryMappedFile::Region icu_region;
81 int fd = base::i18n::GetIcuDataFileHandle(&icu_region); 81 int fd = base::i18n::GetIcuDataFileHandle(&icu_region);
82 files_to_register->ShareWithRegion(kAndroidICUDataDescriptor, fd, icu_region); 82 files_to_register->ShareWithRegion(kAndroidICUDataDescriptor, fd, icu_region);
83 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE 83 #endif // ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
84 84
85 return files_to_register; 85 return files_to_register;
86 } 86 }
87 87
88 void ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread( 88 void ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread(
89 const FileDescriptorInfo& files_to_register, 89 const PosixFileDescriptorInfo& files_to_register,
90 base::LaunchOptions* options) { 90 base::LaunchOptions* options) {}
91 }
92 91
93 ChildProcessLauncherHelper::Process 92 ChildProcessLauncherHelper::Process
94 ChildProcessLauncherHelper::LaunchProcessOnLauncherThread( 93 ChildProcessLauncherHelper::LaunchProcessOnLauncherThread(
95 const base::LaunchOptions& options, 94 const base::LaunchOptions& options,
96 std::unique_ptr<FileDescriptorInfo> files_to_register, 95 std::unique_ptr<PosixFileDescriptorInfo> files_to_register,
97 bool* is_synchronous_launch, 96 bool* is_synchronous_launch,
98 int* launch_result) { 97 int* launch_result) {
99 *is_synchronous_launch = false; 98 *is_synchronous_launch = false;
100 99
101 JNIEnv* env = AttachCurrentThread(); 100 JNIEnv* env = AttachCurrentThread();
102 DCHECK(env); 101 DCHECK(env);
103 102
104 // Create the Command line String[] 103 // Create the Command line String[]
105 ScopedJavaLocalRef<jobjectArray> j_argv = 104 ScopedJavaLocalRef<jobjectArray> j_argv =
106 ToJavaArrayOfStrings(env, command_line()->argv()); 105 ToJavaArrayOfStrings(env, command_line()->argv());
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 AttachCurrentThread())); 225 AttachCurrentThread()));
227 } 226 }
228 227
229 } // namespace internal 228 } // namespace internal
230 229
231 bool RegisterChildProcessLauncher(JNIEnv* env) { 230 bool RegisterChildProcessLauncher(JNIEnv* env) {
232 return internal::RegisterNativesImpl(env); 231 return internal::RegisterNativesImpl(env);
233 } 232 }
234 233
235 } // namespace content 234 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698