OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/file_version_info.h" | 8 #include "base/file_version_info.h" |
9 #include "base/win/win_util.h" | 9 #include "base/win/win_util.h" |
10 #include "chrome/installer/util/google_update_settings.h" | 10 #include "chrome/installer/util/google_update_settings.h" |
11 #include "chrome/installer/util/install_util.h" | 11 #include "chrome/installer/util/install_util.h" |
12 #include "chrome_frame/chrome_frame_reporting.h" | 12 #include "chrome_frame/chrome_frame_reporting.h" |
13 #include "chrome_frame/exception_barrier.h" | 13 #include "chrome_frame/exception_barrier.h" |
14 #include "chrome_frame/utils.h" | 14 #include "chrome_frame/utils.h" |
15 | 15 |
16 // Well known SID for the system principal. | 16 // Well known SID for the system principal. |
17 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; | 17 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; |
18 const wchar_t kChromePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; | 18 const wchar_t kChromePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; |
19 | 19 |
20 // Returns the custom info structure based on the dll in parameter | 20 // Returns the custom info structure based on the dll in parameter |
21 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* dll_path) { | 21 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* dll_path) { |
22 std::wstring product; | 22 std::wstring product; |
23 std::wstring version; | 23 std::wstring version; |
24 scoped_ptr<FileVersionInfo> | 24 scoped_ptr<FileVersionInfo> version_info( |
25 version_info(FileVersionInfo::CreateFileVersionInfo(FilePath(dll_path))); | 25 FileVersionInfo::CreateFileVersionInfo(base::FilePath(dll_path))); |
26 if (version_info.get()) { | 26 if (version_info.get()) { |
27 version = version_info->product_version(); | 27 version = version_info->product_version(); |
28 product = version_info->product_short_name(); | 28 product = version_info->product_short_name(); |
29 } | 29 } |
30 | 30 |
31 if (version.empty()) | 31 if (version.empty()) |
32 version = L"0.1.0.0"; | 32 version = L"0.1.0.0"; |
33 | 33 |
34 if (product.empty()) | 34 if (product.empty()) |
35 product = L"ChromeFrame"; | 35 product = L"ChromeFrame"; |
(...skipping 17 matching lines...) Expand all Loading... |
53 // We want to use the Google Update crash reporting. We need to check if the | 53 // We want to use the Google Update crash reporting. We need to check if the |
54 // user allows it first. | 54 // user allows it first. |
55 if (!always_take_dump && !GoogleUpdateSettings::GetCollectStatsConsent()) | 55 if (!always_take_dump && !GoogleUpdateSettings::GetCollectStatsConsent()) |
56 return true; | 56 return true; |
57 | 57 |
58 // If we got here, we want to report crashes, so make sure all | 58 // If we got here, we want to report crashes, so make sure all |
59 // ExceptionBarrierBase instances do so. | 59 // ExceptionBarrierBase instances do so. |
60 ExceptionBarrierConfig::set_enabled(true); | 60 ExceptionBarrierConfig::set_enabled(true); |
61 | 61 |
62 // Get the alternate dump directory. We use the temp path. | 62 // Get the alternate dump directory. We use the temp path. |
63 FilePath temp_directory; | 63 base::FilePath temp_directory; |
64 if (!file_util::GetTempDir(&temp_directory) || temp_directory.empty()) { | 64 if (!file_util::GetTempDir(&temp_directory) || temp_directory.empty()) { |
65 return false; | 65 return false; |
66 } | 66 } |
67 | 67 |
68 wchar_t dll_path[MAX_PATH * 2] = {0}; | 68 wchar_t dll_path[MAX_PATH * 2] = {0}; |
69 GetModuleFileName(reinterpret_cast<HMODULE>(&__ImageBase), dll_path, | 69 GetModuleFileName(reinterpret_cast<HMODULE>(&__ImageBase), dll_path, |
70 arraysize(dll_path)); | 70 arraysize(dll_path)); |
71 | 71 |
72 if (always_take_dump) { | 72 if (always_take_dump) { |
73 return InitializeVectoredCrashReportingWithPipeName(true, kChromePipeName, | 73 return InitializeVectoredCrashReportingWithPipeName(true, kChromePipeName, |
(...skipping 13 matching lines...) Expand all Loading... |
87 } | 87 } |
88 | 88 |
89 return InitializeVectoredCrashReporting(false, user_sid.c_str(), | 89 return InitializeVectoredCrashReporting(false, user_sid.c_str(), |
90 temp_directory.value(), GetCustomInfo(dll_path)); | 90 temp_directory.value(), GetCustomInfo(dll_path)); |
91 } | 91 } |
92 | 92 |
93 bool ShutdownCrashReporting() { | 93 bool ShutdownCrashReporting() { |
94 ExceptionBarrierConfig::set_enabled(false); | 94 ExceptionBarrierConfig::set_enabled(false); |
95 return ShutdownVectoredCrashReporting(); | 95 return ShutdownVectoredCrashReporting(); |
96 } | 96 } |
OLD | NEW |