| 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 "base/memory/ptr_util.h" | 5 #include "base/memory/ptr_util.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/posix/global_descriptors.h" | 7 #include "base/posix/global_descriptors.h" |
| 8 #include "content/browser/bootstrap_sandbox_manager_mac.h" | 8 #include "content/browser/bootstrap_sandbox_manager_mac.h" |
| 9 #include "content/browser/child_process_launcher.h" | 9 #include "content/browser/child_process_launcher.h" |
| 10 #include "content/browser/child_process_launcher_helper.h" | 10 #include "content/browser/child_process_launcher_helper.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 BootstrapSandboxManager::GetInstance()->sandbox()->RevokeToken( | 109 BootstrapSandboxManager::GetInstance()->sandbox()->RevokeToken( |
| 110 pre_exec_delegate->sandbox_token()); | 110 pre_exec_delegate->sandbox_token()); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 // After updating the broker, release the lock and let the child's message be | 114 // After updating the broker, release the lock and let the child's message be |
| 115 // processed on the broker's thread. | 115 // processed on the broker's thread. |
| 116 broker->GetLock().Release(); | 116 broker->GetLock().Release(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 // static | |
| 120 base::TerminationStatus ChildProcessLauncherHelper::GetTerminationStatus( | 119 base::TerminationStatus ChildProcessLauncherHelper::GetTerminationStatus( |
| 121 const ChildProcessLauncherHelper::Process& process, | 120 const ChildProcessLauncherHelper::Process& process, |
| 122 bool known_dead, | 121 bool known_dead, |
| 123 int* exit_code) { | 122 int* exit_code) { |
| 124 return known_dead | 123 return known_dead |
| 125 ? base::GetKnownDeadTerminationStatus(process.process.Handle(), exit_code) | 124 ? base::GetKnownDeadTerminationStatus(process.process.Handle(), exit_code) |
| 126 : base::GetTerminationStatus(process.process.Handle(), exit_code); | 125 : base::GetTerminationStatus(process.process.Handle(), exit_code); |
| 127 } | 126 } |
| 128 | 127 |
| 129 // static | 128 // static |
| 130 bool ChildProcessLauncherHelper::TerminateProcess( | 129 bool ChildProcessLauncherHelper::TerminateProcess( |
| 131 const base::Process& process, int exit_code, bool wait) { | 130 const base::Process& process, int exit_code, bool wait) { |
| 132 return process.Terminate(exit_code, wait); | 131 return process.Terminate(exit_code, wait); |
| 133 } | 132 } |
| 134 | 133 |
| 135 // static | 134 // static |
| 136 void ChildProcessLauncherHelper::ForceNormalProcessTerminationSync( | 135 void ChildProcessLauncherHelper::ForceNormalProcessTerminationSync( |
| 137 ChildProcessLauncherHelper::Process process) { | 136 ChildProcessLauncherHelper::Process process) { |
| 138 DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER); | 137 DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER); |
| 139 // Client has gone away, so just kill the process. Using exit code 0 means | 138 // Client has gone away, so just kill the process. Using exit code 0 means |
| 140 // that UMA won't treat this as a crash. | 139 // that UMA won't treat this as a crash. |
| 141 process.process.Terminate(RESULT_CODE_NORMAL_EXIT, false); | 140 process.process.Terminate(RESULT_CODE_NORMAL_EXIT, false); |
| 142 base::EnsureProcessTerminated(std::move(process.process)); | 141 base::EnsureProcessTerminated(std::move(process.process)); |
| 143 } | 142 } |
| 144 | 143 |
| 145 // static | |
| 146 void ChildProcessLauncherHelper::SetProcessBackgroundedOnLauncherThread( | 144 void ChildProcessLauncherHelper::SetProcessBackgroundedOnLauncherThread( |
| 147 base::Process process, bool background) { | 145 base::Process process, bool background) { |
| 148 if (process.CanBackgroundProcesses()) | 146 if (process.CanBackgroundProcesses()) |
| 149 process.SetProcessBackgrounded(MachBroker::GetInstance(), background); | 147 process.SetProcessBackgrounded(MachBroker::GetInstance(), background); |
| 150 } | 148 } |
| 151 | 149 |
| 152 // static | 150 // static |
| 153 void ChildProcessLauncherHelper::SetRegisteredFilesForService( | 151 void ChildProcessLauncherHelper::SetRegisteredFilesForService( |
| 154 const std::string& service_name, | 152 const std::string& service_name, |
| 155 catalog::RequiredFileMap required_files) { | 153 catalog::RequiredFileMap required_files) { |
| 156 // No file passing from the manifest on Mac yet. | 154 // No file passing from the manifest on Mac yet. |
| 157 DCHECK(required_files.empty()); | 155 DCHECK(required_files.empty()); |
| 158 } | 156 } |
| 159 | 157 |
| 160 // static | 158 // static |
| 161 void ChildProcessLauncherHelper::ResetRegisteredFilesForTesting() {} | 159 void ChildProcessLauncherHelper::ResetRegisteredFilesForTesting() {} |
| 162 | 160 |
| 163 // static | 161 // static |
| 164 base::File OpenFileToShare(const base::FilePath& path, | 162 base::File OpenFileToShare(const base::FilePath& path, |
| 165 base::MemoryMappedFile::Region* region) { | 163 base::MemoryMappedFile::Region* region) { |
| 166 // Not used yet (until required files are described in the service manifest on | 164 // Not used yet (until required files are described in the service manifest on |
| 167 // Mac). | 165 // Mac). |
| 168 NOTREACHED(); | 166 NOTREACHED(); |
| 169 return base::File(); | 167 return base::File(); |
| 170 } | 168 } |
| 171 | 169 |
| 172 } // namespace internal | 170 } // namespace internal |
| 173 } // namespace content | 171 } // namespace content |
| OLD | NEW |