Use different name for wait events for different apps

This commit is contained in:
Cheng Zhao 2015-08-04 19:30:35 +08:00
parent 14803e4cf8
commit db58048077
4 changed files with 19 additions and 13 deletions

View file

@ -21,6 +21,7 @@ const MINIDUMP_TYPE kSmallDumpType = static_cast<MINIDUMP_TYPE>(
MiniDumpWithProcessThreadData | // Get PEB and TEB. MiniDumpWithProcessThreadData | // Get PEB and TEB.
MiniDumpWithUnloadedModules); // Get unloaded modules when available. MiniDumpWithUnloadedModules); // Get unloaded modules when available.
const wchar_t kWaitEventFormat[] = L"$1CrashServiceWaitEvent";
const wchar_t kPipeNameFormat[] = L"\\\\.\\pipe\\$1 Crash Service"; const wchar_t kPipeNameFormat[] = L"\\\\.\\pipe\\$1 Crash Service";
} // namespace } // namespace
@ -47,13 +48,14 @@ void CrashReporterWin::InitBreakpad(const std::string& product_name,
base::string16 pipe_name = ReplaceStringPlaceholders( base::string16 pipe_name = ReplaceStringPlaceholders(
kPipeNameFormat, base::UTF8ToUTF16(product_name), NULL); kPipeNameFormat, base::UTF8ToUTF16(product_name), NULL);
base::string16 wait_name = ReplaceStringPlaceholders(
kWaitEventFormat, base::UTF8ToUTF16(product_name), NULL);
// Wait until the crash service is started. // Wait until the crash service is started.
HANDLE waiting_event = HANDLE wait_event = ::CreateEventW(NULL, TRUE, FALSE, wait_name.c_str());
::CreateEventW(NULL, TRUE, FALSE, L"g_atom_shell_crash_service"); if (wait_event != NULL) {
if (waiting_event != NULL) { WaitForSingleObject(wait_event, 1000);
WaitForSingleObject(waiting_event, 1000); CloseHandle(wait_event);
CloseHandle(waiting_event);
} }
// ExceptionHandler() attaches our handler and ~ExceptionHandler() detaches // ExceptionHandler() attaches our handler and ~ExceptionHandler() detaches

View file

@ -14,6 +14,7 @@
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/win/windows_version.h" #include "base/win/windows_version.h"
#include "vendor/breakpad/src/client/windows/crash_generation/client_info.h" #include "vendor/breakpad/src/client/windows/crash_generation/client_info.h"
@ -24,6 +25,7 @@ namespace breakpad {
namespace { namespace {
const wchar_t kWaitEventFormat[] = L"$1CrashServiceWaitEvent";
const wchar_t kTestPipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; const wchar_t kTestPipeName[] = L"\\\\.\\pipe\\ChromeCrashServices";
const wchar_t kGoogleReportURL[] = L"https://clients2.google.com/cr/report"; const wchar_t kGoogleReportURL[] = L"https://clients2.google.com/cr/report";
@ -193,7 +195,8 @@ CrashService::~CrashService() {
delete sender_; delete sender_;
} }
bool CrashService::Initialize(const base::FilePath& operating_dir, bool CrashService::Initialize(const base::string16& application_name,
const base::FilePath& operating_dir,
const base::FilePath& dumps_path) { const base::FilePath& dumps_path) {
using google_breakpad::CrashReportSender; using google_breakpad::CrashReportSender;
using google_breakpad::CrashGenerationServer; using google_breakpad::CrashGenerationServer;
@ -298,11 +301,10 @@ bool CrashService::Initialize(const base::FilePath& operating_dir,
// Create or open an event to signal the browser process that the crash // Create or open an event to signal the browser process that the crash
// service is initialized. // service is initialized.
HANDLE running_event = base::string16 wait_name = ReplaceStringPlaceholders(
::CreateEventW(NULL, TRUE, TRUE, L"g_atom_shell_crash_service"); kWaitEventFormat, application_name, NULL);
// If the browser already had the event open, the CreateEvent call did not HANDLE wait_event = ::CreateEventW(NULL, TRUE, FALSE, wait_name.c_str());
// signal it. We need to do it manually. ::SetEvent(wait_event);
::SetEvent(running_event);
return true; return true;
} }

View file

@ -37,7 +37,8 @@ class CrashService {
// other members in that case. |operating_dir| is where the CrashService // other members in that case. |operating_dir| is where the CrashService
// should store breakpad's checkpoint file. |dumps_path| is the directory // should store breakpad's checkpoint file. |dumps_path| is the directory
// where the crash dumps should be stored. // where the crash dumps should be stored.
bool Initialize(const base::FilePath& operating_dir, bool Initialize(const base::string16& application_name,
const base::FilePath& operating_dir,
const base::FilePath& dumps_path); const base::FilePath& dumps_path);
// Command line switches: // Command line switches:

View file

@ -77,7 +77,8 @@ int Main(const wchar_t* cmd) {
cmd_line.AppendSwitchNative("pipe-name", pipe_name); cmd_line.AppendSwitchNative("pipe-name", pipe_name);
breakpad::CrashService crash_service; breakpad::CrashService crash_service;
if (!crash_service.Initialize(operating_dir, operating_dir)) if (!crash_service.Initialize(application_name, operating_dir,
operating_dir))
return 2; return 2;
VLOG(1) << "Ready to process crash requests"; VLOG(1) << "Ready to process crash requests";