| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // Implementation of wrapper around common crash reporting. | 5 // Implementation of wrapper around common crash reporting. |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/file_version_info.h" | 9 #include "base/file_version_info.h" |
| 10 #include "base/win_util.h" | 10 #include "base/win_util.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 static google_breakpad::CustomInfoEntry prod_entry(L"prod", product.c_str()); | 39 static google_breakpad::CustomInfoEntry prod_entry(L"prod", product.c_str()); |
| 40 static google_breakpad::CustomInfoEntry plat_entry(L"plat", L"Win32"); | 40 static google_breakpad::CustomInfoEntry plat_entry(L"plat", L"Win32"); |
| 41 static google_breakpad::CustomInfoEntry type_entry(L"ptype", L"chrome_frame"); | 41 static google_breakpad::CustomInfoEntry type_entry(L"ptype", L"chrome_frame"); |
| 42 static google_breakpad::CustomInfoEntry entries[] = { | 42 static google_breakpad::CustomInfoEntry entries[] = { |
| 43 ver_entry, prod_entry, plat_entry, type_entry }; | 43 ver_entry, prod_entry, plat_entry, type_entry }; |
| 44 static google_breakpad::CustomClientInfo custom_info = { | 44 static google_breakpad::CustomClientInfo custom_info = { |
| 45 entries, arraysize(entries) }; | 45 entries, arraysize(entries) }; |
| 46 return &custom_info; | 46 return &custom_info; |
| 47 } | 47 } |
| 48 | 48 |
| 49 | |
| 50 void CALLBACK BreakpadHandler(EXCEPTION_POINTERS *ptrs) { | |
| 51 WriteMinidumpForException(ptrs); | |
| 52 } | |
| 53 | |
| 54 extern "C" IMAGE_DOS_HEADER __ImageBase; | 49 extern "C" IMAGE_DOS_HEADER __ImageBase; |
| 55 | 50 |
| 56 bool InitializeCrashReporting() { | 51 bool InitializeCrashReporting() { |
| 57 // In headless mode we want crashes to be reported back. | 52 // In headless mode we want crashes to be reported back. |
| 58 bool always_take_dump = IsHeadlessMode(); | 53 bool always_take_dump = IsHeadlessMode(); |
| 59 // We want to use the Google Update crash reporting. We need to check if the | 54 // We want to use the Google Update crash reporting. We need to check if the |
| 60 // user allows it first. | 55 // user allows it first. |
| 61 if (!always_take_dump && !GoogleUpdateSettings::GetCollectStatsConsent()) | 56 if (!always_take_dump && !GoogleUpdateSettings::GetCollectStatsConsent()) |
| 62 return true; | 57 return true; |
| 63 | 58 |
| 64 // Set the handler for ExceptionBarrier for this module: | 59 // If we got here, we want to report crashes, so make sure all |
| 65 DCHECK(ExceptionBarrier::handler() == NULL); | 60 // ExceptionBarrierBase instances do so. |
| 66 ExceptionBarrier::set_handler(BreakpadHandler); | 61 ExceptionBarrierConfig::set_enabled(true); |
| 67 | 62 |
| 68 // Get the alternate dump directory. We use the temp path. | 63 // Get the alternate dump directory. We use the temp path. |
| 69 FilePath temp_directory; | 64 FilePath temp_directory; |
| 70 if (!file_util::GetTempDir(&temp_directory) || temp_directory.empty()) { | 65 if (!file_util::GetTempDir(&temp_directory) || temp_directory.empty()) { |
| 71 return false; | 66 return false; |
| 72 } | 67 } |
| 73 | 68 |
| 74 wchar_t dll_path[MAX_PATH * 2] = {0}; | 69 wchar_t dll_path[MAX_PATH * 2] = {0}; |
| 75 GetModuleFileName(reinterpret_cast<HMODULE>(&__ImageBase), dll_path, | 70 GetModuleFileName(reinterpret_cast<HMODULE>(&__ImageBase), dll_path, |
| 76 arraysize(dll_path)); | 71 arraysize(dll_path)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 90 } | 85 } |
| 91 } else { | 86 } else { |
| 92 user_sid = kSystemPrincipalSid; | 87 user_sid = kSystemPrincipalSid; |
| 93 } | 88 } |
| 94 | 89 |
| 95 return InitializeVectoredCrashReporting(false, user_sid.c_str(), | 90 return InitializeVectoredCrashReporting(false, user_sid.c_str(), |
| 96 temp_directory.value(), GetCustomInfo(dll_path)); | 91 temp_directory.value(), GetCustomInfo(dll_path)); |
| 97 } | 92 } |
| 98 | 93 |
| 99 bool ShutdownCrashReporting() { | 94 bool ShutdownCrashReporting() { |
| 95 ExceptionBarrierConfig::set_enabled(false); |
| 100 return ShutdownVectoredCrashReporting(); | 96 return ShutdownVectoredCrashReporting(); |
| 101 } | 97 } |
| OLD | NEW |