Index: chrome/nacl/nacl_broker_listener.cc |
diff --git a/chrome/nacl/nacl_broker_listener.cc b/chrome/nacl/nacl_broker_listener.cc |
index 8d1360001b61537c3d7a28c88e29465e139980e9..086f2a66c3fcdaa5b1b6b78c683dc9acee0ad7e0 100644 |
--- a/chrome/nacl/nacl_broker_listener.cc |
+++ b/chrome/nacl/nacl_broker_listener.cc |
@@ -11,13 +11,12 @@ |
#include "base/message_loop_proxy.h" |
#include "base/path_service.h" |
#include "base/process_util.h" |
-#include "base/threading/platform_thread.h" |
#include "chrome/common/nacl_cmd_line.h" |
+#include "chrome/common/nacl_debug_exception_handler_win.h" |
#include "chrome/common/nacl_messages.h" |
#include "content/common/sandbox_policy.h" |
#include "content/public/common/content_switches.h" |
#include "ipc/ipc_switches.h" |
-#include "native_client/src/trusted/service_runtime/win/debug_exception_handler.h" |
namespace { |
@@ -25,62 +24,6 @@ void SendReply(IPC::Channel* channel, int32 pid) { |
channel->Send(new NaClProcessMsg_DebugExceptionHandlerLaunched(pid)); |
} |
-class DebugExceptionHandler : public base::PlatformThread::Delegate { |
- public: |
- DebugExceptionHandler(base::MessageLoopProxy* message_loop, |
- IPC::Channel* channel, int32 pid) |
- : message_loop_(message_loop), channel_(channel), pid_(pid) { |
- } |
- |
- virtual void ThreadMain() OVERRIDE { |
- // In the Windows API, the set of processes being debugged is |
- // thread-local, so we have to attach to the process (using |
- // DebugActiveProcess()) on the same thread on which |
- // NaClDebugLoop() receives debug events for the process. |
- BOOL attached = false; |
- base::ProcessHandle process_handle = base::kNullProcessHandle; |
- if (!base::OpenProcessHandleWithAccess( |
- pid_, |
- base::kProcessAccessQueryInformation | |
- base::kProcessAccessSuspendResume | |
- base::kProcessAccessTerminate | |
- base::kProcessAccessVMOperation | |
- base::kProcessAccessVMRead | |
- base::kProcessAccessVMWrite | |
- base::kProcessAccessWaitForTermination, |
- &process_handle)) { |
- LOG(ERROR) << "Failed to get process handle"; |
- } else { |
- attached = DebugActiveProcess(pid_); |
- if (!attached) { |
- LOG(ERROR) << "Failed to connect to the process"; |
- } |
- } |
- // At the moment we do not say in the reply whether attaching as a |
- // debugger succeeded. In the future, when we attach on demand |
- // when an exception handler is first registered, we can make the |
- // NaCl syscall indicate whether attaching succeeded. |
- message_loop_->PostDelayedTask(FROM_HERE, |
- base::Bind(SendReply, channel_, pid_), base::TimeDelta()); |
- |
- if (attached) { |
- DWORD exit_code; |
- NaClDebugLoop(process_handle, &exit_code); |
- } |
- if (process_handle != base::kNullProcessHandle) { |
- base::CloseProcessHandle(process_handle); |
- } |
- delete this; |
- } |
- |
- private: |
- base::MessageLoopProxy* message_loop_; |
- IPC::Channel* channel_; |
- int32 pid_; |
- |
- DISALLOW_COPY_AND_ASSIGN(DebugExceptionHandler); |
-}; |
- |
} // namespace |
NaClBrokerListener::NaClBrokerListener() |
@@ -156,14 +99,9 @@ void NaClBrokerListener::OnLaunchLoaderThroughBroker( |
} |
void NaClBrokerListener::OnLaunchDebugExceptionHandler(int32 pid) { |
- // The new PlatformThread will take ownership of the |
- // DebugExceptionHandler object, which will delete itself on exit. |
- DebugExceptionHandler* handler = new DebugExceptionHandler( |
- base::MessageLoopProxy::current(), channel_.get(), pid); |
- if (!base::PlatformThread::CreateNonJoinable(0, handler)) { |
- SendReply(channel_.get(), pid); |
- delete handler; |
- } |
+ base::Closure reply_sender(base::Bind(SendReply, channel_.get(), pid)); |
+ NaClStartDebugExceptionHandlerThread(pid, base::MessageLoopProxy::current(), |
+ reply_sender); |
} |
void NaClBrokerListener::OnStopBroker() { |