blob: 2817f3e1758ffd4a1d884cb1bb588eb56504a260 [file] [log] [blame]
Elly Jonesa44d22d2012-01-05 18:05:56 -05001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Elly Jones1c4c3a12011-12-20 15:01:59 -05002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Alex Vakulenko262be3f2014-07-30 15:25:50 -07005#ifndef DEBUGD_SRC_PROCESS_WITH_OUTPUT_H_
6#define DEBUGD_SRC_PROCESS_WITH_OUTPUT_H_
Elly Jones1c4c3a12011-12-20 15:01:59 -05007
8#include <string>
9#include <vector>
10
Ben Chan9953a592014-02-05 23:32:00 -080011#include <base/files/file_path.h>
Elly Fong-Jonesd9a16cd2012-11-12 16:09:49 -050012
Alex Vakulenko262be3f2014-07-30 15:25:50 -070013#include "debugd/src/sandboxed_process.h"
Elly Jones1c4c3a12011-12-20 15:01:59 -050014
15namespace 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-Jonesd9a16cd2012-11-12 16:09:49 -050020class ProcessWithOutput : public SandboxedProcess {
Elly Jones1c4c3a12011-12-20 15:01:59 -050021 public:
22 ProcessWithOutput();
Ben Chan4b110122014-08-29 08:22:59 -070023 ~ProcessWithOutput() override;
24 bool Init() override;
Elly Jones1c4c3a12011-12-20 15:01:59 -050025 bool GetOutput(std::string* output);
26 bool GetOutputLines(std::vector<std::string>* output);
Ben Chana0011d82014-05-13 00:19:29 -070027
Elly Jones1c4c3a12011-12-20 15:01:59 -050028 private:
Ben Chan9953a592014-02-05 23:32:00 -080029 base::FilePath outfile_path_;
Elly Jones1c4c3a12011-12-20 15:01:59 -050030 FILE *outfile_;
31};
32
Ben Chana0011d82014-05-13 00:19:29 -070033} // namespace debugd
Elly Jones1c4c3a12011-12-20 15:01:59 -050034
Alex Vakulenko262be3f2014-07-30 15:25:50 -070035#endif // DEBUGD_SRC_PROCESS_WITH_OUTPUT_H_