Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 | |
| 15 #ifndef CRASHPAD_TEST_WIN_CHILD_LAUNCHER_H_ | |
| 16 #define CRASHPAD_TEST_WIN_CHILD_LAUNCHER_H_ | |
| 17 | |
| 18 #include <windows.h> | |
| 19 | |
| 20 #include <string> | |
| 21 | |
| 22 #include "util/win/scoped_handle.h" | |
| 23 | |
| 24 namespace crashpad { | |
| 25 | |
| 26 //! \brief Creates a child process for testing. Uses gtest `ASSERT_*` to | |
| 27 //! indicate failure. The child's output is passed through a pipe and is | |
| 28 //! available via stdout_read_handle(). | |
| 29 class ChildLauncher { | |
| 30 public: | |
| 31 //! \brief Creates the object. \a executable will be prepended to | |
| 32 //! \a command_line to build the command line of the child. | |
| 33 ChildLauncher(const std::wstring& executable, | |
| 34 const std::wstring& command_line); | |
| 35 | |
| 36 ~ChildLauncher(); | |
| 37 | |
| 38 //! \brief Starts the child process, after which the handle functions below | |
| 39 //! will be valid. | |
| 40 void Start(); | |
| 41 | |
| 42 //! \brief The child process's `HANDLE`. | |
| 43 HANDLE process_handle() const { return process_handle_.get(); } | |
| 44 | |
| 45 //! \brief The main thread's `HANDLE`. | |
|
Mark Mentovai
2015/09/19 03:02:47
child process’ main thread’s `HANDLE`, right?
scottmg
2015/09/19 04:24:42
Yes, done.
| |
| 46 HANDLE main_thread_handle() const { return main_thread_handle_.get(); } | |
| 47 | |
| 48 //! \brief The read end of a pipe attached to the child's stdout. | |
| 49 HANDLE stdout_read_handle() const { return stdout_read_handle_.get(); } | |
| 50 | |
| 51 private: | |
| 52 std::wstring executable_; | |
| 53 std::wstring command_line_; | |
| 54 ScopedKernelHANDLE process_handle_; | |
| 55 ScopedKernelHANDLE main_thread_handle_; | |
| 56 ScopedFileHANDLE stdout_read_handle_; | |
| 57 }; | |
| 58 | |
| 59 } // namespace crashpad | |
| 60 | |
| 61 #endif // CRASHPAD_TEST_WIN_CHILD_LAUNCHER_H_ | |
| OLD | NEW |