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

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

Issue 1332003002: Add option to disallow the discarding of a tab that was previously discarded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sky@ comments + fix tests. Created 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_OOM_PRIORITY_MANAGER_H_ 5 #ifndef CHROME_BROWSER_MEMORY_OOM_PRIORITY_MANAGER_H_
6 #define CHROME_BROWSER_MEMORY_OOM_PRIORITY_MANAGER_H_ 6 #define CHROME_BROWSER_MEMORY_OOM_PRIORITY_MANAGER_H_
7 7
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 public: 46 public:
47 OomPriorityManager(); 47 OomPriorityManager();
48 ~OomPriorityManager(); 48 ~OomPriorityManager();
49 49
50 // Number of discard events since Chrome started. 50 // Number of discard events since Chrome started.
51 int discard_count() const { return discard_count_; } 51 int discard_count() const { return discard_count_; }
52 52
53 // See member comment. 53 // See member comment.
54 bool recent_tab_discard() const { return recent_tab_discard_; } 54 bool recent_tab_discard() const { return recent_tab_discard_; }
55 55
56 void Start(); 56 // If |discard_once| is set, tabs that get discarded once will never get
57 // discarded again.
58 void Start(bool discard_once);
57 void Stop(); 59 void Stop();
58 60
59 // Returns the list of the stats for all renderers. Must be called on the UI 61 // Returns the list of the stats for all renderers. Must be called on the UI
60 // thread. 62 // thread.
61 TabStatsList GetTabStats(); 63 TabStatsList GetTabStats();
62 64
63 // Discards a tab to free the memory occupied by its renderer. The tab still 65 // Discards a tab to free the memory occupied by its renderer. The tab still
64 // exists in the tab-strip; clicking on it will reload it. Returns true if it 66 // exists in the tab-strip; clicking on it will reload it. Returns true if it
65 // successfully found a tab and discarded it. 67 // successfully found a tab and discarded it.
66 bool DiscardTab(); 68 bool DiscardTab();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // Adds all the stats of the tabs in |browser_list| into |stats_list|. If 108 // Adds all the stats of the tabs in |browser_list| into |stats_list|. If
107 // |active_desktop| is true, we consider its first window as being active. 109 // |active_desktop| is true, we consider its first window as being active.
108 void AddTabStats(BrowserList* browser_list, 110 void AddTabStats(BrowserList* browser_list,
109 bool active_desktop, 111 bool active_desktop,
110 TabStatsList* stats_list); 112 TabStatsList* stats_list);
111 113
112 // Callback for when |update_timer_| fires. Takes care of executing the tasks 114 // Callback for when |update_timer_| fires. Takes care of executing the tasks
113 // that need to be run periodically (see comment in implementation). 115 // that need to be run periodically (see comment in implementation).
114 void UpdateTimerCallback(); 116 void UpdateTimerCallback();
115 117
118 // Goes through a list of checks to see if a tab is allowed to be discarded by
119 // the automatic tab discarding mechanism. Note that this is not used when
120 // discarding a particular tab from about:discards.
121 bool CanDiscardTab(int64 target_web_contents_id) const;
122
116 static bool CompareTabStats(TabStats first, TabStats second); 123 static bool CompareTabStats(TabStats first, TabStats second);
117 124
118 // Called by the memory pressure listener when the memory pressure rises. 125 // Called by the memory pressure listener when the memory pressure rises.
119 void OnMemoryPressure( 126 void OnMemoryPressure(
120 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); 127 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
121 128
122 // Timer to periodically update the stats of the renderers. 129 // Timer to periodically update the stats of the renderers.
123 base::RepeatingTimer<OomPriorityManager> update_timer_; 130 base::RepeatingTimer<OomPriorityManager> update_timer_;
124 131
125 // Timer to periodically report whether a tab has been discarded since the 132 // Timer to periodically report whether a tab has been discarded since the
(...skipping 14 matching lines...) Expand all
140 // times for discontinuities caused by suspend/resume. 147 // times for discontinuities caused by suspend/resume.
141 base::TimeTicks last_adjust_time_; 148 base::TimeTicks last_adjust_time_;
142 149
143 // Number of times we have discarded a tab, for statistics. 150 // Number of times we have discarded a tab, for statistics.
144 int discard_count_; 151 int discard_count_;
145 152
146 // Whether a tab discard event has occurred during the last time interval, 153 // Whether a tab discard event has occurred during the last time interval,
147 // used for statistics normalized by usage. 154 // used for statistics normalized by usage.
148 bool recent_tab_discard_; 155 bool recent_tab_discard_;
149 156
157 // Whether we ever only discard a tab once.
158 bool discard_once_;
159
150 #if defined(OS_CHROMEOS) 160 #if defined(OS_CHROMEOS)
151 scoped_ptr<OomPriorityManagerDelegate> delegate_; 161 scoped_ptr<OomPriorityManagerDelegate> delegate_;
152 #endif 162 #endif
153 163
154 DISALLOW_COPY_AND_ASSIGN(OomPriorityManager); 164 DISALLOW_COPY_AND_ASSIGN(OomPriorityManager);
155 }; 165 };
156 166
157 } // namespace memory 167 } // namespace memory
158 168
159 #endif // CHROME_BROWSER_MEMORY_OOM_PRIORITY_MANAGER_H_ 169 #endif // CHROME_BROWSER_MEMORY_OOM_PRIORITY_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698