| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/memory_pressure/direct_memory_pressure_calculator_linux.h" | 5 #include "components/memory_pressure/direct_memory_pressure_calculator_linux.h" |
| 6 | 6 |
| 7 #include "base/process/process_metrics.h" | 7 #include "base/process/process_metrics.h" |
| 8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
| 9 | 9 |
| 10 namespace memory_pressure { | 10 namespace memory_pressure { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 static const int kKiBperMiB = 1024; | 14 const int kKiBperMiB = 1024; |
| 15 | 15 |
| 16 int GetAvailableSystemMemoryMiB(const base::SystemMemoryInfoKB* mem_info) { | 16 int GetAvailableSystemMemoryMiB(const base::SystemMemoryInfoKB* mem_info) { |
| 17 // How much system memory is actively available for use right now, in MBs. | 17 // How much system memory is actively available for use right now, in MBs. |
| 18 return (mem_info->available | 18 return (mem_info->available |
| 19 ? mem_info->available | 19 ? mem_info->available |
| 20 : (mem_info->free + mem_info->buffers + mem_info->cached)) / | 20 : (mem_info->free + mem_info->buffers + mem_info->cached)) / |
| 21 kKiBperMiB; | 21 kKiBperMiB; |
| 22 } | 22 } |
| 23 | 23 |
| 24 } // namespace | 24 } // namespace |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 if (!GetSystemMemoryInfo(&mem_info)) | 71 if (!GetSystemMemoryInfo(&mem_info)) |
| 72 return; | 72 return; |
| 73 | 73 |
| 74 moderate_threshold_mb_ = | 74 moderate_threshold_mb_ = |
| 75 mem_info.total * (100 - kDefaultModerateThresholdPc) / 100 / kKiBperMiB; | 75 mem_info.total * (100 - kDefaultModerateThresholdPc) / 100 / kKiBperMiB; |
| 76 critical_threshold_mb_ = | 76 critical_threshold_mb_ = |
| 77 mem_info.total * (100 - kDefaultCriticalThresholdPc) / 100 / kKiBperMiB; | 77 mem_info.total * (100 - kDefaultCriticalThresholdPc) / 100 / kKiBperMiB; |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace memory_pressure | 80 } // namespace memory_pressure |
| OLD | NEW |