| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 AdjustOomPriorities(tab_manager_->GetUnsortedTabStats()); | 445 AdjustOomPriorities(tab_manager_->GetUnsortedTabStats()); |
| 446 } | 446 } |
| 447 } | 447 } |
| 448 | 448 |
| 449 // If able to get the list of ARC procsses, prioritize tabs and apps as a whole. | 449 // If able to get the list of ARC procsses, prioritize tabs and apps as a whole. |
| 450 // Otherwise try to kill tabs only. | 450 // Otherwise try to kill tabs only. |
| 451 void TabManagerDelegate::LowMemoryKill( | 451 void TabManagerDelegate::LowMemoryKill( |
| 452 const TabStatsList& tab_list) { | 452 const TabStatsList& tab_list) { |
| 453 arc::ArcProcessService* arc_process_service = arc::ArcProcessService::Get(); | 453 arc::ArcProcessService* arc_process_service = arc::ArcProcessService::Get(); |
| 454 if (arc_process_service && | 454 if (arc_process_service && |
| 455 arc_process_service->RequestProcessList( | 455 arc_process_service->RequestAppProcessList( |
| 456 base::Bind(&TabManagerDelegate::LowMemoryKillImpl, | 456 base::Bind(&TabManagerDelegate::LowMemoryKillImpl, |
| 457 weak_ptr_factory_.GetWeakPtr(), tab_list))) { | 457 weak_ptr_factory_.GetWeakPtr(), tab_list))) { |
| 458 // LowMemoryKillImpl will be called asynchronously so nothing left to do. | 458 // LowMemoryKillImpl will be called asynchronously so nothing left to do. |
| 459 return; | 459 return; |
| 460 } | 460 } |
| 461 // If the list of ARC processes is not available, call LowMemoryKillImpl | 461 // If the list of ARC processes is not available, call LowMemoryKillImpl |
| 462 // synchronously with an empty list of apps. | 462 // synchronously with an empty list of apps. |
| 463 std::vector<arc::ArcProcess> dummy_apps; | 463 std::vector<arc::ArcProcess> dummy_apps; |
| 464 LowMemoryKillImpl(tab_list, dummy_apps); | 464 LowMemoryKillImpl(tab_list, dummy_apps); |
| 465 } | 465 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 // | 586 // |
| 587 // Things we need to collect on the browser thread (because | 587 // Things we need to collect on the browser thread (because |
| 588 // TabStripModel isn't thread safe): | 588 // TabStripModel isn't thread safe): |
| 589 // 1) whether or not a tab is pinned | 589 // 1) whether or not a tab is pinned |
| 590 // 2) last time a tab was selected | 590 // 2) last time a tab was selected |
| 591 // 3) is the tab currently selected | 591 // 3) is the tab currently selected |
| 592 void TabManagerDelegate::AdjustOomPriorities(const TabStatsList& tab_list) { | 592 void TabManagerDelegate::AdjustOomPriorities(const TabStatsList& tab_list) { |
| 593 if (IsArcMemoryManagementEnabled()) { | 593 if (IsArcMemoryManagementEnabled()) { |
| 594 arc::ArcProcessService* arc_process_service = arc::ArcProcessService::Get(); | 594 arc::ArcProcessService* arc_process_service = arc::ArcProcessService::Get(); |
| 595 if (arc_process_service && | 595 if (arc_process_service && |
| 596 arc_process_service->RequestProcessList( | 596 arc_process_service->RequestAppProcessList( |
| 597 base::Bind(&TabManagerDelegate::AdjustOomPrioritiesImpl, | 597 base::Bind(&TabManagerDelegate::AdjustOomPrioritiesImpl, |
| 598 weak_ptr_factory_.GetWeakPtr(), tab_list))) { | 598 weak_ptr_factory_.GetWeakPtr(), tab_list))) { |
| 599 return; | 599 return; |
| 600 } | 600 } |
| 601 } | 601 } |
| 602 // Pass in a dummy list if unable to get ARC processes. | 602 // Pass in a dummy list if unable to get ARC processes. |
| 603 AdjustOomPrioritiesImpl(tab_list, std::vector<arc::ArcProcess>()); | 603 AdjustOomPrioritiesImpl(tab_list, std::vector<arc::ArcProcess>()); |
| 604 } | 604 } |
| 605 | 605 |
| 606 // Excludes persistent ARC apps, but still preserves active chrome tabs and | 606 // Excludes persistent ARC apps, but still preserves active chrome tabs and |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 } | 830 } |
| 831 } | 831 } |
| 832 priority += priority_increment; | 832 priority += priority_increment; |
| 833 } | 833 } |
| 834 | 834 |
| 835 if (oom_score_for_tabs.size()) | 835 if (oom_score_for_tabs.size()) |
| 836 SetOomScoreAdjForTabs(oom_score_for_tabs); | 836 SetOomScoreAdjForTabs(oom_score_for_tabs); |
| 837 } | 837 } |
| 838 | 838 |
| 839 } // namespace memory | 839 } // namespace memory |
| OLD | NEW |