| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 const char kExoShellSurfaceWindowName[] = "ExoShellSurface"; | 58 const char kExoShellSurfaceWindowName[] = "ExoShellSurface"; |
| 59 const char kArcProcessNamePrefix[] = "org.chromium.arc."; | 59 const char kArcProcessNamePrefix[] = "org.chromium.arc."; |
| 60 | 60 |
| 61 // When switching to a new tab the tab's renderer's OOM score needs to be | 61 // When switching to a new tab the tab's renderer's OOM score needs to be |
| 62 // updated to reflect its front-most status and protect it from discard. | 62 // updated to reflect its front-most status and protect it from discard. |
| 63 // However, doing this immediately might slow down tab switch time, so wait | 63 // However, doing this immediately might slow down tab switch time, so wait |
| 64 // a little while before doing the adjustment. | 64 // a little while before doing the adjustment. |
| 65 const int kFocusedProcessScoreAdjustIntervalMs = 500; | 65 const int kFocusedProcessScoreAdjustIntervalMs = 500; |
| 66 | 66 |
| 67 const uint32_t kMinVersionForKillProcess = 1; | |
| 68 | |
| 69 aura::client::ActivationClient* GetActivationClient() { | 67 aura::client::ActivationClient* GetActivationClient() { |
| 70 if (!ash::Shell::HasInstance()) | 68 if (!ash::Shell::HasInstance()) |
| 71 return nullptr; | 69 return nullptr; |
| 72 return aura::client::GetActivationClient(ash::Shell::GetPrimaryRootWindow()); | 70 return aura::client::GetActivationClient(ash::Shell::GetPrimaryRootWindow()); |
| 73 } | 71 } |
| 74 | 72 |
| 75 // Checks if a window renders ARC apps. | 73 // Checks if a window renders ARC apps. |
| 76 bool IsArcWindow(aura::Window* window) { | 74 bool IsArcWindow(aura::Window* window) { |
| 77 if (!window || window->GetName() != kExoShellSurfaceWindowName) | 75 if (!window || window->GetName() != kExoShellSurfaceWindowName) |
| 78 return false; | 76 return false; |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 std::sort(candidates.begin(), candidates.end()); | 541 std::sort(candidates.begin(), candidates.end()); |
| 544 | 542 |
| 545 return candidates; | 543 return candidates; |
| 546 } | 544 } |
| 547 | 545 |
| 548 bool TabManagerDelegate::KillArcProcess(const int nspid) { | 546 bool TabManagerDelegate::KillArcProcess(const int nspid) { |
| 549 auto* arc_service_manager = arc::ArcServiceManager::Get(); | 547 auto* arc_service_manager = arc::ArcServiceManager::Get(); |
| 550 if (!arc_service_manager) | 548 if (!arc_service_manager) |
| 551 return false; | 549 return false; |
| 552 | 550 |
| 553 auto* arc_process_instance = | 551 auto* arc_process_instance = GET_INSTANCE_FOR_METHOD( |
| 554 arc_service_manager->arc_bridge_service() | 552 arc_service_manager->arc_bridge_service()->process(), KillProcess); |
| 555 ->process() | |
| 556 ->GetInstanceForMethod("KillProcess", kMinVersionForKillProcess); | |
| 557 if (!arc_process_instance) | 553 if (!arc_process_instance) |
| 558 return false; | 554 return false; |
| 559 | 555 |
| 560 arc_process_instance->KillProcess(nspid, "LowMemoryKill"); | 556 arc_process_instance->KillProcess(nspid, "LowMemoryKill"); |
| 561 return true; | 557 return true; |
| 562 } | 558 } |
| 563 | 559 |
| 564 bool TabManagerDelegate::KillTab(int64_t tab_id) { | 560 bool TabManagerDelegate::KillTab(int64_t tab_id) { |
| 565 // Check |tab_manager_| is alive before taking tabs into consideration. | 561 // Check |tab_manager_| is alive before taking tabs into consideration. |
| 566 return tab_manager_ && | 562 return tab_manager_ && |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 } | 714 } |
| 719 priority += priority_increment; | 715 priority += priority_increment; |
| 720 } | 716 } |
| 721 | 717 |
| 722 if (oom_scores_to_change.size()) | 718 if (oom_scores_to_change.size()) |
| 723 GetDebugDaemonClient()->SetOomScoreAdj( | 719 GetDebugDaemonClient()->SetOomScoreAdj( |
| 724 oom_scores_to_change, base::Bind(&OnSetOomScoreAdj)); | 720 oom_scores_to_change, base::Bind(&OnSetOomScoreAdj)); |
| 725 } | 721 } |
| 726 | 722 |
| 727 } // namespace memory | 723 } // namespace memory |
| OLD | NEW |