| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 child_process_host_->AddFilter(filter->GetFilter()); | 212 child_process_host_->AddFilter(filter->GetFilter()); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void BrowserChildProcessHostImpl::NotifyProcessInstanceCreated( | 215 void BrowserChildProcessHostImpl::NotifyProcessInstanceCreated( |
| 216 const ChildProcessData& data) { | 216 const ChildProcessData& data) { |
| 217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 218 FOR_EACH_OBSERVER(BrowserChildProcessObserver, g_observers.Get(), | 218 FOR_EACH_OBSERVER(BrowserChildProcessObserver, g_observers.Get(), |
| 219 BrowserChildProcessInstanceCreated(data)); | 219 BrowserChildProcessInstanceCreated(data)); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void BrowserChildProcessHostImpl::HistogramBadMessageTerminated( |
| 223 int process_type) { |
| 224 UMA_HISTOGRAM_ENUMERATION("ChildProcess.BadMessgeTerminated", process_type, |
| 225 PROCESS_TYPE_MAX); |
| 226 } |
| 227 |
| 222 base::TerminationStatus BrowserChildProcessHostImpl::GetTerminationStatus( | 228 base::TerminationStatus BrowserChildProcessHostImpl::GetTerminationStatus( |
| 223 bool known_dead, int* exit_code) { | 229 bool known_dead, int* exit_code) { |
| 224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 230 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 225 if (!child_process_) // If the delegate doesn't use Launch() helper. | 231 if (!child_process_) // If the delegate doesn't use Launch() helper. |
| 226 return base::GetTerminationStatus(data_.handle, exit_code); | 232 return base::GetTerminationStatus(data_.handle, exit_code); |
| 227 return child_process_->GetChildTerminationStatus(known_dead, | 233 return child_process_->GetChildTerminationStatus(known_dead, |
| 228 exit_code); | 234 exit_code); |
| 229 } | 235 } |
| 230 | 236 |
| 231 bool BrowserChildProcessHostImpl::OnMessageReceived( | 237 bool BrowserChildProcessHostImpl::OnMessageReceived( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 245 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 251 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 246 base::Bind(&NotifyProcessHostConnected, data_)); | 252 base::Bind(&NotifyProcessHostConnected, data_)); |
| 247 | 253 |
| 248 delegate_->OnChannelConnected(peer_pid); | 254 delegate_->OnChannelConnected(peer_pid); |
| 249 } | 255 } |
| 250 | 256 |
| 251 void BrowserChildProcessHostImpl::OnChannelError() { | 257 void BrowserChildProcessHostImpl::OnChannelError() { |
| 252 delegate_->OnChannelError(); | 258 delegate_->OnChannelError(); |
| 253 } | 259 } |
| 254 | 260 |
| 261 void BrowserChildProcessHostImpl::OnBadMessageReceived( |
| 262 const IPC::Message& message) { |
| 263 HistogramBadMessageTerminated(data_.process_type); |
| 264 base::KillProcess(GetHandle(), RESULT_CODE_KILLED_BAD_MESSAGE, false); |
| 265 } |
| 266 |
| 255 bool BrowserChildProcessHostImpl::CanShutdown() { | 267 bool BrowserChildProcessHostImpl::CanShutdown() { |
| 256 return delegate_->CanShutdown(); | 268 return delegate_->CanShutdown(); |
| 257 } | 269 } |
| 258 | 270 |
| 259 void BrowserChildProcessHostImpl::OnChildDisconnected() { | 271 void BrowserChildProcessHostImpl::OnChildDisconnected() { |
| 260 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 261 if (child_process_.get() || data_.handle) { | 273 if (child_process_.get() || data_.handle) { |
| 262 DCHECK(data_.handle != base::kNullProcessHandle); | 274 DCHECK(data_.handle != base::kNullProcessHandle); |
| 263 int exit_code; | 275 int exit_code; |
| 264 base::TerminationStatus status = GetTerminationStatus( | 276 base::TerminationStatus status = GetTerminationStatus( |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 | 359 |
| 348 void BrowserChildProcessHostImpl::OnProcessExitedEarly( | 360 void BrowserChildProcessHostImpl::OnProcessExitedEarly( |
| 349 base::WaitableEvent* event) { | 361 base::WaitableEvent* event) { |
| 350 DeleteProcessWaitableEvent(event); | 362 DeleteProcessWaitableEvent(event); |
| 351 OnChildDisconnected(); | 363 OnChildDisconnected(); |
| 352 } | 364 } |
| 353 | 365 |
| 354 #endif | 366 #endif |
| 355 | 367 |
| 356 } // namespace content | 368 } // namespace content |
| OLD | NEW |