| 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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 AdjustOomPriorities(tab_manager_->GetUnsortedTabStats()); | 430 AdjustOomPriorities(tab_manager_->GetUnsortedTabStats()); |
| 431 } | 431 } |
| 432 } | 432 } |
| 433 | 433 |
| 434 // If able to get the list of ARC procsses, prioritize tabs and apps as a whole. | 434 // If able to get the list of ARC procsses, prioritize tabs and apps as a whole. |
| 435 // Otherwise try to kill tabs only. | 435 // Otherwise try to kill tabs only. |
| 436 void TabManagerDelegate::LowMemoryKill( | 436 void TabManagerDelegate::LowMemoryKill( |
| 437 const TabStatsList& tab_list) { | 437 const TabStatsList& tab_list) { |
| 438 arc::ArcProcessService* arc_process_service = arc::ArcProcessService::Get(); | 438 arc::ArcProcessService* arc_process_service = arc::ArcProcessService::Get(); |
| 439 if (arc_process_service && | 439 if (arc_process_service && |
| 440 arc_process_service->RequestProcessList( | 440 arc_process_service->RequestAppProcessList( |
| 441 base::Bind(&TabManagerDelegate::LowMemoryKillImpl, | 441 base::Bind(&TabManagerDelegate::LowMemoryKillImpl, |
| 442 weak_ptr_factory_.GetWeakPtr(), tab_list))) { | 442 weak_ptr_factory_.GetWeakPtr(), tab_list))) { |
| 443 // LowMemoryKillImpl will be called asynchronously so nothing left to do. | 443 // LowMemoryKillImpl will be called asynchronously so nothing left to do. |
| 444 return; | 444 return; |
| 445 } | 445 } |
| 446 // If the list of ARC processes is not available, call LowMemoryKillImpl | 446 // If the list of ARC processes is not available, call LowMemoryKillImpl |
| 447 // synchronously with an empty list of apps. | 447 // synchronously with an empty list of apps. |
| 448 std::vector<arc::ArcProcess> dummy_apps; | 448 std::vector<arc::ArcProcess> dummy_apps; |
| 449 LowMemoryKillImpl(tab_list, dummy_apps); | 449 LowMemoryKillImpl(tab_list, dummy_apps); |
| 450 } | 450 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 // | 562 // |
| 563 // Things we need to collect on the browser thread (because | 563 // Things we need to collect on the browser thread (because |
| 564 // TabStripModel isn't thread safe): | 564 // TabStripModel isn't thread safe): |
| 565 // 1) whether or not a tab is pinned | 565 // 1) whether or not a tab is pinned |
| 566 // 2) last time a tab was selected | 566 // 2) last time a tab was selected |
| 567 // 3) is the tab currently selected | 567 // 3) is the tab currently selected |
| 568 void TabManagerDelegate::AdjustOomPriorities(const TabStatsList& tab_list) { | 568 void TabManagerDelegate::AdjustOomPriorities(const TabStatsList& tab_list) { |
| 569 if (IsArcMemoryManagementEnabled()) { | 569 if (IsArcMemoryManagementEnabled()) { |
| 570 arc::ArcProcessService* arc_process_service = arc::ArcProcessService::Get(); | 570 arc::ArcProcessService* arc_process_service = arc::ArcProcessService::Get(); |
| 571 if (arc_process_service && | 571 if (arc_process_service && |
| 572 arc_process_service->RequestProcessList( | 572 arc_process_service->RequestAppProcessList( |
| 573 base::Bind(&TabManagerDelegate::AdjustOomPrioritiesImpl, | 573 base::Bind(&TabManagerDelegate::AdjustOomPrioritiesImpl, |
| 574 weak_ptr_factory_.GetWeakPtr(), tab_list))) { | 574 weak_ptr_factory_.GetWeakPtr(), tab_list))) { |
| 575 return; | 575 return; |
| 576 } | 576 } |
| 577 } | 577 } |
| 578 // Pass in a dummy list if unable to get ARC processes. | 578 // Pass in a dummy list if unable to get ARC processes. |
| 579 AdjustOomPrioritiesImpl(tab_list, std::vector<arc::ArcProcess>()); | 579 AdjustOomPrioritiesImpl(tab_list, std::vector<arc::ArcProcess>()); |
| 580 } | 580 } |
| 581 | 581 |
| 582 // Excludes persistent ARC apps, but still preserves active chrome tabs and | 582 // Excludes persistent ARC apps, but still preserves active chrome tabs and |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 } | 780 } |
| 781 priority += priority_increment; | 781 priority += priority_increment; |
| 782 } | 782 } |
| 783 | 783 |
| 784 if (oom_scores_to_change.size()) | 784 if (oom_scores_to_change.size()) |
| 785 GetDebugDaemonClient()->SetOomScoreAdj( | 785 GetDebugDaemonClient()->SetOomScoreAdj( |
| 786 oom_scores_to_change, base::Bind(&OnSetOomScoreAdj)); | 786 oom_scores_to_change, base::Bind(&OnSetOomScoreAdj)); |
| 787 } | 787 } |
| 788 | 788 |
| 789 } // namespace memory | 789 } // namespace memory |
| OLD | NEW |