diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-14 01:48:21 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-14 01:48:21 +0000 |
commit | ac3c102d462701dd6a7ef0046bddb54c0a9fe706 (patch) | |
tree | a7a1223cf0247773a046b71564614b952a98198a /chrome/browser/chromeos/oom_priority_manager.cc | |
parent | e9021ab004e4c17bc221966db9db2d036aaac4e3 (diff) | |
download | chromium_src-ac3c102d462701dd6a7ef0046bddb54c0a9fe706.zip chromium_src-ac3c102d462701dd6a7ef0046bddb54c0a9fe706.tar.gz chromium_src-ac3c102d462701dd6a7ef0046bddb54c0a9fe706.tar.bz2 |
Fix tab discarder heuristic when multiple windows are open
Right now the tab discarder tries to protect the "selected" tab from being discarded. This is a noble goal, but the implementation actually protects the selected tab in every open window. This can result in a user with lots of open windows getting into a state where their active window has only two tabs but they get discarded and reload every time the user switches.
This patch changes the logic for "selected" tab protection to only consider the selected tab in the last active browser window.
BUG=132587
TEST=manual, open window 1 and search for "a", open window 2 and search for "b", open window 3 and search for "c", open a new tab in window 3 and search for "d". Open one more new tab and go to about:discards. Verified that "a" is at the bottom of the list (and hence the target for the next discard) and not "c".
Review URL: https://chromiumcodereview.appspot.com/10536153
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142065 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/oom_priority_manager.cc')
-rw-r--r-- | chrome/browser/chromeos/oom_priority_manager.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/chrome/browser/chromeos/oom_priority_manager.cc b/chrome/browser/chromeos/oom_priority_manager.cc index 32312df..4085f54 100644 --- a/chrome/browser/chromeos/oom_priority_manager.cc +++ b/chrome/browser/chromeos/oom_priority_manager.cc @@ -429,8 +429,11 @@ OomPriorityManager::TabStatsList OomPriorityManager::GetTabStatsOnUIThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); TabStatsList stats_list; stats_list.reserve(32); // 99% of users have < 30 tabs open - for (BrowserList::const_iterator browser_iterator = BrowserList::begin(); - browser_iterator != BrowserList::end(); ++browser_iterator) { + bool browser_active = true; + for (BrowserList::const_reverse_iterator browser_iterator = + BrowserList::begin_last_active(); + browser_iterator != BrowserList::end_last_active(); + ++browser_iterator) { Browser* browser = *browser_iterator; const TabStripModel* model = browser->tab_strip_model(); for (int i = 0; i < model->count(); i++) { @@ -438,7 +441,7 @@ OomPriorityManager::TabStatsList OomPriorityManager::GetTabStatsOnUIThread() { if (!contents->IsCrashed()) { TabStats stats; stats.is_pinned = model->IsTabPinned(i); - stats.is_selected = model->IsTabSelected(i); + stats.is_selected = browser_active && model->IsTabSelected(i); stats.is_discarded = model->IsTabDiscarded(i); stats.sudden_termination_allowed = contents->GetRenderProcessHost()->SuddenTerminationAllowed(); @@ -449,6 +452,8 @@ OomPriorityManager::TabStatsList OomPriorityManager::GetTabStatsOnUIThread() { stats_list.push_back(stats); } } + // We process the active browser window in the first iteration. + browser_active = false; } // Sort the data we collected so that least desirable to be // killed is first, most desirable is last. |