summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chrome_child_process_watcher.cc
blob: 77367e945a3c69932e0c6b79257d606e7dc1ed78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/chrome_child_process_watcher.h"

#include "base/command_line.h"
#include "base/metrics/histogram.h"
#include "chrome/common/chrome_result_codes.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/browser_child_process_observer.h"
#include "content/public/browser/child_process_data.h"

namespace {

void AnalyzeCrash(int exit_code) {
  if (exit_code == chrome::RESULT_CODE_INVALID_SANDBOX_STATE) {
    base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
    const bool no_startup_window =
        command_line->HasSwitch(switches::kNoStartupWindow);
    UMA_HISTOGRAM_BOOLEAN(
        "ChildProcess.InvalidSandboxStateCrash.NoStartupWindow",
        no_startup_window);
  }
}

}  // namespace

ChromeChildProcessWatcher::ChromeChildProcessWatcher() {
  BrowserChildProcessObserver::Add(this);
}

ChromeChildProcessWatcher::~ChromeChildProcessWatcher() {
  BrowserChildProcessObserver::Remove(this);
}

void ChromeChildProcessWatcher::BrowserChildProcessCrashed(
    const content::ChildProcessData& data,
    int exit_code) {
  AnalyzeCrash(exit_code);
}