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.
5 #ifndef CONTENT_BROWSER_BAD_MESSAGE_H_
6 #define CONTENT_BROWSER_BAD_MESSAGE_H_
9 class BrowserMessageFilter
;
10 class RenderProcessHost
;
12 namespace bad_message
{
14 // The browser process often chooses to terminate a renderer if it receives
15 // a bad IPC message. The reasons are tracked for metrics.
17 // Content embedders should implement their own bad message statistics but
18 // should use similar histogram names to make analysis easier.
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
22 // values in histograms.
23 enum BadMessageReason
{
24 NC_IN_PAGE_NAVIGATION
= 0,
25 RFH_CAN_COMMIT_URL_BLOCKED
= 1,
26 RFH_CAN_ACCESS_FILES_OF_PAGE_STATE
= 2,
27 RFH_SANDBOX_FLAGS
= 3,
28 RFH_NO_PROXY_TO_PARENT
= 4,
29 RPH_DESERIALIZATION_FAILED
= 5,
30 RVH_CAN_ACCESS_FILES_OF_PAGE_STATE
= 6,
31 RVH_FILE_CHOOSER_PATH
= 7,
32 RWH_SYNTHETIC_GESTURE
= 8,
35 RWH_SHARED_BITMAP
= 11,
36 RWH_BAD_ACK_MESSAGE
= 12,
37 RWHVA_SHARED_MEMORY
= 13,
38 SERVICE_WORKER_BAD_URL
= 14,
39 WC_INVALID_FRAME_SOURCE
= 15,
40 RWHVM_UNEXPECTED_FRAME_TYPE
= 16,
42 DFH_BAD_EMBEDDER_MESSAGE
= 18,
43 NC_AUTO_SUBFRAME
= 19,
44 CSDH_NOT_RECOGNIZED
= 20,
45 DSMF_OPEN_STORAGE
= 21,
46 DSMF_LOAD_STORAGE
= 22,
47 DBMF_INVALID_ORIGIN_ON_OPEN
= 23,
48 DBMF_DB_NOT_OPEN_ON_MODIFY
= 24,
49 DBMF_DB_NOT_OPEN_ON_CLOSE
= 25,
50 DBMF_INVALID_ORIGIN_ON_SQLITE_ERROR
= 26,
51 RDH_INVALID_PRIORITY
= 27,
52 RDH_REQUEST_NOT_TRANSFERRING
= 28,
53 RDH_BAD_DOWNLOAD
= 29,
54 NMF_NO_PERMISSION_SHOW
= 30,
55 NMF_NO_PERMISSION_CLOSE
= 31,
56 NMF_NO_PERMISSION_VERIFY
= 32,
57 MH_INVALID_MIDI_PORT
= 33,
58 MH_SYS_EX_PERMISSION
= 34,
61 ACDH_SET_SPAWNING
= 37,
62 ACDH_SELECT_CACHE
= 38,
63 ACDH_SELECT_CACHE_FOR_WORKER
= 39,
64 ACDH_SELECT_CACHE_FOR_SHARED_WORKER
= 40,
65 ACDH_MARK_AS_FOREIGN_ENTRY
= 41,
66 ACDH_PENDING_REPLY_IN_GET_STATUS
= 42,
68 ACDH_PENDING_REPLY_IN_START_UPDATE
= 44,
69 ACDH_START_UPDATE
= 45,
70 ACDH_PENDING_REPLY_IN_SWAP_CACHE
= 46,
72 SWDH_NOT_HANDLED
= 48,
73 SWDH_REGISTER_BAD_URL
= 49,
74 SWDH_REGISTER_NO_HOST
= 50,
75 SWDH_REGISTER_CANNOT
= 51,
76 SWDH_UNREGISTER_BAD_URL
= 52,
77 SWDH_UNREGISTER_NO_HOST
= 53,
78 SWDH_UNREGISTER_CANNOT
= 54,
79 SWDH_GET_REGISTRATION_BAD_URL
= 55,
80 SWDH_GET_REGISTRATION_NO_HOST
= 56,
81 SWDH_GET_REGISTRATION_CANNOT
= 57,
82 SWDH_GET_REGISTRATION_FOR_READY_NO_HOST
= 58,
83 SWDH_GET_REGISTRATION_FOR_READY_ALREADY_IN_PROGRESS
= 59,
84 SWDH_POST_MESSAGE
= 60,
85 SWDH_PROVIDER_CREATED_NO_HOST
= 61,
86 SWDH_PROVIDER_DESTROYED_NO_HOST
= 62,
87 SWDH_SET_HOSTED_VERSION_NO_HOST
= 63,
88 SWDH_SET_HOSTED_VERSION
= 64,
89 SWDH_WORKER_SCRIPT_LOAD_NO_HOST
= 65,
90 SWDH_INCREMENT_WORKER_BAD_HANDLE
= 66,
91 SWDH_DECREMENT_WORKER_BAD_HANDLE
= 67,
92 SWDH_INCREMENT_REGISTRATION_BAD_HANDLE
= 68,
93 SWDH_DECREMENT_REGISTRATION_BAD_HANDLE
= 69,
94 SWDH_TERMINATE_BAD_HANDLE
= 70,
95 FAMF_APPEND_ITEM_TO_BLOB
= 71,
96 FAMF_APPEND_SHARED_MEMORY_TO_BLOB
= 72,
97 FAMF_MALFORMED_STREAM_URL
= 73,
98 FAMF_APPEND_ITEM_TO_STREAM
= 74,
99 FAMF_APPEND_SHARED_MEMORY_TO_STREAM
= 75,
100 IDBDH_CAN_READ_FILE
= 76,
101 IDBDH_GET_OR_TERMINATE
= 77,
102 RMF_SET_COOKIE_BAD_ORIGIN
= 78,
103 RMF_GET_COOKIES_BAD_ORIGIN
= 79,
104 SWDH_GET_REGISTRATIONS_NO_HOST
= 80,
105 SWDH_GET_REGISTRATIONS_INVALID_ORIGIN
= 81,
106 ARH_UNAUTHORIZED_URL
= 82,
107 BDH_INVALID_SERVICE_ID
= 83,
108 RFH_COMMIT_DESERIALIZATION_FAILED
= 84,
109 BDH_INVALID_CHARACTERISTIC_ID
= 85,
110 SWDH_UPDATE_NO_HOST
= 86,
111 SWDH_UPDATE_BAD_REGISTRATION_ID
= 87,
112 SWDH_UPDATE_CANNOT
= 88,
113 SWDH_UNREGISTER_BAD_REGISTRATION_ID
= 89,
114 BDH_INVALID_WRITE_VALUE_LENGTH
= 90,
115 WC_MEMORY_CACHE_RESOURCE_BAD_SECURITY_INFO
= 91,
116 WC_RENDERER_DID_NAVIGATE_BAD_SECURITY_INFO
= 92,
117 BDH_DUPLICATE_REQUEST_DEVICE_ID
= 93,
119 // Please add new elements here. The naming convention is abbreviated class
120 // name (e.g. RenderFrameHost becomes RFH) plus a unique description of the
121 // reason. After making changes, you MUST update histograms.xml by running:
122 // "python tools/metrics/histograms/update_bad_message_reasons.py"
126 // Called when the browser receives a bad IPC message from a renderer process on
127 // the UI thread. Logs the event, records a histogram metric for the |reason|,
128 // and terminates the process for |host|.
129 void ReceivedBadMessage(RenderProcessHost
* host
, BadMessageReason reason
);
131 // Called when a browser message filter receives a bad IPC message from a
132 // renderer or other child process. Logs the event, records a histogram metric
133 // for the |reason|, and terminates the process for |filter|.
134 void ReceivedBadMessage(BrowserMessageFilter
* filter
, BadMessageReason reason
);
136 } // namespace bad_message
137 } // namespace content
139 #endif // CONTENT_BROWSER_BAD_MESSAGE_H_