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

Unified Diff: chrome/browser/chromeos/oom_priority_manager.cc

Issue 10860023: cros: Protect app windows from out-of-memory kills (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
Index: chrome/browser/chromeos/oom_priority_manager.cc
diff --git a/chrome/browser/chromeos/oom_priority_manager.cc b/chrome/browser/chromeos/oom_priority_manager.cc
index 4085f5425340846d42a6bc4e254274ca5ecac046..f7c9eed85e121ce70c0faef963e269187f7fb036 100644
--- a/chrome/browser/chromeos/oom_priority_manager.cc
+++ b/chrome/browser/chromeos/oom_priority_manager.cc
@@ -125,7 +125,8 @@ void OomMemoryDetails::OnDetailsAvailable() {
// OomPriorityManager
OomPriorityManager::TabStats::TabStats()
- : is_pinned(false),
+ : is_app(false),
+ is_pinned(false),
is_selected(false),
is_discarded(false),
sudden_termination_allowed(false),
@@ -190,7 +191,8 @@ std::vector<string16> OomPriorityManager::GetTabTitles() {
int score = pid_to_oom_score_[it->renderer_handle];
str += base::IntToString16(score);
str += ASCIIToUTF16(")");
- str += ASCIIToUTF16(it->sudden_termination_allowed ? " sudden_ok " : "");
Greg Spencer (Chromium) 2012/08/21 18:51:42 Did you mean to remove the output of the sudden_te
+ str += ASCIIToUTF16(it->is_app ? " app" : "");
+ str += ASCIIToUTF16(it->is_pinned ? " pinned" : "");
str += ASCIIToUTF16(it->is_discarded ? " discarded" : "");
titles.push_back(str);
}
@@ -314,6 +316,11 @@ bool OomPriorityManager::CompareTabStats(TabStats first,
if (first.is_pinned != second.is_pinned)
return first.is_pinned == true;
+ // Being an app is important too, as you're the only visible surface in the
+ // window and we don't want to discard that.
+ if (first.is_app != second.is_app)
+ return first.is_app == true;
+
// TODO(jamescook): Incorporate sudden_termination_allowed into the sort
// order. We don't do this now because pages with unload handlers set
// sudden_termination_allowed false, and that covers too many common pages
@@ -435,11 +442,13 @@ OomPriorityManager::TabStatsList OomPriorityManager::GetTabStatsOnUIThread() {
browser_iterator != BrowserList::end_last_active();
++browser_iterator) {
Browser* browser = *browser_iterator;
+ bool is_browser_for_app = browser->is_app();
const TabStripModel* model = browser->tab_strip_model();
for (int i = 0; i < model->count(); i++) {
WebContents* contents = model->GetTabContentsAt(i)->web_contents();
if (!contents->IsCrashed()) {
TabStats stats;
+ stats.is_app = is_browser_for_app;
stats.is_pinned = model->IsTabPinned(i);
stats.is_selected = browser_active && model->IsTabSelected(i);
stats.is_discarded = model->IsTabDiscarded(i);
« no previous file with comments | « chrome/browser/chromeos/oom_priority_manager.h ('k') | chrome/browser/chromeos/oom_priority_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698