Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: chrome/browser/memory/tab_manager_delegate_chromeos.h

Issue 2133503002: arc: Revamp the ArcBridgeService interface (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Fix ui_arc_unittests Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 ANDROID_PERSISTENT = 1 << 30, 68 ANDROID_PERSISTENT = 1 << 30,
69 ANDROID_NON_EXISTS = 0x7FFFFFFF 69 ANDROID_NON_EXISTS = 0x7FFFFFFF
70 }; 70 };
71 71
72 // The Chrome OS TabManagerDelegate is responsible for keeping the 72 // The Chrome OS TabManagerDelegate is responsible for keeping the
73 // renderers' scores up to date in /proc/<pid>/oom_score_adj. 73 // renderers' scores up to date in /proc/<pid>/oom_score_adj.
74 // 74 //
75 // Note that AdjustOomPriorities will be called on the UI thread by 75 // Note that AdjustOomPriorities will be called on the UI thread by
76 // TabManager, but the actual work will take place on the file thread 76 // TabManager, but the actual work will take place on the file thread
77 // (see implementation of AdjustOomPriorities). 77 // (see implementation of AdjustOomPriorities).
78 class TabManagerDelegate : public arc::ArcBridgeService::Observer, 78 class TabManagerDelegate : public arc::ArcBridgeService::InstanceObserver<
79 arc::mojom::ProcessInstance>,
79 public aura::client::ActivationChangeObserver, 80 public aura::client::ActivationChangeObserver,
80 public content::NotificationObserver, 81 public content::NotificationObserver,
81 public chrome::BrowserListObserver { 82 public chrome::BrowserListObserver {
82 public: 83 public:
83 class MemoryStat; 84 class MemoryStat;
84 85
85 explicit TabManagerDelegate(const base::WeakPtr<TabManager>& tab_manager); 86 explicit TabManagerDelegate(const base::WeakPtr<TabManager>& tab_manager);
86 87
87 TabManagerDelegate(const base::WeakPtr<TabManager>& tab_manager, 88 TabManagerDelegate(const base::WeakPtr<TabManager>& tab_manager,
88 TabManagerDelegate::MemoryStat* mem_stat); 89 TabManagerDelegate::MemoryStat* mem_stat);
89 90
90 ~TabManagerDelegate() override; 91 ~TabManagerDelegate() override;
91 92
92 void OnBrowserSetLastActive(Browser* browser) override; 93 void OnBrowserSetLastActive(Browser* browser) override;
93 94
94 // ArcBridgeService::Observer overrides. 95 // ArcBridgeService::InstanceObserver<arc::mojom::ProcessInstance> overrides.
95 void OnProcessInstanceReady() override; 96 void OnInstanceReady(arc::mojom::ProcessInstance* process_instance,
96 void OnProcessInstanceClosed() override; 97 uint32_t version) override;
98 void OnInstanceClosed(arc::mojom::ProcessInstance*) override;
97 99
98 // aura::ActivationChangeObserver overrides. 100 // aura::ActivationChangeObserver overrides.
99 void OnWindowActivated( 101 void OnWindowActivated(
100 aura::client::ActivationChangeObserver::ActivationReason reason, 102 aura::client::ActivationChangeObserver::ActivationReason reason,
101 aura::Window* gained_active, 103 aura::Window* gained_active,
102 aura::Window* lost_active) override; 104 aura::Window* lost_active) override;
103 105
104 // Kills a process on memory pressure. 106 // Kills a process on memory pressure.
105 void LowMemoryKill(const TabStatsList& tab_stats); 107 void LowMemoryKill(const TabStatsList& tab_stats);
106 108
(...skipping 22 matching lines...) Expand all
129 131
130 private: 132 private:
131 FRIEND_TEST_ALL_PREFIXES(TabManagerDelegateTest, CandidatesSorted); 133 FRIEND_TEST_ALL_PREFIXES(TabManagerDelegateTest, CandidatesSorted);
132 FRIEND_TEST_ALL_PREFIXES(TabManagerDelegateTest, KillMultipleProcesses); 134 FRIEND_TEST_ALL_PREFIXES(TabManagerDelegateTest, KillMultipleProcesses);
133 FRIEND_TEST_ALL_PREFIXES(TabManagerDelegateTest, SetOomScoreAdj); 135 FRIEND_TEST_ALL_PREFIXES(TabManagerDelegateTest, SetOomScoreAdj);
134 136
135 struct Candidate; 137 struct Candidate;
136 class FocusedProcess; 138 class FocusedProcess;
137 class UmaReporter; 139 class UmaReporter;
138 140
139 friend std::ostream& operator<<( 141 friend std::ostream& operator<<(std::ostream& out,
140 std::ostream& out, const Candidate& candidate); 142 const Candidate& candidate);
141 143
142 // content::NotificationObserver: 144 // content::NotificationObserver:
143 void Observe(int type, 145 void Observe(int type,
144 const content::NotificationSource& source, 146 const content::NotificationSource& source,
145 const content::NotificationDetails& details) override; 147 const content::NotificationDetails& details) override;
146 148
147 // Pair to hold child process host id and ProcessHandle. 149 // Pair to hold child process host id and ProcessHandle.
148 typedef std::pair<int, base::ProcessHandle> ProcessInfo; 150 typedef std::pair<int, base::ProcessHandle> ProcessInfo;
149 151
150 // Cache OOM scores in memory. 152 // Cache OOM scores in memory.
151 typedef base::hash_map<base::ProcessHandle, int> ProcessScoreMap; 153 typedef base::hash_map<base::ProcessHandle, int> ProcessScoreMap; // NOLINT
hidehiko 2016/07/11 05:24:53 Clarification: For what ... ? > NOLINT.
Luis Héctor Chávez 2016/07/11 17:13:33 `git cl lint` flags this as std::hash_map. I'll tr
Luis Héctor Chávez 2016/07/11 20:10:44 Filed crbug.com/627202. I have a fix ready and wil
152 154
153 // Get the list of candidates to kill, sorted by reversed importance. 155 // Get the list of candidates to kill, sorted by reversed importance.
154 static std::vector<Candidate> GetSortedCandidates( 156 static std::vector<Candidate> GetSortedCandidates(
155 const TabStatsList& tab_list, 157 const TabStatsList& tab_list,
156 const std::vector<arc::ArcProcess>& arc_processes); 158 const std::vector<arc::ArcProcess>& arc_processes);
157 159
158 // Posts AdjustFocusedTabScore task to the file thread. 160 // Posts AdjustFocusedTabScore task to the file thread.
159 void OnFocusTabScoreAdjustmentTimeout(); 161 void OnFocusTabScoreAdjustmentTimeout();
160 162
161 // Kills a process after getting all info of tabs and apps. 163 // Kills a process after getting all info of tabs and apps.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // On ARC enabled machines, either a tab or an app could be a possible 238 // On ARC enabled machines, either a tab or an app could be a possible
237 // victim of low memory kill process. This is a helper struct which holds a 239 // victim of low memory kill process. This is a helper struct which holds a
238 // pointer to an app or a tab (but not both) to facilitate prioritizing the 240 // pointer to an app or a tab (but not both) to facilitate prioritizing the
239 // victims. 241 // victims.
240 struct TabManagerDelegate::Candidate { 242 struct TabManagerDelegate::Candidate {
241 Candidate(const TabStats* _tab, int _priority) 243 Candidate(const TabStats* _tab, int _priority)
242 : tab(_tab), priority(_priority), is_arc_app(false) {} 244 : tab(_tab), priority(_priority), is_arc_app(false) {}
243 Candidate(const arc::ArcProcess* _app, int _priority) 245 Candidate(const arc::ArcProcess* _app, int _priority)
244 : app(_app), priority(_priority), is_arc_app(true) {} 246 : app(_app), priority(_priority), is_arc_app(true) {}
245 247
246 bool operator<(const Candidate& rhs) const { 248 bool operator<(const Candidate& rhs) const { return priority < rhs.priority; }
247 return priority < rhs.priority;
248 }
249 249
250 union { 250 union {
251 const TabStats* tab; 251 const TabStats* tab;
252 const arc::ArcProcess* app; 252 const arc::ArcProcess* app;
253 }; 253 };
254 int priority; 254 int priority;
255 bool is_arc_app; 255 bool is_arc_app;
256 }; 256 };
257 257
258 // A thin wrapper over library process_metric.h to get memory status so unit 258 // A thin wrapper over library process_metric.h to get memory status so unit
(...skipping 15 matching lines...) Expand all
274 // reported if available memory is under the number. 274 // reported if available memory is under the number.
275 static int LowMemoryMarginKB(); 275 static int LowMemoryMarginKB();
276 276
277 // Reads in an integer. 277 // Reads in an integer.
278 static int ReadIntFromFile(const char* file_name, int default_val); 278 static int ReadIntFromFile(const char* file_name, int default_val);
279 }; 279 };
280 280
281 } // namespace memory 281 } // namespace memory
282 282
283 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_DELEGATE_CHROMEOS_H_ 283 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_DELEGATE_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698