OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/test/base/chrome_process_util.h" | 5 #include "chrome/test/base/chrome_process_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 ++process_iter) { | 28 ++process_iter) { |
29 cmdline.push_back("-p"); | 29 cmdline.push_back("-p"); |
30 cmdline.push_back(base::IntToString(*process_iter)); | 30 cmdline.push_back(base::IntToString(*process_iter)); |
31 } | 31 } |
32 | 32 |
33 // Invoke it | 33 // Invoke it |
34 std::string ps_output; | 34 std::string ps_output; |
35 if (!base::GetAppOutput(base::CommandLine(cmdline), &ps_output)) | 35 if (!base::GetAppOutput(base::CommandLine(cmdline), &ps_output)) |
36 return result; // All the pids might have exited | 36 return result; // All the pids might have exited |
37 | 37 |
38 // Process the results | 38 // Process the results. |
39 std::vector<std::string> ps_output_lines; | 39 for (const std::string& raw_line : base::SplitString( |
40 base::SplitString(ps_output, '\n', &ps_output_lines); | 40 ps_output, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { |
41 std::vector<std::string>::const_iterator line_iter; | 41 std::string line(base::CollapseWhitespaceASCII(raw_line, false)); |
42 for (line_iter = ps_output_lines.begin(); | 42 std::vector<base::StringPiece> values = base::SplitStringPiece( |
43 line_iter != ps_output_lines.end(); | 43 line, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
44 ++line_iter) { | |
45 std::string line(base::CollapseWhitespaceASCII(*line_iter, false)); | |
46 std::vector<std::string> values; | |
47 base::SplitString(line, ' ', &values); | |
48 if (values.size() == 3) { | 44 if (values.size() == 3) { |
49 MacChromeProcessInfo proc_info; | 45 MacChromeProcessInfo proc_info; |
50 int pid; | 46 int pid; |
51 base::StringToInt(values[0], &pid); | 47 base::StringToInt(values[0], &pid); |
52 proc_info.pid = pid; | 48 proc_info.pid = pid; |
53 base::StringToInt(values[1], &proc_info.rsz_in_kb); | 49 base::StringToInt(values[1], &proc_info.rsz_in_kb); |
54 base::StringToInt(values[2], &proc_info.vsz_in_kb); | 50 base::StringToInt(values[2], &proc_info.vsz_in_kb); |
55 if (proc_info.pid && proc_info.rsz_in_kb && proc_info.vsz_in_kb) | 51 if (proc_info.pid && proc_info.rsz_in_kb && proc_info.vsz_in_kb) |
56 result.push_back(proc_info); | 52 result.push_back(proc_info); |
57 } | 53 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 GetMemoryValuesHack(process_handle_, &virtual_size, &working_set_size); | 95 GetMemoryValuesHack(process_handle_, &virtual_size, &working_set_size); |
100 return virtual_size; | 96 return virtual_size; |
101 } | 97 } |
102 | 98 |
103 size_t ChromeTestProcessMetrics::GetWorkingSetSize() { | 99 size_t ChromeTestProcessMetrics::GetWorkingSetSize() { |
104 size_t virtual_size; | 100 size_t virtual_size; |
105 size_t working_set_size; | 101 size_t working_set_size; |
106 GetMemoryValuesHack(process_handle_, &virtual_size, &working_set_size); | 102 GetMemoryValuesHack(process_handle_, &virtual_size, &working_set_size); |
107 return working_set_size; | 103 return working_set_size; |
108 } | 104 } |
OLD | NEW |