OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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 #include "chromecast/app/linux/cast_crash_reporter_client.h" |
| 6 |
| 7 #include "base/time/time.h" |
| 8 #include "chromecast/base/error_codes.h" |
| 9 #include "chromecast/crash/linux/crash_util.h" |
| 10 #include "components/crash/app/breakpad_linux.h" |
| 11 #include "content/public/common/content_switches.h" |
| 12 |
| 13 namespace chromecast { |
| 14 |
| 15 namespace { |
| 16 |
| 17 std::string* g_process_type = nullptr; |
| 18 uint64_t g_process_start_time_ms = 0u; |
| 19 |
| 20 } // namespace |
| 21 |
| 22 // static |
| 23 void CastCrashReporterClient::InitCrashReporter( |
| 24 const std::string& process_type) { |
| 25 DCHECK(!g_process_type); |
| 26 g_process_start_time_ms = |
| 27 (base::TimeTicks::Now() - base::TimeTicks()).InMilliseconds(); |
| 28 |
| 29 // Save the process type (leaked). |
| 30 g_process_type = new std::string(process_type); |
| 31 |
| 32 // Start up breakpad for this process, if applicable. |
| 33 breakpad::InitCrashReporter(process_type); |
| 34 } |
| 35 |
| 36 // static |
| 37 const char* CastCrashReporterClient::GetProcessType() { |
| 38 return g_process_type ? g_process_type->c_str() : nullptr; |
| 39 } |
| 40 |
| 41 // static |
| 42 uint64_t CastCrashReporterClient::GetProcessStartTime() { |
| 43 return g_process_start_time_ms; |
| 44 } |
| 45 |
| 46 CastCrashReporterClient::CastCrashReporterClient() { |
| 47 } |
| 48 CastCrashReporterClient::~CastCrashReporterClient() { |
| 49 } |
| 50 |
| 51 bool CastCrashReporterClient::EnableBreakpadForProcess( |
| 52 const std::string& process_type) { |
| 53 return process_type == switches::kRendererProcess || |
| 54 process_type == switches::kZygoteProcess || |
| 55 process_type == switches::kGpuProcess; |
| 56 } |
| 57 |
| 58 bool CastCrashReporterClient::HandleCrashDump(const char* crashdump_filename) { |
| 59 // Set the initial error code to ERROR_WEB_CONTENT_RENDER_VIEW_GONE to show |
| 60 // an error message on next cast_shell run. Though the error code is for |
| 61 // renderer process crash, the actual messages can be used for browser process |
| 62 // as well. |
| 63 if (!GetProcessType() || !strcmp(GetProcessType(), "")) |
| 64 SetInitialErrorCode(ERROR_WEB_CONTENT_RENDER_VIEW_GONE); |
| 65 |
| 66 // Upload crash dump. If user didn't opt-in crash report, minidump writer |
| 67 // instantiated within CrashUtil::RequestUploadCrashDump() does nothing. |
| 68 CrashUtil::RequestUploadCrashDump(crashdump_filename, |
| 69 GetProcessType() ? GetProcessType() : "", |
| 70 GetProcessStartTime()); |
| 71 |
| 72 // Always return true to indicate that this crash dump has been processed, |
| 73 // so that it won't fallback to use chrome's default uploader. |
| 74 return true; |
| 75 } |
| 76 |
| 77 } // namespace chromecast |
OLD | NEW |