bad_message.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2017 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. #ifndef COMPONENTS_GUEST_VIEW_BROWSER_BAD_MESSAGE_H_
  5. #define COMPONENTS_GUEST_VIEW_BROWSER_BAD_MESSAGE_H_
  6. namespace content {
  7. class RenderProcessHost;
  8. } // namespace content
  9. namespace guest_view {
  10. namespace bad_message {
  11. // The browser process often chooses to terminate a renderer if it receives
  12. // a bad IPC message. The reasons are tracked for metrics.
  13. //
  14. // See also content/browser/bad_message.h.
  15. //
  16. // NOTE: Do not remove or reorder elements in this list. Add new entries at the
  17. // end. Items may be renamed but do not change the values. We rely on the enum
  18. // values in histograms.
  19. enum BadMessageReason {
  20. GVM_EMBEDDER_FORBIDDEN_ACCESS_TO_GUEST = 0,
  21. GVM_INVALID_GUESTVIEW_TYPE = 1,
  22. GVMF_UNEXPECTED_MESSAGE_BEFORE_GVM_CREATION = 2,
  23. GVM_INVALID_ATTACH = 3,
  24. // Please add new elements here. The naming convention is abbreviated class
  25. // name (e.g. GuestViewManager becomes GVM) plus a unique description of
  26. // the reason. After making changes, you MUST update histograms.xml by
  27. // running:
  28. // "python tools/metrics/histograms/update_bad_message_reasons.py"
  29. BAD_MESSAGE_MAX
  30. };
  31. // Called when the browser receives a bad IPC message from a renderer.
  32. // Logs the event, records a histogram metric for the |reason|,
  33. // and terminates the process for |host| / |render_process_id|.
  34. void ReceivedBadMessage(content::RenderProcessHost* host,
  35. BadMessageReason reason);
  36. void ReceivedBadMessage(int render_process_id, BadMessageReason reason);
  37. } // namespace bad_message
  38. } // namespace guest_view
  39. #endif // COMPONENTS_GUEST_VIEW_BROWSER_BAD_MESSAGE_H_