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 | |
| 5 | #ifndef PROCESS_WITH_OUTPUT_H |
| 6 | #define PROCESS_WITH_OUTPUT_H |
| 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 | |
| 13 | #include "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(); |
| 23 | ~ProcessWithOutput(); |
Elly Fong-Jones | d9a16cd | 2012-11-12 16:09:49 -0500 | [diff] [blame] | 24 | virtual bool Init(); |
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); |
| 27 | private: |
Ben Chan | 9953a59 | 2014-02-05 23:32:00 -0800 | [diff] [blame^] | 28 | base::FilePath outfile_path_; |
Elly Jones | 1c4c3a1 | 2011-12-20 15:01:59 -0500 | [diff] [blame] | 29 | FILE *outfile_; |
| 30 | }; |
| 31 | |
| 32 | }; // namespace debugd |
| 33 | |
| 34 | #endif // PROCESS_WITH_OUTPUT_H |