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" |
11 #include "chrome/installer/util/google_update_settings.h" | 11 #include "chrome/installer/util/google_update_settings.h" |
12 #include "chrome/installer/util/install_util.h" | 12 #include "chrome/installer/util/install_util.h" |
13 #include "chrome_frame/chrome_frame_reporting.h" | 13 #include "chrome_frame/chrome_frame_reporting.h" |
| 14 #include "chrome_frame/exception_barrier.h" |
14 #include "chrome_frame/utils.h" | 15 #include "chrome_frame/utils.h" |
15 | 16 |
16 // Well known SID for the system principal. | 17 // Well known SID for the system principal. |
17 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; | 18 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; |
18 const wchar_t kChromePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; | 19 const wchar_t kChromePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; |
19 | 20 |
20 // Returns the custom info structure based on the dll in parameter | 21 // Returns the custom info structure based on the dll in parameter |
21 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* dll_path) { | 22 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* dll_path) { |
22 std::wstring product; | 23 std::wstring product; |
23 std::wstring version; | 24 std::wstring version; |
(...skipping 14 matching lines...) Expand all Loading... |
38 static google_breakpad::CustomInfoEntry prod_entry(L"prod", product.c_str()); | 39 static google_breakpad::CustomInfoEntry prod_entry(L"prod", product.c_str()); |
39 static google_breakpad::CustomInfoEntry plat_entry(L"plat", L"Win32"); | 40 static google_breakpad::CustomInfoEntry plat_entry(L"plat", L"Win32"); |
40 static google_breakpad::CustomInfoEntry type_entry(L"ptype", L"chrome_frame"); | 41 static google_breakpad::CustomInfoEntry type_entry(L"ptype", L"chrome_frame"); |
41 static google_breakpad::CustomInfoEntry entries[] = { | 42 static google_breakpad::CustomInfoEntry entries[] = { |
42 ver_entry, prod_entry, plat_entry, type_entry }; | 43 ver_entry, prod_entry, plat_entry, type_entry }; |
43 static google_breakpad::CustomClientInfo custom_info = { | 44 static google_breakpad::CustomClientInfo custom_info = { |
44 entries, arraysize(entries) }; | 45 entries, arraysize(entries) }; |
45 return &custom_info; | 46 return &custom_info; |
46 } | 47 } |
47 | 48 |
| 49 |
| 50 void CALLBACK BreakpadHandler(EXCEPTION_POINTERS *ptrs) { |
| 51 WriteMinidumpForException(ptrs); |
| 52 } |
| 53 |
48 extern "C" IMAGE_DOS_HEADER __ImageBase; | 54 extern "C" IMAGE_DOS_HEADER __ImageBase; |
49 | 55 |
50 bool InitializeCrashReporting() { | 56 bool InitializeCrashReporting() { |
51 // In headless mode we want crashes to be reported back. | 57 // In headless mode we want crashes to be reported back. |
52 bool always_take_dump = IsHeadlessMode(); | 58 bool always_take_dump = IsHeadlessMode(); |
53 // We want to use the Google Update crash reporting. We need to check if the | 59 // We want to use the Google Update crash reporting. We need to check if the |
54 // user allows it first. | 60 // user allows it first. |
55 if (!always_take_dump && !GoogleUpdateSettings::GetCollectStatsConsent()) | 61 if (!always_take_dump && !GoogleUpdateSettings::GetCollectStatsConsent()) |
56 return true; | 62 return true; |
57 | 63 |
| 64 // Set the handler for ExceptionBarrier for this module: |
| 65 DCHECK(ExceptionBarrier::handler() == NULL); |
| 66 ExceptionBarrier::set_handler(BreakpadHandler); |
| 67 |
58 // Get the alternate dump directory. We use the temp path. | 68 // Get the alternate dump directory. We use the temp path. |
59 FilePath temp_directory; | 69 FilePath temp_directory; |
60 if (!file_util::GetTempDir(&temp_directory) || temp_directory.empty()) { | 70 if (!file_util::GetTempDir(&temp_directory) || temp_directory.empty()) { |
61 return false; | 71 return false; |
62 } | 72 } |
63 | 73 |
64 wchar_t dll_path[MAX_PATH * 2] = {0}; | 74 wchar_t dll_path[MAX_PATH * 2] = {0}; |
65 GetModuleFileName(reinterpret_cast<HMODULE>(&__ImageBase), dll_path, | 75 GetModuleFileName(reinterpret_cast<HMODULE>(&__ImageBase), dll_path, |
66 arraysize(dll_path)); | 76 arraysize(dll_path)); |
67 | 77 |
(...skipping 14 matching lines...) Expand all Loading... |
82 user_sid = kSystemPrincipalSid; | 92 user_sid = kSystemPrincipalSid; |
83 } | 93 } |
84 | 94 |
85 return InitializeVectoredCrashReporting(false, user_sid.c_str(), | 95 return InitializeVectoredCrashReporting(false, user_sid.c_str(), |
86 temp_directory.value(), GetCustomInfo(dll_path)); | 96 temp_directory.value(), GetCustomInfo(dll_path)); |
87 } | 97 } |
88 | 98 |
89 bool ShutdownCrashReporting() { | 99 bool ShutdownCrashReporting() { |
90 return ShutdownVectoredCrashReporting(); | 100 return ShutdownVectoredCrashReporting(); |
91 } | 101 } |
OLD | NEW |