| 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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 AdjustOomPriorities(tab_manager_->GetUnsortedTabStats()); | 439 AdjustOomPriorities(tab_manager_->GetUnsortedTabStats()); |
| 440 } | 440 } |
| 441 } | 441 } |
| 442 | 442 |
| 443 // If able to get the list of ARC procsses, prioritize tabs and apps as a whole. | 443 // If able to get the list of ARC procsses, prioritize tabs and apps as a whole. |
| 444 // Otherwise try to kill tabs only. | 444 // Otherwise try to kill tabs only. |
| 445 void TabManagerDelegate::LowMemoryKill( | 445 void TabManagerDelegate::LowMemoryKill( |
| 446 const TabStatsList& tab_list) { | 446 const TabStatsList& tab_list) { |
| 447 arc::ArcProcessService* arc_process_service = arc::ArcProcessService::Get(); | 447 arc::ArcProcessService* arc_process_service = arc::ArcProcessService::Get(); |
| 448 if (arc_process_service && | 448 if (arc_process_service && |
| 449 arc_process_service->RequestProcessList( | 449 arc_process_service->RequestAppProcessList( |
| 450 base::Bind(&TabManagerDelegate::LowMemoryKillImpl, | 450 base::Bind(&TabManagerDelegate::LowMemoryKillImpl, |
| 451 weak_ptr_factory_.GetWeakPtr(), tab_list))) { | 451 weak_ptr_factory_.GetWeakPtr(), tab_list))) { |
| 452 // LowMemoryKillImpl will be called asynchronously so nothing left to do. | 452 // LowMemoryKillImpl will be called asynchronously so nothing left to do. |
| 453 return; | 453 return; |
| 454 } | 454 } |
| 455 // If the list of ARC processes is not available, call LowMemoryKillImpl | 455 // If the list of ARC processes is not available, call LowMemoryKillImpl |
| 456 // synchronously with an empty list of apps. | 456 // synchronously with an empty list of apps. |
| 457 std::vector<arc::ArcProcess> dummy_apps; | 457 std::vector<arc::ArcProcess> dummy_apps; |
| 458 LowMemoryKillImpl(tab_list, dummy_apps); | 458 LowMemoryKillImpl(tab_list, dummy_apps); |
| 459 } | 459 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 // | 580 // |
| 581 // Things we need to collect on the browser thread (because | 581 // Things we need to collect on the browser thread (because |
| 582 // TabStripModel isn't thread safe): | 582 // TabStripModel isn't thread safe): |
| 583 // 1) whether or not a tab is pinned | 583 // 1) whether or not a tab is pinned |
| 584 // 2) last time a tab was selected | 584 // 2) last time a tab was selected |
| 585 // 3) is the tab currently selected | 585 // 3) is the tab currently selected |
| 586 void TabManagerDelegate::AdjustOomPriorities(const TabStatsList& tab_list) { | 586 void TabManagerDelegate::AdjustOomPriorities(const TabStatsList& tab_list) { |
| 587 if (IsArcMemoryManagementEnabled()) { | 587 if (IsArcMemoryManagementEnabled()) { |
| 588 arc::ArcProcessService* arc_process_service = arc::ArcProcessService::Get(); | 588 arc::ArcProcessService* arc_process_service = arc::ArcProcessService::Get(); |
| 589 if (arc_process_service && | 589 if (arc_process_service && |
| 590 arc_process_service->RequestProcessList( | 590 arc_process_service->RequestAppProcessList( |
| 591 base::Bind(&TabManagerDelegate::AdjustOomPrioritiesImpl, | 591 base::Bind(&TabManagerDelegate::AdjustOomPrioritiesImpl, |
| 592 weak_ptr_factory_.GetWeakPtr(), tab_list))) { | 592 weak_ptr_factory_.GetWeakPtr(), tab_list))) { |
| 593 return; | 593 return; |
| 594 } | 594 } |
| 595 } | 595 } |
| 596 // Pass in a dummy list if unable to get ARC processes. | 596 // Pass in a dummy list if unable to get ARC processes. |
| 597 AdjustOomPrioritiesImpl(tab_list, std::vector<arc::ArcProcess>()); | 597 AdjustOomPrioritiesImpl(tab_list, std::vector<arc::ArcProcess>()); |
| 598 } | 598 } |
| 599 | 599 |
| 600 // Excludes persistent ARC apps, but still preserves active chrome tabs and | 600 // Excludes persistent ARC apps, but still preserves active chrome tabs and |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 } | 817 } |
| 818 } | 818 } |
| 819 priority += priority_increment; | 819 priority += priority_increment; |
| 820 } | 820 } |
| 821 | 821 |
| 822 if (oom_score_for_tabs.size()) | 822 if (oom_score_for_tabs.size()) |
| 823 SetOomScoreAdjForTabs(oom_score_for_tabs); | 823 SetOomScoreAdjForTabs(oom_score_for_tabs); |
| 824 } | 824 } |
| 825 | 825 |
| 826 } // namespace memory | 826 } // namespace memory |
| OLD | NEW |