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" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
18 #include "content/browser/histogram_message_filter.h" | 18 #include "content/browser/histogram_message_filter.h" |
19 #include "content/browser/loader/resource_message_filter.h" | 19 #include "content/browser/loader/resource_message_filter.h" |
20 #include "content/browser/profiler_message_filter.h" | 20 #include "content/browser/profiler_message_filter.h" |
21 #include "content/browser/tracing/trace_message_filter.h" | 21 #include "content/browser/tracing/trace_message_filter.h" |
22 #include "content/common/child_process_host_impl.h" | 22 #include "content/common/child_process_host_impl.h" |
23 #include "content/public/browser/browser_child_process_host_delegate.h" | 23 #include "content/public/browser/browser_child_process_host_delegate.h" |
24 #include "content/public/browser/browser_child_process_observer.h" | 24 #include "content/public/browser/browser_child_process_observer.h" |
25 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
26 #include "content/public/browser/child_process_data.h" | 26 #include "content/public/browser/child_process_data.h" |
27 #include "content/public/browser/content_browser_client.h" | 27 #include "content/public/browser/content_browser_client.h" |
28 #include "content/public/browser/user_metrics.h" | |
28 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
29 #include "content/public/common/process_type.h" | 30 #include "content/public/common/process_type.h" |
30 #include "content/public/common/result_codes.h" | 31 #include "content/public/common/result_codes.h" |
31 | 32 |
32 #if defined(OS_MACOSX) | 33 #if defined(OS_MACOSX) |
33 #include "content/browser/mach_broker_mac.h" | 34 #include "content/browser/mach_broker_mac.h" |
34 #endif | 35 #endif |
35 | 36 |
36 namespace content { | 37 namespace content { |
37 namespace { | 38 namespace { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 246 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
246 base::Bind(&NotifyProcessHostConnected, data_)); | 247 base::Bind(&NotifyProcessHostConnected, data_)); |
247 | 248 |
248 delegate_->OnChannelConnected(peer_pid); | 249 delegate_->OnChannelConnected(peer_pid); |
249 } | 250 } |
250 | 251 |
251 void BrowserChildProcessHostImpl::OnChannelError() { | 252 void BrowserChildProcessHostImpl::OnChannelError() { |
252 delegate_->OnChannelError(); | 253 delegate_->OnChannelError(); |
253 } | 254 } |
254 | 255 |
256 void BrowserChildProcessHostImpl::OnBadMessageReceived( | |
257 const IPC::Message& message) { | |
258 std::string action_name = std::string("BadMessageTerminate_") + | |
259 GetProcessTypeNameInEnglish(data_.process_type); | |
260 // The English name of a process type sometimes has spaces. Remove them since | |
Tom Sepez
2014/05/15 19:57:42
Maybe we want to add GetProcessTypeNameForUMA() ra
jam
2014/05/15 21:19:34
i prefer not adding yet another way of getting a n
| |
261 // UMA action names don't contain whitespaces. | |
262 base::RemoveChars(action_name, " ", &action_name); | |
263 RecordAction(base::UserMetricsAction(action_name.c_str())); | |
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 |