| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/child_process_launcher.h" | 5 #include "content/browser/child_process_launcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/i18n/icu_util.h" | 10 #include "base/i18n/icu_util.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 void ChildProcessLauncher::SetProcessBackgrounded(bool background) { | 62 void ChildProcessLauncher::SetProcessBackgrounded(bool background) { |
| 63 DCHECK(CalledOnValidThread()); | 63 DCHECK(CalledOnValidThread()); |
| 64 base::Process to_pass = process_.process.Duplicate(); | 64 base::Process to_pass = process_.process.Duplicate(); |
| 65 BrowserThread::PostTask( | 65 BrowserThread::PostTask( |
| 66 BrowserThread::PROCESS_LAUNCHER, FROM_HERE, | 66 BrowserThread::PROCESS_LAUNCHER, FROM_HERE, |
| 67 base::Bind( | 67 base::Bind( |
| 68 &ChildProcessLauncherHelper::SetProcessBackgroundedOnLauncherThread, | 68 &ChildProcessLauncherHelper::SetProcessBackgroundedOnLauncherThread, |
| 69 base::Passed(&to_pass), | 69 helper_, base::Passed(&to_pass), background)); |
| 70 background)); | |
| 71 } | 70 } |
| 72 | 71 |
| 73 void ChildProcessLauncher::Notify( | 72 void ChildProcessLauncher::Notify( |
| 74 ChildProcessLauncherHelper::Process process, | 73 ChildProcessLauncherHelper::Process process, |
| 75 mojo::edk::ScopedPlatformHandle server_handle, | 74 mojo::edk::ScopedPlatformHandle server_handle, |
| 76 int error_code) { | 75 int error_code) { |
| 77 DCHECK(CalledOnValidThread()); | 76 DCHECK(CalledOnValidThread()); |
| 78 starting_ = false; | 77 starting_ = false; |
| 79 process_ = std::move(process); | 78 process_ = std::move(process); |
| 80 | 79 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 bool known_dead, | 113 bool known_dead, |
| 115 int* exit_code) { | 114 int* exit_code) { |
| 116 DCHECK(CalledOnValidThread()); | 115 DCHECK(CalledOnValidThread()); |
| 117 if (!process_.process.IsValid()) { | 116 if (!process_.process.IsValid()) { |
| 118 // Process is already gone, so return the cached termination status. | 117 // Process is already gone, so return the cached termination status. |
| 119 if (exit_code) | 118 if (exit_code) |
| 120 *exit_code = exit_code_; | 119 *exit_code = exit_code_; |
| 121 return termination_status_; | 120 return termination_status_; |
| 122 } | 121 } |
| 123 | 122 |
| 124 termination_status_ = ChildProcessLauncherHelper::GetTerminationStatus( | 123 termination_status_ = |
| 125 process_, known_dead, &exit_code_); | 124 helper_->GetTerminationStatus(process_, known_dead, &exit_code_); |
| 126 if (exit_code) | 125 if (exit_code) |
| 127 *exit_code = exit_code_; | 126 *exit_code = exit_code_; |
| 128 | 127 |
| 129 // POSIX: If the process crashed, then the kernel closed the socket for it and | 128 // POSIX: If the process crashed, then the kernel closed the socket for it and |
| 130 // so the child has already died by the time we get here. Since | 129 // so the child has already died by the time we get here. Since |
| 131 // GetTerminationStatus called waitpid with WNOHANG, it'll reap the process. | 130 // GetTerminationStatus called waitpid with WNOHANG, it'll reap the process. |
| 132 // However, if GetTerminationStatus didn't reap the child (because it was | 131 // However, if GetTerminationStatus didn't reap the child (because it was |
| 133 // still running), we'll need to Terminate via ProcessWatcher. So we can't | 132 // still running), we'll need to Terminate via ProcessWatcher. So we can't |
| 134 // close the handle here. | 133 // close the handle here. |
| 135 if (termination_status_ != base::TERMINATION_STATUS_STILL_RUNNING) | 134 if (termination_status_ != base::TERMINATION_STATUS_STILL_RUNNING) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 165 } | 164 } |
| 166 | 165 |
| 167 ChildProcessLauncher::Client* ChildProcessLauncher::ReplaceClientForTest( | 166 ChildProcessLauncher::Client* ChildProcessLauncher::ReplaceClientForTest( |
| 168 Client* client) { | 167 Client* client) { |
| 169 Client* ret = client_; | 168 Client* ret = client_; |
| 170 client_ = client; | 169 client_ = client; |
| 171 return ret; | 170 return ret; |
| 172 } | 171 } |
| 173 | 172 |
| 174 } // namespace content | 173 } // namespace content |
| OLD | NEW |