blob: 9e34153edb91f5463c9ee677353c31361f482bb6 [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
5#ifndef PROCESS_WITH_OUTPUT_H
6#define PROCESS_WITH_OUTPUT_H
7
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
13#include "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();
23 ~ProcessWithOutput();
Elly Fong-Jonesd9a16cd2012-11-12 16:09:49 -050024 virtual bool Init();
Elly Jones1c4c3a12011-12-20 15:01:59 -050025 bool GetOutput(std::string* output);
26 bool GetOutputLines(std::vector<std::string>* output);
27 private:
Ben Chan9953a592014-02-05 23:32:00 -080028 base::FilePath outfile_path_;
Elly Jones1c4c3a12011-12-20 15:01:59 -050029 FILE *outfile_;
30};
31
32}; // namespace debugd
33
34#endif // PROCESS_WITH_OUTPUT_H