Elly Jones | a44d22d | 2012-01-05 18:05:56 -0500 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Elly Jones | 1c4c3a1 | 2011-12-20 15:01:59 -0500 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 5 | #ifndef DEBUGD_SRC_PROCESS_WITH_OUTPUT_H_ |
| 6 | #define DEBUGD_SRC_PROCESS_WITH_OUTPUT_H_ |
Elly Jones | 1c4c3a1 | 2011-12-20 15:01:59 -0500 | [diff] [blame] | 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
Ben Chan | 9953a59 | 2014-02-05 23:32:00 -0800 | [diff] [blame] | 11 | #include <base/files/file_path.h> |
Elly Fong-Jones | d9a16cd | 2012-11-12 16:09:49 -0500 | [diff] [blame] | 12 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 13 | #include "debugd/src/sandboxed_process.h" |
Elly Jones | 1c4c3a1 | 2011-12-20 15:01:59 -0500 | [diff] [blame] | 14 | |
| 15 | namespace debugd { |
| 16 | |
| 17 | // @brief Represents a process whose output can be collected. |
| 18 | // |
| 19 | // The process must be Run() to completion before its output can be collected. |
Elly Fong-Jones | d9a16cd | 2012-11-12 16:09:49 -0500 | [diff] [blame] | 20 | class ProcessWithOutput : public SandboxedProcess { |
Elly Jones | 1c4c3a1 | 2011-12-20 15:01:59 -0500 | [diff] [blame] | 21 | public: |
| 22 | ProcessWithOutput(); |
Ben Chan | 4b11012 | 2014-08-29 08:22:59 -0700 | [diff] [blame] | 23 | ~ProcessWithOutput() override; |
| 24 | bool Init() override; |
Elly Jones | 1c4c3a1 | 2011-12-20 15:01:59 -0500 | [diff] [blame] | 25 | bool GetOutput(std::string* output); |
| 26 | bool GetOutputLines(std::vector<std::string>* output); |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame] | 27 | |
Elly Jones | 1c4c3a1 | 2011-12-20 15:01:59 -0500 | [diff] [blame] | 28 | private: |
Ben Chan | 9953a59 | 2014-02-05 23:32:00 -0800 | [diff] [blame] | 29 | base::FilePath outfile_path_; |
Elly Jones | 1c4c3a1 | 2011-12-20 15:01:59 -0500 | [diff] [blame] | 30 | FILE *outfile_; |
| 31 | }; |
| 32 | |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame] | 33 | } // namespace debugd |
Elly Jones | 1c4c3a1 | 2011-12-20 15:01:59 -0500 | [diff] [blame] | 34 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 35 | #endif // DEBUGD_SRC_PROCESS_WITH_OUTPUT_H_ |