diff options
-rw-r--r-- | chrome/app/breakpad.cc | 16 | ||||
-rw-r--r-- | chrome/app/breakpad.h | 3 |
2 files changed, 8 insertions, 11 deletions
diff --git a/chrome/app/breakpad.cc b/chrome/app/breakpad.cc index 34607a4..773a2da 100644 --- a/chrome/app/breakpad.cc +++ b/chrome/app/breakpad.cc @@ -5,7 +5,6 @@ #include "chrome/app/breakpad.h" #include <windows.h> -#include <process.h> #include <tchar.h> #include "base/base_switches.h" @@ -153,7 +152,7 @@ bool ShowRestartDialogIfCrashed(bool* exit_now) { return true; } -unsigned __stdcall InitCrashReporterThread(void* param) { +static DWORD __stdcall InitCrashReporterThread(void* param) { CrashReporterInfo* info = reinterpret_cast<CrashReporterInfo*>(param); CommandLine command; @@ -242,15 +241,16 @@ void InitCrashReporter(std::wstring dll_path) { // If this is not the browser, we can't be sure that we will be able to // initialize the crash_handler in another thread, so we run it right away. // This is important to keep the thread for the browser process because - // it may take some times to initialize the crash_service process. + // it may take some times to initialize the crash_service process. We use + // the Windows worker pool to make better reuse of the thread. if (info->process_type != L"browser") { InitCrashReporterThread(info); } else { - uintptr_t thread = _beginthreadex(NULL, 0, &InitCrashReporterThread, - info, 0, NULL); - HANDLE thread_handle = reinterpret_cast<HANDLE>(thread); - if (thread_handle != INVALID_HANDLE_VALUE) - ::CloseHandle(thread_handle); + if (QueueUserWorkItem( + &InitCrashReporterThread, info, WT_EXECUTELONGFUNCTION) == 0) { + // We failed to queue to the worker pool, initialize in this thread. + InitCrashReporterThread(info); + } } } } diff --git a/chrome/app/breakpad.h b/chrome/app/breakpad.h index af8fe46..8250b4b 100644 --- a/chrome/app/breakpad.h +++ b/chrome/app/breakpad.h @@ -16,9 +16,6 @@ void InitCrashReporter(std::wstring dll_path); // the browser or not. void InitDefaultCrashCallback(); -// Initializes the crash reporter in chrome. -unsigned __stdcall InitCrashReporterThread(void* param); - // If chrome has been restarted because it crashed, this function will display // a dialog asking for permission to continue execution or to exit now. bool ShowRestartDialogIfCrashed(bool* exit_now); |