summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-04 08:33:49 +0000
committerdeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-04 08:33:49 +0000
commit5080e18216a41a978c42c2bacf4e16ad15ca84e4 (patch)
tree4fba8e99df939aebc81d2f75c104297223ed3ba3
parent3c6e1b473043d00522c448ace074d64b00011202 (diff)
downloadchromium_src-5080e18216a41a978c42c2bacf4e16ad15ca84e4.zip
chromium_src-5080e18216a41a978c42c2bacf4e16ad15ca84e4.tar.gz
chromium_src-5080e18216a41a978c42c2bacf4e16ad15ca84e4.tar.bz2
Use the worker pool instead of a one-time thread for the breakpad initialization. This allows the thread to be reused later.
Review URL: http://codereview.chromium.org/9276 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4585 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/breakpad.cc16
-rw-r--r--chrome/app/breakpad.h3
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);