| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/nacl_debug_exception_handler_win.h" | 5 #include "chrome/common/nacl_debug_exception_handler_win.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/process_util.h" | 8 #include "base/process_util.h" |
| 9 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
| 10 #include "base/win/scoped_handle.h" | 10 #include "base/win/scoped_handle.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 } else { | 36 } else { |
| 37 if (!DebugActiveProcess(pid)) { | 37 if (!DebugActiveProcess(pid)) { |
| 38 LOG(ERROR) << "Failed to connect to the process"; | 38 LOG(ERROR) << "Failed to connect to the process"; |
| 39 } else { | 39 } else { |
| 40 attached = true; | 40 attached = true; |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 message_loop_->PostTask(FROM_HERE, base::Bind(on_connected_, attached)); | 43 message_loop_->PostTask(FROM_HERE, base::Bind(on_connected_, attached)); |
| 44 | 44 |
| 45 if (attached) { | 45 if (attached) { |
| 46 // TODO(mseaborn): Clean up the NaCl side to remove the need for | |
| 47 // a const_cast here. | |
| 48 NaClDebugExceptionHandlerRun( | 46 NaClDebugExceptionHandlerRun( |
| 49 nacl_process_, | 47 nacl_process_, |
| 50 reinterpret_cast<void*>(const_cast<char*>(startup_info_.data())), | 48 reinterpret_cast<const void*>(startup_info_.data()), |
| 51 startup_info_.size()); | 49 startup_info_.size()); |
| 52 } | 50 } |
| 53 delete this; | 51 delete this; |
| 54 } | 52 } |
| 55 | 53 |
| 56 private: | 54 private: |
| 57 base::win::ScopedHandle nacl_process_; | 55 base::win::ScopedHandle nacl_process_; |
| 58 std::string startup_info_; | 56 std::string startup_info_; |
| 59 base::MessageLoopProxy* message_loop_; | 57 base::MessageLoopProxy* message_loop_; |
| 60 base::Callback<void(bool)> on_connected_; | 58 base::Callback<void(bool)> on_connected_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 71 const base::Callback<void(bool)>& on_connected) { | 69 const base::Callback<void(bool)>& on_connected) { |
| 72 // The new PlatformThread will take ownership of the | 70 // The new PlatformThread will take ownership of the |
| 73 // DebugExceptionHandler object, which will delete itself on exit. | 71 // DebugExceptionHandler object, which will delete itself on exit. |
| 74 DebugExceptionHandler* handler = new DebugExceptionHandler( | 72 DebugExceptionHandler* handler = new DebugExceptionHandler( |
| 75 nacl_process, startup_info, message_loop, on_connected); | 73 nacl_process, startup_info, message_loop, on_connected); |
| 76 if (!base::PlatformThread::CreateNonJoinable(0, handler)) { | 74 if (!base::PlatformThread::CreateNonJoinable(0, handler)) { |
| 77 on_connected.Run(false); | 75 on_connected.Run(false); |
| 78 delete handler; | 76 delete handler; |
| 79 } | 77 } |
| 80 } | 78 } |
| OLD | NEW |