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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/flat_map.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/process/process.h" | 18 #include "base/process/process.h" |
19 #include "base/timer/timer.h" | 19 #include "base/timer/timer.h" |
20 #include "chrome/browser/chromeos/arc/process/arc_process.h" | 20 #include "chrome/browser/chromeos/arc/process/arc_process.h" |
21 #include "chrome/browser/memory/tab_manager.h" | 21 #include "chrome/browser/memory/tab_manager.h" |
22 #include "chrome/browser/memory/tab_stats.h" | 22 #include "chrome/browser/memory/tab_stats.h" |
23 #include "chrome/browser/ui/browser_list_observer.h" | 23 #include "chrome/browser/ui/browser_list_observer.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 // content::NotificationObserver: | 121 // content::NotificationObserver: |
122 void Observe(int type, | 122 void Observe(int type, |
123 const content::NotificationSource& source, | 123 const content::NotificationSource& source, |
124 const content::NotificationDetails& details) override; | 124 const content::NotificationDetails& details) override; |
125 | 125 |
126 // Pair to hold child process host id and ProcessHandle. | 126 // Pair to hold child process host id and ProcessHandle. |
127 typedef std::pair<int, base::ProcessHandle> ProcessInfo; | 127 typedef std::pair<int, base::ProcessHandle> ProcessInfo; |
128 | 128 |
129 // Cache OOM scores in memory. | 129 // Cache OOM scores in memory. |
130 typedef base::hash_map<base::ProcessHandle, int> ProcessScoreMap; | 130 typedef base::flat_map<base::ProcessHandle, int> ProcessScoreMap; |
131 | 131 |
132 // A map from an ARC process name to a monotonic timestamp when it's killed. | 132 // A map from an ARC process name to a monotonic timestamp when it's killed. |
133 typedef base::hash_map<std::string, base::TimeTicks> KilledArcProcessesMap; | 133 typedef base::flat_map<std::string, base::TimeTicks> KilledArcProcessesMap; |
134 | 134 |
135 // Get the list of candidates to kill, sorted by descending importance. | 135 // Get the list of candidates to kill, sorted by descending importance. |
136 static std::vector<Candidate> GetSortedCandidates( | 136 static std::vector<Candidate> GetSortedCandidates( |
137 const TabStatsList& tab_list, | 137 const TabStatsList& tab_list, |
138 const std::vector<arc::ArcProcess>& arc_processes); | 138 const std::vector<arc::ArcProcess>& arc_processes); |
139 | 139 |
140 // Sets OOM score for the focused tab. | 140 // Sets OOM score for the focused tab. |
141 void OnFocusTabScoreAdjustmentTimeout(); | 141 void OnFocusTabScoreAdjustmentTimeout(); |
142 | 142 |
143 // Kills a process after getting all info of tabs and apps. | 143 // Kills a process after getting all info of tabs and apps. |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 // reported if available memory is under the number. | 269 // reported if available memory is under the number. |
270 static int LowMemoryMarginKB(); | 270 static int LowMemoryMarginKB(); |
271 | 271 |
272 // Reads in an integer. | 272 // Reads in an integer. |
273 static int ReadIntFromFile(const char* file_name, int default_val); | 273 static int ReadIntFromFile(const char* file_name, int default_val); |
274 }; | 274 }; |
275 | 275 |
276 } // namespace memory | 276 } // namespace memory |
277 | 277 |
278 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_DELEGATE_CHROMEOS_H_ | 278 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_DELEGATE_CHROMEOS_H_ |
OLD | NEW |