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

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

Issue 2874543002: Refactor ARC OOM handler code (Closed)
Patch Set: address comments from Cheng-Yu 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..6bafc72ab5c86986ceb9b7374387730ceff75001 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
+// 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.
+constexpr char kArcHomeProcess[] = "org.chromium.arc.home";
+
+} // 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::IsImportant() const {
+ return process_state() <= mojom::ProcessState::IMPORTANT_FOREGROUND ||
+ process_name() == kArcHomeProcess;
cylee1 2017/05/11 19:29:14 BTW, Is it possible to make the process persistent
Yusuke Sato 2017/05/11 20:01:30 Yes, if we want to. I'll work on it in a separate
+}
+
+bool ArcProcess::IsKernelKillable() 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