| 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 <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // Returns oom_score_adj of a process if the score is cached by |this|. | 83 // Returns oom_score_adj of a process if the score is cached by |this|. |
| 84 // If couldn't find the score in the cache, returns -1001 since the valid | 84 // If couldn't find the score in the cache, returns -1001 since the valid |
| 85 // range of oom_score_adj is [-1000, 1000]. | 85 // range of oom_score_adj is [-1000, 1000]. |
| 86 int GetCachedOomScore(base::ProcessHandle process_handle); | 86 int GetCachedOomScore(base::ProcessHandle process_handle); |
| 87 | 87 |
| 88 // Called when the timer fires, sets oom_adjust_score for all renderers. | 88 // Called when the timer fires, sets oom_adjust_score for all renderers. |
| 89 void AdjustOomPriorities(const TabStatsList& tab_list); | 89 void AdjustOomPriorities(const TabStatsList& tab_list); |
| 90 | 90 |
| 91 protected: | 91 protected: |
| 92 // Sets oom_score_adj for a list of tabs. | 92 // Sets oom_score_adj for a list of tabs. |
| 93 // This is a delegator to to SetOomScoreAdjForTabsOnFileThread(), | 93 // This is a delegator to to SetOomScoreAdjOnFileThread(), |
| 94 // also as a seam for unit test. | 94 // also as a seam for unit test. |
| 95 virtual void SetOomScoreAdjForTabs( | 95 virtual void SetOomScoreAdj( |
| 96 const std::vector<std::pair<base::ProcessHandle, int>>& entries); | 96 const std::vector<std::pair<base::ProcessHandle, int>>& entries); |
| 97 | 97 |
| 98 // Kills an Arc process. Returns true if the kill request is successfully sent | 98 // Kills an Arc process. Returns true if the kill request is successfully sent |
| 99 // to Android. Virtual for unit testing. | 99 // to Android. Virtual for unit testing. |
| 100 virtual bool KillArcProcess(const int nspid); | 100 virtual bool KillArcProcess(const int nspid); |
| 101 | 101 |
| 102 // Kills a tab. Returns true if the tab is killed successfully. | 102 // Kills a tab. Returns true if the tab is killed successfully. |
| 103 // Virtual for unit testing. | 103 // Virtual for unit testing. |
| 104 virtual bool KillTab(int64_t tab_id); | 104 virtual bool KillTab(int64_t tab_id); |
| 105 | 105 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 void AdjustFocusedTabScoreOnFileThread(); | 146 void AdjustFocusedTabScoreOnFileThread(); |
| 147 | 147 |
| 148 // Sets a newly focused tab the highest priority process if it wasn't. | 148 // Sets a newly focused tab the highest priority process if it wasn't. |
| 149 void AdjustFocusedTabScore(base::ProcessHandle pid); | 149 void AdjustFocusedTabScore(base::ProcessHandle pid); |
| 150 | 150 |
| 151 // Called by AdjustOomPriorities. Runs on the main thread. | 151 // Called by AdjustOomPriorities. Runs on the main thread. |
| 152 void AdjustOomPrioritiesImpl( | 152 void AdjustOomPrioritiesImpl( |
| 153 const TabStatsList& tab_list, | 153 const TabStatsList& tab_list, |
| 154 const std::vector<arc::ArcProcess>& arc_processes); | 154 const std::vector<arc::ArcProcess>& arc_processes); |
| 155 | 155 |
| 156 // Sets oom_score_adj of an ARC app. | |
| 157 void SetOomScoreAdjForApp(int nspid, int score); | |
| 158 | |
| 159 // Sets oom_score_adj for a list of tabs on the file thread. | 156 // Sets oom_score_adj for a list of tabs on the file thread. |
| 160 void SetOomScoreAdjForTabsOnFileThread( | 157 void SetOomScoreAdjOnFileThread( |
| 161 const std::vector<std::pair<base::ProcessHandle, int>>& entries); | 158 const std::vector<std::pair<base::ProcessHandle, int>>& entries); |
| 162 | 159 |
| 163 // Sets OOM score for processes in the range [|rbegin|, |rend|) to integers | 160 // Sets OOM score for processes in the range [|rbegin|, |rend|) to integers |
| 164 // distributed evenly in [|range_begin|, |range_end|). | 161 // distributed evenly in [|range_begin|, |range_end|). |
| 165 // The new score is set in |new_map|. | 162 // The new score is set in |new_map|. |
| 166 void DistributeOomScoreInRange( | 163 void DistributeOomScoreInRange( |
| 167 std::vector<TabManagerDelegate::Candidate>::const_iterator begin, | 164 std::vector<TabManagerDelegate::Candidate>::const_iterator begin, |
| 168 std::vector<TabManagerDelegate::Candidate>::const_iterator end, | 165 std::vector<TabManagerDelegate::Candidate>::const_iterator end, |
| 169 int range_begin, | 166 int range_begin, |
| 170 int range_end, | 167 int range_end, |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 // reported if available memory is under the number. | 261 // reported if available memory is under the number. |
| 265 static int LowMemoryMarginKB(); | 262 static int LowMemoryMarginKB(); |
| 266 | 263 |
| 267 // Reads in an integer. | 264 // Reads in an integer. |
| 268 static int ReadIntFromFile(const char* file_name, int default_val); | 265 static int ReadIntFromFile(const char* file_name, int default_val); |
| 269 }; | 266 }; |
| 270 | 267 |
| 271 } // namespace memory | 268 } // namespace memory |
| 272 | 269 |
| 273 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_DELEGATE_CHROMEOS_H_ | 270 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_DELEGATE_CHROMEOS_H_ |
| OLD | NEW |