| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/browser_child_process_host_impl.h" | 5 #include "content/browser/browser_child_process_host_impl.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 const ChildProcessData& BrowserChildProcessHostImpl::GetData() const { | 157 const ChildProcessData& BrowserChildProcessHostImpl::GetData() const { |
| 158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 159 return data_; | 159 return data_; |
| 160 } | 160 } |
| 161 | 161 |
| 162 ChildProcessHost* BrowserChildProcessHostImpl::GetHost() const { | 162 ChildProcessHost* BrowserChildProcessHostImpl::GetHost() const { |
| 163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 164 return child_process_host_.get(); | 164 return child_process_host_.get(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 base::ProcessHandle BrowserChildProcessHostImpl::GetHandle() const { | 167 const base::Process& BrowserChildProcessHostImpl::GetProcess() const { |
| 168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 169 DCHECK(child_process_.get()) | 169 DCHECK(child_process_.get()) |
| 170 << "Requesting a child process handle before launching."; | 170 << "Requesting a child process handle before launching."; |
| 171 DCHECK(child_process_->GetProcess().IsValid()) | 171 DCHECK(child_process_->GetProcess().IsValid()) |
| 172 << "Requesting a child process handle before launch has completed OK."; | 172 << "Requesting a child process handle before launch has completed OK."; |
| 173 return child_process_->GetProcess().Handle(); | 173 return child_process_->GetProcess(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void BrowserChildProcessHostImpl::SetName(const base::string16& name) { | 176 void BrowserChildProcessHostImpl::SetName(const base::string16& name) { |
| 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 178 data_.name = name; | 178 data_.name = name; |
| 179 } | 179 } |
| 180 | 180 |
| 181 void BrowserChildProcessHostImpl::SetHandle(base::ProcessHandle handle) { | 181 void BrowserChildProcessHostImpl::SetHandle(base::ProcessHandle handle) { |
| 182 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 182 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 183 data_.handle = handle; | 183 data_.handle = handle; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 delegate_->OnChannelError(); | 248 delegate_->OnChannelError(); |
| 249 } | 249 } |
| 250 | 250 |
| 251 void BrowserChildProcessHostImpl::OnBadMessageReceived( | 251 void BrowserChildProcessHostImpl::OnBadMessageReceived( |
| 252 const IPC::Message& message) { | 252 const IPC::Message& message) { |
| 253 HistogramBadMessageTerminated(data_.process_type); | 253 HistogramBadMessageTerminated(data_.process_type); |
| 254 if (CommandLine::ForCurrentProcess()->HasSwitch( | 254 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 255 switches::kDisableKillAfterBadIPC)) { | 255 switches::kDisableKillAfterBadIPC)) { |
| 256 return; | 256 return; |
| 257 } | 257 } |
| 258 base::KillProcess(GetHandle(), RESULT_CODE_KILLED_BAD_MESSAGE, false); | 258 base::KillProcess(child_process_->GetProcess().Handle(), |
| 259 RESULT_CODE_KILLED_BAD_MESSAGE, false); |
| 259 } | 260 } |
| 260 | 261 |
| 261 bool BrowserChildProcessHostImpl::CanShutdown() { | 262 bool BrowserChildProcessHostImpl::CanShutdown() { |
| 262 return delegate_->CanShutdown(); | 263 return delegate_->CanShutdown(); |
| 263 } | 264 } |
| 264 | 265 |
| 265 void BrowserChildProcessHostImpl::OnChildDisconnected() { | 266 void BrowserChildProcessHostImpl::OnChildDisconnected() { |
| 266 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 267 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 267 #if defined(OS_WIN) | 268 #if defined(OS_WIN) |
| 268 // OnChildDisconnected may be called without OnChannelConnected, so stop the | 269 // OnChildDisconnected may be called without OnChannelConnected, so stop the |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 339 |
| 339 #if defined(OS_WIN) | 340 #if defined(OS_WIN) |
| 340 | 341 |
| 341 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { | 342 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { |
| 342 OnChildDisconnected(); | 343 OnChildDisconnected(); |
| 343 } | 344 } |
| 344 | 345 |
| 345 #endif | 346 #endif |
| 346 | 347 |
| 347 } // namespace content | 348 } // namespace content |
| OLD | NEW |