wfh | 22e2f4a2 | 2015-04-28 22:39:21 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "chrome/browser/chrome_child_process_watcher.h" |
| 6 | |
| 7 | #include "base/command_line.h" |
| 8 | #include "base/metrics/histogram.h" |
| 9 | #include "chrome/common/chrome_result_codes.h" |
| 10 | #include "chrome/common/chrome_switches.h" |
| 11 | #include "content/public/browser/browser_child_process_observer.h" |
| 12 | #include "content/public/browser/child_process_data.h" |
| 13 | |
| 14 | namespace { |
| 15 | |
| 16 | void AnalyzeCrash(int exit_code) { |
| 17 | if (exit_code == chrome::RESULT_CODE_INVALID_SANDBOX_STATE) { |
| 18 | base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 19 | const bool no_startup_window = |
| 20 | command_line->HasSwitch(switches::kNoStartupWindow); |
| 21 | UMA_HISTOGRAM_BOOLEAN( |
| 22 | "ChildProcess.InvalidSandboxStateCrash.NoStartupWindow", |
| 23 | no_startup_window); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | } // namespace |
| 28 | |
| 29 | ChromeChildProcessWatcher::ChromeChildProcessWatcher() { |
| 30 | BrowserChildProcessObserver::Add(this); |
| 31 | } |
| 32 | |
| 33 | ChromeChildProcessWatcher::~ChromeChildProcessWatcher() { |
| 34 | BrowserChildProcessObserver::Remove(this); |
| 35 | } |
| 36 | |
| 37 | void ChromeChildProcessWatcher::BrowserChildProcessCrashed( |
| 38 | const content::ChildProcessData& data, |
| 39 | int exit_code) { |
| 40 | AnalyzeCrash(exit_code); |
| 41 | } |