| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/breakpad/app/breakpad_win.h" | 5 #include "components/breakpad/app/breakpad_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 #include <tchar.h> | 9 #include <tchar.h> |
| 10 #include <userenv.h> | 10 #include <userenv.h> |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 &version, | 259 &version, |
| 260 &special_build, | 260 &special_build, |
| 261 &channel_name); | 261 &channel_name); |
| 262 | 262 |
| 263 // We only expect this method to be called once per process. | 263 // We only expect this method to be called once per process. |
| 264 DCHECK(!g_custom_entries); | 264 DCHECK(!g_custom_entries); |
| 265 g_custom_entries = new std::vector<google_breakpad::CustomInfoEntry>; | 265 g_custom_entries = new std::vector<google_breakpad::CustomInfoEntry>; |
| 266 | 266 |
| 267 // Common g_custom_entries. | 267 // Common g_custom_entries. |
| 268 g_custom_entries->push_back( | 268 g_custom_entries->push_back( |
| 269 google_breakpad::CustomInfoEntry(L"ver", UTF16ToWide(version).c_str())); | 269 google_breakpad::CustomInfoEntry(L"ver", |
| 270 base::UTF16ToWide(version).c_str())); |
| 270 g_custom_entries->push_back( | 271 g_custom_entries->push_back( |
| 271 google_breakpad::CustomInfoEntry(L"prod", UTF16ToWide(product).c_str())); | 272 google_breakpad::CustomInfoEntry(L"prod", |
| 273 base::UTF16ToWide(product).c_str())); |
| 272 g_custom_entries->push_back( | 274 g_custom_entries->push_back( |
| 273 google_breakpad::CustomInfoEntry(L"plat", L"Win32")); | 275 google_breakpad::CustomInfoEntry(L"plat", L"Win32")); |
| 274 g_custom_entries->push_back( | 276 g_custom_entries->push_back( |
| 275 google_breakpad::CustomInfoEntry(L"ptype", type.c_str())); | 277 google_breakpad::CustomInfoEntry(L"ptype", type.c_str())); |
| 276 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( | 278 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( |
| 277 L"pid", base::StringPrintf(L"%d", ::GetCurrentProcessId()).c_str())); | 279 L"pid", base::StringPrintf(L"%d", ::GetCurrentProcessId()).c_str())); |
| 278 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( | 280 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( |
| 279 L"channel", base::UTF16ToWide(channel_name).c_str())); | 281 L"channel", base::UTF16ToWide(channel_name).c_str())); |
| 280 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( | 282 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( |
| 281 L"profile-type", GetProfileType().c_str())); | 283 L"profile-type", GetProfileType().c_str())); |
| 282 | 284 |
| 283 if (g_deferred_crash_uploads) | 285 if (g_deferred_crash_uploads) |
| 284 g_custom_entries->push_back( | 286 g_custom_entries->push_back( |
| 285 google_breakpad::CustomInfoEntry(L"deferred-upload", L"true")); | 287 google_breakpad::CustomInfoEntry(L"deferred-upload", L"true")); |
| 286 | 288 |
| 287 if (!special_build.empty()) | 289 if (!special_build.empty()) |
| 288 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( | 290 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( |
| 289 L"special", UTF16ToWide(special_build).c_str())); | 291 L"special", base::UTF16ToWide(special_build).c_str())); |
| 290 | 292 |
| 291 if (type == L"plugin" || type == L"ppapi") { | 293 if (type == L"plugin" || type == L"ppapi") { |
| 292 std::wstring plugin_path = | 294 std::wstring plugin_path = |
| 293 CommandLine::ForCurrentProcess()->GetSwitchValueNative("plugin-path"); | 295 CommandLine::ForCurrentProcess()->GetSwitchValueNative("plugin-path"); |
| 294 if (!plugin_path.empty()) | 296 if (!plugin_path.empty()) |
| 295 SetPluginPath(plugin_path); | 297 SetPluginPath(plugin_path); |
| 296 } | 298 } |
| 297 | 299 |
| 298 // Check whether configuration management controls crash reporting. | 300 // Check whether configuration management controls crash reporting. |
| 299 bool crash_reporting_enabled = true; | 301 bool crash_reporting_enabled = true; |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 } | 661 } |
| 660 | 662 |
| 661 void InitCrashReporter(const std::string& process_type_switch) { | 663 void InitCrashReporter(const std::string& process_type_switch) { |
| 662 const CommandLine& command = *CommandLine::ForCurrentProcess(); | 664 const CommandLine& command = *CommandLine::ForCurrentProcess(); |
| 663 if (command.HasSwitch(switches::kDisableBreakpad)) | 665 if (command.HasSwitch(switches::kDisableBreakpad)) |
| 664 return; | 666 return; |
| 665 | 667 |
| 666 // Disable the message box for assertions. | 668 // Disable the message box for assertions. |
| 667 _CrtSetReportMode(_CRT_ASSERT, 0); | 669 _CrtSetReportMode(_CRT_ASSERT, 0); |
| 668 | 670 |
| 669 std::wstring process_type = ASCIIToWide(process_type_switch); | 671 std::wstring process_type = base::ASCIIToWide(process_type_switch); |
| 670 if (process_type.empty()) | 672 if (process_type.empty()) |
| 671 process_type = L"browser"; | 673 process_type = L"browser"; |
| 672 | 674 |
| 673 wchar_t exe_path[MAX_PATH]; | 675 wchar_t exe_path[MAX_PATH]; |
| 674 exe_path[0] = 0; | 676 exe_path[0] = 0; |
| 675 GetModuleFileNameW(NULL, exe_path, MAX_PATH); | 677 GetModuleFileNameW(NULL, exe_path, MAX_PATH); |
| 676 | 678 |
| 677 bool is_per_user_install = | 679 bool is_per_user_install = |
| 678 GetBreakpadClient()->GetIsPerUserInstall(base::FilePath(exe_path)); | 680 GetBreakpadClient()->GetIsPerUserInstall(base::FilePath(exe_path)); |
| 679 | 681 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 701 std::string pipe_name_ascii; | 703 std::string pipe_name_ascii; |
| 702 if (!env->GetVar(kPipeNameVar, &pipe_name_ascii)) { | 704 if (!env->GetVar(kPipeNameVar, &pipe_name_ascii)) { |
| 703 // Breakpad is not enabled. Configuration is managed or the user | 705 // Breakpad is not enabled. Configuration is managed or the user |
| 704 // did not allow Google Update to send crashes. We need to use | 706 // did not allow Google Update to send crashes. We need to use |
| 705 // our default crash handler instead, but only for the | 707 // our default crash handler instead, but only for the |
| 706 // browser/service processes. | 708 // browser/service processes. |
| 707 if (default_filter) | 709 if (default_filter) |
| 708 InitDefaultCrashCallback(default_filter); | 710 InitDefaultCrashCallback(default_filter); |
| 709 return; | 711 return; |
| 710 } | 712 } |
| 711 std::wstring pipe_name = ASCIIToWide(pipe_name_ascii); | 713 std::wstring pipe_name = base::ASCIIToWide(pipe_name_ascii); |
| 712 | 714 |
| 713 #ifdef _WIN64 | 715 #ifdef _WIN64 |
| 714 // The protocol for connecting to the out-of-process Breakpad crash | 716 // The protocol for connecting to the out-of-process Breakpad crash |
| 715 // reporter is different for x86-32 and x86-64: the message sizes | 717 // reporter is different for x86-32 and x86-64: the message sizes |
| 716 // are different because the message struct contains a pointer. As | 718 // are different because the message struct contains a pointer. As |
| 717 // a result, there are two different named pipes to connect to. The | 719 // a result, there are two different named pipes to connect to. The |
| 718 // 64-bit one is distinguished with an "-x64" suffix. | 720 // 64-bit one is distinguished with an "-x64" suffix. |
| 719 pipe_name += L"-x64"; | 721 pipe_name += L"-x64"; |
| 720 #endif | 722 #endif |
| 721 | 723 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 if (process_type != L"browser" && | 760 if (process_type != L"browser" && |
| 759 !GetBreakpadClient()->IsRunningUnattended()) { | 761 !GetBreakpadClient()->IsRunningUnattended()) { |
| 760 // Initialize the hook TerminateProcess to catch unexpected exits. | 762 // Initialize the hook TerminateProcess to catch unexpected exits. |
| 761 InitTerminateProcessHooks(); | 763 InitTerminateProcessHooks(); |
| 762 } | 764 } |
| 763 #endif | 765 #endif |
| 764 } | 766 } |
| 765 } | 767 } |
| 766 | 768 |
| 767 } // namespace breakpad | 769 } // namespace breakpad |
| OLD | NEW |