Elly Fong-Jones | 5e36789 | 2012-09-18 13:07:09 -0400 | [diff] [blame] | 1 | // 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 SIMONNET | b54b6dc | 2014-07-02 12:13:56 -0700 | [diff] [blame] | 5 | #ifndef LIBCHROMEOS_CHROMEOS_PROCESS_INFORMATION_H_ |
| 6 | #define LIBCHROMEOS_CHROMEOS_PROCESS_INFORMATION_H_ |
| 7 | |
Elly Fong-Jones | 5e36789 | 2012-09-18 13:07:09 -0400 | [diff] [blame] | 8 | #include <set> |
| 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
Alex Vakulenko | 847b871 | 2014-08-29 10:43:06 -0700 | [diff] [blame] | 12 | #include <chromeos/chromeos_export.h> |
| 13 | |
Elly Fong-Jones | 5e36789 | 2012-09-18 13:07:09 -0400 | [diff] [blame] | 14 | namespace chromeos { |
| 15 | |
| 16 | // Information for a single running process. Stores its command line, set of |
| 17 | // open files, process id and working directory. |
Alex Vakulenko | 847b871 | 2014-08-29 10:43:06 -0700 | [diff] [blame] | 18 | class CHROMEOS_EXPORT ProcessInformation { |
Elly Fong-Jones | 5e36789 | 2012-09-18 13:07:09 -0400 | [diff] [blame] | 19 | 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 Vakulenko | 05d2904 | 2015-01-13 09:39:25 -0800 | [diff] [blame^] | 32 | const std::vector<std::string>& get_cmd_line() { return cmd_line_; } |
Elly Fong-Jones | 5e36789 | 2012-09-18 13:07:09 -0400 | [diff] [blame] | 33 | |
| 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 Vakulenko | 05d2904 | 2015-01-13 09:39:25 -0800 | [diff] [blame^] | 41 | const std::set<std::string>& get_open_files() { return open_files_; } |
Elly Fong-Jones | 5e36789 | 2012-09-18 13:07:09 -0400 | [diff] [blame] | 42 | |
| 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 Vakulenko | 05d2904 | 2015-01-13 09:39:25 -0800 | [diff] [blame^] | 50 | const std::string& get_cwd() { return cwd_; } |
Elly Fong-Jones | 5e36789 | 2012-09-18 13:07:09 -0400 | [diff] [blame] | 51 | |
Alex Vakulenko | 05d2904 | 2015-01-13 09:39:25 -0800 | [diff] [blame^] | 52 | void set_process_id(int value) { process_id_ = value; } |
Elly Fong-Jones | 5e36789 | 2012-09-18 13:07:09 -0400 | [diff] [blame] | 53 | |
Alex Vakulenko | 05d2904 | 2015-01-13 09:39:25 -0800 | [diff] [blame^] | 54 | int get_process_id() { return process_id_; } |
Elly Fong-Jones | 5e36789 | 2012-09-18 13:07:09 -0400 | [diff] [blame] | 55 | |
| 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 SIMONNET | b54b6dc | 2014-07-02 12:13:56 -0700 | [diff] [blame] | 64 | |
| 65 | #endif // LIBCHROMEOS_CHROMEOS_PROCESS_INFORMATION_H_ |