[M120][Tizen][Onscreen] Fix build errors for TV profile
[platform/framework/web/chromium-efl.git] / chrome / browser / bad_message.cc
1 // Copyright 2015 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/bad_message.h"
6
7 #include "base/logging.h"
8 #include "base/metrics/histogram_functions.h"
9 #include "base/trace_event/trace_event.h"
10 #include "content/public/browser/browser_message_filter.h"
11 #include "content/public/browser/render_process_host.h"
12
13 namespace bad_message {
14
15 namespace {
16
17 void LogBadMessage(BadMessageReason reason) {
18   LOG(ERROR) << "Terminating renderer for bad IPC message, reason " << reason;
19   base::UmaHistogramSparse("Stability.BadMessageTerminated.Chrome", reason);
20 }
21
22 }  // namespace
23
24 void ReceivedBadMessage(content::RenderProcessHost* host,
25                         BadMessageReason reason) {
26   TRACE_EVENT_INSTANT2("ipc,security", "chrome::ReceivedBadMessage",
27                        TRACE_EVENT_SCOPE_THREAD, "reason", reason,
28                        "render_process_host", host);
29   LogBadMessage(reason);
30   host->ShutdownForBadMessage(
31       content::RenderProcessHost::CrashReportMode::GENERATE_CRASH_DUMP);
32 }
33
34 void ReceivedBadMessage(content::BrowserMessageFilter* filter,
35                         BadMessageReason reason) {
36   TRACE_EVENT_INSTANT1("ipc,security", "chrome::ReceivedBadMessage",
37                        TRACE_EVENT_SCOPE_THREAD, "reason", reason);
38   LogBadMessage(reason);
39   filter->ShutdownForBadMessage();
40 }
41
42 }  // namespace bad_message