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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 void BrowserChildProcessHost::ForceShutdown() { | 132 void BrowserChildProcessHost::ForceShutdown() { |
133 Singleton<ChildProcessList>::get()->remove(this); | 133 Singleton<ChildProcessList>::get()->remove(this); |
134 ChildProcessHost::ForceShutdown(); | 134 ChildProcessHost::ForceShutdown(); |
135 } | 135 } |
136 | 136 |
137 void BrowserChildProcessHost::Notify(NotificationType type) { | 137 void BrowserChildProcessHost::Notify(NotificationType type) { |
138 BrowserThread::PostTask( | 138 BrowserThread::PostTask( |
139 BrowserThread::UI, FROM_HERE, new ChildNotificationTask(type, this)); | 139 BrowserThread::UI, FROM_HERE, new ChildNotificationTask(type, this)); |
140 } | 140 } |
141 | 141 |
142 bool BrowserChildProcessHost::DidChildCrash() { | 142 base::TerminationStatus BrowserChildProcessHost::GetChildTerminationStatus( |
143 return child_process_->DidProcessCrash(); | 143 int* exit_code) { |
144 return child_process_->GetChildTerminationStatus(exit_code); | |
144 } | 145 } |
145 | 146 |
146 void BrowserChildProcessHost::OnChildDied() { | 147 void BrowserChildProcessHost::OnChildDied() { |
147 if (handle() != base::kNullProcessHandle) { | 148 if (handle() != base::kNullProcessHandle) { |
148 bool did_crash = DidChildCrash(); | 149 int exit_code; |
149 if (did_crash) { | 150 base::TerminationStatus status = GetChildTerminationStatus(&exit_code); |
150 OnProcessCrashed(); | 151 switch (status) { |
brettw
2010/12/03 01:01:54
Random suggestion: I would probably write
switch
| |
151 // Report that this child process crashed. | 152 case base::TERMINATION_STATUS_PROCESS_CRASHED: { |
152 Notify(NotificationType::CHILD_PROCESS_CRASHED); | 153 OnProcessCrashed(exit_code); |
153 UMA_HISTOGRAM_COUNTS("ChildProcess.Crashes", this->type()); | 154 |
155 // Report that this child process crashed. | |
156 Notify(NotificationType::CHILD_PROCESS_CRASHED); | |
157 UMA_HISTOGRAM_COUNTS("ChildProcess.Crashes", this->type()); | |
158 break; | |
159 } | |
160 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: { | |
161 OnProcessWasKilled(exit_code); | |
162 | |
163 // Report that this child process was killed. | |
164 Notify(NotificationType::CHILD_PROCESS_WAS_KILLED); | |
165 UMA_HISTOGRAM_COUNTS("ChildProcess.Kills", this->type()); | |
166 break; | |
167 } | |
168 default: | |
169 break; | |
154 } | 170 } |
155 // Notify in the main loop of the disconnection. | 171 // Notify in the main loop of the disconnection. |
156 Notify(NotificationType::CHILD_PROCESS_HOST_DISCONNECTED); | 172 Notify(NotificationType::CHILD_PROCESS_HOST_DISCONNECTED); |
157 } | 173 } |
158 ChildProcessHost::OnChildDied(); | 174 ChildProcessHost::OnChildDied(); |
159 } | 175 } |
160 | 176 |
161 bool BrowserChildProcessHost::InterceptMessageFromChild( | 177 bool BrowserChildProcessHost::InterceptMessageFromChild( |
162 const IPC::Message& msg) { | 178 const IPC::Message& msg) { |
163 bool msg_is_ok = true; | 179 bool msg_is_ok = true; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 | 232 |
217 return *iterator_; | 233 return *iterator_; |
218 } while (true); | 234 } while (true); |
219 | 235 |
220 return NULL; | 236 return NULL; |
221 } | 237 } |
222 | 238 |
223 bool BrowserChildProcessHost::Iterator::Done() { | 239 bool BrowserChildProcessHost::Iterator::Done() { |
224 return iterator_ == Singleton<ChildProcessList>::get()->end(); | 240 return iterator_ == Singleton<ChildProcessList>::get()->end(); |
225 } | 241 } |
OLD | NEW |