mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-28 07:48:14 +08:00
win: Construct ExceptionHandlerServer() with its pipe argument (again)
This re-lands 9d03d54d0ba1, which was partially un-done by an apparent bad rebase leading up to fc7d8b3a27e1. Review URL: https://codereview.chromium.org/1424213005 .
This commit is contained in:
parent
fc7d8b3a27
commit
06ad194571
@ -41,18 +41,16 @@ class RunServerThread : public Thread {
|
||||
public:
|
||||
// Instantiates a thread which will invoke server->Run(delegate, pipe_name);
|
||||
RunServerThread(ExceptionHandlerServer* server,
|
||||
ExceptionHandlerServer::Delegate* delegate,
|
||||
const std::string& pipe_name)
|
||||
: server_(server), delegate_(delegate), pipe_name_(pipe_name) {}
|
||||
ExceptionHandlerServer::Delegate* delegate)
|
||||
: server_(server), delegate_(delegate) {}
|
||||
~RunServerThread() override {}
|
||||
|
||||
private:
|
||||
// Thread:
|
||||
void ThreadMain() override { server_->Run(delegate_, pipe_name_); }
|
||||
void ThreadMain() override { server_->Run(delegate_); }
|
||||
|
||||
ExceptionHandlerServer* server_;
|
||||
ExceptionHandlerServer::Delegate* delegate_;
|
||||
std::string pipe_name_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(RunServerThread);
|
||||
};
|
||||
@ -130,9 +128,8 @@ void TestCrashingChild(const base::string16& directory_modification) {
|
||||
ScopedKernelHANDLE completed(CreateEvent(nullptr, false, false, nullptr));
|
||||
CrashingDelegate delegate(server_ready.get(), completed.get());
|
||||
|
||||
ExceptionHandlerServer exception_handler_server;
|
||||
RunServerThread server_thread(
|
||||
&exception_handler_server, &delegate, pipe_name);
|
||||
ExceptionHandlerServer exception_handler_server(pipe_name);
|
||||
RunServerThread server_thread(&exception_handler_server, &delegate);
|
||||
server_thread.Start();
|
||||
ScopedStopServerAndJoinThread scoped_stop_server_and_join_thread(
|
||||
&exception_handler_server, &server_thread);
|
||||
@ -233,9 +230,8 @@ void TestDumpWithoutCrashingChild(
|
||||
ScopedKernelHANDLE completed(CreateEvent(nullptr, false, false, nullptr));
|
||||
SimulateDelegate delegate(server_ready.get(), completed.get());
|
||||
|
||||
ExceptionHandlerServer exception_handler_server;
|
||||
RunServerThread server_thread(
|
||||
&exception_handler_server, &delegate, pipe_name);
|
||||
ExceptionHandlerServer exception_handler_server(pipe_name);
|
||||
RunServerThread server_thread(&exception_handler_server, &delegate);
|
||||
server_thread.Start();
|
||||
ScopedStopServerAndJoinThread scoped_stop_server_and_join_thread(
|
||||
&exception_handler_server, &server_thread);
|
||||
|
@ -234,8 +234,9 @@ class ClientData {
|
||||
ExceptionHandlerServer::Delegate::~Delegate() {
|
||||
}
|
||||
|
||||
ExceptionHandlerServer::ExceptionHandlerServer()
|
||||
: port_(CreateIoCompletionPort(INVALID_HANDLE_VALUE, nullptr, 0, 1)),
|
||||
ExceptionHandlerServer::ExceptionHandlerServer(const std::string& pipe_name)
|
||||
: pipe_name_(pipe_name),
|
||||
port_(CreateIoCompletionPort(INVALID_HANDLE_VALUE, nullptr, 0, 1)),
|
||||
clients_lock_(),
|
||||
clients_() {
|
||||
}
|
||||
@ -243,13 +244,12 @@ ExceptionHandlerServer::ExceptionHandlerServer()
|
||||
ExceptionHandlerServer::~ExceptionHandlerServer() {
|
||||
}
|
||||
|
||||
void ExceptionHandlerServer::Run(Delegate* delegate,
|
||||
const std::string& pipe_name) {
|
||||
void ExceptionHandlerServer::Run(Delegate* delegate) {
|
||||
uint64_t shutdown_token = base::RandUint64();
|
||||
// We create two pipe instances, so that there's one listening while the
|
||||
// PipeServiceProc is processing a registration.
|
||||
ScopedKernelHANDLE thread_handles[2];
|
||||
base::string16 pipe_name_16(base::UTF8ToUTF16(pipe_name));
|
||||
base::string16 pipe_name_16(base::UTF8ToUTF16(pipe_name_));
|
||||
for (int i = 0; i < arraysize(thread_handles); ++i) {
|
||||
HANDLE pipe =
|
||||
CreateNamedPipe(pipe_name_16.c_str(),
|
||||
@ -311,7 +311,7 @@ void ExceptionHandlerServer::Run(Delegate* delegate,
|
||||
message.type = ClientToServerMessage::kShutdown;
|
||||
message.shutdown.token = shutdown_token;
|
||||
ServerToClientMessage response;
|
||||
SendToCrashHandlerServer(base::UTF8ToUTF16(pipe_name),
|
||||
SendToCrashHandlerServer(pipe_name_16,
|
||||
reinterpret_cast<ClientToServerMessage&>(message),
|
||||
&response);
|
||||
}
|
||||
|
@ -61,16 +61,18 @@ class ExceptionHandlerServer {
|
||||
};
|
||||
|
||||
//! \brief Constructs the exception handling server.
|
||||
ExceptionHandlerServer();
|
||||
//!
|
||||
//! \param[in] pipe_name The name of the pipe to listen on. Must be of the
|
||||
//! form "\\.\pipe\<some_name>".
|
||||
explicit ExceptionHandlerServer(const std::string& pipe_name);
|
||||
|
||||
~ExceptionHandlerServer();
|
||||
|
||||
//! \brief Runs the exception-handling server.
|
||||
//!
|
||||
//! \param[in] delegate The interface to which the exceptions are delegated
|
||||
//! when they are caught in Run(). Ownership is not transferred.
|
||||
//! \param[in] pipe_name The name of the pipe to listen on. Must be of the
|
||||
//! form "\\.\pipe\<some_name>".
|
||||
void Run(Delegate* delegate, const std::string& pipe_name);
|
||||
void Run(Delegate* delegate);
|
||||
|
||||
//! \brief Stops the exception-handling server. Returns immediately. The
|
||||
//! object must not be destroyed until Run() returns.
|
||||
@ -84,6 +86,7 @@ class ExceptionHandlerServer {
|
||||
static void __stdcall OnNonCrashDumpEvent(void* ctx, BOOLEAN);
|
||||
static void __stdcall OnProcessEnd(void* ctx, BOOLEAN);
|
||||
|
||||
std::string pipe_name_;
|
||||
ScopedKernelHANDLE port_;
|
||||
|
||||
base::Lock clients_lock_;
|
||||
|
@ -36,20 +36,18 @@ namespace {
|
||||
// Runs the ExceptionHandlerServer on a background thread.
|
||||
class RunServerThread : public Thread {
|
||||
public:
|
||||
// Instantiates a thread which will invoke server->Run(delegate, pipe_name).
|
||||
// Instantiates a thread which will invoke server->Run(delegate).
|
||||
RunServerThread(ExceptionHandlerServer* server,
|
||||
ExceptionHandlerServer::Delegate* delegate,
|
||||
const std::string& pipe_name)
|
||||
: server_(server), delegate_(delegate), pipe_name_(pipe_name) {}
|
||||
ExceptionHandlerServer::Delegate* delegate)
|
||||
: server_(server), delegate_(delegate) {}
|
||||
~RunServerThread() override {}
|
||||
|
||||
private:
|
||||
// Thread:
|
||||
void ThreadMain() override { server_->Run(delegate_, pipe_name_); }
|
||||
void ThreadMain() override { server_->Run(delegate_); }
|
||||
|
||||
ExceptionHandlerServer* server_;
|
||||
ExceptionHandlerServer::Delegate* delegate_;
|
||||
std::string pipe_name_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(RunServerThread);
|
||||
};
|
||||
@ -85,8 +83,8 @@ class ExceptionHandlerServerTest : public testing::Test {
|
||||
base::StringPrintf("%08x", GetCurrentProcessId())),
|
||||
server_ready_(CreateEvent(nullptr, false, false, nullptr)),
|
||||
delegate_(server_ready_.get()),
|
||||
server_(),
|
||||
server_thread_(&server_, &delegate_, pipe_name_) {}
|
||||
server_(pipe_name_),
|
||||
server_thread_(&server_, &delegate_) {}
|
||||
|
||||
TestDelegate& delegate() { return delegate_; }
|
||||
ExceptionHandlerServer& server() { return server_; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user