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 <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <string> | 10 #include <string> |
8 #include <vector> | 11 #include <vector> |
9 | 12 |
10 #include "base/command_line.h" | 13 #include "base/command_line.h" |
11 #include "base/process/launch.h" | 14 #include "base/process/launch.h" |
12 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
14 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
15 | 18 |
16 MacChromeProcessInfoList GetRunningMacProcessInfo( | 19 MacChromeProcessInfoList GetRunningMacProcessInfo( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 56 } |
54 } | 57 } |
55 | 58 |
56 return result; | 59 return result; |
57 } | 60 } |
58 | 61 |
59 // Common interface for fetching memory values from parsed ps output. | 62 // Common interface for fetching memory values from parsed ps output. |
60 // We fill in both values we may get called for, even though our | 63 // We fill in both values we may get called for, even though our |
61 // callers typically only care about one, just to keep the code | 64 // callers typically only care about one, just to keep the code |
62 // simple and because this is a test. | 65 // simple and because this is a test. |
63 static bool GetMemoryValuesHack(uint32 process_id, | 66 static bool GetMemoryValuesHack(uint32_t process_id, |
64 size_t* virtual_size, | 67 size_t* virtual_size, |
65 size_t* working_set_size) { | 68 size_t* working_set_size) { |
66 DCHECK(virtual_size && working_set_size); | 69 DCHECK(virtual_size && working_set_size); |
67 | 70 |
68 std::vector<base::ProcessId> processes; | 71 std::vector<base::ProcessId> processes; |
69 processes.push_back(process_id); | 72 processes.push_back(process_id); |
70 | 73 |
71 MacChromeProcessInfoList process_info = GetRunningMacProcessInfo(processes); | 74 MacChromeProcessInfoList process_info = GetRunningMacProcessInfo(processes); |
72 if (process_info.empty()) | 75 if (process_info.empty()) |
73 return false; | 76 return false; |
74 | 77 |
75 bool found_process = false; | 78 bool found_process = false; |
(...skipping 19 matching lines...) Expand all Loading... |
95 GetMemoryValuesHack(process_handle_, &virtual_size, &working_set_size); | 98 GetMemoryValuesHack(process_handle_, &virtual_size, &working_set_size); |
96 return virtual_size; | 99 return virtual_size; |
97 } | 100 } |
98 | 101 |
99 size_t ChromeTestProcessMetrics::GetWorkingSetSize() { | 102 size_t ChromeTestProcessMetrics::GetWorkingSetSize() { |
100 size_t virtual_size; | 103 size_t virtual_size; |
101 size_t working_set_size; | 104 size_t working_set_size; |
102 GetMemoryValuesHack(process_handle_, &virtual_size, &working_set_size); | 105 GetMemoryValuesHack(process_handle_, &virtual_size, &working_set_size); |
103 return working_set_size; | 106 return working_set_size; |
104 } | 107 } |
OLD | NEW |