OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/app/breakpad_win.h" | 5 #include "chrome/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 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/base_switches.h" | 14 #include "base/base_switches.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/environment.h" | 16 #include "base/environment.h" |
17 #include "base/file_util.h" | 17 #include "base/file_util.h" |
18 #include "base/file_version_info.h" | 18 #include "base/file_version_info.h" |
19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
20 #include "base/string_split.h" | 20 #include "base/string_split.h" |
21 #include "base/string_util.h" | 21 #include "base/string_util.h" |
22 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
23 #include "base/win/registry.h" | 23 #include "base/win/registry.h" |
24 #include "base/win/win_util.h" | 24 #include "base/win/win_util.h" |
25 #include "breakpad/src/client/windows/handler/exception_handler.h" | 25 #include "breakpad/src/client/windows/handler/exception_handler.h" |
26 #include "chrome/app/hard_error_handler_win.h" | 26 #include "chrome/app/hard_error_handler_win.h" |
27 #include "chrome/common/child_process_logging.h" | 27 #include "chrome/common/child_process_logging.h" |
| 28 #include "chrome/common/chrome_result_codes.h" |
28 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
29 #include "chrome/common/env_vars.h" | 30 #include "chrome/common/env_vars.h" |
30 #include "chrome/installer/util/google_chrome_sxs_distribution.h" | 31 #include "chrome/installer/util/google_chrome_sxs_distribution.h" |
31 #include "chrome/installer/util/google_update_settings.h" | 32 #include "chrome/installer/util/google_update_settings.h" |
32 #include "chrome/installer/util/install_util.h" | 33 #include "chrome/installer/util/install_util.h" |
33 #include "content/common/result_codes.h" | |
34 #include "policy/policy_constants.h" | 34 #include "policy/policy_constants.h" |
35 | 35 |
36 namespace { | 36 namespace { |
37 | 37 |
38 // Minidump with stacks, PEB, TEB, and unloaded module list. | 38 // Minidump with stacks, PEB, TEB, and unloaded module list. |
39 const MINIDUMP_TYPE kSmallDumpType = static_cast<MINIDUMP_TYPE>( | 39 const MINIDUMP_TYPE kSmallDumpType = static_cast<MINIDUMP_TYPE>( |
40 MiniDumpWithProcessThreadData | // Get PEB and TEB. | 40 MiniDumpWithProcessThreadData | // Get PEB and TEB. |
41 MiniDumpWithUnloadedModules); // Get unloaded modules when available. | 41 MiniDumpWithUnloadedModules); // Get unloaded modules when available. |
42 | 42 |
43 // Minidump with all of the above, plus memory referenced from stack. | 43 // Minidump with all of the above, plus memory referenced from stack. |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 | 389 |
390 bool WrapMessageBoxWithSEH(const wchar_t* text, const wchar_t* caption, | 390 bool WrapMessageBoxWithSEH(const wchar_t* text, const wchar_t* caption, |
391 UINT flags, bool* exit_now) { | 391 UINT flags, bool* exit_now) { |
392 // We wrap the call to MessageBoxW with a SEH handler because it some | 392 // We wrap the call to MessageBoxW with a SEH handler because it some |
393 // machines with CursorXP, PeaDict or with FontExplorer installed it crashes | 393 // machines with CursorXP, PeaDict or with FontExplorer installed it crashes |
394 // uncontrollably here. Being this a best effort deal we better go away. | 394 // uncontrollably here. Being this a best effort deal we better go away. |
395 __try { | 395 __try { |
396 *exit_now = (IDOK != ::MessageBoxW(NULL, text, caption, flags)); | 396 *exit_now = (IDOK != ::MessageBoxW(NULL, text, caption, flags)); |
397 } __except(EXCEPTION_EXECUTE_HANDLER) { | 397 } __except(EXCEPTION_EXECUTE_HANDLER) { |
398 // Its not safe to continue executing, exit silently here. | 398 // Its not safe to continue executing, exit silently here. |
399 ::ExitProcess(ResultCodes::RESPAWN_FAILED); | 399 ::ExitProcess(chrome::RESULT_CODE_RESPAWN_FAILED); |
400 } | 400 } |
401 | 401 |
402 return true; | 402 return true; |
403 } | 403 } |
404 | 404 |
405 // This function is executed by the child process that DumpDoneCallback() | 405 // This function is executed by the child process that DumpDoneCallback() |
406 // spawned and basically just shows the 'chrome has crashed' dialog if | 406 // spawned and basically just shows the 'chrome has crashed' dialog if |
407 // the CHROME_CRASHED environment variable is present. | 407 // the CHROME_CRASHED environment variable is present. |
408 bool ShowRestartDialogIfCrashed(bool* exit_now) { | 408 bool ShowRestartDialogIfCrashed(bool* exit_now) { |
409 if (!::GetEnvironmentVariableW(ASCIIToWide(env_vars::kShowRestart).c_str(), | 409 if (!::GetEnvironmentVariableW(ASCIIToWide(env_vars::kShowRestart).c_str(), |
(...skipping 28 matching lines...) Expand all Loading... |
438 flags, exit_now); | 438 flags, exit_now); |
439 } | 439 } |
440 | 440 |
441 // Crashes the process after generating a dump for the provided exception. Note | 441 // Crashes the process after generating a dump for the provided exception. Note |
442 // that the crash reporter should be initialized before calling this function | 442 // that the crash reporter should be initialized before calling this function |
443 // for it to do anything. | 443 // for it to do anything. |
444 extern "C" int __declspec(dllexport) CrashForException( | 444 extern "C" int __declspec(dllexport) CrashForException( |
445 EXCEPTION_POINTERS* info) { | 445 EXCEPTION_POINTERS* info) { |
446 if (g_breakpad) { | 446 if (g_breakpad) { |
447 g_breakpad->WriteMinidumpForException(info); | 447 g_breakpad->WriteMinidumpForException(info); |
448 ::ExitProcess(ResultCodes::KILLED); | 448 ::ExitProcess(content::RESULT_CODE_KILLED); |
449 } | 449 } |
450 return EXCEPTION_CONTINUE_SEARCH; | 450 return EXCEPTION_CONTINUE_SEARCH; |
451 } | 451 } |
452 | 452 |
453 // Determine whether configuration management allows loading the crash reporter. | 453 // Determine whether configuration management allows loading the crash reporter. |
454 // Since the configuration management infrastructure is not initialized at this | 454 // Since the configuration management infrastructure is not initialized at this |
455 // point, we read the corresponding registry key directly. The return status | 455 // point, we read the corresponding registry key directly. The return status |
456 // indicates whether policy data was successfully read. If it is true, |result| | 456 // indicates whether policy data was successfully read. If it is true, |result| |
457 // contains the value set by policy. | 457 // contains the value set by policy. |
458 static bool MetricsReportingControlledByPolicy(bool* result) { | 458 static bool MetricsReportingControlledByPolicy(bool* result) { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 if (QueueUserWorkItem( | 614 if (QueueUserWorkItem( |
615 &InitCrashReporterThread, | 615 &InitCrashReporterThread, |
616 info, | 616 info, |
617 WT_EXECUTELONGFUNCTION) == 0) { | 617 WT_EXECUTELONGFUNCTION) == 0) { |
618 // We failed to queue to the worker pool, initialize in this thread. | 618 // We failed to queue to the worker pool, initialize in this thread. |
619 InitCrashReporterThread(info); | 619 InitCrashReporterThread(info); |
620 } | 620 } |
621 } | 621 } |
622 } | 622 } |
623 } | 623 } |
OLD | NEW |