| 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/process_metrics_memory_dump_provider.h" | 5 #include "components/tracing/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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 pmd->set_has_process_mmaps(); | 196 pmd->set_has_process_mmaps(); |
| 197 return res; | 197 return res; |
| 198 } | 198 } |
| 199 #endif // defined(OS_LINUX) || defined(OS_ANDROID) | 199 #endif // defined(OS_LINUX) || defined(OS_ANDROID) |
| 200 | 200 |
| 201 // static | 201 // static |
| 202 void ProcessMetricsMemoryDumpProvider::RegisterForProcess( | 202 void ProcessMetricsMemoryDumpProvider::RegisterForProcess( |
| 203 base::ProcessId process) { | 203 base::ProcessId process) { |
| 204 scoped_ptr<ProcessMetricsMemoryDumpProvider> metrics_provider( | 204 scoped_ptr<ProcessMetricsMemoryDumpProvider> metrics_provider( |
| 205 new ProcessMetricsMemoryDumpProvider(process)); | 205 new ProcessMetricsMemoryDumpProvider(process)); |
| 206 base::trace_event::MemoryDumpProvider::Options options(process); | 206 base::trace_event::MemoryDumpProvider::Options options; |
| 207 options.target_pid = process; |
| 207 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( | 208 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( |
| 208 metrics_provider.get(), "ProcessMemoryMetrics", nullptr, options); | 209 metrics_provider.get(), "ProcessMemoryMetrics", nullptr, options); |
| 209 bool did_insert = | 210 bool did_insert = |
| 210 g_dump_providers_map.Get() | 211 g_dump_providers_map.Get() |
| 211 .insert(std::make_pair(process, std::move(metrics_provider))) | 212 .insert(std::make_pair(process, std::move(metrics_provider))) |
| 212 .second; | 213 .second; |
| 213 if (!did_insert) { | 214 if (!did_insert) { |
| 214 DLOG(ERROR) << "ProcessMetricsMemoryDumpProvider already registered for " | 215 DLOG(ERROR) << "ProcessMetricsMemoryDumpProvider already registered for " |
| 215 << (process == base::kNullProcessId | 216 << (process == base::kNullProcessId |
| 216 ? "current process" | 217 ? "current process" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 | 297 |
| 297 pmd->process_totals()->set_resident_set_bytes(rss_bytes); | 298 pmd->process_totals()->set_resident_set_bytes(rss_bytes); |
| 298 pmd->set_has_process_totals(); | 299 pmd->set_has_process_totals(); |
| 299 pmd->process_totals()->set_peak_resident_set_bytes(peak_rss_bytes); | 300 pmd->process_totals()->set_peak_resident_set_bytes(peak_rss_bytes); |
| 300 | 301 |
| 301 // Returns true even if other metrics failed, since rss is reported. | 302 // Returns true even if other metrics failed, since rss is reported. |
| 302 return true; | 303 return true; |
| 303 } | 304 } |
| 304 | 305 |
| 305 } // namespace tracing | 306 } // namespace tracing |
| OLD | NEW |