| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/memory/tab_manager_delegate_chromeos.h" | 5 #include "chrome/browser/memory/tab_manager_delegate_chromeos.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 const std::vector<TabManagerDelegate::Candidate> candidates = | 586 const std::vector<TabManagerDelegate::Candidate> candidates = |
| 587 GetSortedCandidates(tab_list, arc_processes); | 587 GetSortedCandidates(tab_list, arc_processes); |
| 588 | 588 |
| 589 int target_memory_to_free_kb = mem_stat_->TargetMemoryToFreeKB(); | 589 int target_memory_to_free_kb = mem_stat_->TargetMemoryToFreeKB(); |
| 590 // Kill processes until the estimated amount of freed memory is sufficient to | 590 // Kill processes until the estimated amount of freed memory is sufficient to |
| 591 // bring the system memory back to a normal level. | 591 // bring the system memory back to a normal level. |
| 592 // The list is sorted by descending importance, so we go through the list | 592 // The list is sorted by descending importance, so we go through the list |
| 593 // backwards. | 593 // backwards. |
| 594 for (auto it = candidates.rbegin(); it != candidates.rend(); ++it) { | 594 for (auto it = candidates.rbegin(); it != candidates.rend(); ++it) { |
| 595 VLOG(3) << "Target memory to free: " << target_memory_to_free_kb << " KB"; | 595 VLOG(3) << "Target memory to free: " << target_memory_to_free_kb << " KB"; |
| 596 // Never kill selected tab or Android foreground app, regardless whether | 596 // Never kill selected tab to align with the behavior in other platforms. |
| 597 // they're in the active window. Since the user experience would be bad. | 597 // Note that non-focused Android apps are prone to be killed, however, |
| 598 // regardless of their visibility. |
| 598 ProcessType process_type = it->process_type(); | 599 ProcessType process_type = it->process_type(); |
| 599 if (process_type == ProcessType::VISIBLE_APP || | 600 if (process_type == ProcessType::FOCUSED_APP || |
| 600 process_type == ProcessType::FOCUSED_APP || | |
| 601 process_type == ProcessType::FOCUSED_TAB) { | 601 process_type == ProcessType::FOCUSED_TAB) { |
| 602 VLOG(2) << "Skipped killing " << *it; | 602 VLOG(2) << "Skipped killing " << *it; |
| 603 continue; | 603 continue; |
| 604 } | 604 } |
| 605 if (it->app()) { | 605 if (it->app()) { |
| 606 int estimated_memory_freed_kb = | 606 int estimated_memory_freed_kb = |
| 607 mem_stat_->EstimatedMemoryFreedKB(it->app()->pid()); | 607 mem_stat_->EstimatedMemoryFreedKB(it->app()->pid()); |
| 608 if (KillArcProcess(it->app()->nspid())) { | 608 if (KillArcProcess(it->app()->nspid())) { |
| 609 target_memory_to_free_kb -= estimated_memory_freed_kb; | 609 target_memory_to_free_kb -= estimated_memory_freed_kb; |
| 610 MemoryKillsMonitor::LogLowMemoryKill("APP", estimated_memory_freed_kb); | 610 MemoryKillsMonitor::LogLowMemoryKill("APP", estimated_memory_freed_kb); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 } | 723 } |
| 724 priority += priority_increment; | 724 priority += priority_increment; |
| 725 } | 725 } |
| 726 | 726 |
| 727 if (oom_scores_to_change.size()) | 727 if (oom_scores_to_change.size()) |
| 728 GetDebugDaemonClient()->SetOomScoreAdj( | 728 GetDebugDaemonClient()->SetOomScoreAdj( |
| 729 oom_scores_to_change, base::Bind(&OnSetOomScoreAdj)); | 729 oom_scores_to_change, base::Bind(&OnSetOomScoreAdj)); |
| 730 } | 730 } |
| 731 | 731 |
| 732 } // namespace memory | 732 } // namespace memory |
| OLD | NEW |