Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3045)

Unified Diff: chrome/browser/chromeos/arc/process/arc_process.cc

Issue 2874543002: Refactor ARC OOM handler code (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/arc/process/arc_process.cc
diff --git a/chrome/browser/chromeos/arc/process/arc_process.cc b/chrome/browser/chromeos/arc/process/arc_process.cc
index abb054a67c82ae8c9a0208f138eea0935f1e33cc..12b10044188e3e36532b838e1b38e9ee16a1b919 100644
--- a/chrome/browser/chromeos/arc/process/arc_process.cc
+++ b/chrome/browser/chromeos/arc/process/arc_process.cc
@@ -8,6 +8,15 @@
namespace arc {
+namespace {
+
+// A special process on Android side which serves as a dummy "focused" app
Yusuke Sato 2017/05/09 22:54:35 moved
+// when the focused window is a Chrome side window (i.e., all Android
+// processes are running in the background). We don't want to kill it anyway.
+static constexpr char kArcHomeProcess[] = "org.chromium.arc.home";
Luis Héctor Chávez 2017/05/09 23:00:10 nit: static is superfluous in the anonymous namesp
Yusuke Sato 2017/05/09 23:20:12 Done.
+
+} // namespace
+
ArcProcess::ArcProcess(base::ProcessId nspid,
base::ProcessId pid,
const std::string& process_name,
@@ -34,4 +43,17 @@ bool ArcProcess::operator<(const ArcProcess& rhs) const {
ArcProcess::ArcProcess(ArcProcess&& other) = default;
ArcProcess& ArcProcess::operator=(ArcProcess&& other) = default;
+bool ArcProcess::IsUserVisible() const {
+ return process_state() <= mojom::ProcessState::IMPORTANT_FOREGROUND ||
+ process_name() == kArcHomeProcess;
+}
+
+bool ArcProcess::IsKillableForKernel() const {
+ // Protect PERSISTENT, PERSISTENT_UI, and our HOME processes since they should
+ // never be killed even by the kernel. Returning false for them allows their
+ // OOM adjustment scores to remain negative.
+ return process_state() > arc::mojom::ProcessState::PERSISTENT_UI &&
+ process_name() != kArcHomeProcess;
+}
+
} // namespace arc

Powered by Google App Engine
This is Rietveld 408576698