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

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

Issue 2357053002: Always use arc::InstanceHolder<T>::GetInstanceForMethod (Closed)
Patch Set: rebased to catch up tot Created 4 years, 3 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 29 matching lines...) Expand all
40 FOCUSED_TAB = FOCUSED_APP, 40 FOCUSED_TAB = FOCUSED_APP,
41 41
42 VISIBLE_APP = 2, 42 VISIBLE_APP = 2,
43 BACKGROUND_TAB = 3, 43 BACKGROUND_TAB = 3,
44 BACKGROUND_APP = 4, 44 BACKGROUND_APP = 4,
45 UNKNOWN_TYPE = 5, 45 UNKNOWN_TYPE = 5,
46 }; 46 };
47 47
48 // The Chrome OS TabManagerDelegate is responsible for keeping the 48 // The Chrome OS TabManagerDelegate is responsible for keeping the
49 // renderers' scores up to date in /proc/<pid>/oom_score_adj. 49 // renderers' scores up to date in /proc/<pid>/oom_score_adj.
50 class TabManagerDelegate 50 class TabManagerDelegate : public aura::client::ActivationChangeObserver,
51 : public arc::InstanceHolder<arc::mojom::ProcessInstance>::Observer, 51 public content::NotificationObserver,
52 public aura::client::ActivationChangeObserver, 52 public chrome::BrowserListObserver {
53 public content::NotificationObserver,
54 public chrome::BrowserListObserver {
55 public: 53 public:
56 class MemoryStat; 54 class MemoryStat;
57 55
58 explicit TabManagerDelegate(const base::WeakPtr<TabManager>& tab_manager); 56 explicit TabManagerDelegate(const base::WeakPtr<TabManager>& tab_manager);
59 57
60 TabManagerDelegate(const base::WeakPtr<TabManager>& tab_manager, 58 TabManagerDelegate(const base::WeakPtr<TabManager>& tab_manager,
61 TabManagerDelegate::MemoryStat* mem_stat); 59 TabManagerDelegate::MemoryStat* mem_stat);
62 60
63 ~TabManagerDelegate() override; 61 ~TabManagerDelegate() override;
64 62
65 void OnBrowserSetLastActive(Browser* browser) override; 63 void OnBrowserSetLastActive(Browser* browser) override;
66 64
67 // InstanceHolder<arc::mojom::ProcessInstance>::Observer overrides.
68 void OnInstanceReady() override;
69 void OnInstanceClosed() override;
70
71 // aura::ActivationChangeObserver overrides. 65 // aura::ActivationChangeObserver overrides.
72 void OnWindowActivated( 66 void OnWindowActivated(
73 aura::client::ActivationChangeObserver::ActivationReason reason, 67 aura::client::ActivationChangeObserver::ActivationReason reason,
74 aura::Window* gained_active, 68 aura::Window* gained_active,
75 aura::Window* lost_active) override; 69 aura::Window* lost_active) override;
76 70
77 // Kills a process on memory pressure. 71 // Kills a process on memory pressure.
78 void LowMemoryKill(const TabStatsList& tab_stats); 72 void LowMemoryKill(const TabStatsList& tab_stats);
79 73
80 // Returns oom_score_adj of a process if the score is cached by |this|. 74 // Returns oom_score_adj of a process if the score is cached by |this|.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // Holds the info of the newly focused tab or app. Its OOM score would be 163 // Holds the info of the newly focused tab or app. Its OOM score would be
170 // adjusted when |focus_process_score_adjust_timer_| is expired. 164 // adjusted when |focus_process_score_adjust_timer_| is expired.
171 std::unique_ptr<FocusedProcess> focused_process_; 165 std::unique_ptr<FocusedProcess> focused_process_;
172 166
173 // Map maintaining the process handle - oom_score mapping. 167 // Map maintaining the process handle - oom_score mapping.
174 ProcessScoreMap oom_score_map_; 168 ProcessScoreMap oom_score_map_;
175 169
176 // Util for getting system memory status. 170 // Util for getting system memory status.
177 std::unique_ptr<TabManagerDelegate::MemoryStat> mem_stat_; 171 std::unique_ptr<TabManagerDelegate::MemoryStat> mem_stat_;
178 172
179 // Holds a weak pointer to arc::mojom::ProcessInstance.
180 arc::mojom::ProcessInstance* arc_process_instance_;
Luis Héctor Chávez 2016/09/23 22:51:03 oh! good catch!
Yusuke Sato 2016/09/24 00:15:22 Acknowledged.
181 // Current ProcessInstance version.
182 int arc_process_instance_version_;
183
184 // Reports UMA histograms. 173 // Reports UMA histograms.
185 std::unique_ptr<UmaReporter> uma_; 174 std::unique_ptr<UmaReporter> uma_;
186 175
187 // Weak pointer factory used for posting tasks to other threads. 176 // Weak pointer factory used for posting tasks to other threads.
188 base::WeakPtrFactory<TabManagerDelegate> weak_ptr_factory_; 177 base::WeakPtrFactory<TabManagerDelegate> weak_ptr_factory_;
189 178
190 DISALLOW_COPY_AND_ASSIGN(TabManagerDelegate); 179 DISALLOW_COPY_AND_ASSIGN(TabManagerDelegate);
191 }; 180 };
192 181
193 // On ARC enabled machines, either a tab or an app could be a possible 182 // On ARC enabled machines, either a tab or an app could be a possible
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 // reported if available memory is under the number. 234 // reported if available memory is under the number.
246 static int LowMemoryMarginKB(); 235 static int LowMemoryMarginKB();
247 236
248 // Reads in an integer. 237 // Reads in an integer.
249 static int ReadIntFromFile(const char* file_name, int default_val); 238 static int ReadIntFromFile(const char* file_name, int default_val);
250 }; 239 };
251 240
252 } // namespace memory 241 } // namespace memory
253 242
254 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_DELEGATE_CHROMEOS_H_ 243 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_DELEGATE_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698