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 #ifndef CHROME_BROWSER_MEMORY_TAB_MANAGER_DELEGATE_CHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_MEMORY_TAB_MANAGER_DELEGATE_CHROMEOS_H_ |
6 #define CHROME_BROWSER_MEMORY_TAB_MANAGER_DELEGATE_CHROMEOS_H_ | 6 #define CHROME_BROWSER_MEMORY_TAB_MANAGER_DELEGATE_CHROMEOS_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // Sets OOM score for processes in the range [|rbegin|, |rend|) to integers | 155 // Sets OOM score for processes in the range [|rbegin|, |rend|) to integers |
156 // distributed evenly in [|range_begin|, |range_end|). | 156 // distributed evenly in [|range_begin|, |range_end|). |
157 // The new score is set in |new_map|. | 157 // The new score is set in |new_map|. |
158 void DistributeOomScoreInRange( | 158 void DistributeOomScoreInRange( |
159 std::vector<TabManagerDelegate::Candidate>::const_iterator begin, | 159 std::vector<TabManagerDelegate::Candidate>::const_iterator begin, |
160 std::vector<TabManagerDelegate::Candidate>::const_iterator end, | 160 std::vector<TabManagerDelegate::Candidate>::const_iterator end, |
161 int range_begin, | 161 int range_begin, |
162 int range_end, | 162 int range_end, |
163 ProcessScoreMap* new_map); | 163 ProcessScoreMap* new_map); |
164 | 164 |
| 165 // Changes |candidates|' OOM scores to |score|. The new scores are set in |
| 166 // |new_map|. |
| 167 void SetOomScore(const std::vector<TabManagerDelegate::Candidate>& candidates, |
| 168 int score, |
| 169 ProcessScoreMap* new_map); |
| 170 |
165 // Initiates an oom priority adjustment. | 171 // Initiates an oom priority adjustment. |
166 void ScheduleEarlyOomPrioritiesAdjustment(); | 172 void ScheduleEarlyOomPrioritiesAdjustment(); |
167 | 173 |
168 // Returns a TimeDelta object that represents a minimum delay for killing | 174 // Returns a TimeDelta object that represents a minimum delay for killing |
169 // the same ARC process again. ARC processes sometimes respawn right after | 175 // the same ARC process again. ARC processes sometimes respawn right after |
170 // being killed. In that case, killing them every time is just a waste of | 176 // being killed. In that case, killing them every time is just a waste of |
171 // resources. | 177 // resources. |
172 static constexpr base::TimeDelta GetArcRespawnKillDelay() { | 178 static constexpr base::TimeDelta GetArcRespawnKillDelay() { |
173 return base::TimeDelta::FromSeconds(60); | 179 return base::TimeDelta::FromSeconds(60); |
174 } | 180 } |
175 | 181 |
| 182 // The lowest OOM adjustment score that will make the process non-killable. |
| 183 static const int kLowestOomScore; |
| 184 |
176 // Holds a reference to the owning TabManager. | 185 // Holds a reference to the owning TabManager. |
177 const base::WeakPtr<TabManager> tab_manager_; | 186 const base::WeakPtr<TabManager> tab_manager_; |
178 | 187 |
179 // Registrar to receive renderer notifications. | 188 // Registrar to receive renderer notifications. |
180 content::NotificationRegistrar registrar_; | 189 content::NotificationRegistrar registrar_; |
181 | 190 |
182 // Timer to guarantee that the tab or app is focused for a certain amount of | 191 // Timer to guarantee that the tab or app is focused for a certain amount of |
183 // time. | 192 // time. |
184 base::OneShotTimer focus_process_score_adjust_timer_; | 193 base::OneShotTimer focus_process_score_adjust_timer_; |
185 // Holds the info of the newly focused tab or app. Its OOM score would be | 194 // Holds the info of the newly focused tab or app. Its OOM score would be |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 // reported if available memory is under the number. | 265 // reported if available memory is under the number. |
257 static int LowMemoryMarginKB(); | 266 static int LowMemoryMarginKB(); |
258 | 267 |
259 // Reads in an integer. | 268 // Reads in an integer. |
260 static int ReadIntFromFile(const char* file_name, int default_val); | 269 static int ReadIntFromFile(const char* file_name, int default_val); |
261 }; | 270 }; |
262 | 271 |
263 } // namespace memory | 272 } // namespace memory |
264 | 273 |
265 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_DELEGATE_CHROMEOS_H_ | 274 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_DELEGATE_CHROMEOS_H_ |
OLD | NEW |