| OLD | NEW |
| 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.h" | 5 #include "content/browser/child_process_launcher_helper.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/i18n/icu_util.h" | 9 #include "base/i18n/icu_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 namespace internal { | 23 namespace internal { |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // Callback invoked from Java once the process has been started. | 27 // Callback invoked from Java once the process has been started. |
| 28 void ChildProcessStartedCallback( | 28 void ChildProcessStartedCallback( |
| 29 ChildProcessLauncherHelper* helper, | 29 ChildProcessLauncherHelper* helper, |
| 30 base::ProcessHandle handle, | 30 base::ProcessHandle handle, |
| 31 int launch_result) { | 31 int launch_result, |
| 32 std::unique_ptr<mojo::edk::PendingProcessConnection> pending_connection, |
| 33 mojo::edk::ScopedPlatformHandle server_handle) { |
| 32 // TODO(jcivelli): Remove this by defining better what happens on what thread | 34 // TODO(jcivelli): Remove this by defining better what happens on what thread |
| 33 // in the corresponding Java code. | 35 // in the corresponding Java code. |
| 34 ChildProcessLauncherHelper::Process process; | 36 ChildProcessLauncherHelper::Process process; |
| 35 process.process = base::Process(handle); | 37 process.process = base::Process(handle); |
| 36 if (BrowserThread::CurrentlyOn(BrowserThread::PROCESS_LAUNCHER)) { | 38 if (BrowserThread::CurrentlyOn(BrowserThread::PROCESS_LAUNCHER)) { |
| 37 helper->PostLaunchOnLauncherThread( | 39 helper->PostLaunchOnLauncherThread( |
| 38 std::move(process), | 40 std::move(process), |
| 39 launch_result, | 41 launch_result, |
| 40 false); // post_launch_on_client_thread_called | 42 false); // post_launch_on_client_thread_called |
| 41 return; | 43 return; |
| 42 } | 44 } |
| 43 | 45 |
| 44 bool on_client_thread = BrowserThread::CurrentlyOn( | 46 bool on_client_thread = BrowserThread::CurrentlyOn( |
| 45 static_cast<BrowserThread::ID>(helper->client_thread_id())); | 47 static_cast<BrowserThread::ID>(helper->client_thread_id())); |
| 46 BrowserThread::PostTask(BrowserThread::PROCESS_LAUNCHER, FROM_HERE, | 48 BrowserThread::PostTask(BrowserThread::PROCESS_LAUNCHER, FROM_HERE, |
| 47 base::Bind(&ChildProcessLauncherHelper::PostLaunchOnLauncherThread, | 49 base::Bind(&ChildProcessLauncherHelper::PostLaunchOnLauncherThread, |
| 48 helper, | 50 helper, |
| 49 base::Passed(std::move(process)), | 51 base::Passed(std::move(process)), |
| 50 launch_result, | 52 launch_result, |
| 51 on_client_thread)); | 53 on_client_thread)); |
| 52 if (on_client_thread) { | 54 if (on_client_thread) { |
| 53 ChildProcessLauncherHelper::Process process; | 55 ChildProcessLauncherHelper::Process process; |
| 54 process.process = base::Process(handle); | 56 process.process = base::Process(handle); |
| 55 helper->PostLaunchOnClientThread(std::move(process), launch_result); | 57 helper->PostLaunchOnClientThread(std::move(process), launch_result, |
| 58 std::move(pending_connection), |
| 59 std::move(server_handle)); |
| 56 } | 60 } |
| 57 } | 61 } |
| 58 | 62 |
| 59 } // namespace | 63 } // namespace |
| 60 | 64 |
| 61 void ChildProcessLauncherHelper::BeforeLaunchOnClientThread() { | 65 void ChildProcessLauncherHelper::BeforeLaunchOnClientThread() { |
| 62 // Android only supports renderer, sandboxed utility and gpu. | 66 // Android only supports renderer, sandboxed utility and gpu. |
| 63 std::string process_type = | 67 std::string process_type = |
| 64 command_line()->GetSwitchValueASCII(switches::kProcessType); | 68 command_line()->GetSwitchValueASCII(switches::kProcessType); |
| 65 CHECK(process_type == switches::kGpuProcess || | 69 CHECK(process_type == switches::kGpuProcess || |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 void ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread( | 127 void ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread( |
| 124 const FileDescriptorInfo& files_to_register, | 128 const FileDescriptorInfo& files_to_register, |
| 125 base::LaunchOptions* options) { | 129 base::LaunchOptions* options) { |
| 126 } | 130 } |
| 127 | 131 |
| 128 ChildProcessLauncherHelper::Process | 132 ChildProcessLauncherHelper::Process |
| 129 ChildProcessLauncherHelper::LaunchProcessOnLauncherThread( | 133 ChildProcessLauncherHelper::LaunchProcessOnLauncherThread( |
| 130 const base::LaunchOptions& options, | 134 const base::LaunchOptions& options, |
| 131 std::unique_ptr<FileDescriptorInfo> files_to_register, | 135 std::unique_ptr<FileDescriptorInfo> files_to_register, |
| 132 bool* is_synchronous_launch, | 136 bool* is_synchronous_launch, |
| 133 int* launch_result) { | 137 int* launch_result, |
| 138 std::unique_ptr<mojo::edk::PendingProcessConnection>* pending_connection, |
| 139 mojo::edk::ScopedPlatformHandle* server_handle) { |
| 134 *is_synchronous_launch = false; | 140 *is_synchronous_launch = false; |
| 135 | 141 |
| 136 StartChildProcess(command_line()->argv(), | 142 StartChildProcess(command_line()->argv(), child_process_id(), |
| 137 child_process_id(), | |
| 138 files_to_register.get(), | 143 files_to_register.get(), |
| 139 base::Bind(&ChildProcessStartedCallback, | 144 base::Bind(&ChildProcessStartedCallback, RetainedRef(this), |
| 140 RetainedRef(this))); | 145 base::Passed(pending_connection), |
| 146 base::Passed(server_handle))); |
| 141 | 147 |
| 142 return Process(); | 148 return Process(); |
| 143 } | 149 } |
| 144 | 150 |
| 145 void ChildProcessLauncherHelper::AfterLaunchOnLauncherThread( | 151 void ChildProcessLauncherHelper::AfterLaunchOnLauncherThread( |
| 146 const ChildProcessLauncherHelper::Process& process, | 152 const ChildProcessLauncherHelper::Process& process, |
| 147 const base::LaunchOptions& options) { | 153 const base::LaunchOptions& options) { |
| 148 } | 154 } |
| 149 | 155 |
| 150 // static | 156 // static |
| (...skipping 23 matching lines...) Expand all Loading... |
| 174 } | 180 } |
| 175 | 181 |
| 176 // static | 182 // static |
| 177 void ChildProcessLauncherHelper::SetProcessBackgroundedOnLauncherThread( | 183 void ChildProcessLauncherHelper::SetProcessBackgroundedOnLauncherThread( |
| 178 base::Process process, bool background) { | 184 base::Process process, bool background) { |
| 179 SetChildProcessInForeground(process.Handle(), !background); | 185 SetChildProcessInForeground(process.Handle(), !background); |
| 180 } | 186 } |
| 181 | 187 |
| 182 } // namespace internal | 188 } // namespace internal |
| 183 } // namespace content | 189 } // namespace content |
| OLD | NEW |