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/memory_pressure/direct_memory_pressure_calculator_win.h" | 5 #include "components/memory_pressure/direct_memory_pressure_calculator_win.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/process/process_metrics.h" | 8 #include "base/process/process_metrics.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 if (large_memory) | 52 if (large_memory) |
53 return total_mb * 2; | 53 return total_mb * 2; |
54 return total_mb / 2; | 54 return total_mb / 2; |
55 } | 55 } |
56 | 56 |
57 // Sets up the memory status to reflect the provided absolute memory left. | 57 // Sets up the memory status to reflect the provided absolute memory left. |
58 void SetMemoryFree(int phys_left_mb) { | 58 void SetMemoryFree(int phys_left_mb) { |
59 // |total| is set in the constructor and not modified. | 59 // |total| is set in the constructor and not modified. |
60 | 60 |
61 // Set the amount of free memory. | 61 // Set the amount of free memory. |
62 mem_info_.free = phys_left_mb * kKBperMB; | 62 mem_info_.available = phys_left_mb * kKBperMB; |
63 DCHECK_LT(mem_info_.free, mem_info_.total); | 63 DCHECK_LT(mem_info_.available, mem_info_.total); |
64 } | 64 } |
65 | 65 |
66 void SetNone() { SetMemoryFree(moderate_threshold_mb() + 1); } | 66 void SetNone() { SetMemoryFree(moderate_threshold_mb() + 1); } |
67 | 67 |
68 void SetModerate() { SetMemoryFree(moderate_threshold_mb() - 1); } | 68 void SetModerate() { SetMemoryFree(moderate_threshold_mb() - 1); } |
69 | 69 |
70 void SetCritical() { SetMemoryFree(critical_threshold_mb() - 1); } | 70 void SetCritical() { SetMemoryFree(critical_threshold_mb() - 1); } |
71 | 71 |
72 private: | 72 private: |
73 bool GetSystemMemoryInfo(base::SystemMemoryInfoKB* mem_info) const override { | 73 bool GetSystemMemoryInfo(base::SystemMemoryInfoKB* mem_info) const override { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 EXPECT_EQ(kModerateMb, calc.moderate_threshold_mb()); | 173 EXPECT_EQ(kModerateMb, calc.moderate_threshold_mb()); |
174 EXPECT_EQ(kCriticalMb, calc.critical_threshold_mb()); | 174 EXPECT_EQ(kCriticalMb, calc.critical_threshold_mb()); |
175 | 175 |
176 ASSERT_NO_FATAL_FAILURE(CalculateCurrentPressureLevelTest(&calc)); | 176 ASSERT_NO_FATAL_FAILURE(CalculateCurrentPressureLevelTest(&calc)); |
177 } | 177 } |
178 | 178 |
179 #endif // defined(MEMORY_PRESSURE_IS_POLLING) | 179 #endif // defined(MEMORY_PRESSURE_IS_POLLING) |
180 | 180 |
181 } // namespace memory_pressure | 181 } // namespace memory_pressure |
OLD | NEW |