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

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

Issue 2167843004: Discardable property support on TabManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change to auto-discardable 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/memory/tab_manager.h ('k') | chrome/browser/memory/tab_manager_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/memory/tab_manager.cc
diff --git a/chrome/browser/memory/tab_manager.cc b/chrome/browser/memory/tab_manager.cc
index 6fa39ad66f4abcae4e9a2b8fd9c2677945db888f..a90170dfa02caf8b073eff7e665c4665834c50a2 100644
--- a/chrome/browser/memory/tab_manager.cc
+++ b/chrome/browser/memory/tab_manager.cc
@@ -617,6 +617,10 @@ bool TabManager::CanDiscardTab(int64_t target_web_contents_id) const {
return false;
}
+ // Do not discard a tab that was explicitly disallowed to.
+ if (!IsTabAutoDiscardable(web_contents))
+ return false;
+
return true;
}
@@ -728,6 +732,10 @@ bool TabManager::CompareTabStats(TabStats first, TabStats second) {
if (first.is_selected != second.is_selected)
return first.is_selected;
+ // Non auto-discardable tabs are more important to protect.
+ if (first.is_auto_discardable != second.is_auto_discardable)
+ return !first.is_auto_discardable;
+
// Protect tabs with pending form entries.
if (first.has_form_entry != second.has_form_entry)
return first.has_form_entry;
@@ -906,4 +914,20 @@ void TabManager::OnDiscardedStateChange(content::WebContents* contents,
OnDiscardedStateChange(contents, is_discarded));
}
+void TabManager::OnAutoDiscardableStateChange(content::WebContents* contents,
+ bool is_auto_discardable) {
+ FOR_EACH_OBSERVER(
+ TabManagerObserver, observers_,
+ OnAutoDiscardableStateChange(contents, is_auto_discardable));
+}
+
+bool TabManager::IsTabAutoDiscardable(content::WebContents* contents) const {
+ return GetWebContentsData(contents)->IsAutoDiscardable();
+}
+
+void TabManager::SetTabAutoDiscardableState(content::WebContents* contents,
+ bool state) {
+ GetWebContentsData(contents)->SetAutoDiscardableState(state);
+}
+
} // namespace memory
« no previous file with comments | « chrome/browser/memory/tab_manager.h ('k') | chrome/browser/memory/tab_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698