| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 void BrowserChildProcessHostImpl::OnChannelError() { | 253 void BrowserChildProcessHostImpl::OnChannelError() { |
| 254 delegate_->OnChannelError(); | 254 delegate_->OnChannelError(); |
| 255 } | 255 } |
| 256 | 256 |
| 257 bool BrowserChildProcessHostImpl::CanShutdown() { | 257 bool BrowserChildProcessHostImpl::CanShutdown() { |
| 258 return delegate_->CanShutdown(); | 258 return delegate_->CanShutdown(); |
| 259 } | 259 } |
| 260 | 260 |
| 261 void BrowserChildProcessHostImpl::OnChildDisconnected() { | 261 void BrowserChildProcessHostImpl::OnChildDisconnected() { |
| 262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 263 DCHECK(data_.handle != base::kNullProcessHandle); | 263 if (child_process_.get() || data_.handle) { |
| 264 int exit_code; | 264 DCHECK(data_.handle != base::kNullProcessHandle); |
| 265 base::TerminationStatus status = GetTerminationStatus(&exit_code); | 265 int exit_code; |
| 266 switch (status) { | 266 base::TerminationStatus status = GetTerminationStatus(&exit_code); |
| 267 case base::TERMINATION_STATUS_PROCESS_CRASHED: | 267 switch (status) { |
| 268 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: { | 268 case base::TERMINATION_STATUS_PROCESS_CRASHED: |
| 269 delegate_->OnProcessCrashed(exit_code); | 269 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: { |
| 270 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 270 delegate_->OnProcessCrashed(exit_code); |
| 271 base::Bind(&NotifyProcessCrashed, data_)); | 271 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 272 UMA_HISTOGRAM_ENUMERATION("ChildProcess.Crashed2", | 272 base::Bind(&NotifyProcessCrashed, data_)); |
| 273 data_.process_type, | 273 UMA_HISTOGRAM_ENUMERATION("ChildProcess.Crashed2", |
| 274 PROCESS_TYPE_MAX); | 274 data_.process_type, |
| 275 break; | 275 PROCESS_TYPE_MAX); |
| 276 break; |
| 277 } |
| 278 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: { |
| 279 delegate_->OnProcessCrashed(exit_code); |
| 280 // Report that this child process was killed. |
| 281 UMA_HISTOGRAM_ENUMERATION("ChildProcess.Killed2", |
| 282 data_.process_type, |
| 283 PROCESS_TYPE_MAX); |
| 284 break; |
| 285 } |
| 286 case base::TERMINATION_STATUS_STILL_RUNNING: { |
| 287 UMA_HISTOGRAM_ENUMERATION("ChildProcess.DisconnectedAlive2", |
| 288 data_.process_type, |
| 289 PROCESS_TYPE_MAX); |
| 290 } |
| 291 default: |
| 292 break; |
| 276 } | 293 } |
| 277 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: { | 294 UMA_HISTOGRAM_ENUMERATION("ChildProcess.Disconnected2", |
| 278 delegate_->OnProcessCrashed(exit_code); | 295 data_.process_type, |
| 279 // Report that this child process was killed. | 296 PROCESS_TYPE_MAX); |
| 280 UMA_HISTOGRAM_ENUMERATION("ChildProcess.Killed2", | |
| 281 data_.process_type, | |
| 282 PROCESS_TYPE_MAX); | |
| 283 break; | |
| 284 } | |
| 285 case base::TERMINATION_STATUS_STILL_RUNNING: { | |
| 286 UMA_HISTOGRAM_ENUMERATION("ChildProcess.DisconnectedAlive2", | |
| 287 data_.process_type, | |
| 288 PROCESS_TYPE_MAX); | |
| 289 } | |
| 290 default: | |
| 291 break; | |
| 292 } | 297 } |
| 293 UMA_HISTOGRAM_ENUMERATION("ChildProcess.Disconnected2", | |
| 294 data_.process_type, | |
| 295 PROCESS_TYPE_MAX); | |
| 296 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 298 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 297 base::Bind(&NotifyProcessHostDisconnected, data_)); | 299 base::Bind(&NotifyProcessHostDisconnected, data_)); |
| 298 delete delegate_; // Will delete us | 300 delete delegate_; // Will delete us |
| 299 } | 301 } |
| 300 | 302 |
| 301 bool BrowserChildProcessHostImpl::Send(IPC::Message* message) { | 303 bool BrowserChildProcessHostImpl::Send(IPC::Message* message) { |
| 302 return child_process_host_->Send(message); | 304 return child_process_host_->Send(message); |
| 303 } | 305 } |
| 304 | 306 |
| 305 void BrowserChildProcessHostImpl::OnProcessLaunched() { | 307 void BrowserChildProcessHostImpl::OnProcessLaunched() { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 343 |
| 342 void BrowserChildProcessHostImpl::OnProcessExitedEarly( | 344 void BrowserChildProcessHostImpl::OnProcessExitedEarly( |
| 343 base::WaitableEvent* event) { | 345 base::WaitableEvent* event) { |
| 344 DeleteProcessWaitableEvent(event); | 346 DeleteProcessWaitableEvent(event); |
| 345 OnChildDisconnected(); | 347 OnChildDisconnected(); |
| 346 } | 348 } |
| 347 | 349 |
| 348 #endif | 350 #endif |
| 349 | 351 |
| 350 } // namespace content | 352 } // namespace content |
| OLD | NEW |