blob: 10a5dd8206c716e6ef4b6e9d5bfd4653731695b1 [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,
Mario Sanchez Pradafe81d6c2019-12-16 11:25:0527 RFH_INVALID_WEB_UI_CONTROLLER = 3,
nick16794822015-06-02 23:23:3128
29 // Please add new elements here. The naming convention is abbreviated class
30 // name (e.g. RenderFrameHost becomes RFH) plus a unique description of the
nickd8ec87b2015-07-17 00:42:5231 // reason. After making changes, you MUST update histograms.xml by running:
32 // "python tools/metrics/histograms/update_bad_message_reasons.py"
nick16794822015-06-02 23:23:3133 BAD_MESSAGE_MAX
34};
35
36// Called when the browser receives a bad IPC message from a renderer process on
37// the UI thread. Logs the event, records a histogram metric for the |reason|,
38// and terminates the process for |host|.
39void ReceivedBadMessage(content::RenderProcessHost* host,
40 BadMessageReason reason);
41
42// Called when a browser message filter receives a bad IPC message from a
43// renderer or other child process. Logs the event, records a histogram metric
44// for the |reason|, and terminates the process for |filter|.
45void ReceivedBadMessage(content::BrowserMessageFilter* filter,
46 BadMessageReason reason);
47
48} // namespace bad_message
49
50#endif // CHROME_BROWSER_BAD_MESSAGE_H_