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