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 #include "chrome/browser/chromeos/memory/oom_priority_manager.h" | 5 #include "chrome/browser/chromeos/memory/oom_priority_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 if (first.is_playing_audio != second.is_playing_audio) | 442 if (first.is_playing_audio != second.is_playing_audio) |
443 return first.is_playing_audio; | 443 return first.is_playing_audio; |
444 | 444 |
445 // TODO(jamescook): Incorporate sudden_termination_allowed into the sort | 445 // TODO(jamescook): Incorporate sudden_termination_allowed into the sort |
446 // order. We don't do this now because pages with unload handlers set | 446 // order. We don't do this now because pages with unload handlers set |
447 // sudden_termination_allowed false, and that covers too many common pages | 447 // sudden_termination_allowed false, and that covers too many common pages |
448 // with ad networks and statistics scripts. Ideally we would like to check | 448 // with ad networks and statistics scripts. Ideally we would like to check |
449 // for beforeUnload handlers, which are likely to present a dialog asking | 449 // for beforeUnload handlers, which are likely to present a dialog asking |
450 // if the user wants to discard state. crbug.com/123049 | 450 // if the user wants to discard state. crbug.com/123049 |
451 | 451 |
452 // Being more recently selected is more important. | 452 // Being more recently active is more important. |
453 return first.last_selected > second.last_selected; | 453 return first.last_active > second.last_active; |
454 } | 454 } |
455 | 455 |
456 void OomPriorityManager::AdjustFocusedTabScoreOnFileThread() { | 456 void OomPriorityManager::AdjustFocusedTabScoreOnFileThread() { |
457 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 457 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
458 base::AutoLock pid_to_oom_score_autolock(pid_to_oom_score_lock_); | 458 base::AutoLock pid_to_oom_score_autolock(pid_to_oom_score_lock_); |
459 content::ZygoteHost::GetInstance()->AdjustRendererOOMScore( | 459 content::ZygoteHost::GetInstance()->AdjustRendererOOMScore( |
460 focused_tab_pid_, chrome::kLowestRendererOomScore); | 460 focused_tab_pid_, chrome::kLowestRendererOomScore); |
461 pid_to_oom_score_[focused_tab_pid_] = chrome::kLowestRendererOomScore; | 461 pid_to_oom_score_[focused_tab_pid_] = chrome::kLowestRendererOomScore; |
462 } | 462 } |
463 | 463 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 WebContents* contents = model->GetWebContentsAt(i); | 571 WebContents* contents = model->GetWebContentsAt(i); |
572 if (!contents->IsCrashed()) { | 572 if (!contents->IsCrashed()) { |
573 TabStats stats; | 573 TabStats stats; |
574 stats.is_app = is_browser_for_app; | 574 stats.is_app = is_browser_for_app; |
575 stats.is_reloadable_ui = | 575 stats.is_reloadable_ui = |
576 IsReloadableUI(contents->GetLastCommittedURL()); | 576 IsReloadableUI(contents->GetLastCommittedURL()); |
577 stats.is_playing_audio = chrome::IsPlayingAudio(contents); | 577 stats.is_playing_audio = chrome::IsPlayingAudio(contents); |
578 stats.is_pinned = model->IsTabPinned(i); | 578 stats.is_pinned = model->IsTabPinned(i); |
579 stats.is_selected = browser_active && model->IsTabSelected(i); | 579 stats.is_selected = browser_active && model->IsTabSelected(i); |
580 stats.is_discarded = model->IsTabDiscarded(i); | 580 stats.is_discarded = model->IsTabDiscarded(i); |
581 stats.last_selected = contents->GetLastSelectedTime(); | 581 stats.last_active = contents->GetLastActiveTime(); |
582 stats.renderer_handle = contents->GetRenderProcessHost()->GetHandle(); | 582 stats.renderer_handle = contents->GetRenderProcessHost()->GetHandle(); |
583 stats.title = contents->GetTitle(); | 583 stats.title = contents->GetTitle(); |
584 stats.tab_contents_id = IdFromWebContents(contents); | 584 stats.tab_contents_id = IdFromWebContents(contents); |
585 stats_list.push_back(stats); | 585 stats_list.push_back(stats); |
586 } | 586 } |
587 } | 587 } |
588 // We process the active browser window in the first iteration. | 588 // We process the active browser window in the first iteration. |
589 browser_active = false; | 589 browser_active = false; |
590 } | 590 } |
591 // Sort the data we collected so that least desirable to be | 591 // Sort the data we collected so that least desirable to be |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 priority += priority_increment; | 649 priority += priority_increment; |
650 } | 650 } |
651 } | 651 } |
652 | 652 |
653 void OomPriorityManager::OnMemoryLow() { | 653 void OomPriorityManager::OnMemoryLow() { |
654 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 654 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
655 LogMemoryAndDiscardTab(); | 655 LogMemoryAndDiscardTab(); |
656 } | 656 } |
657 | 657 |
658 } // namespace chromeos | 658 } // namespace chromeos |
OLD | NEW |