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

Unified Diff: chrome/browser/memory/tab_manager.h

Issue 2153943002: Implementing TabManager extensions API Discard Function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reset protection time Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_test.cc ('k') | chrome/browser/memory/tab_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/memory/tab_manager.h
diff --git a/chrome/browser/memory/tab_manager.h b/chrome/browser/memory/tab_manager.h
index 0f750d35d12d009e6dbdf756a5c28a84ff8de781..fefdcd4eb3bc53bc95078c5aafdb37846752b594 100644
--- a/chrome/browser/memory/tab_manager.h
+++ b/chrome/browser/memory/tab_manager.h
@@ -104,10 +104,16 @@ class TabManager : public TabStripModelObserver {
// Discards a tab with the given unique ID. The tab still exists in the
// tab-strip; clicking on it will reload it. Returns null if the tab cannot
- // be found or cannot be discarded. Otherwise returns the old web_contents
- // that got discarded. This value is mostly useful during testing.
+ // be found or cannot be discarded. Otherwise returns the new web_contents
+ // of the discarded tab.
content::WebContents* DiscardTabById(int64_t target_web_contents_id);
+ // Method used by the extensions API to discard tabs. If |contents| is null,
+ // discards the least important tab using DiscardTab(). Otherwise discards
+ // the given contents. Returns the new web_contents or null if no tab
+ // was discarded.
+ content::WebContents* DiscardTabByExtension(content::WebContents* contents);
+
// Log memory statistics for the running processes, then discards a tab.
// Tab discard happens sometime later, as collecting the statistics touches
// multiple threads and takes time.
@@ -127,6 +133,10 @@ class TabManager : public TabStripModelObserver {
void AddObserver(TabManagerObserver* observer);
void RemoveObserver(TabManagerObserver* observer);
+ // Used in tests to change the protection time of the tabs.
+ void set_minimum_protection_time_for_tests(
+ base::TimeDelta minimum_protection_time);
+
// Returns the auto-discardable state of the tab. When true, the tab is
// eligible to be automatically discarded when critical memory pressure hits,
// otherwise the tab is ignored and will never be automatically discarded.
@@ -271,8 +281,9 @@ class TabManager : public TabStripModelObserver {
// schedules another call to itself as long as memory pressure continues.
void DoChildProcessDispatch();
- // Implementation of DiscardTab.
- bool DiscardTabImpl();
+ // Implementation of DiscardTab. Returns null if no tab was discarded.
+ // Otherwise returns the new web_contents of the discarded tab.
+ content::WebContents* DiscardTabImpl();
// Returns true if tabs can be discarded only once.
bool CanOnlyDiscardOnce();
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_test.cc ('k') | chrome/browser/memory/tab_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698