OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/tracing/common/process_metrics_memory_dump_provider.h" | 5 #include "components/tracing/common/process_metrics_memory_dump_provider.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 } | 153 } |
154 } | 154 } |
155 } | 155 } |
156 return num_valid_regions; | 156 return num_valid_regions; |
157 } | 157 } |
158 #endif // defined(OS_LINUX) || defined(OS_ANDROID) | 158 #endif // defined(OS_LINUX) || defined(OS_ANDROID) |
159 | 159 |
160 std::unique_ptr<base::ProcessMetrics> CreateProcessMetrics( | 160 std::unique_ptr<base::ProcessMetrics> CreateProcessMetrics( |
161 base::ProcessId process) { | 161 base::ProcessId process) { |
162 if (process == base::kNullProcessId) | 162 if (process == base::kNullProcessId) |
163 return base::WrapUnique( | 163 return base::ProcessMetrics::CreateCurrentProcessMetrics(); |
164 base::ProcessMetrics::CreateCurrentProcessMetrics()); | |
165 #if defined(OS_LINUX) || defined(OS_ANDROID) | 164 #if defined(OS_LINUX) || defined(OS_ANDROID) |
166 // Just pass ProcessId instead of handle since they are the same in linux and | 165 // Just pass ProcessId instead of handle since they are the same in linux and |
167 // android. | 166 // android. |
168 return base::WrapUnique(base::ProcessMetrics::CreateProcessMetrics(process)); | 167 return base::ProcessMetrics::CreateProcessMetrics(process); |
169 #else | 168 #else |
170 // Creating process metrics for child processes in mac or windows requires | 169 // Creating process metrics for child processes in mac or windows requires |
171 // additional information like ProcessHandle or port provider. This is a non | 170 // additional information like ProcessHandle or port provider. |
172 // needed use case. | |
173 NOTREACHED(); | 171 NOTREACHED(); |
174 return std::unique_ptr<base::ProcessMetrics>(); | 172 return std::unique_ptr<base::ProcessMetrics>(); |
175 #endif // defined(OS_LINUX) || defined(OS_ANDROID) | 173 #endif // defined(OS_LINUX) || defined(OS_ANDROID) |
176 } | 174 } |
177 | 175 |
178 } // namespace | 176 } // namespace |
179 | 177 |
180 // static | 178 // static |
181 uint64_t ProcessMetricsMemoryDumpProvider::rss_bytes_for_testing = 0; | 179 uint64_t ProcessMetricsMemoryDumpProvider::rss_bytes_for_testing = 0; |
182 | 180 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 | 303 |
306 pmd->process_totals()->set_resident_set_bytes(rss_bytes); | 304 pmd->process_totals()->set_resident_set_bytes(rss_bytes); |
307 pmd->set_has_process_totals(); | 305 pmd->set_has_process_totals(); |
308 pmd->process_totals()->set_peak_resident_set_bytes(peak_rss_bytes); | 306 pmd->process_totals()->set_peak_resident_set_bytes(peak_rss_bytes); |
309 | 307 |
310 // Returns true even if other metrics failed, since rss is reported. | 308 // Returns true even if other metrics failed, since rss is reported. |
311 return true; | 309 return true; |
312 } | 310 } |
313 | 311 |
314 } // namespace tracing | 312 } // namespace tracing |
OLD | NEW |