blob: bc2818e377120af2b305165b94abc0501dabf63e [file] [log] [blame]
Elly Fong-Jones5e367892012-09-18 13:07:09 -04001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Bertrand SIMONNETb54b6dc2014-07-02 12:13:56 -07005#ifndef LIBCHROMEOS_CHROMEOS_PROCESS_INFORMATION_H_
6#define LIBCHROMEOS_CHROMEOS_PROCESS_INFORMATION_H_
7
Elly Fong-Jones5e367892012-09-18 13:07:09 -04008#include <set>
9#include <string>
10#include <vector>
11
Alex Vakulenko847b8712014-08-29 10:43:06 -070012#include <chromeos/chromeos_export.h>
13
Elly Fong-Jones5e367892012-09-18 13:07:09 -040014namespace chromeos {
15
16// Information for a single running process. Stores its command line, set of
17// open files, process id and working directory.
Alex Vakulenko847b8712014-08-29 10:43:06 -070018class CHROMEOS_EXPORT ProcessInformation {
Elly Fong-Jones5e367892012-09-18 13:07:09 -040019 public:
20 ProcessInformation();
21 virtual ~ProcessInformation();
22
23 std::string GetCommandLine();
24
25 // Set the command line array. This method DOES swap out the contents of
26 // |value|. The caller should expect an empty vector on return.
27 void set_cmd_line(std::vector<std::string>* value) {
28 cmd_line_.clear();
29 cmd_line_.swap(*value);
30 }
31
Alex Vakulenko05d29042015-01-13 09:39:25 -080032 const std::vector<std::string>& get_cmd_line() { return cmd_line_; }
Elly Fong-Jones5e367892012-09-18 13:07:09 -040033
34 // Set the command line array. This method DOES swap out the contents of
35 // |value|. The caller should expect an empty set on return.
36 void set_open_files(std::set<std::string>* value) {
37 open_files_.clear();
38 open_files_.swap(*value);
39 }
40
Alex Vakulenko05d29042015-01-13 09:39:25 -080041 const std::set<std::string>& get_open_files() { return open_files_; }
Elly Fong-Jones5e367892012-09-18 13:07:09 -040042
43 // Set the command line array. This method DOES swap out the contents of
44 // |value|. The caller should expect an empty string on return.
45 void set_cwd(std::string* value) {
46 cwd_.clear();
47 cwd_.swap(*value);
48 }
49
Alex Vakulenko05d29042015-01-13 09:39:25 -080050 const std::string& get_cwd() { return cwd_; }
Elly Fong-Jones5e367892012-09-18 13:07:09 -040051
Alex Vakulenko05d29042015-01-13 09:39:25 -080052 void set_process_id(int value) { process_id_ = value; }
Elly Fong-Jones5e367892012-09-18 13:07:09 -040053
Alex Vakulenko05d29042015-01-13 09:39:25 -080054 int get_process_id() { return process_id_; }
Elly Fong-Jones5e367892012-09-18 13:07:09 -040055
56 private:
57 std::vector<std::string> cmd_line_;
58 std::set<std::string> open_files_;
59 std::string cwd_;
60 int process_id_;
61};
62
63} // namespace chromeos
Bertrand SIMONNETb54b6dc2014-07-02 12:13:56 -070064
65#endif // LIBCHROMEOS_CHROMEOS_PROCESS_INFORMATION_H_