blob: 96bed3f82d2df3d481d139227f59fb00ad8fead7 [file] [log] [blame]
nick16794822015-06-02 23:23:311// 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#ifndef CHROME_BROWSER_BAD_MESSAGE_H_
6#define CHROME_BROWSER_BAD_MESSAGE_H_
7
8namespace content {
9class BrowserMessageFilter;
10class RenderProcessHost;
11}
12
13namespace bad_message {
14
15// The browser process often chooses to terminate a renderer if it receives
16// a bad IPC message. The reasons are tracked for metrics.
17//
18// See also content/browser/bad_message.h.
19//
20// NOTE: Do not remove or reorder elements in this list. Add new entries at the
21// end. Items may be renamed but do not change the values. We rely on the enum
nickd8ec87b2015-07-17 00:42:5222// values in histograms.
nick16794822015-06-02 23:23:3123enum BadMessageReason {
24 WRLHH_LOGGING_STOPPED_BAD_STATE = 0,
Ryan Sturmd154e1e2019-06-01 01:18:5925 PPH_EXTRA_PREVIEW_MESSAGE = 1,
26 PMF_INVALID_INITIATOR_ORIGIN = 2,
nick16794822015-06-02 23:23:3127
28 // Please add new elements here. The naming convention is abbreviated class
29 // name (e.g. RenderFrameHost becomes RFH) plus a unique description of the
nickd8ec87b2015-07-17 00:42:5230 // reason. After making changes, you MUST update histograms.xml by running:
31 // "python tools/metrics/histograms/update_bad_message_reasons.py"
nick16794822015-06-02 23:23:3132 BAD_MESSAGE_MAX
33};
34
35// Called when the browser receives a bad IPC message from a renderer process on
36// the UI thread. Logs the event, records a histogram metric for the |reason|,
37// and terminates the process for |host|.
38void ReceivedBadMessage(content::RenderProcessHost* host,
39 BadMessageReason reason);
40
41// Called when a browser message filter receives a bad IPC message from a
42// renderer or other child process. Logs the event, records a histogram metric
43// for the |reason|, and terminates the process for |filter|.
44void ReceivedBadMessage(content::BrowserMessageFilter* filter,
45 BadMessageReason reason);
46
47} // namespace bad_message
48
49#endif // CHROME_BROWSER_BAD_MESSAGE_H_