| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 void LogMemory(const std::string& title, const base::Closure& callback); | 115 void LogMemory(const std::string& title, const base::Closure& callback); |
| 116 | 116 |
| 117 // Used to set the test TickClock, which then gets used by NowTicks(). See | 117 // Used to set the test TickClock, which then gets used by NowTicks(). See |
| 118 // |test_tick_clock_| for more details. | 118 // |test_tick_clock_| for more details. |
| 119 void set_test_tick_clock(base::TickClock* test_tick_clock); | 119 void set_test_tick_clock(base::TickClock* test_tick_clock); |
| 120 | 120 |
| 121 // Returns the list of the stats for all renderers. Must be called on the UI | 121 // Returns the list of the stats for all renderers. Must be called on the UI |
| 122 // thread. | 122 // thread. |
| 123 TabStatsList GetUnsortedTabStats(); | 123 TabStatsList GetUnsortedTabStats(); |
| 124 | 124 |
| 125 // Returns true if |first| is considered less desirable to be killed than |
| 126 // |second|. |
| 127 static bool CompareTabStats(TabStats first, TabStats second); |
| 128 |
| 125 private: | 129 private: |
| 126 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CanOnlyDiscardOnce); | 130 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, CanOnlyDiscardOnce); |
| 127 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ChildProcessNotifications); | 131 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ChildProcessNotifications); |
| 128 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, Comparator); | 132 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, Comparator); |
| 129 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardedTabKeepsLastActiveTime); | 133 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardedTabKeepsLastActiveTime); |
| 130 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardWebContentsAt); | 134 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, DiscardWebContentsAt); |
| 131 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, InvalidOrEmptyURL); | 135 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, InvalidOrEmptyURL); |
| 132 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, IsInternalPage); | 136 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, IsInternalPage); |
| 133 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, OomPressureListener); | 137 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, OomPressureListener); |
| 134 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ProtectPDFPages); | 138 FRIEND_TEST_ALL_PREFIXES(TabManagerTest, ProtectPDFPages); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 227 |
| 224 // Returns true if the tab is currently playing audio or has played audio | 228 // Returns true if the tab is currently playing audio or has played audio |
| 225 // recently, or if the tab is currently accessing the camera, microphone or | 229 // recently, or if the tab is currently accessing the camera, microphone or |
| 226 // mirroring the display. | 230 // mirroring the display. |
| 227 bool IsMediaTab(content::WebContents* contents) const; | 231 bool IsMediaTab(content::WebContents* contents) const; |
| 228 | 232 |
| 229 // Returns the WebContentsData associated with |contents|. Also takes care of | 233 // Returns the WebContentsData associated with |contents|. Also takes care of |
| 230 // creating one if needed. | 234 // creating one if needed. |
| 231 WebContentsData* GetWebContentsData(content::WebContents* contents) const; | 235 WebContentsData* GetWebContentsData(content::WebContents* contents) const; |
| 232 | 236 |
| 233 // Returns true if |first| is considered less desirable to be killed than | |
| 234 // |second|. | |
| 235 static bool CompareTabStats(TabStats first, TabStats second); | |
| 236 | |
| 237 // Returns either the system's clock or the test clock. See |test_tick_clock_| | 237 // Returns either the system's clock or the test clock. See |test_tick_clock_| |
| 238 // for more details. | 238 // for more details. |
| 239 base::TimeTicks NowTicks() const; | 239 base::TimeTicks NowTicks() const; |
| 240 | 240 |
| 241 // Dispatches a memory pressure message to a single child process, and | 241 // Dispatches a memory pressure message to a single child process, and |
| 242 // schedules another call to itself as long as memory pressure continues. | 242 // schedules another call to itself as long as memory pressure continues. |
| 243 void DoChildProcessDispatch(); | 243 void DoChildProcessDispatch(); |
| 244 | 244 |
| 245 // Implementation of DiscardTab. | 245 // Implementation of DiscardTab. |
| 246 bool DiscardTabImpl(); | 246 bool DiscardTabImpl(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 331 |
| 332 // Weak pointer factory used for posting delayed tasks to task_runner_. | 332 // Weak pointer factory used for posting delayed tasks to task_runner_. |
| 333 base::WeakPtrFactory<TabManager> weak_ptr_factory_; | 333 base::WeakPtrFactory<TabManager> weak_ptr_factory_; |
| 334 | 334 |
| 335 DISALLOW_COPY_AND_ASSIGN(TabManager); | 335 DISALLOW_COPY_AND_ASSIGN(TabManager); |
| 336 }; | 336 }; |
| 337 | 337 |
| 338 } // namespace memory | 338 } // namespace memory |
| 339 | 339 |
| 340 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_H_ | 340 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_H_ |
| OLD | NEW |