OLD | NEW |
---|---|
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_TAB_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_MEMORY_TAB_MANAGER_H_ |
6 #define CHROME_BROWSER_MEMORY_TAB_MANAGER_H_ | 6 #define CHROME_BROWSER_MEMORY_TAB_MANAGER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 void set_test_tick_clock(base::TickClock* test_tick_clock); | 121 void set_test_tick_clock(base::TickClock* test_tick_clock); |
122 | 122 |
123 // Returns the list of the stats for all renderers. Must be called on the UI | 123 // Returns the list of the stats for all renderers. Must be called on the UI |
124 // thread. | 124 // thread. |
125 TabStatsList GetUnsortedTabStats(); | 125 TabStatsList GetUnsortedTabStats(); |
126 | 126 |
127 // Add/remove observers. | 127 // Add/remove observers. |
128 void AddObserver(TabManagerObserver* observer); | 128 void AddObserver(TabManagerObserver* observer); |
129 void RemoveObserver(TabManagerObserver* observer); | 129 void RemoveObserver(TabManagerObserver* observer); |
130 | 130 |
131 // Sets/clears the discardable state of the tab. | |
132 void SetDiscardableState(content::WebContents* contents, bool state); | |
Georges Khalil
2016/07/21 21:21:41
nit: SetTabDiscardableState (for consistency).
Anderson Silva
2016/07/21 22:16:45
Done.
| |
133 | |
134 // Returns true if the tab is discardable by auto discarding feature. | |
135 bool IsDiscardable(content::WebContents* contents); | |
Georges Khalil
2016/07/21 21:21:41
ditto. Also, this can be const and put it before t
Anderson Silva
2016/07/21 22:16:45
Done.
| |
136 | |
131 private: | 137 private: |
132 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CanOnlyDiscardOnce); | 138 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CanOnlyDiscardOnce); |
133 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ChildProcessNotifications); | 139 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ChildProcessNotifications); |
134 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, Comparator); | 140 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, Comparator); |
135 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardedTabKeepsLastActiveTime); | 141 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardedTabKeepsLastActiveTime); |
136 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardWebContentsAt); | 142 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardWebContentsAt); |
137 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, InvalidOrEmptyURL); | 143 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, InvalidOrEmptyURL); |
138 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, IsInternalPage); | 144 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, IsInternalPage); |
139 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, OomPressureListener); | 145 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, OomPressureListener); |
140 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ProtectPDFPages); | 146 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ProtectPDFPages); |
141 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ProtectRecentlyUsedTabs); | 147 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ProtectRecentlyUsedTabs); |
142 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ProtectVideoTabs); | 148 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ProtectVideoTabs); |
143 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ReloadDiscardedTabContextMenu); | 149 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ReloadDiscardedTabContextMenu); |
144 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, TabManagerBasics); | 150 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, TabManagerBasics); |
145 | 151 |
146 // This is needed so WebContentsData can call OnDiscardedStateChange. | 152 // This is needed so WebContentsData can call OnDiscardedStateChange. |
147 friend class WebContensData; | 153 friend class WebContensData; |
148 | 154 |
149 // Called by WebContentsData whenever the discard state of a WebContents | 155 // Called by WebContentsData whenever the discard state of a WebContents |
150 // changes, so that observers can be informed. | 156 // changes, so that observers can be informed. |
151 void OnDiscardedStateChange(content::WebContents* contents, | 157 void OnDiscardedStateChange(content::WebContents* contents, |
152 bool is_discarded); | 158 bool is_discarded); |
153 | 159 |
160 // Called by WebContentsData whenever the discardable state of a WebContents | |
161 // changes, so that observers can be informed. | |
162 void OnDiscardableStateChange(content::WebContents* contents, | |
163 bool is_discardable); | |
164 | |
154 // The time that a renderer is given to react to a memory pressure | 165 // The time that a renderer is given to react to a memory pressure |
155 // notification before another renderer is also notified. This prevents all | 166 // notification before another renderer is also notified. This prevents all |
156 // renderers from receiving and acting upon notifications simultaneously, | 167 // renderers from receiving and acting upon notifications simultaneously, |
157 // which can quickly overload a system. Exposed for unittesting. | 168 // which can quickly overload a system. Exposed for unittesting. |
158 // NOTE: This value needs to be big enough to allow a process to get over the | 169 // NOTE: This value needs to be big enough to allow a process to get over the |
159 // hump in responding to memory pressure, so there aren't multiple processes | 170 // hump in responding to memory pressure, so there aren't multiple processes |
160 // fighting for CPU and worse, temporary memory, while trying to free things | 171 // fighting for CPU and worse, temporary memory, while trying to free things |
161 // up. Similarly, it shouldn't be too large otherwise it will take too long | 172 // up. Similarly, it shouldn't be too large otherwise it will take too long |
162 // for the entire system to respond. Ideally, there would be a callback from a | 173 // for the entire system to respond. Ideally, there would be a callback from a |
163 // child process indicating that the message has been handled. In the meantime | 174 // child process indicating that the message has been handled. In the meantime |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 | 359 |
349 // Weak pointer factory used for posting delayed tasks to task_runner_. | 360 // Weak pointer factory used for posting delayed tasks to task_runner_. |
350 base::WeakPtrFactory<TabManager> weak_ptr_factory_; | 361 base::WeakPtrFactory<TabManager> weak_ptr_factory_; |
351 | 362 |
352 DISALLOW_COPY_AND_ASSIGN(TabManager); | 363 DISALLOW_COPY_AND_ASSIGN(TabManager); |
353 }; | 364 }; |
354 | 365 |
355 } // namespace memory | 366 } // namespace memory |
356 | 367 |
357 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_H_ | 368 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_H_ |
OLD | NEW |