| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/bad_message.h" | 5 #include "content/browser/bad_message.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/crash_logging.h" | 8 #include "base/debug/crash_logging.h" |
| 9 #include "base/debug/dump_without_crashing.h" | 9 #include "base/debug/dump_without_crashing.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 base::IntToString(reason)); | 26 base::IntToString(reason)); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void ReceivedBadMessageOnUIThread(int render_process_id, | 29 void ReceivedBadMessageOnUIThread(int render_process_id, |
| 30 BadMessageReason reason) { | 30 BadMessageReason reason) { |
| 31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 32 RenderProcessHost* host = RenderProcessHost::FromID(render_process_id); | 32 RenderProcessHost* host = RenderProcessHost::FromID(render_process_id); |
| 33 if (!host) | 33 if (!host) |
| 34 return; | 34 return; |
| 35 | 35 |
| 36 LogBadMessage(reason); | |
| 37 | |
| 38 // A dump has already been generated by the caller. Don't generate another. | 36 // A dump has already been generated by the caller. Don't generate another. |
| 39 host->ShutdownForBadMessage( | 37 host->ShutdownForBadMessage( |
| 40 RenderProcessHost::CrashReportMode::NO_CRASH_DUMP); | 38 RenderProcessHost::CrashReportMode::NO_CRASH_DUMP); |
| 41 } | 39 } |
| 42 | 40 |
| 43 } // namespace | 41 } // namespace |
| 44 | 42 |
| 45 void ReceivedBadMessage(RenderProcessHost* host, BadMessageReason reason) { | 43 void ReceivedBadMessage(RenderProcessHost* host, BadMessageReason reason) { |
| 46 LogBadMessage(reason); | 44 LogBadMessage(reason); |
| 47 host->ShutdownForBadMessage( | 45 host->ShutdownForBadMessage( |
| 48 RenderProcessHost::CrashReportMode::GENERATE_CRASH_DUMP); | 46 RenderProcessHost::CrashReportMode::GENERATE_CRASH_DUMP); |
| 49 } | 47 } |
| 50 | 48 |
| 51 void ReceivedBadMessage(int render_process_id, BadMessageReason reason) { | 49 void ReceivedBadMessage(int render_process_id, BadMessageReason reason) { |
| 52 // We generate a crash dump here since generating one after posting the UI | 50 // We generate a crash dump here since generating one after posting to the UI |
| 53 // thread is mostly useless. | 51 // thread is less useful. |
| 52 LogBadMessage(reason); |
| 54 base::debug::DumpWithoutCrashing(); | 53 base::debug::DumpWithoutCrashing(); |
| 55 | 54 |
| 56 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 55 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 57 BrowserThread::PostTask( | 56 BrowserThread::PostTask( |
| 58 BrowserThread::UI, | 57 BrowserThread::UI, |
| 59 FROM_HERE, | 58 FROM_HERE, |
| 60 base::Bind(&ReceivedBadMessageOnUIThread, render_process_id, reason)); | 59 base::Bind(&ReceivedBadMessageOnUIThread, render_process_id, reason)); |
| 61 return; | 60 return; |
| 62 } | 61 } |
| 63 ReceivedBadMessageOnUIThread(render_process_id, reason); | 62 ReceivedBadMessageOnUIThread(render_process_id, reason); |
| 64 } | 63 } |
| 65 | 64 |
| 66 void ReceivedBadMessage(BrowserMessageFilter* filter, BadMessageReason reason) { | 65 void ReceivedBadMessage(BrowserMessageFilter* filter, BadMessageReason reason) { |
| 67 LogBadMessage(reason); | 66 LogBadMessage(reason); |
| 68 filter->ShutdownForBadMessage(); | 67 filter->ShutdownForBadMessage(); |
| 69 } | 68 } |
| 70 | 69 |
| 71 } // namespace bad_message | 70 } // namespace bad_message |
| 72 } // namespace content | 71 } // namespace content |
| OLD | NEW |