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

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

Issue 2874543002: Refactor ARC OOM handler code (Closed)
Patch Set: address comments from Luis 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..cb8bc9c02b37fbde297fbc76cde56d0364eac161 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";
cylee1 2017/05/10 16:31:54 A no-so-relevant comment : I'm not sure if what de
Yusuke Sato 2017/05/10 18:29:43 The process still works like that.
+
+} // 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 {
cylee1 2017/05/10 16:31:54 The name is not so right because processes like pe
Yusuke Sato 2017/05/10 18:29:43 Done. Changed to IsImportant.
+ return process_state() <= mojom::ProcessState::IMPORTANT_FOREGROUND ||
+ process_name() == kArcHomeProcess;
+}
+
+bool ArcProcess::IsKernelKillable() const {
+ // Protect PERSISTENT, PERSISTENT_UI, and our HOME processes since they should
cylee1 2017/05/10 16:31:55 Thinking it twice, I feel there's no need to separ
Yusuke Sato 2017/05/10 18:29:43 With this CL, because of the explicit SetOomScore(
cylee1 2017/05/11 08:59:53 Yes. I remember that's what Luigi and me discussed
Yusuke Sato 2017/05/11 18:50:16 Acknowledged.
+ // 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