OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/browser_child_process_host.h" | 5 #include "chrome/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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 void BrowserChildProcessHost::ForceShutdown() { | 134 void BrowserChildProcessHost::ForceShutdown() { |
135 g_child_process_list.Get().remove(this); | 135 g_child_process_list.Get().remove(this); |
136 ChildProcessHost::ForceShutdown(); | 136 ChildProcessHost::ForceShutdown(); |
137 } | 137 } |
138 | 138 |
139 void BrowserChildProcessHost::Notify(NotificationType type) { | 139 void BrowserChildProcessHost::Notify(NotificationType type) { |
140 BrowserThread::PostTask( | 140 BrowserThread::PostTask( |
141 BrowserThread::UI, FROM_HERE, new ChildNotificationTask(type, this)); | 141 BrowserThread::UI, FROM_HERE, new ChildNotificationTask(type, this)); |
142 } | 142 } |
143 | 143 |
144 bool BrowserChildProcessHost::DidChildCrash() { | 144 base::TerminationStatus BrowserChildProcessHost::GetChildTerminationStatus( |
145 return child_process_->DidProcessCrash(); | 145 int* exit_code) { |
| 146 return child_process_->GetChildTerminationStatus(exit_code); |
146 } | 147 } |
147 | 148 |
148 void BrowserChildProcessHost::OnChildDied() { | 149 void BrowserChildProcessHost::OnChildDied() { |
149 if (handle() != base::kNullProcessHandle) { | 150 if (handle() != base::kNullProcessHandle) { |
150 bool did_crash = DidChildCrash(); | 151 int exit_code; |
151 if (did_crash) { | 152 base::TerminationStatus status = GetChildTerminationStatus(&exit_code); |
152 OnProcessCrashed(); | 153 switch (status) { |
153 // Report that this child process crashed. | 154 case base::TERMINATION_STATUS_PROCESS_CRASHED: { |
154 Notify(NotificationType::CHILD_PROCESS_CRASHED); | 155 OnProcessCrashed(exit_code); |
155 UMA_HISTOGRAM_COUNTS("ChildProcess.Crashes", this->type()); | 156 |
| 157 // Report that this child process crashed. |
| 158 Notify(NotificationType::CHILD_PROCESS_CRASHED); |
| 159 UMA_HISTOGRAM_COUNTS("ChildProcess.Crashes", this->type()); |
| 160 break; |
| 161 } |
| 162 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: { |
| 163 OnProcessWasKilled(exit_code); |
| 164 |
| 165 // Report that this child process was killed. |
| 166 Notify(NotificationType::CHILD_PROCESS_WAS_KILLED); |
| 167 UMA_HISTOGRAM_COUNTS("ChildProcess.Kills", this->type()); |
| 168 break; |
| 169 } |
| 170 default: |
| 171 break; |
156 } | 172 } |
157 // Notify in the main loop of the disconnection. | 173 // Notify in the main loop of the disconnection. |
158 Notify(NotificationType::CHILD_PROCESS_HOST_DISCONNECTED); | 174 Notify(NotificationType::CHILD_PROCESS_HOST_DISCONNECTED); |
159 } | 175 } |
160 ChildProcessHost::OnChildDied(); | 176 ChildProcessHost::OnChildDied(); |
161 } | 177 } |
162 | 178 |
163 bool BrowserChildProcessHost::InterceptMessageFromChild( | 179 bool BrowserChildProcessHost::InterceptMessageFromChild( |
164 const IPC::Message& msg) { | 180 const IPC::Message& msg) { |
165 bool msg_is_ok = true; | 181 bool msg_is_ok = true; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 234 |
219 return *iterator_; | 235 return *iterator_; |
220 } while (true); | 236 } while (true); |
221 | 237 |
222 return NULL; | 238 return NULL; |
223 } | 239 } |
224 | 240 |
225 bool BrowserChildProcessHost::Iterator::Done() { | 241 bool BrowserChildProcessHost::Iterator::Done() { |
226 return iterator_ == g_child_process_list.Get().end(); | 242 return iterator_ == g_child_process_list.Get().end(); |
227 } | 243 } |
OLD | NEW |