From a30db914afae7904237b9ccd9576828808868f34 Mon Sep 17 00:00:00 2001 From: Mark Mentovai Date: Mon, 2 Nov 2015 23:15:22 -0500 Subject: [PATCH] win: Add CrashpadClient::GetHandlerIPCPipe() For multiprocess architectures, this method allows the pipe used for registration to be obtained from CrashpadHandler, even when CrashpadHandler chooses its own name. This may happen if the handler is not running on a well-known pipe name but was instead started by CrashpadHandler::StartHandler(). If Chrome uses this interface, for example, the browser process will need to call CrashpadClient::GetHandlerIPCPipe() and pass the pipe name to its child processes. R=scottmg@chromium.org Review URL: https://codereview.chromium.org/1427163004 . --- client/crashpad_client.h | 21 ++++++++++++++++----- client/crashpad_client_win.cc | 5 +++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/client/crashpad_client.h b/client/crashpad_client.h index d3d7e347..18b7b131 100644 --- a/client/crashpad_client.h +++ b/client/crashpad_client.h @@ -72,22 +72,33 @@ class CrashpadClient { const std::vector& arguments); #if defined(OS_WIN) || DOXYGEN - //! \brief Sets the IPC port of a presumably-running Crashpad handler process + //! \brief Sets the IPC pipe of a presumably-running Crashpad handler process //! which was started with StartHandler() or by other compatible means //! and does an IPC message exchange to register this process with the //! handler. However, just like StartHandler(), crashes are not serviced //! until UseHandler() is called. //! - //! The IPC port name (somehow) encodes enough information so that - //! registration is done with a crash handler using the appropriate database - //! and upload server. - //! //! \param[in] ipc_pipe The full name of the crash handler IPC pipe. This is //! a string of the form `"\\.\pipe\NAME"`. //! //! \return `true` on success and `false` on failure. bool SetHandlerIPCPipe(const std::wstring& ipc_pipe); + //! \brief Retrieves the IPC pipe name used to register with the Crashpad + //! handler. + //! + //! This method retrieves the IPC pipe name set by SetHandlerIPCPipe(), or a + //! suitable IPC pipe name chosen by StartHandler(). It is intended to be used + //! to obtain the IPC pipe name so that it may be passed to other processes, + //! so that they may register with an existing Crashpad handler by calling + //! SetHandlerIPCPipe(). + //! + //! This method is only defined on Windows. + //! + //! \return The full name of the crash handler IPC pipe, a string of the form + //! `"\\.\pipe\NAME"`. + std::wstring GetHandlerIPCPipe() const; + //! \brief Requests that the handler capture a dump even though there hasn't //! been a crash. //! diff --git a/client/crashpad_client_win.cc b/client/crashpad_client_win.cc index c4715ad5..3f23dde1 100644 --- a/client/crashpad_client_win.cc +++ b/client/crashpad_client_win.cc @@ -200,6 +200,11 @@ bool CrashpadClient::SetHandlerIPCPipe(const std::wstring& ipc_pipe) { return true; } +std::wstring CrashpadClient::GetHandlerIPCPipe() const { + DCHECK(!ipc_pipe_.empty()); + return ipc_pipe_; +} + bool CrashpadClient::UseHandler() { DCHECK(!ipc_pipe_.empty()); DCHECK_EQ(g_signal_exception, INVALID_HANDLE_VALUE);