| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser_child_process_host.h" | 5 #include "content/browser/browser_child_process_host.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 const FilePath& exposed_dir, | 76 const FilePath& exposed_dir, |
| 77 #elif defined(OS_POSIX) | 77 #elif defined(OS_POSIX) |
| 78 bool use_zygote, | 78 bool use_zygote, |
| 79 const base::environment_vector& environ, | 79 const base::environment_vector& environ, |
| 80 #endif | 80 #endif |
| 81 CommandLine* cmd_line) { | 81 CommandLine* cmd_line) { |
| 82 | 82 |
| 83 content::GetContentClient()->browser()->AppendExtraCommandLineSwitches( | 83 content::GetContentClient()->browser()->AppendExtraCommandLineSwitches( |
| 84 cmd_line, id()); | 84 cmd_line, id()); |
| 85 | 85 |
| 86 #if defined(OS_LINUX) | |
| 87 channel()->SetNeedsOverridePeerPid(); | |
| 88 #endif | |
| 89 | |
| 90 child_process_.reset(new ChildProcessLauncher( | 86 child_process_.reset(new ChildProcessLauncher( |
| 91 #if defined(OS_WIN) | 87 #if defined(OS_WIN) |
| 92 exposed_dir, | 88 exposed_dir, |
| 93 #elif defined(OS_POSIX) | 89 #elif defined(OS_POSIX) |
| 94 use_zygote, | 90 use_zygote, |
| 95 environ, | 91 environ, |
| 96 channel()->GetClientFileDescriptor(), | 92 channel()->GetClientFileDescriptor(), |
| 97 #endif | 93 #endif |
| 98 cmd_line, | 94 cmd_line, |
| 99 &client_)); | 95 &client_)); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 // Must remove the process from the list now, in case it gets used for a | 160 // Must remove the process from the list now, in case it gets used for a |
| 165 // new instance before our watcher tells us that the process terminated. | 161 // new instance before our watcher tells us that the process terminated. |
| 166 g_child_process_list.Get().remove(this); | 162 g_child_process_list.Get().remove(this); |
| 167 } | 163 } |
| 168 | 164 |
| 169 BrowserChildProcessHost::ClientHook::ClientHook(BrowserChildProcessHost* host) | 165 BrowserChildProcessHost::ClientHook::ClientHook(BrowserChildProcessHost* host) |
| 170 : host_(host) { | 166 : host_(host) { |
| 171 } | 167 } |
| 172 | 168 |
| 173 void BrowserChildProcessHost::ClientHook::OnProcessLaunched() { | 169 void BrowserChildProcessHost::ClientHook::OnProcessLaunched() { |
| 174 base::ProcessHandle child_handle = host_->child_process_->GetHandle(); | 170 if (!host_->child_process_->GetHandle()) { |
| 175 if (!child_handle) { | |
| 176 host_->OnChildDied(); | 171 host_->OnChildDied(); |
| 177 return; | 172 return; |
| 178 } | 173 } |
| 179 host_->set_handle(child_handle); | 174 host_->set_handle(host_->child_process_->GetHandle()); |
| 180 #if defined(OS_LINUX) | |
| 181 int32 child_pid = base::GetProcId(child_handle); | |
| 182 host_->channel()->OverridePeerPid(child_pid); | |
| 183 #endif | |
| 184 host_->OnProcessLaunched(); | 175 host_->OnProcessLaunched(); |
| 185 } | 176 } |
| 186 | 177 |
| 187 BrowserChildProcessHost::Iterator::Iterator() | 178 BrowserChildProcessHost::Iterator::Iterator() |
| 188 : all_(true), type_(UNKNOWN_PROCESS) { | 179 : all_(true), type_(UNKNOWN_PROCESS) { |
| 189 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)) << | 180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)) << |
| 190 "ChildProcessInfo::Iterator must be used on the IO thread."; | 181 "ChildProcessInfo::Iterator must be used on the IO thread."; |
| 191 iterator_ = g_child_process_list.Get().begin(); | 182 iterator_ = g_child_process_list.Get().begin(); |
| 192 } | 183 } |
| 193 | 184 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 211 | 202 |
| 212 return *iterator_; | 203 return *iterator_; |
| 213 } while (true); | 204 } while (true); |
| 214 | 205 |
| 215 return NULL; | 206 return NULL; |
| 216 } | 207 } |
| 217 | 208 |
| 218 bool BrowserChildProcessHost::Iterator::Done() { | 209 bool BrowserChildProcessHost::Iterator::Done() { |
| 219 return iterator_ == g_child_process_list.Get().end(); | 210 return iterator_ == g_child_process_list.Get().end(); |
| 220 } | 211 } |
| OLD | NEW |