OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/nacl/common/nacl_debug_exception_handler_win.h" | 5 #include "components/nacl/common/nacl_debug_exception_handler_win.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
10 #include "base/win/scoped_handle.h" | 12 #include "base/win/scoped_handle.h" |
11 #include "native_client/src/public/win/debug_exception_handler.h" | 13 #include "native_client/src/public/win/debug_exception_handler.h" |
12 | 14 |
13 namespace { | 15 namespace { |
14 | 16 |
15 class DebugExceptionHandler : public base::PlatformThread::Delegate { | 17 class DebugExceptionHandler : public base::PlatformThread::Delegate { |
16 public: | 18 public: |
17 DebugExceptionHandler(base::Process nacl_process, | 19 DebugExceptionHandler(base::Process nacl_process, |
18 const std::string& startup_info, | 20 const std::string& startup_info, |
19 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 21 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
20 const base::Callback<void(bool)>& on_connected) | 22 const base::Callback<void(bool)>& on_connected) |
21 : nacl_process_(nacl_process.Pass()), | 23 : nacl_process_(std::move(nacl_process)), |
22 startup_info_(startup_info), | 24 startup_info_(startup_info), |
23 task_runner_(task_runner), | 25 task_runner_(task_runner), |
24 on_connected_(on_connected) {} | 26 on_connected_(on_connected) {} |
25 | 27 |
26 void ThreadMain() override { | 28 void ThreadMain() override { |
27 // In the Windows API, the set of processes being debugged is | 29 // In the Windows API, the set of processes being debugged is |
28 // thread-local, so we have to attach to the process (using | 30 // thread-local, so we have to attach to the process (using |
29 // DebugActiveProcess()) on the same thread on which | 31 // DebugActiveProcess()) on the same thread on which |
30 // NaClDebugExceptionHandlerRun() receives debug events for the | 32 // NaClDebugExceptionHandlerRun() receives debug events for the |
31 // process. | 33 // process. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } // namespace | 66 } // namespace |
65 | 67 |
66 void NaClStartDebugExceptionHandlerThread( | 68 void NaClStartDebugExceptionHandlerThread( |
67 base::Process nacl_process, | 69 base::Process nacl_process, |
68 const std::string& startup_info, | 70 const std::string& startup_info, |
69 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 71 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
70 const base::Callback<void(bool)>& on_connected) { | 72 const base::Callback<void(bool)>& on_connected) { |
71 // The new PlatformThread will take ownership of the | 73 // The new PlatformThread will take ownership of the |
72 // DebugExceptionHandler object, which will delete itself on exit. | 74 // DebugExceptionHandler object, which will delete itself on exit. |
73 DebugExceptionHandler* handler = new DebugExceptionHandler( | 75 DebugExceptionHandler* handler = new DebugExceptionHandler( |
74 nacl_process.Pass(), startup_info, task_runner, on_connected); | 76 std::move(nacl_process), startup_info, task_runner, on_connected); |
75 if (!base::PlatformThread::CreateNonJoinable(0, handler)) { | 77 if (!base::PlatformThread::CreateNonJoinable(0, handler)) { |
76 on_connected.Run(false); | 78 on_connected.Run(false); |
77 delete handler; | 79 delete handler; |
78 } | 80 } |
79 } | 81 } |
OLD | NEW |