| 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 "chrome/browser/metrics/metrics_memory_details.h" | 5 #include "chrome/browser/metrics/metrics_memory_details.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "components/nacl/common/nacl_process_type.h" | 17 #include "components/nacl/common/nacl_process_type.h" |
| 18 #include "content/public/browser/render_process_host.h" | 18 #include "content/public/browser/render_process_host.h" |
| 19 #include "content/public/common/content_constants.h" | 19 #include "content/public/common/content_constants.h" |
| 20 #include "content/public/common/process_type.h" | 20 #include "content/public/common/process_type.h" |
| 21 #include "ppapi/features/features.h" | 21 #include "ppapi/features/features.h" |
| 22 | 22 |
| 23 #if defined(OS_MACOSX) |
| 24 #include "base/mac/mac_util.h" |
| 25 #endif |
| 26 |
| 23 MemoryGrowthTracker::MemoryGrowthTracker() { | 27 MemoryGrowthTracker::MemoryGrowthTracker() { |
| 24 } | 28 } |
| 25 | 29 |
| 26 MemoryGrowthTracker::~MemoryGrowthTracker() { | 30 MemoryGrowthTracker::~MemoryGrowthTracker() { |
| 27 } | 31 } |
| 28 | 32 |
| 29 bool MemoryGrowthTracker::UpdateSample(base::ProcessId pid, | 33 bool MemoryGrowthTracker::UpdateSample(base::ProcessId pid, |
| 30 int sample, | 34 int sample, |
| 31 int* diff) { | 35 int* diff) { |
| 32 // |sample| is memory usage in kB. | 36 // |sample| is memory usage in kB. |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 continue; | 168 continue; |
| 165 case content::PROCESS_TYPE_SANDBOX_HELPER: | 169 case content::PROCESS_TYPE_SANDBOX_HELPER: |
| 166 UMA_HISTOGRAM_MEMORY_KB("Memory.SandboxHelper", sample); | 170 UMA_HISTOGRAM_MEMORY_KB("Memory.SandboxHelper", sample); |
| 167 if (num_open_fds != -1) { | 171 if (num_open_fds != -1) { |
| 168 UMA_HISTOGRAM_COUNTS_10000("Memory.SandboxHelper.OpenFDs", | 172 UMA_HISTOGRAM_COUNTS_10000("Memory.SandboxHelper.OpenFDs", |
| 169 num_open_fds); | 173 num_open_fds); |
| 170 } | 174 } |
| 171 other_count++; | 175 other_count++; |
| 172 continue; | 176 continue; |
| 173 case content::PROCESS_TYPE_GPU: | 177 case content::PROCESS_TYPE_GPU: |
| 178 #if defined(OS_MACOSX) |
| 179 // Physical footprint was introduced in macOS 10.11. |
| 180 if (base::mac::IsAtLeastOS10_11()) { |
| 181 UMA_HISTOGRAM_MEMORY_LARGE_MB( |
| 182 "Memory.Gpu.PhysicalFootprint.MacOS", |
| 183 browser.processes[index].phys_footprint / 1024 / 1024); |
| 184 } |
| 185 #endif |
| 174 UMA_HISTOGRAM_MEMORY_KB("Memory.Gpu", sample); | 186 UMA_HISTOGRAM_MEMORY_KB("Memory.Gpu", sample); |
| 175 if (num_open_fds != -1 && open_fds_soft_limit != -1) { | 187 if (num_open_fds != -1 && open_fds_soft_limit != -1) { |
| 176 UMA_HISTOGRAM_COUNTS_10000("Memory.Gpu.OpenFDs", num_open_fds); | 188 UMA_HISTOGRAM_COUNTS_10000("Memory.Gpu.OpenFDs", num_open_fds); |
| 177 UMA_HISTOGRAM_COUNTS_10000("Memory.Gpu.OpenFDsSoftLimit", | 189 UMA_HISTOGRAM_COUNTS_10000("Memory.Gpu.OpenFDsSoftLimit", |
| 178 open_fds_soft_limit); | 190 open_fds_soft_limit); |
| 179 } | 191 } |
| 180 other_count++; | 192 other_count++; |
| 181 continue; | 193 continue; |
| 182 #if BUILDFLAG(ENABLE_PLUGINS) | 194 #if BUILDFLAG(ENABLE_PLUGINS) |
| 183 case content::PROCESS_TYPE_PPAPI_PLUGIN: { | 195 case content::PROCESS_TYPE_PPAPI_PLUGIN: { |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 memory_growth_tracker_->UpdateSample(process_entry.pid, sample, | 381 memory_growth_tracker_->UpdateSample(process_entry.pid, sample, |
| 370 &diff) && | 382 &diff) && |
| 371 generate_histograms_) { | 383 generate_histograms_) { |
| 372 if (diff < 0) | 384 if (diff < 0) |
| 373 UMA_HISTOGRAM_MEMORY_KB("Memory.RendererShrinkIn30Min", -diff); | 385 UMA_HISTOGRAM_MEMORY_KB("Memory.RendererShrinkIn30Min", -diff); |
| 374 else | 386 else |
| 375 UMA_HISTOGRAM_MEMORY_KB("Memory.RendererGrowthIn30Min", diff); | 387 UMA_HISTOGRAM_MEMORY_KB("Memory.RendererGrowthIn30Min", diff); |
| 376 } | 388 } |
| 377 } | 389 } |
| 378 } | 390 } |
| OLD | NEW |