| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // Goes through a list of checks to see if a tab is allowed to be discarded by | 94 // Goes through a list of checks to see if a tab is allowed to be discarded by |
| 95 // the automatic tab discarding mechanism. Note that this is not used when | 95 // the automatic tab discarding mechanism. Note that this is not used when |
| 96 // discarding a particular tab from about:discards. | 96 // discarding a particular tab from about:discards. |
| 97 bool CanDiscardTab(int64_t target_web_contents_id) const; | 97 bool CanDiscardTab(int64_t target_web_contents_id) const; |
| 98 | 98 |
| 99 // Discards a tab to free the memory occupied by its renderer. The tab still | 99 // Discards a tab to free the memory occupied by its renderer. The tab still |
| 100 // exists in the tab-strip; clicking on it will reload it. | 100 // exists in the tab-strip; clicking on it will reload it. |
| 101 void DiscardTab(); | 101 void DiscardTab(); |
| 102 | 102 |
| 103 // Discards a tab with the given unique ID. The tab still exists in the | 103 // Discards a tab with the given unique ID. The tab still exists in the |
| 104 // tab-strip; clicking on it will reload it. Returns true if it successfully | 104 // tab-strip; clicking on it will reload it. Returns null if the tab cannot |
| 105 // found a tab and discarded it. | 105 // be found or cannot be discarded. Otherwise returns the old web_contents |
| 106 // that got discarded. This value is mostly useful during testing. |
| 106 content::WebContents* DiscardTabById(int64_t target_web_contents_id); | 107 content::WebContents* DiscardTabById(int64_t target_web_contents_id); |
| 107 | 108 |
| 108 // Log memory statistics for the running processes, then discards a tab. | 109 // Log memory statistics for the running processes, then discards a tab. |
| 109 // Tab discard happens sometime later, as collecting the statistics touches | 110 // Tab discard happens sometime later, as collecting the statistics touches |
| 110 // multiple threads and takes time. | 111 // multiple threads and takes time. |
| 111 void LogMemoryAndDiscardTab(); | 112 void LogMemoryAndDiscardTab(); |
| 112 | 113 |
| 113 // Log memory statistics for the running processes, then call the callback. | 114 // Log memory statistics for the running processes, then call the callback. |
| 114 void LogMemory(const std::string& title, const base::Closure& callback); | 115 void LogMemory(const std::string& title, const base::Closure& callback); |
| 115 | 116 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 331 |
| 331 // Weak pointer factory used for posting delayed tasks to task_runner_. | 332 // Weak pointer factory used for posting delayed tasks to task_runner_. |
| 332 base::WeakPtrFactory<TabManager> weak_ptr_factory_; | 333 base::WeakPtrFactory<TabManager> weak_ptr_factory_; |
| 333 | 334 |
| 334 DISALLOW_COPY_AND_ASSIGN(TabManager); | 335 DISALLOW_COPY_AND_ASSIGN(TabManager); |
| 335 }; | 336 }; |
| 336 | 337 |
| 337 } // namespace memory | 338 } // namespace memory |
| 338 | 339 |
| 339 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_H_ | 340 #endif // CHROME_BROWSER_MEMORY_TAB_MANAGER_H_ |
| OLD | NEW |